正在显示
14 个修改的文件
包含
99 行增加
和
124 行删除
| @@ -6,9 +6,7 @@ use App\Enums\Common\Code; | @@ -6,9 +6,7 @@ use App\Enums\Common\Code; | ||
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | use App\Http\Logic\Bside\Blog\BlogCategoryLogic; | 7 | use App\Http\Logic\Bside\Blog\BlogCategoryLogic; |
| 8 | use App\Http\Requests\Bside\Blog\BlogCategoryRequest; | 8 | use App\Http\Requests\Bside\Blog\BlogCategoryRequest; |
| 9 | -use App\Models\Blog\Blog as BlogModel; | ||
| 10 | use App\Models\Blog\BlogCategory as BlogCategoryModel; | 9 | use App\Models\Blog\BlogCategory as BlogCategoryModel; |
| 11 | -use Illuminate\Http\Request; | ||
| 12 | 10 | ||
| 13 | class BlogCategoryController extends BaseController | 11 | class BlogCategoryController extends BaseController |
| 14 | { | 12 | { |
| @@ -3,14 +3,12 @@ | @@ -3,14 +3,12 @@ | ||
| 3 | namespace App\Http\Controllers\Bside\Blog; | 3 | namespace App\Http\Controllers\Bside\Blog; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | -use App\Helper\Common; | ||
| 7 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 8 | use App\Http\Logic\Bside\Blog\BlogCategoryLogic; | 7 | use App\Http\Logic\Bside\Blog\BlogCategoryLogic; |
| 9 | use App\Http\Logic\Bside\Blog\BlogLabelLogic; | 8 | use App\Http\Logic\Bside\Blog\BlogLabelLogic; |
| 10 | use App\Http\Logic\Bside\Blog\BlogLogic; | 9 | use App\Http\Logic\Bside\Blog\BlogLogic; |
| 11 | use App\Http\Requests\Bside\Blog\BlogRequest; | 10 | use App\Http\Requests\Bside\Blog\BlogRequest; |
| 12 | use App\Models\Blog\Blog as BlogModel; | 11 | use App\Models\Blog\Blog as BlogModel; |
| 13 | -use Illuminate\Http\Request; | ||
| 14 | 12 | ||
| 15 | class BlogController extends BaseController | 13 | class BlogController extends BaseController |
| 16 | { | 14 | { |
| @@ -65,7 +65,7 @@ class BlogLabelController extends BaseController | @@ -65,7 +65,7 @@ class BlogLabelController extends BaseController | ||
| 65 | ],[ | 65 | ],[ |
| 66 | 'id.required' => 'ID不能为空', | 66 | 'id.required' => 'ID不能为空', |
| 67 | ]); | 67 | ]); |
| 68 | - $blogLabelLogic->edit_blog_label(); | 68 | + $blogLabelLogic->status_blog_label(); |
| 69 | //TODO::写入日志 | 69 | //TODO::写入日志 |
| 70 | $this->response('success'); | 70 | $this->response('success'); |
| 71 | } | 71 | } |
| @@ -7,6 +7,7 @@ use App\Http\Controllers\Bside\BaseController; | @@ -7,6 +7,7 @@ use App\Http\Controllers\Bside\BaseController; | ||
| 7 | use App\Http\Controllers\Bside\Ids; | 7 | use App\Http\Controllers\Bside\Ids; |
| 8 | use App\Http\Controllers\Bside\json; | 8 | use App\Http\Controllers\Bside\json; |
| 9 | use App\Http\Logic\Bside\ProjectGroupLogic; | 9 | use App\Http\Logic\Bside\ProjectGroupLogic; |
| 10 | +use App\Http\Logic\Bside\User\GroupLogic; | ||
| 10 | use App\Http\Requests\Bside\User\ProjectGroupRequest; | 11 | use App\Http\Requests\Bside\User\ProjectGroupRequest; |
| 11 | use App\Models\ProjectGroup as ProjectGroupModel; | 12 | use App\Models\ProjectGroup as ProjectGroupModel; |
| 12 | use App\Models\User\User as UserModel; | 13 | use App\Models\User\User as UserModel; |
| @@ -36,16 +37,13 @@ class ProjectGroupController extends BaseController | @@ -36,16 +37,13 @@ class ProjectGroupController extends BaseController | ||
| 36 | * @author :liyuhang | 37 | * @author :liyuhang |
| 37 | * @method | 38 | * @method |
| 38 | */ | 39 | */ |
| 39 | - public function info(ProjectGroupModel $projectGroupModel){ | 40 | + public function info(GroupLogic $groupLogic){ |
| 40 | $this->request->validate([ | 41 | $this->request->validate([ |
| 41 | 'id'=>['required', new Ids()], | 42 | 'id'=>['required', new Ids()], |
| 42 | ],[ | 43 | ],[ |
| 43 | 'id.required' => 'ID不能为空', | 44 | 'id.required' => 'ID不能为空', |
| 44 | ]); | 45 | ]); |
| 45 | - $rs = $projectGroupModel->read($this->param); | ||
| 46 | - if($rs === false){ | ||
| 47 | - $this->response('error',Code::USER_ERROR); | ||
| 48 | - } | 46 | + $groupLogic->group_info(); |
| 49 | $this->response('success'); | 47 | $this->response('success'); |
| 50 | } | 48 | } |
| 51 | /** | 49 | /** |
| @@ -54,10 +52,8 @@ class ProjectGroupController extends BaseController | @@ -54,10 +52,8 @@ class ProjectGroupController extends BaseController | ||
| 54 | * @author :liyuhang | 52 | * @author :liyuhang |
| 55 | * @method | 53 | * @method |
| 56 | */ | 54 | */ |
| 57 | - public function get_user_lists(UserModel $userModel){ | ||
| 58 | - $this->map['project_id'] = $this->user['project_id']; | ||
| 59 | - //获取当前项目下的所有用户 | ||
| 60 | - $lists = $userModel->list($this->map); | 55 | + public function get_user_lists(GroupLogic $groupLogic){ |
| 56 | + $lists = $groupLogic->user_list(); | ||
| 61 | $this->response('success',Code::SUCCESS,$lists); | 57 | $this->response('success',Code::SUCCESS,$lists); |
| 62 | } | 58 | } |
| 63 | /** | 59 | /** |
| @@ -68,18 +64,9 @@ class ProjectGroupController extends BaseController | @@ -68,18 +64,9 @@ class ProjectGroupController extends BaseController | ||
| 68 | * @author :liyuhang | 64 | * @author :liyuhang |
| 69 | * @method | 65 | * @method |
| 70 | */ | 66 | */ |
| 71 | - public function add(ProjectGroupRequest $request,ProjectGroupModel $projectGroupModel){ | 67 | + public function add(ProjectGroupRequest $request,GroupLogic $groupLogic){ |
| 72 | $request->validated(); | 68 | $request->validated(); |
| 73 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 74 | - //TODO::成员列表:user_list | ||
| 75 | - if(!isset($this->param['user_list']) || empty($this->param['user_list'])){ | ||
| 76 | - $this->param['user_list'] = $this->uid; | ||
| 77 | - } | ||
| 78 | - $this->param['admin_id'] = $this->uid; | ||
| 79 | - $rs = $projectGroupModel->add($this->param); | ||
| 80 | - if($rs === false){ | ||
| 81 | - $this->response('error',Code::USER_ERROR); | ||
| 82 | - } | 69 | + $groupLogic->group_add($this->param); |
| 83 | $this->response('success'); | 70 | $this->response('success'); |
| 84 | } | 71 | } |
| 85 | 72 | ||
| @@ -91,16 +78,13 @@ class ProjectGroupController extends BaseController | @@ -91,16 +78,13 @@ class ProjectGroupController extends BaseController | ||
| 91 | * @author :liyuhang | 78 | * @author :liyuhang |
| 92 | * @method | 79 | * @method |
| 93 | */ | 80 | */ |
| 94 | - public function edit(ProjectGroupRequest $request,ProjectGroupModel $projectGroupModel){ | 81 | + public function edit(ProjectGroupRequest $request,GroupLogic $groupLogic){ |
| 95 | $request->validate([ | 82 | $request->validate([ |
| 96 | 'id'=>['required'], | 83 | 'id'=>['required'], |
| 97 | ],[ | 84 | ],[ |
| 98 | 'id.required' => 'ID不能为空', | 85 | 'id.required' => 'ID不能为空', |
| 99 | ]); | 86 | ]); |
| 100 | - $rs = $projectGroupModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 101 | - if($rs === false){ | ||
| 102 | - $this->response('error',Code::USER_ERROR); | ||
| 103 | - } | 87 | + $groupLogic->group_edit(); |
| 104 | $this->response('success'); | 88 | $this->response('success'); |
| 105 | } | 89 | } |
| 106 | 90 | ||
| @@ -110,16 +94,13 @@ class ProjectGroupController extends BaseController | @@ -110,16 +94,13 @@ class ProjectGroupController extends BaseController | ||
| 110 | * @author :liyuhang | 94 | * @author :liyuhang |
| 111 | * @method | 95 | * @method |
| 112 | */ | 96 | */ |
| 113 | - public function del(ProjectGroupModel $projectGroupModel){ | 97 | + public function del(GroupLogic $groupLogic){ |
| 114 | $this->request->validate([ | 98 | $this->request->validate([ |
| 115 | 'id'=>['required'], | 99 | 'id'=>['required'], |
| 116 | ],[ | 100 | ],[ |
| 117 | 'id.required' => 'ID不能为空', | 101 | 'id.required' => 'ID不能为空', |
| 118 | ]); | 102 | ]); |
| 119 | - $rs = $projectGroupModel->del($this->param); | ||
| 120 | - if($rs === false){ | ||
| 121 | - $this->response('error',Code::USER_ERROR); | ||
| 122 | - } | 103 | + $groupLogic->group_del($this->param); |
| 123 | $this->response('success'); | 104 | $this->response('success'); |
| 124 | } | 105 | } |
| 125 | } | 106 | } |
| @@ -113,16 +113,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -113,16 +113,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 113 | * @method | 113 | * @method |
| 114 | */ | 114 | */ |
| 115 | public function info_blog_category(){ | 115 | public function info_blog_category(){ |
| 116 | - //读取缓存 | ||
| 117 | - $info = Common::get_user_cache($this->model->getTable(),$this->param['id']); | ||
| 118 | - if(empty($info)){ | ||
| 119 | - $info = $this->model->read($this->param); | ||
| 120 | - if($info === false){ | ||
| 121 | - $this->fail('error'); | ||
| 122 | - } | ||
| 123 | - //写入缓存 | ||
| 124 | - Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); | ||
| 125 | - } | 116 | + $info = $this->info($this->param); |
| 126 | return $this->success($info); | 117 | return $this->success($info); |
| 127 | } | 118 | } |
| 128 | 119 |
| @@ -76,15 +76,22 @@ class BlogLabelLogic extends BaseLogic | @@ -76,15 +76,22 @@ class BlogLabelLogic extends BaseLogic | ||
| 76 | $this->fail('当前标签名称已存在'); | 76 | $this->fail('当前标签名称已存在'); |
| 77 | } | 77 | } |
| 78 | $this->param['operator_id'] = $this->user['id']; | 78 | $this->param['operator_id'] = $this->user['id']; |
| 79 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 80 | - //TODO::路由映射 | ||
| 81 | - if($rs === false){ | ||
| 82 | - $this->fail('error'); | ||
| 83 | - } | 79 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 84 | return $this->success(); | 80 | return $this->success(); |
| 85 | } | 81 | } |
| 86 | 82 | ||
| 87 | /** | 83 | /** |
| 84 | + * @name :编辑状态 | ||
| 85 | + * @return array | ||
| 86 | + * @author :liyuhang | ||
| 87 | + * @method | ||
| 88 | + */ | ||
| 89 | + public function status_blog_label(){ | ||
| 90 | + $this->param['operator_id'] = $this->user['id']; | ||
| 91 | + $this->edit($this->param,['id'=>$this->param['id']]); | ||
| 92 | + return $this->success(); | ||
| 93 | + } | ||
| 94 | + /** | ||
| 88 | * @name :删除标签 | 95 | * @name :删除标签 |
| 89 | * @return array | 96 | * @return array |
| 90 | * @author :liyuhang | 97 | * @author :liyuhang |
| @@ -101,12 +108,7 @@ class BlogLabelLogic extends BaseLogic | @@ -101,12 +108,7 @@ class BlogLabelLogic extends BaseLogic | ||
| 101 | } | 108 | } |
| 102 | } | 109 | } |
| 103 | $this->param['id'] = ['in',$this->param['id']]; | 110 | $this->param['id'] = ['in',$this->param['id']]; |
| 104 | - $rs = $this->model->del($this->param); | ||
| 105 | - if($rs === false){ | ||
| 106 | - $this->fail('error'); | ||
| 107 | - } | ||
| 108 | - //清除缓存 | ||
| 109 | - Common::del_user_cache($this->model->getTable(),$ids); | 111 | + $this->del($this->param,$ids); |
| 110 | return $this->success(); | 112 | return $this->success(); |
| 111 | } | 113 | } |
| 112 | } | 114 | } |
| @@ -116,9 +116,7 @@ class BlogLogic extends BaseLogic | @@ -116,9 +116,7 @@ class BlogLogic extends BaseLogic | ||
| 116 | $this->param['image'] = $this->upload(); | 116 | $this->param['image'] = $this->upload(); |
| 117 | } | 117 | } |
| 118 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); | 118 | RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $this->param['id'], $this->user['project_id']); |
| 119 | - $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 120 | - //清除缓存 | ||
| 121 | - Common::del_user_cache($this->model->getTable(),$this->param['id']); | 119 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 122 | DB::commit(); | 120 | DB::commit(); |
| 123 | }catch (\Exception $e){ | 121 | }catch (\Exception $e){ |
| 124 | DB::rollBack(); | 122 | DB::rollBack(); |
| @@ -22,10 +22,7 @@ class MailLogic extends BaseLogic | @@ -22,10 +22,7 @@ class MailLogic extends BaseLogic | ||
| 22 | * @author :liyuhang | 22 | * @author :liyuhang |
| 23 | */ | 23 | */ |
| 24 | public function mail_info(){ | 24 | public function mail_info(){ |
| 25 | - $info = $this->model->read($this->param); | ||
| 26 | - if($info === false){ | ||
| 27 | - $this->fail('当前数据不存在',Code::USER_ERROR); | ||
| 28 | - } | 25 | + $info = $this->info($this->param); |
| 29 | //生成一条阅读记录 | 26 | //生成一条阅读记录 |
| 30 | $mailUserModel = new MailUserModel(); | 27 | $mailUserModel = new MailUserModel(); |
| 31 | $data = [ | 28 | $data = [ |
| @@ -44,10 +44,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -44,10 +44,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 44 | * @method | 44 | * @method |
| 45 | */ | 45 | */ |
| 46 | public function info_news_category(){ | 46 | public function info_news_category(){ |
| 47 | - $info = $this->model->read($this->param); | ||
| 48 | - if($info === false){ | ||
| 49 | - $this->fail('error',Code::USER_ERROR); | ||
| 50 | - } | 47 | + $info = $this->info($this->param); |
| 51 | return $this->success($info); | 48 | return $this->success($info); |
| 52 | } | 49 | } |
| 53 | /** | 50 | /** |
| @@ -114,10 +111,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -114,10 +111,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 114 | $this->fail('当前分类名称已存在'); | 111 | $this->fail('当前分类名称已存在'); |
| 115 | } | 112 | } |
| 116 | $this->param['operator_id'] = $this->user['id']; | 113 | $this->param['operator_id'] = $this->user['id']; |
| 117 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 118 | - if($rs === false){ | ||
| 119 | - $this->fail('error'); | ||
| 120 | - } | 114 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 121 | return $this->success(); | 115 | return $this->success(); |
| 122 | } | 116 | } |
| 123 | 117 | ||
| @@ -130,10 +124,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -130,10 +124,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 130 | */ | 124 | */ |
| 131 | public function status_news_category(){ | 125 | public function status_news_category(){ |
| 132 | $this->param['operator_id'] = $this->user['id']; | 126 | $this->param['operator_id'] = $this->user['id']; |
| 133 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 134 | - if($rs === false){ | ||
| 135 | - $this->fail('error'); | ||
| 136 | - } | 127 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 137 | return $this->success(); | 128 | return $this->success(); |
| 138 | } | 129 | } |
| 139 | /** | 130 | /** |
| @@ -144,6 +135,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -144,6 +135,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 144 | * @method | 135 | * @method |
| 145 | */ | 136 | */ |
| 146 | public function del_news_category(){ | 137 | public function del_news_category(){ |
| 138 | + $ids = $this->param['id']; | ||
| 147 | foreach ($this->param['id'] as $v){ | 139 | foreach ($this->param['id'] as $v){ |
| 148 | //查询是否有子分类 | 140 | //查询是否有子分类 |
| 149 | $rs = $this->model->read(['pid'=>$v],['id']); | 141 | $rs = $this->model->read(['pid'=>$v],['id']); |
| @@ -158,10 +150,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -158,10 +150,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 158 | } | 150 | } |
| 159 | } | 151 | } |
| 160 | $this->param['id'] = ['in',$this->param['id']]; | 152 | $this->param['id'] = ['in',$this->param['id']]; |
| 161 | - $rs = $this->model->del($this->param); | ||
| 162 | - if($rs === false){ | ||
| 163 | - $this->fail('error'); | ||
| 164 | - } | 153 | + $this->del($this->param,$ids); |
| 165 | return $this->success(); | 154 | return $this->success(); |
| 166 | } | 155 | } |
| 167 | } | 156 | } |
| @@ -158,18 +158,14 @@ class NewsLogic extends BaseLogic | @@ -158,18 +158,14 @@ class NewsLogic extends BaseLogic | ||
| 158 | * @method | 158 | * @method |
| 159 | */ | 159 | */ |
| 160 | public function news_info(){ | 160 | public function news_info(){ |
| 161 | - $info = $this->model->read($this->param); | ||
| 162 | - //获取分类名称 | ||
| 163 | - $cate = explode(',',trim($info['category_id'],',')); | ||
| 164 | - $newsCategoryModel = new NewsCategoryModel(); | ||
| 165 | - $category_list = $newsCategoryModel->list(['id'=>['in',$cate]],'id',['name']); | ||
| 166 | - $str = ''; | ||
| 167 | - foreach ($category_list as $v){ | ||
| 168 | - $str .= $v['name'].','; | ||
| 169 | - } | ||
| 170 | - $info['category_id'] = trim($str,','); | ||
| 171 | - if($info === false){ | ||
| 172 | - $this->fail('error'); | 161 | + //读取缓存 |
| 162 | + $info = Common::get_user_cache($this->model->getTable(),$this->param['id']); | ||
| 163 | + if(empty($info)){ | ||
| 164 | + $info = $this->model->read($this->param); | ||
| 165 | + $newsCategoryLogic = new NewsCategoryLogic(); | ||
| 166 | + $info = $newsCategoryLogic->get_category_name($info); | ||
| 167 | + //写入缓存 | ||
| 168 | + Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); | ||
| 173 | } | 169 | } |
| 174 | return $this->success($info); | 170 | return $this->success($info); |
| 175 | } | 171 | } |
| @@ -181,11 +177,9 @@ class NewsLogic extends BaseLogic | @@ -181,11 +177,9 @@ class NewsLogic extends BaseLogic | ||
| 181 | * @method | 177 | * @method |
| 182 | */ | 178 | */ |
| 183 | public function news_del(){ | 179 | public function news_del(){ |
| 180 | + $ids = $this->param['id']; | ||
| 184 | $this->param['id'] = ['in',$this->param['id']]; | 181 | $this->param['id'] = ['in',$this->param['id']]; |
| 185 | - $rs = $this->model->del($this->param); | ||
| 186 | - if($rs === false){ | ||
| 187 | - $this->fail('error'); | ||
| 188 | - } | 182 | + $this->del($this->param,$ids); |
| 189 | return $this->success(); | 183 | return $this->success(); |
| 190 | } | 184 | } |
| 191 | } | 185 | } |
| @@ -14,4 +14,47 @@ class GroupLogic extends BaseLogic | @@ -14,4 +14,47 @@ class GroupLogic extends BaseLogic | ||
| 14 | $this->model = new ProjectGroup(); | 14 | $this->model = new ProjectGroup(); |
| 15 | $this->param = $this->requestAll; | 15 | $this->param = $this->requestAll; |
| 16 | } | 16 | } |
| 17 | + | ||
| 18 | + public function user_list(){ | ||
| 19 | + return $this->success(); | ||
| 20 | + } | ||
| 21 | + /** | ||
| 22 | + * @name :添加 | ||
| 23 | + * @return void | ||
| 24 | + * @author :liyuhang | ||
| 25 | + * @method | ||
| 26 | + */ | ||
| 27 | + public function group_add(){ | ||
| 28 | + return $this->success(); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @name :编辑 | ||
| 33 | + * @return void | ||
| 34 | + * @author :liyuhang | ||
| 35 | + * @method | ||
| 36 | + */ | ||
| 37 | + public function group_edit(){ | ||
| 38 | + return $this->success(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @name :详情 | ||
| 43 | + * @return void | ||
| 44 | + * @author :liyuhang | ||
| 45 | + * @method | ||
| 46 | + */ | ||
| 47 | + public function group_info(){ | ||
| 48 | + return $this->success(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @name :删除 | ||
| 53 | + * @return void | ||
| 54 | + * @author :liyuhang | ||
| 55 | + * @method | ||
| 56 | + */ | ||
| 57 | + public function group_del(){ | ||
| 58 | + return $this->success(); | ||
| 59 | + } | ||
| 17 | } | 60 | } |
| @@ -64,10 +64,7 @@ class RoleLogic extends BaseLogic | @@ -64,10 +64,7 @@ class RoleLogic extends BaseLogic | ||
| 64 | if($info !== false){ | 64 | if($info !== false){ |
| 65 | $this->fail('当前添加的角色已存在'); | 65 | $this->fail('当前添加的角色已存在'); |
| 66 | } | 66 | } |
| 67 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 68 | - if($rs === false){ | ||
| 69 | - $this->fail('error'); | ||
| 70 | - } | 67 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 71 | return $this->success(); | 68 | return $this->success(); |
| 72 | } | 69 | } |
| 73 | 70 | ||
| @@ -78,10 +75,7 @@ class RoleLogic extends BaseLogic | @@ -78,10 +75,7 @@ class RoleLogic extends BaseLogic | ||
| 78 | * @method | 75 | * @method |
| 79 | */ | 76 | */ |
| 80 | public function role_status(){ | 77 | public function role_status(){ |
| 81 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 82 | - if($rs === false){ | ||
| 83 | - $this->fail('error',Code::USER_PARAMS_ERROE); | ||
| 84 | - } | 78 | + $this->edit($this->param,['id'=>$this->param['id']]); |
| 85 | return $this->success(); | 79 | return $this->success(); |
| 86 | } | 80 | } |
| 87 | 81 | ||
| @@ -100,11 +94,9 @@ class RoleLogic extends BaseLogic | @@ -100,11 +94,9 @@ class RoleLogic extends BaseLogic | ||
| 100 | $this->fail('当前角色下有用户存在,不允许删除',Code::USER_ERROR); | 94 | $this->fail('当前角色下有用户存在,不允许删除',Code::USER_ERROR); |
| 101 | } | 95 | } |
| 102 | } | 96 | } |
| 97 | + $ids = $this->param['id']; | ||
| 103 | $this->param['id'] = ['in',$this->param['id']]; | 98 | $this->param['id'] = ['in',$this->param['id']]; |
| 104 | - $rs = $this->model->del($this->param); | ||
| 105 | - if($rs === false){ | ||
| 106 | - $this->fail('error',Code::USER_ERROR); | ||
| 107 | - } | 99 | + $this->del($this->param,$ids); |
| 108 | return $this->success(); | 100 | return $this->success(); |
| 109 | } | 101 | } |
| 110 | 102 | ||
| @@ -115,10 +107,7 @@ class RoleLogic extends BaseLogic | @@ -115,10 +107,7 @@ class RoleLogic extends BaseLogic | ||
| 115 | * @method | 107 | * @method |
| 116 | */ | 108 | */ |
| 117 | public function role_info(){ | 109 | public function role_info(){ |
| 118 | - $info = $this->model->read($this->param); | ||
| 119 | - if($info === false){ | ||
| 120 | - $this->fail('error',Code::USER_ERROR); | ||
| 121 | - } | 110 | + $info = $this->info($this->param); |
| 122 | return $this->success($info); | 111 | return $this->success($info); |
| 123 | } | 112 | } |
| 124 | 113 |
| @@ -24,10 +24,7 @@ class UserLogic extends BaseLogic | @@ -24,10 +24,7 @@ class UserLogic extends BaseLogic | ||
| 24 | * @method | 24 | * @method |
| 25 | */ | 25 | */ |
| 26 | public function user_info(){ | 26 | public function user_info(){ |
| 27 | - $info = $this->model->read($this->param); | ||
| 28 | - if($info === false){ | ||
| 29 | - $this->fail('error',Code::USER_ERROR); | ||
| 30 | - } | 27 | + $info = $this->info($this->param); |
| 31 | return $this->success($info); | 28 | return $this->success($info); |
| 32 | } | 29 | } |
| 33 | /** | 30 | /** |
| @@ -111,11 +108,9 @@ class UserLogic extends BaseLogic | @@ -111,11 +108,9 @@ class UserLogic extends BaseLogic | ||
| 111 | * @method | 108 | * @method |
| 112 | */ | 109 | */ |
| 113 | public function user_del(){ | 110 | public function user_del(){ |
| 114 | - $this->param['operator_id'] = $this->user['id']; | ||
| 115 | - $rs = $this->model->edit(['status'=>2],['id'=>['in',$this->param['id']]]); | ||
| 116 | - if($rs === false){ | ||
| 117 | - $this->fail('error',Code::USER_ERROR); | ||
| 118 | - } | 111 | + $ids = $this->param['id']; |
| 112 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 113 | + $this->del($this->param,$ids); | ||
| 119 | return $this->success(); | 114 | return $this->success(); |
| 120 | } | 115 | } |
| 121 | 116 |
| @@ -324,12 +324,12 @@ class Logic | @@ -324,12 +324,12 @@ class Logic | ||
| 324 | * @author :liyuhang | 324 | * @author :liyuhang |
| 325 | * @method | 325 | * @method |
| 326 | */ | 326 | */ |
| 327 | - public function edit($map,$id){ | ||
| 328 | - $rs = $this->model->edit($map,['id'=>$id]); | 327 | + public function edit($map,$condition){ |
| 328 | + $rs = $this->model->edit($map,$condition); | ||
| 329 | if($rs === false){ | 329 | if($rs === false){ |
| 330 | $this->fail('error'); | 330 | $this->fail('error'); |
| 331 | } | 331 | } |
| 332 | - CommonHelper::del_user_cache($this->model->getTable(),$id); | 332 | + CommonHelper::del_user_cache($this->model->getTable(),$condition['id']); |
| 333 | $this->success(); | 333 | $this->success(); |
| 334 | } | 334 | } |
| 335 | 335 | ||
| @@ -344,7 +344,7 @@ class Logic | @@ -344,7 +344,7 @@ class Logic | ||
| 344 | if(empty($info)){ | 344 | if(empty($info)){ |
| 345 | $info = $this->model->read($map); | 345 | $info = $this->model->read($map); |
| 346 | if($info === false){ | 346 | if($info === false){ |
| 347 | - $this->fail('error'); | 347 | + $this->fail('当前数据不存在'); |
| 348 | } | 348 | } |
| 349 | CommonHelper::set_user_cache($info,$this->model->getTable(),$map['id']); | 349 | CommonHelper::set_user_cache($info,$this->model->getTable(),$map['id']); |
| 350 | } | 350 | } |
-
请 注册 或 登录 后发表评论