正在显示
12 个修改的文件
包含
268 行增加
和
15 行删除
| @@ -2,7 +2,11 @@ | @@ -2,7 +2,11 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Controllers\Aside\User; | 3 | namespace App\Http\Controllers\Aside\User; |
| 4 | 4 | ||
| 5 | +use App\Enums\Common\Code; | ||
| 5 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | +use App\Http\Logic\Aside\User\ProjectRoleLogic; | ||
| 8 | +use App\Http\Requests\Aside\User\ProjectRoleRequest; | ||
| 9 | +use App\Models\ProjectRole as ProjectRoleModel; | ||
| 6 | 10 | ||
| 7 | class ProjectRoleController extends BaseController | 11 | class ProjectRoleController extends BaseController |
| 8 | { | 12 | { |
| @@ -13,6 +17,61 @@ class ProjectRoleController extends BaseController | @@ -13,6 +17,61 @@ class ProjectRoleController extends BaseController | ||
| 13 | * @method | 17 | * @method |
| 14 | */ | 18 | */ |
| 15 | public function lists (){ | 19 | public function lists (){ |
| 20 | + $roleModel = new ProjectRoleModel(); | ||
| 21 | + $lists = $roleModel->lists($this->map,$this->page,$this->row,$this->order,['*']); | ||
| 22 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @name :添加角色 | ||
| 27 | + * @return void | ||
| 28 | + * @author :liyuhang | ||
| 29 | + * @method | ||
| 30 | + */ | ||
| 31 | + public function add(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){ | ||
| 32 | + $request->validated(); | ||
| 33 | + //TODO::添加 | ||
| 34 | + $this->response('success'); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @name :编辑角色 | ||
| 39 | + * @return void | ||
| 40 | + * @author :liyuhang | ||
| 41 | + * @method | ||
| 42 | + */ | ||
| 43 | + public function edit(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){ | ||
| 44 | + $request->validate([ | ||
| 45 | + 'id'=>'required' | ||
| 46 | + ],[ | ||
| 47 | + 'id.required' => 'ID不能为空' | ||
| 48 | + ]); | ||
| 49 | + //TODO::编辑 | ||
| 50 | + $this->response('success'); | ||
| 51 | + } | ||
| 16 | 52 | ||
| 53 | + public function info(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){ | ||
| 54 | + $request->validate([ | ||
| 55 | + 'id'=>'required' | ||
| 56 | + ],[ | ||
| 57 | + 'id.required' => 'ID不能为空' | ||
| 58 | + ]); | ||
| 59 | + //TODO::详情 | ||
| 60 | + $this->response('success'); | ||
| 61 | + } | ||
| 62 | + /** | ||
| 63 | + * @name :删除角色 | ||
| 64 | + * @return void | ||
| 65 | + * @author :liyuhang | ||
| 66 | + * @method | ||
| 67 | + */ | ||
| 68 | + public function del(ProjectRoleRequest $request,ProjectRoleLogic $roleLogic){ | ||
| 69 | + $request->validate([ | ||
| 70 | + 'id'=>'required' | ||
| 71 | + ],[ | ||
| 72 | + 'id.required' => 'ID不能为空' | ||
| 73 | + ]); | ||
| 74 | + //TODO::删除 | ||
| 75 | + $this->response('success'); | ||
| 17 | } | 76 | } |
| 18 | } | 77 | } |
| @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Aside\User; | @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Aside\User; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | +use App\Http\Logic\Aside\User\UserLogic; | ||
| 8 | +use App\Http\Requests\Aside\User\UserRequest; | ||
| 7 | use App\Models\User as UserModel; | 9 | use App\Models\User as UserModel; |
| 8 | 10 | ||
| 9 | class ProjectUserController extends BaseController | 11 | class ProjectUserController extends BaseController |
| @@ -16,17 +18,67 @@ class ProjectUserController extends BaseController | @@ -16,17 +18,67 @@ class ProjectUserController extends BaseController | ||
| 16 | */ | 18 | */ |
| 17 | public function lists(){ | 19 | public function lists(){ |
| 18 | $userModel = new UserModel(); | 20 | $userModel = new UserModel(); |
| 19 | - $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','mobile','name','created_at','updated_at','image','operator_id']); | 21 | + $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order, |
| 22 | + ['id','mobile','name','created_at','updated_at','image','operator_id']); | ||
| 20 | $this->response('列表',Code::SUCCESS,$lists); | 23 | $this->response('列表',Code::SUCCESS,$lists); |
| 21 | } | 24 | } |
| 22 | 25 | ||
| 23 | /** | 26 | /** |
| 27 | + * @name :详情 | ||
| 28 | + * @return void | ||
| 29 | + * @author :liyuhang | ||
| 30 | + * @method | ||
| 31 | + */ | ||
| 32 | + public function info(UserRequest $request,UserLogic $userLogic){ | ||
| 33 | + $request->validate([ | ||
| 34 | + 'id'=>'required' | ||
| 35 | + ],[ | ||
| 36 | + 'id.required' => 'ID不能为空' | ||
| 37 | + ]); | ||
| 38 | + $userLogic->user_info(); | ||
| 39 | + $this->response('success'); | ||
| 40 | + } | ||
| 41 | + /** | ||
| 24 | * @name :添加用户 | 42 | * @name :添加用户 |
| 25 | * @return void | 43 | * @return void |
| 26 | * @author :liyuhang | 44 | * @author :liyuhang |
| 27 | * @method | 45 | * @method |
| 28 | */ | 46 | */ |
| 29 | - public function add(){ | 47 | + public function add(UserRequest $request,UserLogic $userLogic){ |
| 48 | + $request->validated(); | ||
| 49 | + $userLogic->user_add(); | ||
| 50 | + $this->response('success'); | ||
| 51 | + } | ||
| 30 | 52 | ||
| 53 | + /** | ||
| 54 | + * @name : 编辑 | ||
| 55 | + * @return void | ||
| 56 | + * @author :liyuhang | ||
| 57 | + * @method | ||
| 58 | + */ | ||
| 59 | + public function edit(UserRequest $request,UserLogic $userLogic){ | ||
| 60 | + $request->validate([ | ||
| 61 | + 'id'=>'required' | ||
| 62 | + ],[ | ||
| 63 | + 'id.required' => 'ID不能为空' | ||
| 64 | + ]); | ||
| 65 | + $userLogic->user_edit(); | ||
| 66 | + $this->response('success'); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * @name :批量删除 | ||
| 71 | + * @return void | ||
| 72 | + * @author :liyuhang | ||
| 73 | + * @method | ||
| 74 | + */ | ||
| 75 | + public function del(UserRequest $request,UserLogic $userLogic){ | ||
| 76 | + $request->validate([ | ||
| 77 | + 'id'=>'required' | ||
| 78 | + ],[ | ||
| 79 | + 'id.required' => 'ID不能为空' | ||
| 80 | + ]); | ||
| 81 | + $userLogic->user_del(); | ||
| 82 | + $this->response('success'); | ||
| 31 | } | 83 | } |
| 32 | } | 84 | } |
| @@ -84,6 +84,12 @@ class BaseController extends Controller | @@ -84,6 +84,12 @@ class BaseController extends Controller | ||
| 84 | case 'row': | 84 | case 'row': |
| 85 | $this->row = $v; | 85 | $this->row = $v; |
| 86 | break; | 86 | break; |
| 87 | + case "status": | ||
| 88 | + $this->map['status'] = $v; | ||
| 89 | + break; | ||
| 90 | + case "category_id": | ||
| 91 | + $this->map['category_id'] = $v; | ||
| 92 | + break; | ||
| 87 | case "name": | 93 | case "name": |
| 88 | $this->map['name'] = ['like','%'.$v.'%']; | 94 | $this->map['name'] = ['like','%'.$v.'%']; |
| 89 | break; | 95 | break; |
| @@ -97,7 +103,9 @@ class BaseController extends Controller | @@ -97,7 +103,9 @@ class BaseController extends Controller | ||
| 97 | $this->map['updated_at'] = ['between', $this->_btw]; | 103 | $this->map['updated_at'] = ['between', $this->_btw]; |
| 98 | break; | 104 | break; |
| 99 | default: | 105 | default: |
| 100 | - $this->map[$k] = $v; | 106 | + if(!empty($v)){ |
| 107 | + $this->map[$k] = $v; | ||
| 108 | + } | ||
| 101 | break; | 109 | break; |
| 102 | } | 110 | } |
| 103 | } | 111 | } |
| @@ -20,7 +20,7 @@ class BlogController extends BaseController | @@ -20,7 +20,7 @@ class BlogController extends BaseController | ||
| 20 | public function lists(BlogModel $blogModel){ | 20 | public function lists(BlogModel $blogModel){ |
| 21 | //搜索条件 | 21 | //搜索条件 |
| 22 | $this->map['project_id'] = $this->user['project_id']; | 22 | $this->map['project_id'] = $this->user['project_id']; |
| 23 | - $lists = $blogModel->lists($this->map,$this->page,$this->row); | 23 | + $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order); |
| 24 | if(!empty($lists['list'])){ | 24 | if(!empty($lists['list'])){ |
| 25 | foreach ($lists['list'] as $k => $v){ | 25 | foreach ($lists['list'] as $k => $v){ |
| 26 | $blogCategoryModel= new BlogCategoryModel(); | 26 | $blogCategoryModel= new BlogCategoryModel(); |
| @@ -114,7 +114,7 @@ class ImageController | @@ -114,7 +114,7 @@ class ImageController | ||
| 114 | $filename = date('ymdHis').rand(10000,99999); | 114 | $filename = date('ymdHis').rand(10000,99999); |
| 115 | $res = $this->request->file('image')->move($url,$filename); | 115 | $res = $this->request->file('image')->move($url,$filename); |
| 116 | if ($res === false) { | 116 | if ($res === false) { |
| 117 | - return $this->fail($files->getError(), Code::USER_ERROR); | 117 | + return $this->response($files->getError(), Code::USER_ERROR); |
| 118 | } | 118 | } |
| 119 | $imageModel = new ImageModel(); | 119 | $imageModel = new ImageModel(); |
| 120 | $data = [ | 120 | $data = [ |
| @@ -126,7 +126,7 @@ class ImageController | @@ -126,7 +126,7 @@ class ImageController | ||
| 126 | ]; | 126 | ]; |
| 127 | $rs = $imageModel->add($data); | 127 | $rs = $imageModel->add($data); |
| 128 | if ($rs === false) { | 128 | if ($rs === false) { |
| 129 | - return $this->fail('添加失败', Code::USER_ERROR); | 129 | + return $this->response('添加失败', Code::USER_ERROR); |
| 130 | } | 130 | } |
| 131 | return $hash.$filename; | 131 | return $hash.$filename; |
| 132 | } | 132 | } |
| @@ -161,7 +161,7 @@ class ImageController | @@ -161,7 +161,7 @@ class ImageController | ||
| 161 | $filename = date('ymdHis').rand(10000,99999); | 161 | $filename = date('ymdHis').rand(10000,99999); |
| 162 | $res = $file->move($url,$filename); | 162 | $res = $file->move($url,$filename); |
| 163 | if ($res === false) { | 163 | if ($res === false) { |
| 164 | - return $this->fail($file->getError(), 400); | 164 | + return $this->response($file->getError(), Code::USER_ERROR); |
| 165 | } | 165 | } |
| 166 | $save_data[] = [ | 166 | $save_data[] = [ |
| 167 | 'path' => $url.$filename, | 167 | 'path' => $url.$filename, |
| @@ -173,8 +173,8 @@ class ImageController | @@ -173,8 +173,8 @@ class ImageController | ||
| 173 | $data[] = $hash.$filename; | 173 | $data[] = $hash.$filename; |
| 174 | } | 174 | } |
| 175 | $imageModel = new ImageModel(); | 175 | $imageModel = new ImageModel(); |
| 176 | - $imageModel->insertAll($data); | ||
| 177 | - $this->response('上传成功!', 200, $data); | 176 | + $imageModel->insertAll($save_data); |
| 177 | + return $data; | ||
| 178 | } | 178 | } |
| 179 | /** | 179 | /** |
| 180 | * @name 统一返回参数 | 180 | * @name 统一返回参数 |
| @@ -17,6 +17,19 @@ class UserLogic extends BaseLogic | @@ -17,6 +17,19 @@ class UserLogic extends BaseLogic | ||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | + * @name :获取详情 | ||
| 21 | + * @return void | ||
| 22 | + * @author :liyuhang | ||
| 23 | + * @method | ||
| 24 | + */ | ||
| 25 | + public function user_info(){ | ||
| 26 | + $info = $this->model->read($this->param); | ||
| 27 | + if($info === false){ | ||
| 28 | + $this->fail('添加失败'); | ||
| 29 | + } | ||
| 30 | + return $this->success($info); | ||
| 31 | + } | ||
| 32 | + /** | ||
| 20 | * @name :添加会员 | 33 | * @name :添加会员 |
| 21 | * @return void | 34 | * @return void |
| 22 | * @author :liyuhang | 35 | * @author :liyuhang |
| @@ -25,7 +38,47 @@ class UserLogic extends BaseLogic | @@ -25,7 +38,47 @@ class UserLogic extends BaseLogic | ||
| 25 | public function user_add(){ | 38 | public function user_add(){ |
| 26 | $info = $this->model->read(['mobile'=>$this->param['mobile']]); | 39 | $info = $this->model->read(['mobile'=>$this->param['mobile']]); |
| 27 | if($info !== false){ | 40 | if($info !== false){ |
| 28 | - $this->fail('error',Code::USER_ERROR); | 41 | + $this->fail('当前手机号码已存在'); |
| 42 | + } | ||
| 43 | + //TODO::上传头像 | ||
| 44 | + $rs = $this->model->add($this->param); | ||
| 45 | + if($rs === false){ | ||
| 46 | + $this->fail('添加失败'); | ||
| 47 | + } | ||
| 48 | + return $this->success(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @name :编辑会员 | ||
| 53 | + * @return void | ||
| 54 | + * @author :liyuhang | ||
| 55 | + * @method | ||
| 56 | + */ | ||
| 57 | + public function user_edit(){ | ||
| 58 | + $info = $this->model->read(['mobile'=>$this->param['mobile'],'id'=>['!=',$this->param['id']]]); | ||
| 59 | + if($info !== false){ | ||
| 60 | + $this->fail('当前手机号码已存在'); | ||
| 61 | + } | ||
| 62 | + //TODO::上传头像 | ||
| 63 | + $rs = $this->model->edits($this->param); | ||
| 64 | + if($rs === false){ | ||
| 65 | + $this->fail('添加失败'); | ||
| 66 | + } | ||
| 67 | + return $this->success(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @name :删除会员 | ||
| 72 | + * @return void | ||
| 73 | + * @author :liyuhang | ||
| 74 | + * @method | ||
| 75 | + */ | ||
| 76 | + public function user_del(){ | ||
| 77 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 78 | + $rs = $this->model->del($this->param); | ||
| 79 | + if($rs === false){ | ||
| 80 | + $this->fail('删除失败'); | ||
| 29 | } | 81 | } |
| 82 | + return $this->success(); | ||
| 30 | } | 83 | } |
| 31 | } | 84 | } |
| @@ -36,7 +36,7 @@ class MailLogic extends BaseLogic | @@ -36,7 +36,7 @@ class MailLogic extends BaseLogic | ||
| 36 | if($read_info === false){ | 36 | if($read_info === false){ |
| 37 | $rs = $mailUserModel->add($data); | 37 | $rs = $mailUserModel->add($data); |
| 38 | if($rs === false){ | 38 | if($rs === false){ |
| 39 | - $this->fail('error',Code::USER_ERROR); | 39 | + $this->fail('添加失败'); |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | return $this->success($info); | 42 | return $this->success($info); |
| @@ -59,7 +59,7 @@ class UserLogic extends BaseLogic | @@ -59,7 +59,7 @@ class UserLogic extends BaseLogic | ||
| 59 | $this->param['operator_id'] = $this->user['id']; | 59 | $this->param['operator_id'] = $this->user['id']; |
| 60 | try { | 60 | try { |
| 61 | //上传图片 | 61 | //上传图片 |
| 62 | - if(isset($this->param['image'])){ | 62 | + if(isset($this->param['image']) && is_file($this->param['image'])){ |
| 63 | //查看当前用户是否已有头像 | 63 | //查看当前用户是否已有头像 |
| 64 | $info = $this->model->read(['id'=>$this->param['id']],['id','image']); | 64 | $info = $this->model->read(['id'=>$this->param['id']],['id','image']); |
| 65 | if($info !== false && !empty($info['image'])){ | 65 | if($info !== false && !empty($info['image'])){ |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\User; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class ProjectRoleRequest extends FormRequest | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * Determine if the user is authorized to make this request. | ||
| 11 | + * | ||
| 12 | + * @return bool | ||
| 13 | + */ | ||
| 14 | + public function authorize() | ||
| 15 | + { | ||
| 16 | + return true; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public function rules() | ||
| 20 | + { | ||
| 21 | + return [ | ||
| 22 | + 'name'=>'required|max:11||unique:gl_project_role', | ||
| 23 | + 'role_menu'=>'required|string', | ||
| 24 | + ]; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public function messages() | ||
| 28 | + { | ||
| 29 | + return [ | ||
| 30 | + 'name.required'=>'名称必须填写', | ||
| 31 | + 'name.max' => '名称不大于11字符.', | ||
| 32 | + 'role_menu.required'=>'角色列表必须填写', | ||
| 33 | + ]; | ||
| 34 | + } | ||
| 35 | +} |
app/Http/Requests/Aside/User/UserRequest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Aside\User; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class UserRequest extends FormRequest | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * Determine if the user is authorized to make this request. | ||
| 11 | + * | ||
| 12 | + * @return bool | ||
| 13 | + */ | ||
| 14 | + public function authorize() | ||
| 15 | + { | ||
| 16 | + return true; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * Get the validation rules that apply to the request. | ||
| 21 | + * | ||
| 22 | + * @return array | ||
| 23 | + */ | ||
| 24 | + public function rules() | ||
| 25 | + { | ||
| 26 | + return [ | ||
| 27 | + 'mobile'=>'required|string|max:11||unique:gl_project_user', | ||
| 28 | + 'password'=>'required|string|min:5', | ||
| 29 | + 'name'=>'required|max:20', | ||
| 30 | + 'role_id'=>'required' | ||
| 31 | + ]; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public function messages() | ||
| 35 | + { | ||
| 36 | + return [ | ||
| 37 | + 'mobile.required'=>'号码必须填写', | ||
| 38 | + 'mobile.string'=>'号码中含有非法文字', | ||
| 39 | + 'mobile.max' => '号码不大于11字符.', | ||
| 40 | + 'password.required'=>'密码必须填写', | ||
| 41 | + 'password.string'=>'密码中含有非法文字', | ||
| 42 | + 'password.min' => '密码不小于5字符.', | ||
| 43 | + 'name.required'=>'名称必须填写', | ||
| 44 | + 'name.min' => '名称不小于5字符.', | ||
| 45 | + 'role_id.required'=>'角色必须填写', | ||
| 46 | + ]; | ||
| 47 | + } | ||
| 48 | +} |
-
请 注册 或 登录 后发表评论