Merge branch 'dev' of http://47.244.231.31:8099/zhl/globalso-v6 into dev
正在显示
20 个修改的文件
包含
447 行增加
和
421 行删除
| @@ -16,7 +16,7 @@ class BaseController extends Controller | @@ -16,7 +16,7 @@ class BaseController extends Controller | ||
| 16 | protected $token = ''; //token | 16 | protected $token = ''; //token |
| 17 | protected $request = [];//助手函数 | 17 | protected $request = [];//助手函数 |
| 18 | protected $allCount = 0;//总条数 | 18 | protected $allCount = 0;//总条数 |
| 19 | - protected $p = 1;//当前页 | 19 | + protected $page = 1;//当前页 |
| 20 | protected $row = 20;//每页条数 | 20 | protected $row = 20;//每页条数 |
| 21 | protected $header = [];//设置请求头参数 | 21 | protected $header = [];//设置请求头参数 |
| 22 | protected $order = 'id'; | 22 | protected $order = 'id'; |
| @@ -35,7 +35,6 @@ class BaseController extends Controller | @@ -35,7 +35,6 @@ class BaseController extends Controller | ||
| 35 | $info = Cache::get($this->token); | 35 | $info = Cache::get($this->token); |
| 36 | $this->user = $info; | 36 | $this->user = $info; |
| 37 | $this->uid = $info['id']; | 37 | $this->uid = $info['id']; |
| 38 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 39 | }else{ | 38 | }else{ |
| 40 | return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']); | 39 | return response(['code'=>Code::USER_ERROR,'msg'=>'当前用户未登录']); |
| 41 | } | 40 | } |
| @@ -80,8 +79,8 @@ class BaseController extends Controller | @@ -80,8 +79,8 @@ class BaseController extends Controller | ||
| 80 | case "order": | 79 | case "order": |
| 81 | $this->order = $v; | 80 | $this->order = $v; |
| 82 | break; | 81 | break; |
| 83 | - case 'p': | ||
| 84 | - $this->p = $v; | 82 | + case 'page': |
| 83 | + $this->page = $v; | ||
| 85 | break; | 84 | break; |
| 86 | case 'row': | 85 | case 'row': |
| 87 | $this->row = $v; | 86 | $this->row = $v; |
| @@ -7,6 +7,7 @@ use App\Models\Project as ProjectModel; | @@ -7,6 +7,7 @@ use App\Models\Project as ProjectModel; | ||
| 7 | use App\Models\ProjectMenu as ProjectMenuModel; | 7 | use App\Models\ProjectMenu as ProjectMenuModel; |
| 8 | use App\Models\ProjectRole as ProjectRoleModel; | 8 | use App\Models\ProjectRole as ProjectRoleModel; |
| 9 | use App\Models\User as UserModel; | 9 | use App\Models\User as UserModel; |
| 10 | +use Illuminate\Http\Request; | ||
| 10 | use Illuminate\Support\Facades\Cache; | 11 | use Illuminate\Support\Facades\Cache; |
| 11 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| 12 | use Illuminate\Support\Facades\Validator; | 13 | use Illuminate\Support\Facades\Validator; |
| @@ -22,25 +23,18 @@ class ComController extends BaseController | @@ -22,25 +23,18 @@ class ComController extends BaseController | ||
| 22 | * @author :liyuhang | 23 | * @author :liyuhang |
| 23 | * @method | 24 | * @method |
| 24 | */ | 25 | */ |
| 25 | - public function login(){ | ||
| 26 | - $rules = [ | ||
| 27 | - 'mobile'=>'required|string|max:12', | ||
| 28 | - 'password'=>'required|string', | ||
| 29 | - ]; | ||
| 30 | - //验证的提示信息 | ||
| 31 | - $message = [ | 26 | + public function login(Request $request){ |
| 27 | + $request->validate([ | ||
| 28 | + 'mobile'=>['required,string,max:12'], | ||
| 29 | + 'password'=>['required,string'], | ||
| 30 | + ],[ | ||
| 32 | 'mobile.required'=>'标题必须填写', | 31 | 'mobile.required'=>'标题必须填写', |
| 33 | 'mobile.string'=>'标题中含有非法文字', | 32 | 'mobile.string'=>'标题中含有非法文字', |
| 34 | 'password.required'=>'内容必须填写', | 33 | 'password.required'=>'内容必须填写', |
| 35 | 'password.string'=>'内容中含有非法文字', | 34 | 'password.string'=>'内容中含有非法文字', |
| 36 | 'mobile.max' => 'account不大于12字符.', | 35 | 'mobile.max' => 'account不大于12字符.', |
| 37 | - ]; | ||
| 38 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 39 | - if($validate->errors()->first()){ | ||
| 40 | - return $this->response($validate->errors()->first(),Code::USER_ERROR,$this->param); | ||
| 41 | - } | 36 | + ]); |
| 42 | $userModel = new UserModel(); | 37 | $userModel = new UserModel(); |
| 43 | - Cache::add('1345951a03fd1916a53c48c16b2fdecb','23423423423423'); | ||
| 44 | $res = $userModel->login($this->param); | 38 | $res = $userModel->login($this->param); |
| 45 | if($res === false){ | 39 | if($res === false){ |
| 46 | $this->response('当前用户不存在或者被禁用,登录失败',Code::USER_ERROR,[]); | 40 | $this->response('当前用户不存在或者被禁用,登录失败',Code::USER_ERROR,[]); |
| @@ -94,23 +88,17 @@ class ComController extends BaseController | @@ -94,23 +88,17 @@ class ComController extends BaseController | ||
| 94 | * @author :liyuhang | 88 | * @author :liyuhang |
| 95 | * @method | 89 | * @method |
| 96 | */ | 90 | */ |
| 97 | - public function edit_info(){ | ||
| 98 | - $rules = [ | ||
| 99 | - 'password'=>'required|string|min:5', | ||
| 100 | - 'name'=>'required|max:20', | ||
| 101 | - ]; | ||
| 102 | - //验证的提示信息 | ||
| 103 | - $message = [ | 91 | + public function edit_info(Request $request){ |
| 92 | + $request->validate([ | ||
| 93 | + 'password'=>['required,string,min:5'], | ||
| 94 | + 'name'=>['required,max:20'], | ||
| 95 | + ],[ | ||
| 104 | 'password.required'=>'密码必须填写', | 96 | 'password.required'=>'密码必须填写', |
| 105 | 'password.string'=>'密码中含有非法文字', | 97 | 'password.string'=>'密码中含有非法文字', |
| 106 | 'password.min' => '密码不小于5字符.', | 98 | 'password.min' => '密码不小于5字符.', |
| 107 | 'name.required'=>'名称必须填写', | 99 | 'name.required'=>'名称必须填写', |
| 108 | 'name.min' => '名称不小于5字符.', | 100 | 'name.min' => '名称不小于5字符.', |
| 109 | - ]; | ||
| 110 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 111 | - if($validate->fails()){ | ||
| 112 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 113 | - } | 101 | + ]); |
| 114 | $userModel = new UserModel(); | 102 | $userModel = new UserModel(); |
| 115 | $this->param['id'] = $this->uid; | 103 | $this->param['id'] = $this->uid; |
| 116 | $rs = $userModel->edits($this->param); | 104 | $rs = $userModel->edits($this->param); |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\News; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Bside\BaseController; | ||
| 7 | +use App\Http\Requests\Bside\News\NewsCategoryRequest; | ||
| 8 | +use App\Models\News\News as NewsModel; | ||
| 9 | +use App\Models\News\NewsCategory as NewsCategoryModel; | ||
| 10 | +use Illuminate\Http\Request; | ||
| 11 | + | ||
| 12 | +class NewsCategoryController extends BaseController | ||
| 13 | +{ | ||
| 14 | + /** | ||
| 15 | + * @name :新闻分类列表 | ||
| 16 | + * @return json | ||
| 17 | + * @author :liyuhang | ||
| 18 | + * @method | ||
| 19 | + */ | ||
| 20 | + public function lists(NewsCategoryModel $newsCategory){ | ||
| 21 | + $lists = $newsCategory->lists($this->map,$this->page,$this->row); | ||
| 22 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @name :添加分类 | ||
| 27 | + * @return json | ||
| 28 | + * @author :liyuhang | ||
| 29 | + * @method | ||
| 30 | + */ | ||
| 31 | + public function add(NewsCategoryRequest $request,NewsCategoryModel $newsCategory){ | ||
| 32 | + $request->validated(); | ||
| 33 | + $rs = $newsCategory->add($this->param); | ||
| 34 | + if($rs === false){ | ||
| 35 | + $this->response('error',Code::USER_ERROR); | ||
| 36 | + } | ||
| 37 | + $this->response('success',Code::SUCCESS); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * @name :编辑分类 | ||
| 42 | + * @return void | ||
| 43 | + * @author :liyuhang | ||
| 44 | + * @method | ||
| 45 | + */ | ||
| 46 | + public function edit(NewsCategoryRequest $request,NewsCategoryModel $newsCategory){ | ||
| 47 | + $request->validate([ | ||
| 48 | + 'id'=>['required'] | ||
| 49 | + ],[ | ||
| 50 | + 'id.required' => 'ID不能为空' | ||
| 51 | + ]); | ||
| 52 | + $rs = $newsCategory->edit($this->param,['id'=>$this->param['id']]); | ||
| 53 | + if($rs === false){ | ||
| 54 | + $this->response('error',Code::USER_ERROR); | ||
| 55 | + } | ||
| 56 | + $this->response('success',Code::SUCCESS); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * @name :编辑状态 | ||
| 61 | + * @return void | ||
| 62 | + * @author :liyuhang | ||
| 63 | + * @method | ||
| 64 | + */ | ||
| 65 | + public function status(Request $request,NewsCategoryModel $newsCategory){ | ||
| 66 | + $request->validate([ | ||
| 67 | + 'id'=>['required'], | ||
| 68 | + 'status'=>['required'], | ||
| 69 | + ],[ | ||
| 70 | + 'id.required' => 'ID不能为空', | ||
| 71 | + 'status.required' => 'status不能为空' | ||
| 72 | + ]); | ||
| 73 | + $rs = $newsCategory->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); | ||
| 74 | + if($rs === false){ | ||
| 75 | + $this->response('error',Code::USER_ERROR); | ||
| 76 | + } | ||
| 77 | + $this->response('success'); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * @name :删除分类 | ||
| 82 | + * @return void | ||
| 83 | + * @author :liyuhang | ||
| 84 | + * @method | ||
| 85 | + */ | ||
| 86 | + public function del(Request $request,NewsCategoryModel $newsCategory,NewsModel $news){ | ||
| 87 | + $request->validate([ | ||
| 88 | + 'id'=>['required'], | ||
| 89 | + ],[ | ||
| 90 | + 'id.required' => 'ID不能为空', | ||
| 91 | + ]); | ||
| 92 | + foreach ($this->param['id'] as $v){ | ||
| 93 | + var_dump($v); | ||
| 94 | + //查询是否有子分类 | ||
| 95 | + $id = $newsCategory->read(['pid'=>$v],['id']); | ||
| 96 | + if($id !== false){ | ||
| 97 | + $this->response('当前分类拥有子分类不允许删除',Code::USER_ERROR); | ||
| 98 | + } | ||
| 99 | + //查看当前分内下是否有商品 | ||
| 100 | + $id = $news->read(['category_id'=>$v],['id']); | ||
| 101 | + | ||
| 102 | + if($id !== false){ | ||
| 103 | + $this->response('当前分类拥有商品',Code::USER_ERROR); | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + $this->param['id'] = ['in',$id]; | ||
| 107 | + var_dump($this->map); | ||
| 108 | + die(); | ||
| 109 | + $rs = $newsCategory->del($this->param); | ||
| 110 | + if($rs === false){ | ||
| 111 | + $this->response('error',Code::USER_ERROR); | ||
| 112 | + } | ||
| 113 | + $this->response('success'); | ||
| 114 | + } | ||
| 115 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\News; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Bside\BaseController; | ||
| 6 | + | ||
| 7 | +class NewsController extends BaseController | ||
| 8 | +{ | ||
| 9 | + /** | ||
| 10 | + * @name :获取新闻列表 | ||
| 11 | + * @return void | ||
| 12 | + * @author :liyuhang | ||
| 13 | + * @method | ||
| 14 | + */ | ||
| 15 | + public function lists(){ | ||
| 16 | + | ||
| 17 | + } | ||
| 18 | +} |
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace App\Http\Controllers\Bside; | ||
| 4 | - | ||
| 5 | -use App\Enums\Common\Code; | ||
| 6 | -use App\Models\Product as ProductModel; | ||
| 7 | -use App\Models\ProductClassify as ProductClassifyModel; | ||
| 8 | -use Illuminate\Support\Facades\Validator; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @name:产品表 | ||
| 12 | - */ | ||
| 13 | -class ProductController extends BaseController | ||
| 14 | -{ | ||
| 15 | - /** | ||
| 16 | - * @name : 产品列表 | ||
| 17 | - * @return void | ||
| 18 | - * @author :liyuhang | ||
| 19 | - * @method | ||
| 20 | - */ | ||
| 21 | - public function lists(){ | ||
| 22 | - //获取当前登录用户下的产品列表 | ||
| 23 | - $this->map['project_id'] = $this->user['project_id']; | ||
| 24 | - $productModel = new ProductModel(); | ||
| 25 | - $lists = $productModel->lists($this->map,$this->p,$this->row,$this->order); | ||
| 26 | - $this->allCount = $productModel->allCount; | ||
| 27 | - $this->response('success',Code::SUCCESS, $lists); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * @name :添加产品 | ||
| 32 | - * @return void | ||
| 33 | - * @author :liyuhang | ||
| 34 | - * @method | ||
| 35 | - */ | ||
| 36 | - public function add(){ | ||
| 37 | - //参数验证 | ||
| 38 | - $rules = [ | ||
| 39 | - 'name'=>'required|max:11', | ||
| 40 | - 'image'=>'required', | ||
| 41 | - 'describe'=>'required', | ||
| 42 | - 'keywords'=>'required|max:50', | ||
| 43 | - ]; | ||
| 44 | - //验证的提示信息 | ||
| 45 | - $message = [ | ||
| 46 | - 'name.required'=>'名称必须填写', | ||
| 47 | - 'name.max' => '名称不大于16字符.', | ||
| 48 | - 'image.required'=>'图片必须上传', | ||
| 49 | - 'describe.required'=>'描述必须填写', | ||
| 50 | - 'keywords.required'=>'关键字必须填写', | ||
| 51 | - ]; | ||
| 52 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 53 | - if($validate->fails()){ | ||
| 54 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 55 | - } | ||
| 56 | - //TODO::关联项目 | ||
| 57 | - $this->param['project_id'] = $this->user['project_id']; | ||
| 58 | - $productModel = new ProductModel(); | ||
| 59 | - $this->param['image'] = $this->uploads(); | ||
| 60 | - $rs = $productModel->add($this->param); | ||
| 61 | - if($rs === false){ | ||
| 62 | - $this->response('error',Code::USER_ERROR); | ||
| 63 | - } | ||
| 64 | - $this->response('success',Code::SUCCESS); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - public function edit(){ | ||
| 68 | - //参数验证 | ||
| 69 | - $rules = [ | ||
| 70 | - 'name'=>'required|max:11', | ||
| 71 | - 'image'=>'required', | ||
| 72 | - 'describe'=>'required', | ||
| 73 | - 'keywords'=>'required|max:50', | ||
| 74 | - ]; | ||
| 75 | - //验证的提示信息 | ||
| 76 | - $message = [ | ||
| 77 | - 'name.required'=>'名称必须填写', | ||
| 78 | - 'name.max' => '名称不大于16字符.', | ||
| 79 | - 'image.required'=>'图片必须上传', | ||
| 80 | - 'describe.required'=>'描述必须填写', | ||
| 81 | - 'keywords.required'=>'关键字必须填写', | ||
| 82 | - ]; | ||
| 83 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 84 | - if($validate->fails()){ | ||
| 85 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 86 | - } | ||
| 87 | - if(isset($this->param['image'])){ | ||
| 88 | - //TODO::删除上一次的图片 | ||
| 89 | - $this->param['image'] = $this->uploads(); | ||
| 90 | - } | ||
| 91 | - $productModel = new ProductModel(); | ||
| 92 | - $rs = $productModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 93 | - if($rs === false){ | ||
| 94 | - $this->response('error',Code::USER_ERROR); | ||
| 95 | - } | ||
| 96 | - $this->response('success',Code::SUCCESS); | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - /** | ||
| 100 | - * @name :修改产品状态 | ||
| 101 | - * @return void | ||
| 102 | - * @author :liyuhang | ||
| 103 | - * @method | ||
| 104 | - */ | ||
| 105 | - public function status(){ | ||
| 106 | - //参数验证 | ||
| 107 | - $rules = [ | ||
| 108 | - 'id'=>'required', | ||
| 109 | - 'status'=>'required', | ||
| 110 | - ]; | ||
| 111 | - //验证的提示信息 | ||
| 112 | - $message = [ | ||
| 113 | - 'id.required'=>'主键必须填写', | ||
| 114 | - 'status.required'=>'状态必须填写', | ||
| 115 | - ]; | ||
| 116 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 117 | - if($validate->fails()){ | ||
| 118 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 119 | - } | ||
| 120 | - $productModel = new ProductModel(); | ||
| 121 | - $rs = $productModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); | ||
| 122 | - if($rs === false){ | ||
| 123 | - $this->response('error',Code::USER_ERROR); | ||
| 124 | - } | ||
| 125 | - $this->response('success',Code::SUCCESS); | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - /** | ||
| 129 | - * @name :删除产品 | ||
| 130 | - * @return void | ||
| 131 | - * @author :liyuhang | ||
| 132 | - * @method | ||
| 133 | - */ | ||
| 134 | - public function del(){ | ||
| 135 | - //参数验证 | ||
| 136 | - $rules = [ | ||
| 137 | - 'id'=>'required', | ||
| 138 | - ]; | ||
| 139 | - //验证的提示信息 | ||
| 140 | - $message = [ | ||
| 141 | - 'id.required'=>'主键必须填写', | ||
| 142 | - ]; | ||
| 143 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 144 | - if($validate->fails()){ | ||
| 145 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 146 | - } | ||
| 147 | - $productModel = new ProductModel(); | ||
| 148 | - $info = $productModel->read(['id'=>$this->param['id']],['image']); | ||
| 149 | - //TODO::删除添加的图片 | ||
| 150 | - shell_exec('rm -rf '.request()->path().'../../'.$info['image']); | ||
| 151 | - $rs = $productModel->del(['id'=>$this->param['id']]); | ||
| 152 | - if($rs === false){ | ||
| 153 | - $this->response('error',Code::USER_ERROR); | ||
| 154 | - } | ||
| 155 | - $this->response('success',Code::SUCCESS); | ||
| 156 | - } | ||
| 157 | -} |
| @@ -5,6 +5,10 @@ namespace App\Http\Controllers\Bside; | @@ -5,6 +5,10 @@ namespace App\Http\Controllers\Bside; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Logic\Bside\ProjectGroupLogic; | 6 | use App\Http\Logic\Bside\ProjectGroupLogic; |
| 7 | use App\Http\Requests\Bside\ProjectGroupRequest; | 7 | use App\Http\Requests\Bside\ProjectGroupRequest; |
| 8 | +use App\Models\ProjectGroup as ProjectGroupModel; | ||
| 9 | +use App\Models\User as UserModel; | ||
| 10 | +use Illuminate\Http\Request; | ||
| 11 | + | ||
| 8 | 12 | ||
| 9 | /** | 13 | /** |
| 10 | * @name:用户组相关 | 14 | * @name:用户组相关 |
| @@ -17,12 +21,25 @@ class ProjectGroupController extends BaseController | @@ -17,12 +21,25 @@ class ProjectGroupController extends BaseController | ||
| 17 | * @author :liyuhang | 21 | * @author :liyuhang |
| 18 | * @method | 22 | * @method |
| 19 | */ | 23 | */ |
| 20 | - public function lists() | 24 | + public function lists(ProjectGroupModel $projectGroupModel) |
| 21 | { | 25 | { |
| 22 | - | 26 | + $lists = $projectGroupModel->lists($this->map,$this->page,$this->row); |
| 27 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 23 | } | 28 | } |
| 24 | 29 | ||
| 25 | /** | 30 | /** |
| 31 | + * @name:添加用户组获取用户列表 | ||
| 32 | + * @return void | ||
| 33 | + * @author :liyuhang | ||
| 34 | + * @method | ||
| 35 | + */ | ||
| 36 | + public function get_user_lists(UserModel $userModel){ | ||
| 37 | + $this->map['project_id'] = $this->user['project_id']; | ||
| 38 | + //获取当前项目下的所有用户 | ||
| 39 | + $lists = $userModel->list($this->map); | ||
| 40 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 41 | + } | ||
| 42 | + /** | ||
| 26 | * @param ProjectGroupRequest $request | 43 | * @param ProjectGroupRequest $request |
| 27 | * @param ProjectGroupLogic $logic | 44 | * @param ProjectGroupLogic $logic |
| 28 | * @name : 添加用户组 | 45 | * @name : 添加用户组 |
| @@ -30,7 +47,18 @@ class ProjectGroupController extends BaseController | @@ -30,7 +47,18 @@ class ProjectGroupController extends BaseController | ||
| 30 | * @author :liyuhang | 47 | * @author :liyuhang |
| 31 | * @method | 48 | * @method |
| 32 | */ | 49 | */ |
| 33 | - public function add(ProjectGroupRequest $request){ | 50 | + public function add(ProjectGroupRequest $request,ProjectGroupModel $projectGroupModel){ |
| 51 | + $request->validated(); | ||
| 52 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 53 | + //TODO::成员列表:user_list | ||
| 54 | + if(!isset($this->param['user_list']) || empty($this->param['user_list'])){ | ||
| 55 | + $this->param['user_list'] = $this->uid; | ||
| 56 | + } | ||
| 57 | + $this->param['admin_id'] = $this->uid; | ||
| 58 | + $rs = $projectGroupModel->add($this->param); | ||
| 59 | + if($rs === false){ | ||
| 60 | + $this->response('error',Code::USER_ERROR); | ||
| 61 | + } | ||
| 34 | $this->response('success'); | 62 | $this->response('success'); |
| 35 | } | 63 | } |
| 36 | 64 | ||
| @@ -42,8 +70,16 @@ class ProjectGroupController extends BaseController | @@ -42,8 +70,16 @@ class ProjectGroupController extends BaseController | ||
| 42 | * @author :liyuhang | 70 | * @author :liyuhang |
| 43 | * @method | 71 | * @method |
| 44 | */ | 72 | */ |
| 45 | - public function edit(ProjectGroupRequest $request){ | ||
| 46 | - $request->validated(); | 73 | + public function edit(ProjectGroupRequest $request,ProjectGroupModel $projectGroupModel){ |
| 74 | + $request->validate([ | ||
| 75 | + 'id'=>['required'], | ||
| 76 | + ],[ | ||
| 77 | + 'id.required' => 'ID不能为空', | ||
| 78 | + ]); | ||
| 79 | + $rs = $projectGroupModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 80 | + if($rs === false){ | ||
| 81 | + $this->response('error',Code::USER_ERROR); | ||
| 82 | + } | ||
| 47 | $this->response('success'); | 83 | $this->response('success'); |
| 48 | } | 84 | } |
| 49 | 85 | ||
| @@ -53,7 +89,16 @@ class ProjectGroupController extends BaseController | @@ -53,7 +89,16 @@ class ProjectGroupController extends BaseController | ||
| 53 | * @author :liyuhang | 89 | * @author :liyuhang |
| 54 | * @method | 90 | * @method |
| 55 | */ | 91 | */ |
| 56 | - public function del(){ | ||
| 57 | - | 92 | + public function del(Request $request,ProjectGroupModel $projectGroupModel){ |
| 93 | + $request->validate([ | ||
| 94 | + 'id'=>['required'], | ||
| 95 | + ],[ | ||
| 96 | + 'id.required' => 'ID不能为空', | ||
| 97 | + ]); | ||
| 98 | + $rs = $projectGroupModel->del($this->param); | ||
| 99 | + if($rs === false){ | ||
| 100 | + $this->response('error',Code::USER_ERROR); | ||
| 101 | + } | ||
| 102 | + $this->response('success'); | ||
| 58 | } | 103 | } |
| 59 | } | 104 | } |
| @@ -3,9 +3,11 @@ | @@ -3,9 +3,11 @@ | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | namespace App\Http\Controllers\Bside; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Http\Requests\Bside\ProjectRoleRequest; | ||
| 6 | use App\Models\ProjectMenu as ProjectMenuModel; | 7 | use App\Models\ProjectMenu as ProjectMenuModel; |
| 7 | use App\Models\ProjectRole as ProjectRoleModel; | 8 | use App\Models\ProjectRole as ProjectRoleModel; |
| 8 | use App\Models\User as UserModel; | 9 | use App\Models\User as UserModel; |
| 10 | +use Illuminate\Http\Request; | ||
| 9 | use Illuminate\Support\Facades\Validator; | 11 | use Illuminate\Support\Facades\Validator; |
| 10 | 12 | ||
| 11 | class ProjectRoleController extends BaseController | 13 | class ProjectRoleController extends BaseController |
| @@ -22,7 +24,7 @@ class ProjectRoleController extends BaseController | @@ -22,7 +24,7 @@ class ProjectRoleController extends BaseController | ||
| 22 | $this->map['status'] = 0; | 24 | $this->map['status'] = 0; |
| 23 | $this->map['project_id'] = $this->user['project_id']; | 25 | $this->map['project_id'] = $this->user['project_id']; |
| 24 | //获取当前登录用户自己的菜单栏 | 26 | //获取当前登录用户自己的菜单栏 |
| 25 | - $lists = $projectRoleModel->lists($this->map,$this->p,$this->row,$this->order); | 27 | + $lists = $projectRoleModel->lists($this->map,$this->page,$this->row,$this->order); |
| 26 | $this->response('success',Code::SUCCESS,$lists); | 28 | $this->response('success',Code::SUCCESS,$lists); |
| 27 | } | 29 | } |
| 28 | 30 | ||
| @@ -56,23 +58,8 @@ class ProjectRoleController extends BaseController | @@ -56,23 +58,8 @@ class ProjectRoleController extends BaseController | ||
| 56 | * @author :liyuhang | 58 | * @author :liyuhang |
| 57 | * @method | 59 | * @method |
| 58 | */ | 60 | */ |
| 59 | - public function add(){ | ||
| 60 | - //TODO::获取当前用户的所在项目组 | ||
| 61 | - //参数验证 | ||
| 62 | - $rules = [ | ||
| 63 | - 'name'=>'required|max:11', | ||
| 64 | - 'role_menu'=>'required|string', | ||
| 65 | - ]; | ||
| 66 | - //验证的提示信息 | ||
| 67 | - $message = [ | ||
| 68 | - 'name.required'=>'名称必须填写', | ||
| 69 | - 'name.max' => '号码不大于11字符.', | ||
| 70 | - 'role_menu.required'=>'密码必须填写', | ||
| 71 | - ]; | ||
| 72 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 73 | - if($validate->fails()){ | ||
| 74 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 75 | - } | 61 | + public function add(ProjectRoleRequest $request){ |
| 62 | + $request->validated(); | ||
| 76 | $this->param['project_id'] = $this->user['project_id']; | 63 | $this->param['project_id'] = $this->user['project_id']; |
| 77 | //获取当前项目下的角色超级管理员 | 64 | //获取当前项目下的角色超级管理员 |
| 78 | $projectRoleModel = new ProjectRoleModel(); | 65 | $projectRoleModel = new ProjectRoleModel(); |
| @@ -94,28 +81,19 @@ class ProjectRoleController extends BaseController | @@ -94,28 +81,19 @@ class ProjectRoleController extends BaseController | ||
| 94 | * @author :liyuhang | 81 | * @author :liyuhang |
| 95 | * @method | 82 | * @method |
| 96 | */ | 83 | */ |
| 97 | - public function edit(){ | ||
| 98 | - //TODO::根据当前登录用户返回 | ||
| 99 | - //参数验证 | ||
| 100 | - $rules = [ | ||
| 101 | - 'id'=>'required', | ||
| 102 | - 'name'=>'required|max:11', | ||
| 103 | - 'role_menu'=>'required', | ||
| 104 | - ]; | ||
| 105 | - //验证的提示信息 | ||
| 106 | - $message = [ | ||
| 107 | - 'id.required'=>'主键必须填写', | ||
| 108 | - 'name.required'=>'名称必须填写', | ||
| 109 | - 'role_menu.required'=>'菜单权限列表填写', | ||
| 110 | - ]; | ||
| 111 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 112 | - if($validate->fails()){ | ||
| 113 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE); | ||
| 114 | - } | ||
| 115 | - $projectRoleModel = new ProjectRoleModel(); | 84 | + public function edit(ProjectRoleRequest $request,ProjectRoleModel $projectRoleModel){ |
| 85 | + $request->validate([ | ||
| 86 | + 'id'=>['required'] | ||
| 87 | + ],[ | ||
| 88 | + 'id.required' => 'ID不能为空' | ||
| 89 | + ]); | ||
| 116 | //TODO::查询当前名称是否重复 | 90 | //TODO::查询当前名称是否重复 |
| 117 | - $info = $projectRoleModel->where('id','<>',$this->param['id']) | ||
| 118 | - ->where(['name'=>$this->param['name'],'project_id'=>$this->user['project_id']])->first(); | 91 | + $condition = [ |
| 92 | + ['id'=>['!=',$this->param['id']]], | ||
| 93 | + ['name'=>$this->param['name']], | ||
| 94 | + ['project_id'=>$this->user['project_id']], | ||
| 95 | + ]; | ||
| 96 | + $info = $projectRoleModel->formatQuery($condition)->first(); | ||
| 119 | if(!empty($info)){ | 97 | if(!empty($info)){ |
| 120 | $this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE); | 98 | $this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE); |
| 121 | } | 99 | } |
| @@ -123,7 +101,7 @@ class ProjectRoleController extends BaseController | @@ -123,7 +101,7 @@ class ProjectRoleController extends BaseController | ||
| 123 | if($rs === false){ | 101 | if($rs === false){ |
| 124 | $this->response('编辑失败',Code::USER_PARAMS_ERROE); | 102 | $this->response('编辑失败',Code::USER_PARAMS_ERROE); |
| 125 | } | 103 | } |
| 126 | - $this->response('编辑成功',Code::SUCCESS); | 104 | + $this->response('编辑成功'); |
| 127 | } | 105 | } |
| 128 | 106 | ||
| 129 | /** | 107 | /** |
| @@ -132,22 +110,14 @@ class ProjectRoleController extends BaseController | @@ -132,22 +110,14 @@ class ProjectRoleController extends BaseController | ||
| 132 | * @author :liyuhang | 110 | * @author :liyuhang |
| 133 | * @method | 111 | * @method |
| 134 | */ | 112 | */ |
| 135 | - public function status(){ | ||
| 136 | - //参数验证 | ||
| 137 | - $rules = [ | ||
| 138 | - 'id'=>'required', | ||
| 139 | - 'status'=>'required', | ||
| 140 | - ]; | ||
| 141 | - //验证的提示信息 | ||
| 142 | - $message = [ | ||
| 143 | - 'id.required'=>'主键必须填写', | ||
| 144 | - 'status.required'=>'状态必须填写', | ||
| 145 | - ]; | ||
| 146 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 147 | - if($validate->fails()){ | ||
| 148 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 149 | - } | ||
| 150 | - $projectRoleModel = new ProjectRoleModel(); | 113 | + public function status(Request $request,ProjectRoleModel $projectRoleModel){ |
| 114 | + $request->validate([ | ||
| 115 | + 'id'=>['required'], | ||
| 116 | + 'status'=>['required'], | ||
| 117 | + ],[ | ||
| 118 | + 'id.required' => 'ID不能为空', | ||
| 119 | + 'status.required' => 'status不能为空' | ||
| 120 | + ]); | ||
| 151 | $rs = $projectRoleModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); | 121 | $rs = $projectRoleModel->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); |
| 152 | if($rs === false){ | 122 | if($rs === false){ |
| 153 | $this->response('编辑失败',Code::USER_PARAMS_ERROE); | 123 | $this->response('编辑失败',Code::USER_PARAMS_ERROE); |
| @@ -161,20 +131,12 @@ class ProjectRoleController extends BaseController | @@ -161,20 +131,12 @@ class ProjectRoleController extends BaseController | ||
| 161 | * @author :liyuhang | 131 | * @author :liyuhang |
| 162 | * @method | 132 | * @method |
| 163 | */ | 133 | */ |
| 164 | - public function del(){ | ||
| 165 | - //参数验证 | ||
| 166 | - $rules = [ | ||
| 167 | - 'id'=>'required', | ||
| 168 | - ]; | ||
| 169 | - //验证的提示信息 | ||
| 170 | - $message = [ | ||
| 171 | - 'id.required'=>'主键必须填写', | ||
| 172 | - ]; | ||
| 173 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 174 | - if($validate->fails()){ | ||
| 175 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 176 | - } | ||
| 177 | - $projectRoleModel = new ProjectRoleModel(); | 134 | + public function del(Request $request,ProjectRoleModel $projectRoleModel){ |
| 135 | + $request->validate([ | ||
| 136 | + 'id'=>['required'] | ||
| 137 | + ],[ | ||
| 138 | + 'id.required' => 'ID不能为空' | ||
| 139 | + ]); | ||
| 178 | //查询当前角色下是否有用户 | 140 | //查询当前角色下是否有用户 |
| 179 | $userModel = new UserModel(); | 141 | $userModel = new UserModel(); |
| 180 | $user_info = $userModel->read(['role_id'=>$this->param['id']]); | 142 | $user_info = $userModel->read(['role_id'=>$this->param['id']]); |
| @@ -185,6 +147,6 @@ class ProjectRoleController extends BaseController | @@ -185,6 +147,6 @@ class ProjectRoleController extends BaseController | ||
| 185 | if($rs === false){ | 147 | if($rs === false){ |
| 186 | $this->response('error',Code::USER_ERROR); | 148 | $this->response('error',Code::USER_ERROR); |
| 187 | } | 149 | } |
| 188 | - $this->response('success',Code::SUCCESS); | 150 | + $this->response('success'); |
| 189 | } | 151 | } |
| 190 | } | 152 | } |
| @@ -3,8 +3,10 @@ | @@ -3,8 +3,10 @@ | ||
| 3 | namespace App\Http\Controllers\Bside; | 3 | namespace App\Http\Controllers\Bside; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | +use App\Http\Requests\Bside\UserRequest; | ||
| 6 | use App\Models\User as UserModel; | 7 | use App\Models\User as UserModel; |
| 7 | -use Illuminate\Support\Facades\Validator; | 8 | +use App\Rules\Ids; |
| 9 | +use Illuminate\Http\Request; | ||
| 8 | 10 | ||
| 9 | class UserController extends BaseController | 11 | class UserController extends BaseController |
| 10 | { | 12 | { |
| @@ -14,11 +16,10 @@ class UserController extends BaseController | @@ -14,11 +16,10 @@ class UserController extends BaseController | ||
| 14 | * @author :liyuhang | 16 | * @author :liyuhang |
| 15 | * @method | 17 | * @method |
| 16 | */ | 18 | */ |
| 17 | - public function lists(){ | 19 | + public function lists(UserModel $userModel){ |
| 18 | //TODO::搜索参数处理 | 20 | //TODO::搜索参数处理 |
| 19 | - $userModel = new UserModel(); | ||
| 20 | $this->map['project_id'] = $this->user['project_id']; | 21 | $this->map['project_id'] = $this->user['project_id']; |
| 21 | - $lists = $userModel->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile','created_at']); | 22 | + $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at']); |
| 22 | if(empty($lists)){ | 23 | if(empty($lists)){ |
| 23 | $this->response('请求失败',Code::USER_ERROR,[]); | 24 | $this->response('请求失败',Code::USER_ERROR,[]); |
| 24 | } | 25 | } |
| @@ -31,30 +32,8 @@ class UserController extends BaseController | @@ -31,30 +32,8 @@ class UserController extends BaseController | ||
| 31 | * @author :liyuhang | 32 | * @author :liyuhang |
| 32 | * @method | 33 | * @method |
| 33 | */ | 34 | */ |
| 34 | - public function add(){ | ||
| 35 | - $rules = [ | ||
| 36 | - 'mobile'=>'required|string|max:11', | ||
| 37 | - 'password'=>'required|string|min:5', | ||
| 38 | - 'name'=>'required|max:20', | ||
| 39 | - 'role_id'=>'required' | ||
| 40 | - ]; | ||
| 41 | - //验证的提示信息 | ||
| 42 | - $message = [ | ||
| 43 | - 'mobile.required'=>'号码必须填写', | ||
| 44 | - 'mobile.string'=>'号码中含有非法文字', | ||
| 45 | - 'mobile.max' => '号码不大于11字符.', | ||
| 46 | - 'password.required'=>'密码必须填写', | ||
| 47 | - 'password.string'=>'密码中含有非法文字', | ||
| 48 | - 'password.min' => '密码不小于5字符.', | ||
| 49 | - 'name.required'=>'名称必须填写', | ||
| 50 | - 'name.min' => '名称不小于5字符.', | ||
| 51 | - 'role_id.required'=>'角色必须填写', | ||
| 52 | - ]; | ||
| 53 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 54 | - if($validate->fails()){ | ||
| 55 | - return $this->response($validate->errors()->first(),Code::USER_LOGIN_ERROE); | ||
| 56 | - } | ||
| 57 | - $userModel = new UserModel(); | 35 | + public function add(UserRequest $request,UserModel $userModel){ |
| 36 | + $request->validated(); | ||
| 58 | $this->param['project_id'] = $this->user['project_id']; | 37 | $this->param['project_id'] = $this->user['project_id']; |
| 59 | $rs = $userModel->adds($this->param); | 38 | $rs = $userModel->adds($this->param); |
| 60 | if($rs === false){ | 39 | if($rs === false){ |
| @@ -69,31 +48,12 @@ class UserController extends BaseController | @@ -69,31 +48,12 @@ class UserController extends BaseController | ||
| 69 | * @author :liyuhang | 48 | * @author :liyuhang |
| 70 | * @method | 49 | * @method |
| 71 | */ | 50 | */ |
| 72 | - public function edit(){ | ||
| 73 | - $rules = [ | ||
| 74 | - 'id'=>'required', | ||
| 75 | - 'mobile'=>'required|string|max:11', | ||
| 76 | - 'password'=>'required|string|min:5', | ||
| 77 | - 'name'=>'required|max:20', | ||
| 78 | - ]; | ||
| 79 | - //验证的提示信息 | ||
| 80 | - $message = [ | ||
| 81 | - 'id.required'=>'主键不能为空', | ||
| 82 | - 'mobile.required'=>'号码必须填写', | ||
| 83 | - 'mobile.string'=>'号码中含有非法文字', | ||
| 84 | - 'mobile.max' => '号码不大于11字符.', | ||
| 85 | - 'password.required'=>'密码必须填写', | ||
| 86 | - 'password.string'=>'密码中含有非法文字', | ||
| 87 | - 'password.min' => '密码不小于5字符.', | ||
| 88 | - 'name.required'=>'名称必须填写', | ||
| 89 | - 'name.min' => '名称不小于5字符.', | ||
| 90 | - ]; | ||
| 91 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 92 | - if($validate->fails()){ | ||
| 93 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 94 | - } | ||
| 95 | - $userModel = new UserModel(); | ||
| 96 | - //TODO::查询当前手机号码是否重复 | 51 | + public function edit(UserRequest $request,UserModel $userModel){ |
| 52 | + $request->validate([ | ||
| 53 | + 'id'=>['required'] | ||
| 54 | + ],[ | ||
| 55 | + 'id.required' => 'ID不能为空' | ||
| 56 | + ]); | ||
| 97 | $info = $userModel->where('id','<>',$this->param['id']) | 57 | $info = $userModel->where('id','<>',$this->param['id']) |
| 98 | ->where(['mobile'=>$this->param['mobile']])->first(); | 58 | ->where(['mobile'=>$this->param['mobile']])->first(); |
| 99 | if(!empty($info)){ | 59 | if(!empty($info)){ |
| @@ -112,27 +72,19 @@ class UserController extends BaseController | @@ -112,27 +72,19 @@ class UserController extends BaseController | ||
| 112 | * @author :liyuhang | 72 | * @author :liyuhang |
| 113 | * @method | 73 | * @method |
| 114 | */ | 74 | */ |
| 115 | - public function status(){ | ||
| 116 | - //参数验证 | ||
| 117 | - $rules = [ | ||
| 118 | - 'id'=>'required', | ||
| 119 | - 'status'=>'required', | ||
| 120 | - ]; | ||
| 121 | - //验证的提示信息 | ||
| 122 | - $message = [ | ||
| 123 | - 'id.required'=>'主键必须填写', | ||
| 124 | - 'status.required'=>'状态必须填写', | ||
| 125 | - ]; | ||
| 126 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 127 | - if($validate->fails()){ | ||
| 128 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 129 | - } | ||
| 130 | - $userLogic = new UserModel(); | ||
| 131 | - $rs = $userLogic->edit($this->param,['id'=>$this->param['id']]); | 75 | + public function status(Request $request,UserModel $userModel){ |
| 76 | + $request->validate([ | ||
| 77 | + 'id'=>['required'], | ||
| 78 | + 'status'=>['required'], | ||
| 79 | + ],[ | ||
| 80 | + 'id.required' => 'ID不能为空', | ||
| 81 | + 'status.required' => 'status不能为空' | ||
| 82 | + ]); | ||
| 83 | + $rs = $userModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 132 | if($rs === false){ | 84 | if($rs === false){ |
| 133 | $this->response('error',Code::USER_ERROR); | 85 | $this->response('error',Code::USER_ERROR); |
| 134 | } | 86 | } |
| 135 | - $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功',Code::SUCCESS); | 87 | + $this->response($this->param['status'] == 0 ? '启用成功' : '禁用成功'); |
| 136 | } | 88 | } |
| 137 | /** | 89 | /** |
| 138 | * @name :删除管理员 | 90 | * @name :删除管理员 |
| @@ -140,19 +92,12 @@ class UserController extends BaseController | @@ -140,19 +92,12 @@ class UserController extends BaseController | ||
| 140 | * @author :liyuhang | 92 | * @author :liyuhang |
| 141 | * @method | 93 | * @method |
| 142 | */ | 94 | */ |
| 143 | - public function del(){ | ||
| 144 | - $rules = [ | ||
| 145 | - 'id'=>'required', | ||
| 146 | - ]; | ||
| 147 | - //验证的提示信息 | ||
| 148 | - $message = [ | ||
| 149 | - 'id.required'=>'主键不能为空', | ||
| 150 | - ]; | ||
| 151 | - $validate = Validator::make($this->param, $rules, $message); | ||
| 152 | - if($validate->fails()){ | ||
| 153 | - return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param); | ||
| 154 | - } | ||
| 155 | - $userModel = new UserModel(); | 95 | + public function del(Request $request,UserModel $userModel){ |
| 96 | + $request->validate([ | ||
| 97 | + 'id'=>['required', new Ids()], | ||
| 98 | + ],[ | ||
| 99 | + 'id.required' => 'ID不能为空', | ||
| 100 | + ]); | ||
| 156 | $rs = $userModel->del($this->param); | 101 | $rs = $userModel->del($this->param); |
| 157 | if($rs === false){ | 102 | if($rs === false){ |
| 158 | $this->response('删除失败',Code::USER_ERROR); | 103 | $this->response('删除失败',Code::USER_ERROR); |
app/Http/Logic/Bside/UserLogic.php
已删除
100644 → 0
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside\News; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class NewsCategoryRequest 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 | + 'name'=>'required', | ||
| 28 | + ]; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public function messages() | ||
| 32 | + { | ||
| 33 | + return [ | ||
| 34 | + 'name.required'=>'名称必须填写', | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | +} |
app/Http/Requests/Bside/News/NewsRequest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside\News; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class NewsRequest 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 | + 'name'=>'required', | ||
| 28 | + ]; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public function messages() | ||
| 32 | + { | ||
| 33 | + return [ | ||
| 34 | + 'name.required'=>'名称必须填写', | ||
| 35 | + ]; | ||
| 36 | + } | ||
| 37 | +} |
| @@ -16,22 +16,17 @@ class ProjectGroupRequest extends FormRequest | @@ -16,22 +16,17 @@ class ProjectGroupRequest extends FormRequest | ||
| 16 | return true; | 16 | return true; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | - /** | ||
| 20 | - * Get the validation rules that apply to the request. | ||
| 21 | - * | ||
| 22 | - * @return array | ||
| 23 | - */ | ||
| 24 | public function rules() | 19 | public function rules() |
| 25 | { | 20 | { |
| 26 | return [ | 21 | return [ |
| 27 | - 'name'=>['required'], | 22 | + 'name' => 'required|max:255', |
| 28 | ]; | 23 | ]; |
| 29 | } | 24 | } |
| 30 | 25 | ||
| 31 | public function messages() | 26 | public function messages() |
| 32 | { | 27 | { |
| 33 | return [ | 28 | return [ |
| 34 | - 'name.required' => '请输入描述名称', | 29 | + 'name.required' => '请输入用户组名称', |
| 35 | ]; | 30 | ]; |
| 36 | } | 31 | } |
| 37 | } | 32 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside; | ||
| 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', | ||
| 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 | +} |
| @@ -24,7 +24,25 @@ class UserRequest extends FormRequest | @@ -24,7 +24,25 @@ class UserRequest extends FormRequest | ||
| 24 | public function rules() | 24 | public function rules() |
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | - 'mobile'=>['required'], | 27 | + 'mobile'=>'required|string|max:11', |
| 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'=>'角色必须填写', | ||
| 28 | ]; | 46 | ]; |
| 29 | } | 47 | } |
| 30 | } | 48 | } |
| @@ -15,7 +15,6 @@ class Base extends Model | @@ -15,7 +15,6 @@ class Base extends Model | ||
| 15 | 'created_at' => 'datetime:Y-m-d H:i:s', | 15 | 'created_at' => 'datetime:Y-m-d H:i:s', |
| 16 | 'updated_at' => 'datetime:Y-m-d H:i:s', | 16 | 'updated_at' => 'datetime:Y-m-d H:i:s', |
| 17 | ]; | 17 | ]; |
| 18 | - | ||
| 19 | /** | 18 | /** |
| 20 | * 日期序列化 勿删 删了时间就不是东八区时间了哈 | 19 | * 日期序列化 勿删 删了时间就不是东八区时间了哈 |
| 21 | * @param \DateTimeInterface $date | 20 | * @param \DateTimeInterface $date |
| @@ -27,30 +26,26 @@ class Base extends Model | @@ -27,30 +26,26 @@ class Base extends Model | ||
| 27 | { | 26 | { |
| 28 | return $date->format('Y-m-d H:i:s'); | 27 | return $date->format('Y-m-d H:i:s'); |
| 29 | } | 28 | } |
| 30 | - | ||
| 31 | /** | 29 | /** |
| 32 | * @name 列表数据 | 30 | * @name 列表数据 |
| 33 | * @return void | 31 | * @return void |
| 34 | * @author :liyuhang | 32 | * @author :liyuhang |
| 35 | * @method | 33 | * @method |
| 36 | */ | 34 | */ |
| 37 | - public function lists($map, $p, $row, $order = 'id', $fields = ['*']){ | ||
| 38 | - //TODO::where(['id'=>'','name'=>'']) | 35 | + public function lists($map, $page, $row, $order = 'id', $fields = ['*']){ |
| 39 | $query = $this->formatQuery($map); | 36 | $query = $this->formatQuery($map); |
| 40 | - $lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $p); | 37 | + $lists = $query->select($fields)->orderBy($order)->paginate($row, ['*'], 'page', $page); |
| 41 | if (empty($lists)) { | 38 | if (empty($lists)) { |
| 42 | return false; | 39 | return false; |
| 43 | } | 40 | } |
| 44 | $lists = $lists->toArray(); | 41 | $lists = $lists->toArray(); |
| 45 | return $lists; | 42 | return $lists; |
| 46 | } | 43 | } |
| 47 | - | ||
| 48 | - | ||
| 49 | /** | 44 | /** |
| 45 | + * @name :无分页列表 | ||
| 50 | * @param $map | 46 | * @param $map |
| 51 | * @param $order | 47 | * @param $order |
| 52 | * @param $fields | 48 | * @param $fields |
| 53 | - * @name :无分页列表 | ||
| 54 | * @return mixed | 49 | * @return mixed |
| 55 | * @author :liyuhang | 50 | * @author :liyuhang |
| 56 | * @method | 51 | * @method |
| @@ -65,8 +60,8 @@ class Base extends Model | @@ -65,8 +60,8 @@ class Base extends Model | ||
| 65 | return $lists; | 60 | return $lists; |
| 66 | } | 61 | } |
| 67 | /** | 62 | /** |
| 68 | - * @param array:$condition | ||
| 69 | * @name :获取单条数据详情 | 63 | * @name :获取单条数据详情 |
| 64 | + * @param array | ||
| 70 | * @return mixed | 65 | * @return mixed |
| 71 | * @author :liyuhang | 66 | * @author :liyuhang |
| 72 | * @method get | 67 | * @method get |
| @@ -81,8 +76,6 @@ class Base extends Model | @@ -81,8 +76,6 @@ class Base extends Model | ||
| 81 | $info = $info->toArray(); | 76 | $info = $info->toArray(); |
| 82 | return $info; | 77 | return $info; |
| 83 | } | 78 | } |
| 84 | - | ||
| 85 | - | ||
| 86 | /** | 79 | /** |
| 87 | * @name :新增 | 80 | * @name :新增 |
| 88 | * @return void | 81 | * @return void |
| @@ -94,7 +87,6 @@ class Base extends Model | @@ -94,7 +87,6 @@ class Base extends Model | ||
| 94 | $data['updated_at'] = date('Y-m-d H:i:s'); | 87 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 95 | return $this->insert($data); | 88 | return $this->insert($data); |
| 96 | } | 89 | } |
| 97 | - | ||
| 98 | /** | 90 | /** |
| 99 | * @name :编辑 | 91 | * @name :编辑 |
| 100 | * @return void | 92 | * @return void |
| @@ -107,7 +99,6 @@ class Base extends Model | @@ -107,7 +99,6 @@ class Base extends Model | ||
| 107 | $rs = $query->update($data); | 99 | $rs = $query->update($data); |
| 108 | return $rs; | 100 | return $rs; |
| 109 | } | 101 | } |
| 110 | - | ||
| 111 | /** | 102 | /** |
| 112 | * @name : 删除数据 | 103 | * @name : 删除数据 |
| 113 | * @return void | 104 | * @return void |
| @@ -118,12 +109,10 @@ class Base extends Model | @@ -118,12 +109,10 @@ class Base extends Model | ||
| 118 | $query = $this->formatQuery($condition); | 109 | $query = $this->formatQuery($condition); |
| 119 | return $query->delete(); | 110 | return $query->delete(); |
| 120 | } | 111 | } |
| 121 | - | ||
| 122 | - | ||
| 123 | /** | 112 | /** |
| 113 | + * @name :参数处理查询 | ||
| 124 | * @param $map = ['$k'=>['like',$v],$k1] | 114 | * @param $map = ['$k'=>['like',$v],$k1] |
| 125 | * @param $val | 115 | * @param $val |
| 126 | - * @name :参数处理查询 | ||
| 127 | * @return Base | 116 | * @return Base |
| 128 | * @author :liyuhang | 117 | * @author :liyuhang |
| 129 | * @method | 118 | * @method |
| @@ -132,46 +121,49 @@ class Base extends Model | @@ -132,46 +121,49 @@ class Base extends Model | ||
| 132 | $model = $query ?: $this; | 121 | $model = $query ?: $this; |
| 133 | $query = $model->where(function ($query) use ($map){ | 122 | $query = $model->where(function ($query) use ($map){ |
| 134 | foreach ($map as $k => $v){ | 123 | foreach ($map as $k => $v){ |
| 135 | - if(is_array($v)){ | ||
| 136 | - //拼接数据 | 124 | + if(!is_array($v)){ |
| 125 | + $query->where($k,$v); | ||
| 126 | + continue; | ||
| 127 | + } | ||
| 137 | foreach ($v as $k1 => $v1){ | 128 | foreach ($v as $k1 => $v1){ |
| 138 | - switch ($k1){ | 129 | + if(!is_array($v1)){ |
| 130 | + $query->where($k1,$v1); | ||
| 131 | + continue; | ||
| 132 | + } | ||
| 133 | + switch ($v1[0]){ | ||
| 139 | case 'like': | 134 | case 'like': |
| 140 | // like查询 ['name|title'=> ['like','%a%']] | 135 | // like查询 ['name|title'=> ['like','%a%']] |
| 141 | - if (strpos($k, '|') !== false) { | ||
| 142 | - $query->where(function ($query) use ($k,$v1) { | ||
| 143 | - $item = explode('|', $k); | 136 | + if (strpos($k1, '|') !== false) { |
| 137 | + $query->where(function ($query) use ($k1,$v1) { | ||
| 138 | + $item = explode('|', $k1); | ||
| 144 | foreach ($item as $vo) { | 139 | foreach ($item as $vo) { |
| 145 | $query->orWhere($vo, $v1[0], $v1[1]); | 140 | $query->orWhere($vo, $v1[0], $v1[1]); |
| 146 | } | 141 | } |
| 147 | }); | 142 | }); |
| 148 | } else { | 143 | } else { |
| 149 | - $query->where($k,$v1[0], $v1[1]); | 144 | + $query->where($k1,$v1[0], $v1[1]); |
| 150 | } | 145 | } |
| 151 | break; | 146 | break; |
| 152 | case 'in': | 147 | case 'in': |
| 153 | // in查询 ['id'=>['in'=>[1,2,3]]] | 148 | // in查询 ['id'=>['in'=>[1,2,3]]] |
| 154 | - $query->whereIn($k, $v1[1]); | 149 | + $query->whereIn($k1, $v1[1]); |
| 155 | break; | 150 | break; |
| 156 | case 'no in': | 151 | case 'no in': |
| 157 | // in查询 ['id'=>['not in'=>[1,2,3]]] | 152 | // in查询 ['id'=>['not in'=>[1,2,3]]] |
| 158 | - $query->whereNotIn($k, $v1[1]); | 153 | + $query->whereNotIn($k1, $v1[1]); |
| 159 | break; | 154 | break; |
| 160 | case 'between': | 155 | case 'between': |
| 161 | // in查询 ['id'=>['between'=>[create1,create2]]] | 156 | // in查询 ['id'=>['between'=>[create1,create2]]] |
| 162 | - $query->whereBetween($k, $v1[1]); | 157 | + $query->whereBetween($k1, $v1[1]); |
| 163 | case 'not between': | 158 | case 'not between': |
| 164 | // not between查询 ['created_at'=>['not between'=>['xxx', 'xxx]]] | 159 | // not between查询 ['created_at'=>['not between'=>['xxx', 'xxx]]] |
| 165 | - $query->whereNotBetween($k, $v1[1]); | 160 | + $query->whereNotBetween($k1, $v1[1]); |
| 166 | break; | 161 | break; |
| 167 | default: | 162 | default: |
| 168 | - $query->where($k,$k1,$v1[1]); | 163 | + $query->where($k1,$v1[0],$v1[1]); |
| 169 | break; | 164 | break; |
| 170 | } | 165 | } |
| 171 | } | 166 | } |
| 172 | - }else{ | ||
| 173 | - $query->where($k,$v); | ||
| 174 | - } | ||
| 175 | } | 167 | } |
| 176 | }); | 168 | }); |
| 177 | return $query; | 169 | return $query; |
app/Models/News/News.php
0 → 100644
app/Models/News/NewsCategory.php
0 → 100644
| @@ -119,11 +119,11 @@ class User extends Base | @@ -119,11 +119,11 @@ class User extends Base | ||
| 119 | public function edits($param){ | 119 | public function edits($param){ |
| 120 | //查看密码是否修改 | 120 | //查看密码是否修改 |
| 121 | $info = $this->read(['id'=>$param['id']]); | 121 | $info = $this->read(['id'=>$param['id']]); |
| 122 | + $param['password'] = base64_encode(md5($param['password'])); | ||
| 122 | if($param['password'] == $info['password']){ | 123 | if($param['password'] == $info['password']){ |
| 123 | unset($param['password']); | 124 | unset($param['password']); |
| 124 | } | 125 | } |
| 125 | //密码加密 | 126 | //密码加密 |
| 126 | - $param['password'] = base64_encode(md5($param['password'])); | ||
| 127 | $rs = $this->edit($param,['id'=>$param['id']]); | 127 | $rs = $this->edit($param,['id'=>$param['id']]); |
| 128 | if($rs === false){ | 128 | if($rs === false){ |
| 129 | return false; | 129 | return false; |
| @@ -30,16 +30,24 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -30,16 +30,24 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 30 | //group相关路由 | 30 | //group相关路由 |
| 31 | Route::any('/project_group/add', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'add'])->name('project_group_add'); | 31 | Route::any('/project_group/add', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'add'])->name('project_group_add'); |
| 32 | Route::any('/project_group/edit', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'edit'])->name('project_group_edit'); | 32 | Route::any('/project_group/edit', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'edit'])->name('project_group_edit'); |
| 33 | - Route::any('/project_group/status', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'status'])->name('project_group_status'); | ||
| 34 | Route::any('/project_group/lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'lists'])->name('project_group_lists'); | 33 | Route::any('/project_group/lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'lists'])->name('project_group_lists'); |
| 35 | Route::any('/project_group/del', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'del'])->name('project_group_del'); | 34 | Route::any('/project_group/del', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'del'])->name('project_group_del'); |
| 35 | + Route::any('/project_group/get_user_lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists'); | ||
| 36 | + | ||
| 37 | + //新闻分类相关路由 | ||
| 38 | + Route::any('/news_category/add', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'add'])->name('news_category_add'); | ||
| 39 | + Route::any('/news_category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'edit'])->name('news_category_edit'); | ||
| 40 | + Route::any('/news_category/lists', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'lists'])->name('news_category_lists'); | ||
| 41 | + Route::any('/news_category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); | ||
| 42 | + Route::any('/news_category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'get_user_lists'])->name('news_category_status'); | ||
| 43 | + | ||
| 36 | 44 | ||
| 37 | //产品 | 45 | //产品 |
| 38 | Route::prefix('product')->group(function () { | 46 | Route::prefix('product')->group(function () { |
| 39 | //产品 | 47 | //产品 |
| 40 | Route::get('/', [\App\Http\Controllers\Bside\Product\ProductController::class, 'index'])->name('product'); | 48 | Route::get('/', [\App\Http\Controllers\Bside\Product\ProductController::class, 'index'])->name('product'); |
| 41 | Route::get('/info', [\App\Http\Controllers\Bside\Product\ProductController::class, 'info'])->name('product_info'); | 49 | Route::get('/info', [\App\Http\Controllers\Bside\Product\ProductController::class, 'info'])->name('product_info'); |
| 42 | - Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name('product_save'); | 50 | + Route::post('/save', [\App\Http\Controllers\Bside\Product\ProductController::class, 'save'])->name(' '); |
| 43 | Route::any('/delete', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delete'])->name('product_delete'); | 51 | Route::any('/delete', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delete'])->name('product_delete'); |
| 44 | 52 | ||
| 45 | //产品分类 | 53 | //产品分类 |
-
请 注册 或 登录 后发表评论