作者 赵彬吉

Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev

  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Bside\User;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Http\Controllers\Bside\BaseController;
  7 +use App\Http\Logic\Bside\User\DeptUserLogic;
  8 +use App\Models\User\DeptUser;
  9 +use App\Models\User\ViewDeptUser;
  10 +
  11 +class DeptUserController extends BaseController
  12 +{
  13 + /**
  14 + * @param ViewDeptUser $viewDeptUser
  15 + * @name :(列表)lists
  16 + * @author :lyh
  17 + * @method :post
  18 + * @time :2023/5/17 17:27
  19 + */
  20 + public function lists(ViewDeptUser $viewDeptUser){
  21 + $this->param['project_id'] = $this->user['project_id'];
  22 + $lists = $viewDeptUser->lists($this->map,$this->page,$this->row,$this->order);
  23 + $this->response('success',Code::SUCCESS,$lists);
  24 + }
  25 +
  26 + /**
  27 + * @name :(获取成员列表)get_user_list
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2023/5/17 17:38
  31 + */
  32 + public function get_user_list(DeptUserLogic $deptUserLogic){
  33 + //获取当前用户已添加的成员
  34 + $list = $deptUserLogic->get_user_list();
  35 + $this->response('success',Code::SUCCESS,$list);
  36 + }
  37 + /**
  38 + * @name :(添加或编辑成员)save
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2023/5/17 17:36
  42 + */
  43 + public function add(DeptUserLogic $deptUserLogic){
  44 + $this->param['project_id'] = $this->user['project_id'];
  45 + $deptUserLogic->dept_user_add();
  46 + $this->response('success');
  47 + }
  48 +}
1 -<?php  
2 -  
3 -namespace App\Http\Controllers\Bside\User;  
4 -  
5 -use App\Enums\Common\Code;  
6 -use App\Http\Controllers\Bside\BaseController;  
7 -use App\Http\Controllers\Bside\Ids;  
8 -use App\Http\Controllers\Bside\json;  
9 -use App\Http\Logic\Bside\ProjectGroupLogic;  
10 -use App\Http\Logic\Bside\User\GroupLogic;  
11 -use App\Http\Requests\Bside\User\ProjectGroupRequest;  
12 -use App\Models\User\ProjectGroup;  
13 -  
14 -  
15 -/**  
16 - * @name:用户组相关  
17 - */  
18 -class ProjectGroupController extends BaseController  
19 -{  
20 - /**  
21 - * @name :用户组列表  
22 - * @return json  
23 - * @author :liyuhang  
24 - * @method  
25 - */  
26 - public function lists(ProjectGroup $projectGroup)  
27 - {  
28 - $lists = $projectGroup->list($this->map,'id',['name','user_list','pid','id']);  
29 - $menu = [];  
30 - foreach ($lists as $k => $v){  
31 - $v = (array)$v;  
32 - if ($v['pid'] == 0) {  
33 - $v['sub'] = _get_child($v['id'], $lists);  
34 - $menu[] = $v;  
35 - }  
36 - }  
37 - $this->response('success',Code::SUCCESS,$menu);  
38 - }  
39 -  
40 - /**  
41 - * @name :详情  
42 - * @return json  
43 - * @author :liyuhang  
44 - * @method  
45 - */  
46 - public function info(GroupLogic $groupLogic){  
47 - $this->request->validate([  
48 - 'id'=>['required', new Ids()],  
49 - ],[  
50 - 'id.required' => 'ID不能为空',  
51 - ]);  
52 - $groupLogic->group_info();  
53 - $this->response('success');  
54 - }  
55 - /**  
56 - * @name:添加用户组获取用户列表  
57 - * @return void  
58 - * @author :liyuhang  
59 - * @method  
60 - */  
61 - public function get_user_lists(GroupLogic $groupLogic){  
62 - $lists = $groupLogic->user_list();  
63 - $this->response('success',Code::SUCCESS,$lists);  
64 - }  
65 - /**  
66 - * @param ProjectGroupRequest $request  
67 - * @param ProjectGroupLogic $logic  
68 - * @name : 添加用户组  
69 - * @return void  
70 - * @author :liyuhang  
71 - * @method  
72 - */  
73 - public function add(ProjectGroupRequest $request,GroupLogic $groupLogic){  
74 - $request->validated();  
75 - $groupLogic->group_add();  
76 - $this->response('success');  
77 - }  
78 -  
79 - /**  
80 - * @param ProjectGroupRequest $request  
81 - * @param ProjectGroupLogic $logic  
82 - * @name :编辑用户组  
83 - * @return void  
84 - * @author :liyuhang  
85 - * @method  
86 - */  
87 - public function edit(ProjectGroupRequest $request,GroupLogic $groupLogic){  
88 - $request->validate([  
89 - 'id'=>['required'],  
90 - ],[  
91 - 'id.required' => 'ID不能为空',  
92 - ]);  
93 - $groupLogic->group_edit();  
94 - $this->response('success');  
95 - }  
96 -  
97 - /**  
98 - * @name :删除用户组  
99 - * @return void  
100 - * @author :liyuhang  
101 - * @method  
102 - */  
103 - public function del(GroupLogic $groupLogic){  
104 - $this->request->validate([  
105 - 'id'=>['required','array'],  
106 - ],[  
107 - 'id.required' => 'ID不能为空',  
108 - 'id.array' => 'ID为数组',  
109 - ]);  
110 - $groupLogic->group_del();  
111 - $this->response('success');  
112 - }  
113 -}  
1 -<?php  
2 -  
3 -namespace App\Http\Logic\Aside\User;  
4 -  
5 -use App\Http\Logic\Aside\BaseLogic;  
6 -use App\Models\User\ProjectMenu;  
7 -  
8 -class ProjectGroupLogic extends BaseLogic  
9 -{  
10 - public function __construct()  
11 - {  
12 - parent::__construct();  
13 -  
14 - $this->model = new ProjectMenu();  
15 - $this->param = $this->requestAll;  
16 - }  
17 -  
18 - /**  
19 - * @name :详情  
20 - * @return void  
21 - * @author :liyuhang  
22 - * @method  
23 - */  
24 - public function group_info(){  
25 - $info = $this->info($this->param);  
26 - return $this->success($info);  
27 - }  
28 -  
29 - /**  
30 - * @name :添加  
31 - * @return void  
32 - * @author :liyuhang  
33 - * @method  
34 - */  
35 - public function group_add(){  
36 - //查看当前用户组是否存在  
37 - $this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]);  
38 - $rs = $this->model->add($this->param);  
39 - if($rs === false){  
40 - $this->fail('error');  
41 - }  
42 - return $this->success();  
43 - }  
44 -  
45 - /**  
46 - * @name :编辑  
47 - * @return void  
48 - * @author :liyuhang  
49 - * @method  
50 - */  
51 - public function group_edit(){  
52 - //查看当前用户组是否存在  
53 - $rs = $this->model->read(['name'=>$this->param['name'],'create_id'=>$this->user['id']]);  
54 - if($rs === false){  
55 - $this->fail('error');  
56 - }  
57 - return $this->success();  
58 - }  
59 -  
60 - /**  
61 - * @name :删除  
62 - * @return void  
63 - * @author :liyuhang  
64 - * @method  
65 - */  
66 - public function group_del(){  
67 - $this->param['id'] = ['in',$this->param['id']];  
68 - $rs = $this->model->del($this->param);  
69 - if($rs === false){  
70 - $this->fail('error');  
71 - }  
72 - return $this->success();  
73 - }  
74 -}  
@@ -64,7 +64,7 @@ class AyrReleaseLogic extends BaseLogic @@ -64,7 +64,7 @@ class AyrReleaseLogic extends BaseLogic
64 $arr[] = $v1['ayr_url']; 64 $arr[] = $v1['ayr_url'];
65 } 65 }
66 }else{ 66 }else{
67 - $arr[] = url('/b/file_hash/' . $v.rand(10000,99999).'mp4');; 67 + $arr[] = url('/b/file_hash/' . $v.rand(10000,99999).'mp4');
68 } 68 }
69 } 69 }
70 return $this->success($arr); 70 return $this->success($arr);
@@ -4,7 +4,7 @@ namespace App\Http\Logic\Bside\User; @@ -4,7 +4,7 @@ namespace App\Http\Logic\Bside\User;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
7 -use App\Models\ProjectDept; 7 +use App\Models\User\ProjectDept;
8 8
9 /** 9 /**
10 * Class DeptLogic 10 * Class DeptLogic
  1 +<?php
  2 +
  3 +namespace App\Http\Logic\Bside\User;
  4 +
  5 +use App\Http\Logic\Bside\BaseLogic;
  6 +use App\Models\User\DeptUser;
  7 +use App\Models\User\User;
  8 +
  9 +class DeptUserLogic extends BaseLogic
  10 +{
  11 + public function __construct()
  12 + {
  13 + parent::__construct();
  14 +
  15 + $this->model = new DeptUser();
  16 + $this->param = $this->requestAll;
  17 + }
  18 +
  19 + /**
  20 + * @name :(添加用户时获取成员列表)user_list
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2023/5/17 17:40
  24 + */
  25 + public function get_user_list(){
  26 + $param = [
  27 + 'project_id'=>$this->user['project_id'],
  28 + 'dept_id'=>$this->param['dept_id'],
  29 + ];
  30 + $dept_list = $this->model->list($param,'id');
  31 + if(!empty($dept_list)){
  32 + $arr = [];
  33 + foreach ($dept_list as $k => $v){
  34 + $arr[] = $v['user_id'];
  35 + }
  36 + }
  37 + $userModel = new User();
  38 + $param = [
  39 + 'project_id'=>$this->user['project_id'],
  40 + 'id'=>['not in',$arr],
  41 + ];
  42 + $list = $userModel->list($param,'id',['id','name','email','mobile','created_at']);
  43 + return $this->success($list);
  44 + }
  45 +
  46 + /**
  47 + * @name :dept_user_add
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2023/5/17 17:54
  51 + */
  52 + public function dept_user_add(){
  53 +
  54 + }
  55 +}
@@ -4,6 +4,8 @@ namespace App\Http\Logic\Bside\User; @@ -4,6 +4,8 @@ namespace App\Http\Logic\Bside\User;
4 4
5 use App\Http\Logic\Bside\BaseLogic; 5 use App\Http\Logic\Bside\BaseLogic;
6 use App\Models\User\ProjectGroup; 6 use App\Models\User\ProjectGroup;
  7 +use App\Models\User\User as UserModel;
  8 +use Illuminate\Support\Facades\DB;
7 9
8 class GroupLogic extends BaseLogic 10 class GroupLogic extends BaseLogic
9 { 11 {
@@ -15,52 +17,86 @@ class GroupLogic extends BaseLogic @@ -15,52 +17,86 @@ class GroupLogic extends BaseLogic
15 $this->param = $this->requestAll; 17 $this->param = $this->requestAll;
16 } 18 }
17 /** 19 /**
18 - * @name :添加 20 + * @name :添加用户组
19 * @return void 21 * @return void
20 * @author :liyuhang 22 * @author :liyuhang
21 * @method 23 * @method
22 */ 24 */
23 public function group_add(){ 25 public function group_add(){
24 $this->param['project_id'] = $this->user['project_id']; 26 $this->param['project_id'] = $this->user['project_id'];
25 - $this->param['admin_id'] = $this->user['admin_id'];  
26 - $this->param['create_id'] = $this->user['create_id'];  
27 - $this->param['operator_id'] = $this->user['operator_id'];  
28 - $this->param['user_list'] = ','.trim($this->param['user_list'],',').','; 27 + $this->param['admin_id'] = $this->user['id'];
  28 + $this->param['create_id'] = $this->user['id'];
  29 + $this->param['operator_id'] = $this->user['id'];
29 $rs = $this->model->add($this->param); 30 $rs = $this->model->add($this->param);
30 if($rs === false){ 31 if($rs === false){
31 $this->fail('error'); 32 $this->fail('error');
32 } 33 }
33 - if(isset($this->param['pid']) && !empty($this->param['pid'])){  
34 - $this->add_update_parent($this->param);  
35 - }  
36 return $this->success(); 34 return $this->success();
37 } 35 }
38 36
39 /** 37 /**
  38 + * @name :(添加成员)group_add_user
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2023/5/17 15:58
  42 + */
  43 + public function group_add_user(){
  44 + $info = $this->model->read(['id'=>$this->param['id']]);
  45 + //组装数据
  46 + $str = ltrim($info['user_list'],',').$this->param['user_list'];
  47 + $arr = array_unique(explode(',',$str));
  48 + sort($arr);
  49 + $str = ','.implode(',',$arr).',';
  50 + DB::beginTransaction();
  51 + try {
  52 + $this->model->edit(['user_list'=>$str],['id'=>$this->param['id']]);
  53 + //更新父类
  54 + $this->update_parent($this->param,$info);
  55 + DB::commit();
  56 + }catch (\Exception $e){
  57 + DB::rollBack();
  58 + $this->fail('添加成员失败');
  59 + }
  60 + return $this->success();
  61 + }
  62 + /**
40 * @name :编辑 63 * @name :编辑
41 * @return void 64 * @return void
42 * @author :liyuhang 65 * @author :liyuhang
43 * @method 66 * @method
44 */ 67 */
45 public function group_edit(){ 68 public function group_edit(){
46 - $this->param['user_list'] = ','.trim($this->param['user_list'],',').',';  
47 $rs = $this->edit($this->param,['id'=>$this->param['id']]); 69 $rs = $this->edit($this->param,['id'=>$this->param['id']]);
48 if($rs === false){ 70 if($rs === false){
49 $this->fail('error'); 71 $this->fail('error');
50 } 72 }
51 - //更新父类  
52 - $this->update_parent($this->param,$this->param['id']);  
53 return $this->success(); 73 return $this->success();
54 } 74 }
55 75
56 /** 76 /**
  77 + * @name :(获取成员列表)user_list
  78 + * @author :lyh
  79 + * @method :post
  80 + * @time :2023/5/17 14:51
  81 + */
  82 + public function user_list($data = [],$order = 'id'){
  83 + unset($this->param['id']);
  84 + $userModel = new UserModel();
  85 + $data = array_merge($data,$this->param);
  86 + $lists = $userModel->list($data,$order,['id','name','mobile','created_at']);
  87 + return $this->success($lists);
  88 + }
  89 + /**
57 * @name :详情 90 * @name :详情
58 * @return void 91 * @return void
59 * @author :liyuhang 92 * @author :liyuhang
60 * @method 93 * @method
61 */ 94 */
62 - public function group_info(){  
63 - $info = $this->info($this->param); 95 + public function group_info($param = []){
  96 + if(empty($param)){
  97 + $param = $this->param;
  98 + }
  99 + $info = $this->model->read($this->param);
64 return $this->success($info); 100 return $this->success($info);
65 } 101 }
66 102
@@ -76,7 +112,7 @@ class GroupLogic extends BaseLogic @@ -76,7 +112,7 @@ class GroupLogic extends BaseLogic
76 if($info !== false){ 112 if($info !== false){
77 $this->fail('当前删除组织拥有下级组织,不允许删除'); 113 $this->fail('当前删除组织拥有下级组织,不允许删除');
78 } 114 }
79 - $rs = $this->model->del($this->param); 115 + $rs = $this->del($this->param);
80 if($rs === false){ 116 if($rs === false){
81 $this->fail('error'); 117 $this->fail('error');
82 } 118 }
@@ -89,26 +125,51 @@ class GroupLogic extends BaseLogic @@ -89,26 +125,51 @@ class GroupLogic extends BaseLogic
89 * @method :post 125 * @method :post
90 * @time :2023/5/17 9:22 126 * @time :2023/5/17 9:22
91 */ 127 */
92 - public function update_parent($param,$id = ''){  
93 - if(!empty($id)){  
94 - $param = $this->model->read(['id'=>$id]);  
95 - } 128 + public function update_parent($param,$info){
96 //查询当前组是否拥有父类 129 //查询当前组是否拥有父类
97 - if($param['pid'] != 0){  
98 - $parent_info = $this->model->read(['id'=>$param['pid']]); 130 + if($info['pid'] != 0){
  131 + $parent_info = $this->model->read(['id'=>$info['pid']]);
99 //把添加成员合并到上级 132 //把添加成员合并到上级
100 - $str = trim($param['user_list'].$parent_info['user_list'],',');  
101 - $mergedString = ','.implode(',', array_unique(explode(',', $str))).','; 133 + $str = trim(trim($param['user_list'],',').$parent_info['user_list'],',');
  134 + $arr = array_unique(explode(',', $str));
  135 + sort($arr);
  136 + $mergedString = ','.implode(',', $arr).',';
102 $rs = $this->model->edit(['user_list'=>$mergedString],['id'=>$parent_info['id']]); 137 $rs = $this->model->edit(['user_list'=>$mergedString],['id'=>$parent_info['id']]);
103 if($rs === false){ 138 if($rs === false){
104 $this->fail('更新父级失败'); 139 $this->fail('更新父级失败');
105 } 140 }
106 //查看当前父级是否还拥有父级 141 //查看当前父级是否还拥有父级
107 if($parent_info['pid'] != 0){ 142 if($parent_info['pid'] != 0){
108 - $rs = $this->update_parent($parent_info); 143 + return $this->update_parent($param,$parent_info);
109 } 144 }
110 } 145 }
111 - return $this->success($rs); 146 + return $this->success();
112 } 147 }
113 148
  149 + /**
  150 + * @name :(更新子类,同时清空子集成员)edit_son
  151 + * @author :lyh
  152 + * @method :post
  153 + * @time :2023/5/17 13:52
  154 + */
  155 + public function update_son($param,$id){
  156 + //当前数据详情
  157 + $info = $this->model->read(['id'=>$id]);
  158 + //子集详情
  159 + $son_list = $this->model->list(['pid'=>$info['id']],'id');
  160 + if(!empty($son_list)){
  161 + //循环查询
  162 + foreach ($son_list as $k => $v){
  163 + $son_data = explode(',',trim($v['user_list'],','));
  164 + $son_str = '';
  165 + foreach ($son_data as $v1){
  166 + if(strpos($param['user_list'],','.$v1.',') > -1){
  167 + $son_str .= $v1.',';
  168 + }
  169 + }
  170 + $this->model->edit(['user_list'=>','.$son_str],['id'=>$v['id']]);
  171 + }
  172 + }
  173 + return true;
  174 + }
114 } 175 }
@@ -187,7 +187,7 @@ class Base extends Model @@ -187,7 +187,7 @@ class Base extends Model
187 // in查询 ['id'=>['in',[1,2,3]]] 187 // in查询 ['id'=>['in',[1,2,3]]]
188 $query->orWhere($k, $v[1]); 188 $query->orWhere($k, $v[1]);
189 break; 189 break;
190 - case 'no in': 190 + case 'not in':
191 // in查询 ['id'=>['not in',[1,2,3]]] 191 // in查询 ['id'=>['not in',[1,2,3]]]
192 $query->whereNotIn($k, $v[1]); 192 $query->whereNotIn($k, $v[1]);
193 break; 193 break;
@@ -4,10 +4,7 @@ namespace App\Models\User; @@ -4,10 +4,7 @@ namespace App\Models\User;
4 4
5 use App\Models\Base; 5 use App\Models\Base;
6 6
7 -class ProjectGroup extends Base 7 +class DeptUser extends Base
8 { 8 {
9 - //设置关联表名  
10 - protected $table = 'gl_project_group';  
11 - //自动维护create_at创建时间 updated_at修改时间  
12 - public $timestamps = true; 9 + protected $table = 'gl_project_dept_user';
13 } 10 }
1 <?php 1 <?php
2 2
3 -namespace App\Models; 3 +namespace App\Models\User;
4 4
  5 +use App\Models\Base;
5 use Illuminate\Database\Eloquent\SoftDeletes; 6 use Illuminate\Database\Eloquent\SoftDeletes;
6 7
7 class ProjectDept extends Base 8 class ProjectDept extends Base
  1 +<?php
  2 +
  3 +namespace App\Models\User;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class ViewDeptUser extends Base
  8 +{
  9 + protected $table = 'gl_view_dept_user';
  10 +}
@@ -42,16 +42,6 @@ Route::middleware(['bloginauth'])->group(function () { @@ -42,16 +42,6 @@ Route::middleware(['bloginauth'])->group(function () {
42 Route::any('/get_user_list', [\App\Http\Controllers\Bside\User\ProjectRoleController::class, 'get_user_list'])->name('project_role_get_user_list'); 42 Route::any('/get_user_list', [\App\Http\Controllers\Bside\User\ProjectRoleController::class, 'get_user_list'])->name('project_role_get_user_list');
43 }); 43 });
44 44
45 - //group相关路  
46 - Route::prefix('group')->group(function () {  
47 - Route::any('/', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'lists'])->name('project_group_lists');  
48 - Route::any('/add', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'add'])->name('project_group_add');  
49 - Route::any('/edit', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'edit'])->name('project_group_edit');  
50 - Route::any('/info', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'info'])->name('project_group_info');  
51 - Route::any('/del', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'del'])->name('project_group_del');  
52 - Route::any('/get_user_lists', [\App\Http\Controllers\Bside\User\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists');  
53 - });  
54 -  
55 //新闻相关路由 45 //新闻相关路由
56 Route::prefix('news')->group(function () { 46 Route::prefix('news')->group(function () {
57 //分类 47 //分类
@@ -182,6 +172,16 @@ Route::middleware(['bloginauth'])->group(function () { @@ -182,6 +172,16 @@ Route::middleware(['bloginauth'])->group(function () {
182 Route::get('/info', [\App\Http\Controllers\Bside\User\DeptController::class, 'info'])->name('dept_info'); 172 Route::get('/info', [\App\Http\Controllers\Bside\User\DeptController::class, 'info'])->name('dept_info');
183 Route::post('/save', [\App\Http\Controllers\Bside\User\DeptController::class, 'save'])->name('dept_save'); 173 Route::post('/save', [\App\Http\Controllers\Bside\User\DeptController::class, 'save'])->name('dept_save');
184 Route::any('/delete', [\App\Http\Controllers\Bside\User\DeptController::class, 'delete'])->name('dept_delete'); 174 Route::any('/delete', [\App\Http\Controllers\Bside\User\DeptController::class, 'delete'])->name('dept_delete');
  175 + //成员管理
  176 + //组织架构
  177 + Route::prefix('user')->group(function () {
  178 + Route::any('/', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'lists'])->name('dept_user');
  179 + Route::any('/get_user_list', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'get_user_list'])->name('dept_user_get_user_list');
  180 + Route::any('/info', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'info'])->name('dept_user_info');
  181 + Route::post('/save', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'save'])->name('dept_user_save');
  182 + Route::any('/delete', [\App\Http\Controllers\Bside\User\DeptUserController::class, 'delete'])->name('dept_user_delete');
  183 +
  184 + });
185 }); 185 });
186 186
187 //文件操作 187 //文件操作