新增人员管理模块
This commit is contained in:
parent
84624e77d2
commit
c7fbb1a0f1
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller\supervision_team;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\supervision_team\SupervisionProjectPersonnelLists;
|
||||
use app\adminapi\logic\supervision_team\SupervisionProjectPersonnelLogic;
|
||||
use app\adminapi\validate\supervision_team\SupervisionProjectPersonnelValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--人员管理控制器
|
||||
* Class SupervisionProjectPersonnelController
|
||||
* @package app\adminapi\controller\supervision_team
|
||||
*/
|
||||
class SupervisionProjectPersonnelController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--人员管理列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupervisionProjectPersonnelLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--人员管理
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new SupervisionProjectPersonnelValidate())->post()->goCheck('add');
|
||||
$result = SupervisionProjectPersonnelLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionProjectPersonnelLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--人员管理
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupervisionProjectPersonnelValidate())->post()->goCheck('edit');
|
||||
$result = SupervisionProjectPersonnelLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupervisionProjectPersonnelLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--人员管理
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupervisionProjectPersonnelValidate())->post()->goCheck('delete');
|
||||
SupervisionProjectPersonnelLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--人员管理详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupervisionProjectPersonnelValidate())->goCheck('detail');
|
||||
$result = SupervisionProjectPersonnelLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\supervision_team;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\model\supervision_team\SupervisionProjectPersonnel;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--人员管理列表
|
||||
* Class SupervisionProjectPersonnelLists
|
||||
* @package app\adminapi\listssupervision_team
|
||||
*/
|
||||
class SupervisionProjectPersonnelLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['project_id'],
|
||||
'%like%' => ['name', 'dept', 'job'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--人员管理列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupervisionProjectPersonnel::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$project = SupervisionProject::field('project_name,project_manager')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['project_manager'] = $project['project_manager'];
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--人员管理数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupervisionProjectPersonnel::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\supervision_team;
|
||||
|
||||
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\model\supervision_team\SupervisionProjectPersonnel;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--人员管理逻辑
|
||||
* Class SupervisionProjectPersonnelLogic
|
||||
* @package app\adminapi\logic\supervision_team
|
||||
*/
|
||||
class SupervisionProjectPersonnelLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加工程监理--人员管理
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionProjectPersonnel::create([
|
||||
'project_id' => $params['project_id'],
|
||||
'name' => $params['name'],
|
||||
'dept' => $params['dept'],
|
||||
'start_time' => !empty($params['start_time']) ? strtotime($params['start_time']) : 0,
|
||||
'end_time' => !empty($params['end_time']) ? strtotime($params['end_time']) : 0,
|
||||
'job' => $params['job'],
|
||||
'remark' => $params['remark']
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑工程监理--人员管理
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
SupervisionProjectPersonnel::where('id', $params['id'])->update([
|
||||
'project_id' => $params['project_id'],
|
||||
'name' => $params['name'],
|
||||
'dept' => $params['dept'],
|
||||
'start_time' => !empty($params['start_time']) ? strtotime($params['start_time']) : 0,
|
||||
'end_time' => !empty($params['end_time']) ? strtotime($params['end_time']) : 0,
|
||||
'job' => $params['job'],
|
||||
'remark' => $params['remark'],
|
||||
'update_time' => time()
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除工程监理--人员管理
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SupervisionProjectPersonnel::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工程监理--人员管理详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupervisionProjectPersonnel::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$project = SupervisionProject::field('project_name,project_manager')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['project_manager'] = $project['project_manager'];
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\supervision_team;
|
||||
|
||||
|
||||
use app\common\model\supervision_project\SupervisionProject;
|
||||
use app\common\model\supervision_team\SupervisionProjectPersonnel;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--人员管理验证器
|
||||
* Class SupervisionProjectPersonnelValidate
|
||||
* @package app\adminapi\validate\supervision_team
|
||||
*/
|
||||
class SupervisionProjectPersonnelValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'project_id' => 'require|checkProject',
|
||||
'name' => 'require',
|
||||
'dept' => 'require',
|
||||
'job' => 'require',
|
||||
'start_time' => 'dateFormat:Y-m-d',
|
||||
'end_time' => 'dateFormat:Y-m-d',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'project_id' => '项目id',
|
||||
'name' => '姓名',
|
||||
'dept' => '部门',
|
||||
'job' => '负责岗位',
|
||||
'start_time' => '项目调入时间',
|
||||
'end_time' => '项目调出时间',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupervisionProjectPersonnelValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id',true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupervisionProjectPersonnelValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupervisionProjectPersonnelValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupervisionProjectPersonnelValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/05 15:29
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SupervisionProjectPersonnel::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '数据不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$data = SupervisionProject::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
return '项目信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\supervision_team;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 工程监理--人员管理模型
|
||||
* Class SupervisionProjectPersonnel
|
||||
* @package app\common\model\supervision_team
|
||||
*/
|
||||
class SupervisionProjectPersonnel extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'supervision_project_personnel';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getStartTimeAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
public function getEndTimeAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user