DeptUserLogic.php
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
namespace App\Http\Logic\Bside\User;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\User\DeptUser;
use App\Models\User\ProjectRole;
use App\Models\User\User as UserModel;
use Illuminate\Support\Facades\DB;
class DeptUserLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new DeptUser();
$this->param = $this->requestAll;
}
/**
* @name :(部门用户)dept_user_add
* @author :lyh
* @method :post
* @time :2023/5/18 10:21
*/
public function dept_user_save(){
if(isset($this->param['id']) && !empty($this->param['id'])){
$rs = $this->dept_user_edit();
}else{
$rs = $this->dept_user_add();
}
if ($rs === false) {
$this->fail('error');
}
return $this->success();
}
/**
* @name :(部门添加用户)dept_user_add
* @author :lyh
* @method :post
* @time :2023/5/18 10:21
*/
public function dept_user_add(){
$param = [
'dept_id'=> $this->param['dept_id'],
'project_id'=>$this->user['project_id'],
'user_id'=>$this->param['user_id'],
'operator_id'=>$this->user['id'],
'create_id'=>$this->user['id']
];
$rs = $this->model->add($param);
if($rs === false){
$this->fail('部门添加成员失败');
}
return $this->success();
}
/**
* @name :(用户更改部门)dept_user_edit
* @author :lyh
* @method :post
* @time :2023/5/17 17:54
*/
public function dept_user_edit(){
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(用户设置角色)user_edit_role
* @author :lyh
* @method :post
* @time :2023/5/19 9:35
*/
public function user_edit_role(){
$roleModel = new ProjectRole();
$roleInfo = $roleModel->read(['project_id'=>$this->user['project_id'],'id'=>$this->param['role_id']]);
if($roleInfo == false){
$this->fail('当前角色id不是当前项目角色');
}
$userModel = new UserModel();
$rs = $userModel->edit(['role_id'=>$this->param['role_id']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @name :(获取详情)dept_user_info
* @author :lyh
* @method :post
* @time :2023/6/14 14:41
*/
public function dept_user_info(){
$info = $this->model->read($this->param);
if($info === false){
$this->fail('error');
}
return $this->success();
}
}