代码提交
This commit is contained in:
@@ -15,6 +15,7 @@ Route::group('v1', function () {
|
||||
Route::get('department/list', 'app\\api\\controller\\AccountController@getDepartmentList'); // 获取部门列表 √
|
||||
Route::post('department/update', 'app\\api\\controller\\AccountController@updateDepartment'); // 更新部门 √
|
||||
Route::post('department/delete', 'app\\api\\controller\\AccountController@deleteDepartment'); // 删除部门 √
|
||||
Route::post('department/setPrivileges', 'app\\api\\controller\\AccountController@setPrivileges'); // 设置部门权限 √
|
||||
});
|
||||
|
||||
// Device控制器路由
|
||||
|
||||
@@ -520,7 +520,7 @@ class AccountController extends BaseController
|
||||
* 修改部门权限
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function setPrivileges($id = '')
|
||||
public function setPrivileges($data = [])
|
||||
{
|
||||
// 获取授权token
|
||||
$authorization = trim($this->request->header('authorization', $this->authorization));
|
||||
@@ -530,23 +530,26 @@ class AccountController extends BaseController
|
||||
|
||||
try {
|
||||
// 获取并验证请求参数
|
||||
$id = !empty($id) ? $id : $this->request->param('id', 0);
|
||||
|
||||
$id = !empty($data['id']) ? $data['id'] : $this->request->param('id', 0);
|
||||
if (empty($id)) {
|
||||
return errorJson('部门ID不能为空');
|
||||
}
|
||||
|
||||
$privilegeIds = !empty($data['privilegeIds']) ? $data['privilegeIds'] : '1001,1002,1004,1023,1406,20003,20021,20022,20023,20032,20041,20049,20054,20055,20060,20100,20102,20107';
|
||||
$privilegeIds = explode(',',$privilegeIds);
|
||||
|
||||
// 验证部门是否存在
|
||||
$department = CompanyModel::where('id', $id)->find();
|
||||
if (empty($department)) {
|
||||
return errorJson('部门不存在');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 构建请求参数
|
||||
$params = [
|
||||
'departmentId' => $id,
|
||||
'privilegeIds' => [1001,1002,1004,1023,1406,20003,20021,20022,20023,20032,20041,20049,20054,20055,20060,20100,20102,20107],
|
||||
'privilegeIds' => $privilegeIds,
|
||||
'syncPrivilege' => true
|
||||
];
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ class WorkbenchController extends Controller
|
||||
$day = intval($day);
|
||||
|
||||
|
||||
if($dailyAverage > 0){
|
||||
if($dailyAverage > 0 && $totalAccounts > 0 && $day > 0){
|
||||
$dailyAverage = $dailyAverage / $totalAccounts / $day;
|
||||
}
|
||||
|
||||
@@ -706,17 +706,15 @@ class WorkbenchController extends Controller
|
||||
return json(['code' => 400, 'msg' => '请求方式错误']);
|
||||
}
|
||||
|
||||
$param = $this->request->post();
|
||||
$id = $this->request->param('id','');
|
||||
|
||||
// 验证数据
|
||||
$validate = new WorkbenchValidate;
|
||||
if (!$validate->scene('update_status')->check($param)) {
|
||||
return json(['code' => 400, 'msg' => $validate->getError()]);
|
||||
if(empty($id)){
|
||||
return json(['code' => 400, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$workbench = Workbench::where([
|
||||
['id', '=', $param['id']],
|
||||
['userId', '=', $this->request->userInfo['id']]
|
||||
['id', '=', $id],
|
||||
['companyId', '=', $this->request->userInfo['companyId']]
|
||||
])->find();
|
||||
|
||||
if (empty($workbench)) {
|
||||
|
||||
@@ -266,8 +266,9 @@ class CreateCompanyController extends BaseController
|
||||
*/
|
||||
protected function setDepartmentPrivileges(array $params): void
|
||||
{
|
||||
$params = ArrHelper::getValue('companyId=id,companyId,name,memo,status', $params);
|
||||
$result = CompanyModel::create($params);
|
||||
$params = ArrHelper::getValue('companyId', $params);
|
||||
$accountController = new \app\api\controller\AccountController();
|
||||
$accountController->setPrivileges(['id' => $params['companyId']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user