修改部门和岗位
This commit is contained in:
parent
dfcfd78557
commit
6cc76c9f8e
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catchAdmin\permissions;
|
namespace catchAdmin\permissions;
|
||||||
|
|
||||||
use catcher\base\CatchRequest as Request;
|
use app\Request;
|
||||||
use catchAdmin\permissions\model\Permissions;
|
use catchAdmin\permissions\model\Permissions;
|
||||||
use catcher\Code;
|
use catcher\Code;
|
||||||
use catcher\exceptions\PermissionForbiddenException;
|
use catcher\exceptions\PermissionForbiddenException;
|
||||||
|
@ -3,6 +3,9 @@ namespace catchAdmin\permissions\controller;
|
|||||||
|
|
||||||
use catcher\base\CatchController;
|
use catcher\base\CatchController;
|
||||||
use catchAdmin\permissions\model\Department as DepartmentModel;
|
use catchAdmin\permissions\model\Department as DepartmentModel;
|
||||||
|
use catcher\base\CatchRequest;
|
||||||
|
use catcher\CatchResponse;
|
||||||
|
use catcher\Tree;
|
||||||
|
|
||||||
class Department extends CatchController
|
class Department extends CatchController
|
||||||
{
|
{
|
||||||
@ -13,23 +16,53 @@ class Department extends CatchController
|
|||||||
$this->department = $department;
|
$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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,66 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catchAdmin\permissions\controller;
|
namespace catchAdmin\permissions\controller;
|
||||||
|
|
||||||
|
use catchAdmin\permissions\model\Job as JobModel;
|
||||||
use catcher\base\CatchController;
|
use catcher\base\CatchController;
|
||||||
|
use catcher\base\CatchRequest;
|
||||||
|
use catcher\CatchResponse;
|
||||||
|
|
||||||
class Job extends CatchController
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,23 @@ class Department extends CatchModel
|
|||||||
'created_at', // 创建时间
|
'created_at', // 创建时间
|
||||||
'updated_at', // 更新时间
|
'updated_at', // 更新时间
|
||||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
'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();
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,6 +18,27 @@ class Job extends CatchModel
|
|||||||
'created_at', // 创建时间
|
'created_at', // 创建时间
|
||||||
'updated_at', // 更新时间
|
'updated_at', // 更新时间
|
||||||
'deleted_at', // 删除状态,null 未删除 timestamp 已删除
|
'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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,6 +3,9 @@
|
|||||||
$router->resource('roles', '\catchAdmin\permissions\controller\Role');
|
$router->resource('roles', '\catchAdmin\permissions\controller\Role');
|
||||||
// 角色列表
|
// 角色列表
|
||||||
$router->get('/role/get/permissions', '\catchAdmin\permissions\controller\Role@getPermissions');
|
$router->get('/role/get/permissions', '\catchAdmin\permissions\controller\Role@getPermissions');
|
||||||
|
|
||||||
// 权限
|
// 权限
|
||||||
$router->resource('permissions', '\catchAdmin\permissions\controller\Permission');
|
$router->resource('permissions', '\catchAdmin\permissions\controller\Permission');
|
||||||
|
// 部门
|
||||||
|
$router->resource('departments', '\catchAdmin\permissions\controller\Department');
|
||||||
|
// 岗位
|
||||||
|
$router->resource('jobs', '\catchAdmin\permissions\controller\Job');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user