正在显示
5 个修改的文件
包含
96 行增加
和
245 行删除
app/Http/Logic/Bside/User/GroupLogic.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Logic\Bside\User; | ||
| 4 | - | ||
| 5 | -use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | -use App\Models\User\ProjectGroup; | ||
| 7 | -use App\Models\User\User as UserModel; | ||
| 8 | -use Illuminate\Support\Facades\DB; | ||
| 9 | - | ||
| 10 | -class GroupLogic extends BaseLogic | ||
| 11 | -{ | ||
| 12 | - public function __construct() | ||
| 13 | - { | ||
| 14 | - parent::__construct(); | ||
| 15 | - | ||
| 16 | - $this->model = new ProjectGroup(); | ||
| 17 | - $this->param = $this->requestAll; | ||
| 18 | - } | ||
| 19 | - /** | ||
| 20 | - * @name :添加用户组 | ||
| 21 | - * @return void | ||
| 22 | - * @author :liyuhang | ||
| 23 | - * @method | ||
| 24 | - */ | ||
| 25 | - public function group_add(){ | ||
| 26 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 27 | - $this->param['admin_id'] = $this->user['id']; | ||
| 28 | - $this->param['create_id'] = $this->user['id']; | ||
| 29 | - $this->param['operator_id'] = $this->user['id']; | ||
| 30 | - $rs = $this->model->add($this->param); | ||
| 31 | - if($rs === false){ | ||
| 32 | - $this->fail('error'); | ||
| 33 | - } | ||
| 34 | - return $this->success(); | ||
| 35 | - } | ||
| 36 | - | ||
| 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 | - /** | ||
| 63 | - * @name :编辑 | ||
| 64 | - * @return void | ||
| 65 | - * @author :liyuhang | ||
| 66 | - * @method | ||
| 67 | - */ | ||
| 68 | - public function group_edit(){ | ||
| 69 | - $rs = $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 70 | - if($rs === false){ | ||
| 71 | - $this->fail('error'); | ||
| 72 | - } | ||
| 73 | - return $this->success(); | ||
| 74 | - } | ||
| 75 | - | ||
| 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 | - /** | ||
| 90 | - * @name :详情 | ||
| 91 | - * @return void | ||
| 92 | - * @author :liyuhang | ||
| 93 | - * @method | ||
| 94 | - */ | ||
| 95 | - public function group_info($param = []){ | ||
| 96 | - if(empty($param)){ | ||
| 97 | - $param = $this->param; | ||
| 98 | - } | ||
| 99 | - $info = $this->model->read($this->param); | ||
| 100 | - return $this->success($info); | ||
| 101 | - } | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * @name :删除 | ||
| 105 | - * @return void | ||
| 106 | - * @author :liyuhang | ||
| 107 | - * @method | ||
| 108 | - */ | ||
| 109 | - public function group_del(){ | ||
| 110 | - //查看当前是否拥有父类 | ||
| 111 | - $info = $this->model->read(['pid'=>$this->param['id']]); | ||
| 112 | - if($info !== false){ | ||
| 113 | - $this->fail('当前删除组织拥有下级组织,不允许删除'); | ||
| 114 | - } | ||
| 115 | - $rs = $this->del($this->param); | ||
| 116 | - if($rs === false){ | ||
| 117 | - $this->fail('error'); | ||
| 118 | - } | ||
| 119 | - return $this->success(); | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - /** | ||
| 123 | - * @name :(更新父类成员)update_parent | ||
| 124 | - * @author :lyh | ||
| 125 | - * @method :post | ||
| 126 | - * @time :2023/5/17 9:22 | ||
| 127 | - */ | ||
| 128 | - public function update_parent($param,$info){ | ||
| 129 | - //查询当前组是否拥有父类 | ||
| 130 | - if($info['pid'] != 0){ | ||
| 131 | - $parent_info = $this->model->read(['id'=>$info['pid']]); | ||
| 132 | - //把添加成员合并到上级 | ||
| 133 | - $str = trim(trim($param['user_list'],',').$parent_info['user_list'],','); | ||
| 134 | - $arr = array_unique(explode(',', $str)); | ||
| 135 | - sort($arr); | ||
| 136 | - $mergedString = ','.implode(',', $arr).','; | ||
| 137 | - $rs = $this->model->edit(['user_list'=>$mergedString],['id'=>$parent_info['id']]); | ||
| 138 | - if($rs === false){ | ||
| 139 | - $this->fail('更新父级失败'); | ||
| 140 | - } | ||
| 141 | - //查看当前父级是否还拥有父级 | ||
| 142 | - if($parent_info['pid'] != 0){ | ||
| 143 | - return $this->update_parent($param,$parent_info); | ||
| 144 | - } | ||
| 145 | - } | ||
| 146 | - return $this->success(); | ||
| 147 | - } | ||
| 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 | - } | ||
| 175 | -} |
| @@ -18,10 +18,48 @@ class RoleLogic extends BaseLogic | @@ -18,10 +18,48 @@ class RoleLogic extends BaseLogic | ||
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | - * @name :添加角色 | ||
| 22 | - * @return void | ||
| 23 | - * @author :liyuhang | ||
| 24 | - * @method | 21 | + * @remark :获取菜单 |
| 22 | + * @name :role_get_menu | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2023/6/17 16:40 | ||
| 26 | + */ | ||
| 27 | + public function role_get_menu(){ | ||
| 28 | + //根据当前登录用户角色返回用户菜单列表 | ||
| 29 | + $info = $this->model->read(['id'=>$this->user['role_id']]); | ||
| 30 | + $info['role_menu'] = trim($info['role_menu'],','); | ||
| 31 | + $menuModel = new ProjectMenuModel(); | ||
| 32 | + $lists = $menuModel->where(['status'=>0])->whereIn('id',explode(',',$info['role_menu']))->get(); | ||
| 33 | + $lists = $lists->toArray(); | ||
| 34 | + $menu = array(); | ||
| 35 | + foreach ($lists as $k => $v){ | ||
| 36 | + $v = (array)$v; | ||
| 37 | + if ($v['pid'] == 0) { | ||
| 38 | + $v['sub'] = _get_child($v['id'], $lists); | ||
| 39 | + $menu[] = $v; | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + return $this->success($menu); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * @remark :获取详情 | ||
| 47 | + * @name :role_info | ||
| 48 | + * @author :lyh | ||
| 49 | + * @method :post | ||
| 50 | + * @time :2023/6/17 16:39 | ||
| 51 | + */ | ||
| 52 | + public function role_info(){ | ||
| 53 | + $info = $this->info($this->param); | ||
| 54 | + return $this->success($info); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @remark :添加角色 | ||
| 59 | + * @name :role_add | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2023/6/17 16:38 | ||
| 25 | */ | 63 | */ |
| 26 | public function role_add(){ | 64 | public function role_add(){ |
| 27 | $condition = [ | 65 | $condition = [ |
| @@ -48,10 +86,11 @@ class RoleLogic extends BaseLogic | @@ -48,10 +86,11 @@ class RoleLogic extends BaseLogic | ||
| 48 | } | 86 | } |
| 49 | 87 | ||
| 50 | /** | 88 | /** |
| 51 | - * @name :编辑角色 | ||
| 52 | - * @return void | ||
| 53 | - * @author :liyuhang | ||
| 54 | - * @method | 89 | + * @remark :编辑角色 |
| 90 | + * @name :role_edit | ||
| 91 | + * @author :lyh | ||
| 92 | + * @method :post | ||
| 93 | + * @time :2023/6/17 16:38 | ||
| 55 | */ | 94 | */ |
| 56 | public function role_edit(){ | 95 | public function role_edit(){ |
| 57 | //TODO::查询当前名称是否重复 | 96 | //TODO::查询当前名称是否重复 |
| @@ -69,10 +108,11 @@ class RoleLogic extends BaseLogic | @@ -69,10 +108,11 @@ class RoleLogic extends BaseLogic | ||
| 69 | } | 108 | } |
| 70 | 109 | ||
| 71 | /** | 110 | /** |
| 72 | - * @name :修改状态/排序 | ||
| 73 | - * @return void | ||
| 74 | - * @author :liyuhang | ||
| 75 | - * @method | 111 | + * @remark :编辑角色状态 |
| 112 | + * @name :role_status | ||
| 113 | + * @author :lyh | ||
| 114 | + * @method :post | ||
| 115 | + * @time :2023/6/17 16:38 | ||
| 76 | */ | 116 | */ |
| 77 | public function role_status(){ | 117 | public function role_status(){ |
| 78 | $this->edit($this->param,['id'=>$this->param['id']]); | 118 | $this->edit($this->param,['id'=>$this->param['id']]); |
| @@ -80,9 +120,11 @@ class RoleLogic extends BaseLogic | @@ -80,9 +120,11 @@ class RoleLogic extends BaseLogic | ||
| 80 | } | 120 | } |
| 81 | 121 | ||
| 82 | /** | 122 | /** |
| 83 | - * @name :删除角色 | ||
| 84 | - * @return void | ||
| 85 | - * @author :liyuhang | 123 | + * @remark :删除角色 |
| 124 | + * @name :role_del | ||
| 125 | + * @author :lyh | ||
| 126 | + * @method :post | ||
| 127 | + * @time :2023/6/17 16:38 | ||
| 86 | */ | 128 | */ |
| 87 | public function role_del(){ | 129 | public function role_del(){ |
| 88 | //查询当前角色下是否有用户 | 130 | //查询当前角色下是否有用户 |
| @@ -100,38 +142,4 @@ class RoleLogic extends BaseLogic | @@ -100,38 +142,4 @@ class RoleLogic extends BaseLogic | ||
| 100 | return $this->success(); | 142 | return $this->success(); |
| 101 | } | 143 | } |
| 102 | 144 | ||
| 103 | - /** | ||
| 104 | - * @name :获取角色详情 | ||
| 105 | - * @return void | ||
| 106 | - * @author :liyuhang | ||
| 107 | - * @method | ||
| 108 | - */ | ||
| 109 | - public function role_info(){ | ||
| 110 | - $info = $this->info($this->param); | ||
| 111 | - return $this->success($info); | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - /** | ||
| 115 | - * @name :获取菜单列表 | ||
| 116 | - * @return array | ||
| 117 | - * @author :liyuhang | ||
| 118 | - * @method | ||
| 119 | - */ | ||
| 120 | - public function role_get_menu(){ | ||
| 121 | - //根据当前登录用户角色返回用户菜单列表 | ||
| 122 | - $info = $this->model->read(['id'=>$this->user['role_id']]); | ||
| 123 | - $info['role_menu'] = trim($info['role_menu'],','); | ||
| 124 | - $menuModel = new ProjectMenuModel(); | ||
| 125 | - $lists = $menuModel->where(['status'=>0])->whereIn('id',explode(',',$info['role_menu']))->get(); | ||
| 126 | - $lists = $lists->toArray(); | ||
| 127 | - $menu = array(); | ||
| 128 | - foreach ($lists as $k => $v){ | ||
| 129 | - $v = (array)$v; | ||
| 130 | - if ($v['pid'] == 0) { | ||
| 131 | - $v['sub'] = _get_child($v['id'], $lists); | ||
| 132 | - $menu[] = $v; | ||
| 133 | - } | ||
| 134 | - } | ||
| 135 | - return $this->success($menu); | ||
| 136 | - } | ||
| 137 | } | 145 | } |
| @@ -19,19 +19,25 @@ class UserLogic extends BaseLogic | @@ -19,19 +19,25 @@ class UserLogic extends BaseLogic | ||
| 19 | $this->model = new User(); | 19 | $this->model = new User(); |
| 20 | $this->param = $this->requestAll; | 20 | $this->param = $this->requestAll; |
| 21 | } | 21 | } |
| 22 | + | ||
| 22 | /** | 23 | /** |
| 23 | - * @name :用户详情 | ||
| 24 | - * @return void | ||
| 25 | - * @author :liyuhang | ||
| 26 | - * @method | 24 | + * @remark :获取用户详情 |
| 25 | + * @name :User_info | ||
| 26 | + * @author :lyh | ||
| 27 | + * @method :post | ||
| 28 | + * @time :2023/6/17 16:42 | ||
| 27 | */ | 29 | */ |
| 28 | public function user_info(){ | 30 | public function user_info(){ |
| 29 | $info = $this->model->read($this->param); | 31 | $info = $this->model->read($this->param); |
| 30 | return $this->success($info); | 32 | return $this->success($info); |
| 31 | } | 33 | } |
| 34 | + | ||
| 32 | /** | 35 | /** |
| 33 | - * @name :添加会员 | ||
| 34 | - * @author :liyuhang | 36 | + * @remark :添加用户 |
| 37 | + * @name :user_add | ||
| 38 | + * @author :lyh | ||
| 39 | + * @method :post | ||
| 40 | + * @time :2023/6/17 16:42 | ||
| 35 | */ | 41 | */ |
| 36 | public function user_add(){ | 42 | public function user_add(){ |
| 37 | //验证当前用户是否存在 | 43 | //验证当前用户是否存在 |
| @@ -56,8 +62,11 @@ class UserLogic extends BaseLogic | @@ -56,8 +62,11 @@ class UserLogic extends BaseLogic | ||
| 56 | } | 62 | } |
| 57 | 63 | ||
| 58 | /** | 64 | /** |
| 59 | - * @name :编辑用户 | ||
| 60 | - * @author :liyuhang | 65 | + * @remark :编辑用户 |
| 66 | + * @name :user_edit | ||
| 67 | + * @author :lyh | ||
| 68 | + * @method :post | ||
| 69 | + * @time :2023/6/17 16:42 | ||
| 61 | */ | 70 | */ |
| 62 | public function user_edit(){ | 71 | public function user_edit(){ |
| 63 | $condition = [ | 72 | $condition = [ |
| @@ -82,8 +91,11 @@ class UserLogic extends BaseLogic | @@ -82,8 +91,11 @@ class UserLogic extends BaseLogic | ||
| 82 | } | 91 | } |
| 83 | 92 | ||
| 84 | /** | 93 | /** |
| 85 | - * @name :编辑状态/排序 | ||
| 86 | - * @author :liyuhang | 94 | + * @remark :编辑状态与排序 |
| 95 | + * @name :user_status | ||
| 96 | + * @author :lyh | ||
| 97 | + * @method :post | ||
| 98 | + * @time :2023/6/17 16:41 | ||
| 87 | */ | 99 | */ |
| 88 | public function user_status(){ | 100 | public function user_status(){ |
| 89 | $this->param['operator_id'] = $this->user['id']; | 101 | $this->param['operator_id'] = $this->user['id']; |
| @@ -95,8 +107,11 @@ class UserLogic extends BaseLogic | @@ -95,8 +107,11 @@ class UserLogic extends BaseLogic | ||
| 95 | } | 107 | } |
| 96 | 108 | ||
| 97 | /** | 109 | /** |
| 98 | - * @name :删除用户(逻辑删除) | ||
| 99 | - * @author :liyuhang | 110 | + * @remark :删除用户 |
| 111 | + * @name :user_del | ||
| 112 | + * @author :lyh | ||
| 113 | + * @method :post | ||
| 114 | + * @time :2023/6/17 16:41 | ||
| 100 | */ | 115 | */ |
| 101 | public function user_del(){ | 116 | public function user_del(){ |
| 102 | $this->param['id'] = ['in',$this->param['id']]; | 117 | $this->param['id'] = ['in',$this->param['id']]; |
| @@ -107,10 +122,11 @@ class UserLogic extends BaseLogic | @@ -107,10 +122,11 @@ class UserLogic extends BaseLogic | ||
| 107 | 122 | ||
| 108 | /** | 123 | /** |
| 109 | * @param $param | 124 | * @param $param |
| 110 | - * @name :编辑管理员 | ||
| 111 | - * @return bool | ||
| 112 | - * @author :liyuhang | ||
| 113 | - * @method | 125 | + * @remark :编辑用户 |
| 126 | + * @name :edits | ||
| 127 | + * @author :lyh | ||
| 128 | + * @method :post | ||
| 129 | + * @time :2023/6/17 16:41 | ||
| 114 | */ | 130 | */ |
| 115 | public function edits($param){ | 131 | public function edits($param){ |
| 116 | //查看密码是否修改 | 132 | //查看密码是否修改 |
| @@ -27,10 +27,12 @@ class UserLoginLogic | @@ -27,10 +27,12 @@ class UserLoginLogic | ||
| 27 | 27 | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | - /*** | ||
| 31 | - * @name :登录 | ||
| 32 | - * @author :liyuhang | ||
| 33 | - * @method | 30 | + /** |
| 31 | + * @remark :登录接口 | ||
| 32 | + * @name :login | ||
| 33 | + * @author :lyh | ||
| 34 | + * @method :post | ||
| 35 | + * @time :2023/6/17 16:43 | ||
| 34 | */ | 36 | */ |
| 35 | public function login(){ | 37 | public function login(){ |
| 36 | //验证账号密码是否正确 | 38 | //验证账号密码是否正确 |
-
请 注册 或 登录 后发表评论