修改部门和岗位

This commit is contained in:
wuyanwen 2020-01-09 22:20:36 +08:00
parent dfcfd78557
commit 6cc76c9f8e
6 changed files with 169 additions and 38 deletions

View File

@ -1,7 +1,7 @@
<?php
namespace catchAdmin\permissions;
use catcher\base\CatchRequest as Request;
use app\Request;
use catchAdmin\permissions\model\Permissions;
use catcher\Code;
use catcher\exceptions\PermissionForbiddenException;

View File

@ -3,6 +3,9 @@ namespace catchAdmin\permissions\controller;
use catcher\base\CatchController;
use catchAdmin\permissions\model\Department as DepartmentModel;
use catcher\base\CatchRequest;
use catcher\CatchResponse;
use catcher\Tree;
class Department extends CatchController
{
@ -13,23 +16,53 @@ class Department extends CatchController
$this->department = $department;
}
public function index()
/**
* 列表
*
* @time 2020年01月09日
* @param CatchRequest $request
* @return \think\response\Json
* @throws \think\db\exception\DbException
*/
public function index(CatchRequest $request): \think\response\Json
{
return CatchResponse::success(Tree::done($this->department->getList($request->param())));
}
public function save()
/**
* 保存
*
* @time 2020年01月09日
* @param CatchRequest $request
* @return \think\response\Json
*/
public function save(CatchRequest $request): \think\response\Json
{
return CatchResponse::success($this->department->storeBy($request->post()));
}
public function update()
/**
* 更新
*
* @time 2020年01月09日
* @param $id
* @param CatchRequest $request
* @return \think\response\Json
*/
public function update($id, CatchRequest $request): \think\response\Json
{
return CatchResponse::success($this->department->updateBy($id, $request->post()));
}
public function delete($id)
/**
* 删除
*
* @time 2020年01月09日
* @param $id
* @return \think\response\Json
*/
public function delete($id): \think\response\Json
{
return CatchResponse::success($this->department->deleteBy($id));
}
}

View File

@ -1,9 +1,66 @@
<?php
namespace catchAdmin\permissions\controller;
use catchAdmin\permissions\model\Job as JobModel;
use catcher\base\CatchController;
use catcher\base\CatchRequest;
use catcher\CatchResponse;
class Job extends CatchController
{
protected $job;
public function __construct(JobModel $job)
{
$this->job = $job;
}
/**
* 列表
*
* @time 2020年01月09日
* @param CatchRequest $request
* @return \think\response\Json
*/
public function index(CatchRequest $request): \think\response\Json
{
return CatchResponse::paginate($this->job->getList($request->param()));
}
/**
* 保存
*
* @time 2020年01月09日
* @param CatchRequest $request
* @return \think\response\Json
*/
public function save(CatchRequest $request): \think\response\Json
{
return CatchResponse::success($this->job->storeBy($request->post()));
}
/**
* 更新
*
* @time 2020年01月09日
* @param $id
* @param CatchRequest $request
* @return \think\response\Json
*/
public function update($id, CatchRequest $request): \think\response\Json
{
return CatchResponse::success($this->job->updateBy($id, $request->post()));
}
/**
* 删除
*
* @time 2020年01月09日
* @param $id
* @return \think\response\Json
*/
public function delete($id): \think\response\Json
{
return CatchResponse::success($this->job->deleteBy($id));
}
}

View File

@ -8,18 +8,35 @@ class Department extends CatchModel
protected $name = 'department';
protected $field = [
'id', //
'department_name', // 部门名称
'parent_id', // 父级ID
'principal', // 负责人
'mobile', // 联系电话
'email', // 联系又想
'creator_id', // 创建人ID
'status', // 1 正常 2 停用
'sort', // 排序字段
'created_at', // 创建时间
'updated_at', // 更新时间
'deleted_at', // 删除状态null 未删除 timestamp 已删除
];
}
'id', //
'department_name', // 部门名称
'parent_id', // 父级ID
'principal', // 负责人
'mobile', // 联系电话
'email', // 联系又想
'creator_id', // 创建人ID
'status', // 1 正常 2 停用
'sort', // 排序字段
'created_at', // 创建时间
'updated_at', // 更新时间
'deleted_at', // 删除状态null 未删除 timestamp 已删除
];
/**
* 列表数据
*
* @time 2020年01月09日
* @param $params
* @throws \think\db\exception\DbException
*/
public function getList($params)
{
return $this->when($params['department_name'] ?? false, function ($query) use ($params){
$query->whereLike('department_name', '%' . $params['department_name'] . '%');
})
->when($params['status'] ?? false, function ($query) use ($params){
$query->where('status', $params['status']);
})
->select()->toArray();
}
}

View File

@ -8,16 +8,37 @@ class Job extends CatchModel
protected $name = 'job';
protected $field = [
'id', //
'job_name', // 岗位名称
'coding', // 编码
'creator_id', // 创建人ID
'status', // 1 正常 2 停用
'sort', // 排序字段
'description', // 描述
'created_at', // 创建时间
'updated_at', // 更新时间
'deleted_at', // 删除状态null 未删除 timestamp 已删除
];
}
'id', //
'job_name', // 岗位名称
'coding', // 编码
'creator_id', // 创建人ID
'status', // 1 正常 2 停用
'sort', // 排序字段
'description', // 描述
'created_at', // 创建时间
'updated_at', // 更新时间
'deleted_at', // 删除状态null 未删除 timestamp 已删除
];
/**
* 列表
*
* @time 2020年01月09日
* @param $params
* @throws \think\db\exception\DbException
* @return \think\Paginator
*/
public function getList($params)
{
return $this->when($params['job_name'] ?? false, function ($query) use ($params){
$query->whereLike('job_name', '%' . $params['job_name'] . '%');
})
->when($params['status'] ?? false, function ($query) use ($params){
$query->where('status', $params['status']);
})
->when($params['coding'] ?? false, function ($query) use ($params){
$query->whereLike('coding', '%' . $params['coding'] . '%');
})
->paginate($parmas['limit'] ?? $this->limit);
}
}

View File

@ -3,6 +3,9 @@
$router->resource('roles', '\catchAdmin\permissions\controller\Role');
// 角色列表
$router->get('/role/get/permissions', '\catchAdmin\permissions\controller\Role@getPermissions');
// 权限
$router->resource('permissions', '\catchAdmin\permissions\controller\Permission');
// 部门
$router->resource('departments', '\catchAdmin\permissions\controller\Department');
// 岗位
$router->resource('jobs', '\catchAdmin\permissions\controller\Job');