正在显示
14 个修改的文件
包含
489 行增加
和
30 行删除
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Blog; | ||
| 4 | + | ||
| 5 | +use App\Http\Controllers\Bside\BaseController; | ||
| 6 | +use App\Http\Requests\Bside\Blog\BlogCategoryRequest; | ||
| 7 | +use App\Models\Blog\Blog as BlogModel; | ||
| 8 | +use App\Models\Blog\BlogCategory as BlogCategoryModel; | ||
| 9 | +use Illuminate\Http\Request; | ||
| 10 | + | ||
| 11 | +class BlogCategoryController extends BaseController | ||
| 12 | +{ | ||
| 13 | + /** | ||
| 14 | + * @name :博客分类列表 | ||
| 15 | + * @return json | ||
| 16 | + * @author :liyuhang | ||
| 17 | + * @method | ||
| 18 | + */ | ||
| 19 | + public function lists(BlogCategoryModel $blogCategoryModel){ | ||
| 20 | + //搜索条件 | ||
| 21 | + $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row); | ||
| 22 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @name :获取当前分类详情 | ||
| 27 | + * @return void | ||
| 28 | + * @author :liyuhang | ||
| 29 | + * @method | ||
| 30 | + */ | ||
| 31 | + public function info(Request $request,BlogCategoryModel $blogCategoryModel){ | ||
| 32 | + $request->validate([ | ||
| 33 | + 'id'=>['required'] | ||
| 34 | + ],[ | ||
| 35 | + 'id.required' => 'ID不能为空' | ||
| 36 | + ]); | ||
| 37 | + $info = $blogCategoryModel->read($this->param); | ||
| 38 | + if($info === false){ | ||
| 39 | + $this->response('error',Code::USER_ERROR); | ||
| 40 | + } | ||
| 41 | + $this->response('success',Code::SUCCESS,$info); | ||
| 42 | + } | ||
| 43 | + /** | ||
| 44 | + * @name :添加分类 | ||
| 45 | + * @return json | ||
| 46 | + * @author :liyuhang | ||
| 47 | + * @method | ||
| 48 | + */ | ||
| 49 | + public function add(BlogCategoryRequest $request,BlogCategoryModel $blogCategoryModel,BlogModel $blogModel){ | ||
| 50 | + $request->validated(); | ||
| 51 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 52 | + $this->param['Operator_id'] = $this->uid; | ||
| 53 | + $this->param['create_id'] = $this->uid; | ||
| 54 | + DB::beginTransaction(); | ||
| 55 | + $rs = $blogCategoryModel->add($this->param); | ||
| 56 | + if($rs === false){ | ||
| 57 | + DB::rollBack(); | ||
| 58 | + $this->response('error',Code::USER_ERROR); | ||
| 59 | + } | ||
| 60 | + //TODO::判断当前分内是否为一级分类 | ||
| 61 | + if(isset($this->param['pid']) && !empty($this->param['pid'])){ | ||
| 62 | + //查看当前上级分类下是否有其他分类 | ||
| 63 | + $cate_info = $blogCategoryModel->read(['pid'=>$this->param['pid'],'id'=>['!=',$blogCategoryModel->id]]); | ||
| 64 | + if($cate_info === false){ | ||
| 65 | + //查看当前上一级分类下是否有商品 | ||
| 66 | + $news_info = $blogModel->read(['category_id'=>$this->param['pid'],'pid'=>0]); | ||
| 67 | + if($news_info !== false){ | ||
| 68 | + //更新所有商品到当前分类 | ||
| 69 | + $rs = $blogModel->edit(['category_id'=>$blogCategoryModel->id],['category_id'=>$this->param['pid']]); | ||
| 70 | + if($rs === false){ | ||
| 71 | + DB::rollBack(); | ||
| 72 | + $this->response('error',Code::USER_ERROR); | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + //TODO::写入日志 | ||
| 78 | + DB::commit(); | ||
| 79 | + $this->response('success'); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * @name :编辑分类 | ||
| 84 | + * @return void | ||
| 85 | + * @author :liyuhang | ||
| 86 | + * @method | ||
| 87 | + */ | ||
| 88 | + public function edit(BlogCategoryRequest $request,BlogCategoryModel $blogCategoryModel){ | ||
| 89 | + $request->validate([ | ||
| 90 | + 'id'=>['required'] | ||
| 91 | + ],[ | ||
| 92 | + 'id.required' => 'ID不能为空' | ||
| 93 | + ]); | ||
| 94 | + $this->param['Operator_id'] = $this->uid; | ||
| 95 | + $rs = $blogCategoryModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 96 | + if($rs === false){ | ||
| 97 | + $this->response('error',Code::USER_ERROR); | ||
| 98 | + } | ||
| 99 | + //TODO::写入日志 | ||
| 100 | + $this->response('success',Code::SUCCESS); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * @name :编辑状态/与排序 | ||
| 105 | + * @return void | ||
| 106 | + * @author :liyuhang | ||
| 107 | + * @method | ||
| 108 | + */ | ||
| 109 | + public function status(Request $request,BlogCategoryModel $blogCategoryModel){ | ||
| 110 | + $request->validate([ | ||
| 111 | + 'id'=>['required'], | ||
| 112 | + ],[ | ||
| 113 | + 'id.required' => 'ID不能为空', | ||
| 114 | + ]); | ||
| 115 | + $this->param['Operator_id'] = $this->uid; | ||
| 116 | + $rs = $blogCategoryModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 117 | + if($rs === false){ | ||
| 118 | + $this->response('error',Code::USER_ERROR); | ||
| 119 | + } | ||
| 120 | + $this->response('success'); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * @name :删除分类 | ||
| 125 | + * @return void | ||
| 126 | + * @author :liyuhang | ||
| 127 | + * @method | ||
| 128 | + */ | ||
| 129 | + public function del(Request $request,BlogCategoryModel $blogCategoryModel,BlogModel $blogModel){ | ||
| 130 | + $request->validate([ | ||
| 131 | + 'id'=>['required'], | ||
| 132 | + ],[ | ||
| 133 | + 'id.required' => 'ID不能为空', | ||
| 134 | + ]); | ||
| 135 | + foreach ($this->param['id'] as $v){ | ||
| 136 | + //查询是否有子分类 | ||
| 137 | + $rs = $blogCategoryModel->read(['pid'=>$v],['id']); | ||
| 138 | + if($rs !== false){ | ||
| 139 | + $this->response('当前分类拥有子分类不允许删除',Code::USER_ERROR); | ||
| 140 | + } | ||
| 141 | + //查看当前分内下是否有博客 | ||
| 142 | + $rs = $blogModel->read(['category_id'=>$v],['id']); | ||
| 143 | + if($rs !== false){ | ||
| 144 | + $this->response('当前分类拥有博客',Code::USER_ERROR); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 148 | + $rs = BlogCategoryModel->del($this->param); | ||
| 149 | + if($rs === false){ | ||
| 150 | + $this->response('error',Code::USER_ERROR); | ||
| 151 | + } | ||
| 152 | + //TODO::写入操作日志 | ||
| 153 | + $this->response('success'); | ||
| 154 | + } | ||
| 155 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Controllers\Bside\Blog; | ||
| 4 | + | ||
| 5 | +use App\Enums\Common\Code; | ||
| 6 | +use App\Http\Controllers\Bside\BaseController; | ||
| 7 | +use App\Http\Requests\Bside\Blog\BlogRequest; | ||
| 8 | +use App\Models\Blog\Blog as BlogModel; | ||
| 9 | +use App\Models\Blog\BlogCategory as BlogCategoryModel; | ||
| 10 | +use Illuminate\Http\Request; | ||
| 11 | + | ||
| 12 | +class BlogController extends BaseController | ||
| 13 | +{ | ||
| 14 | + /** | ||
| 15 | + * @name :博客列表 | ||
| 16 | + * @return json | ||
| 17 | + * @author :liyuhang | ||
| 18 | + * @method | ||
| 19 | + */ | ||
| 20 | + public function lists(BlogModel $blogModel){ | ||
| 21 | + //搜索条件 | ||
| 22 | + $lists = $blogModel->lists($this->map,$this->page,$this->row); | ||
| 23 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * @name :获取当前博客详情 | ||
| 28 | + * @return void | ||
| 29 | + * @author :liyuhang | ||
| 30 | + * @method | ||
| 31 | + */ | ||
| 32 | + public function info(Request $request,BlogModel $blogModel){ | ||
| 33 | + $request->validate([ | ||
| 34 | + 'id'=>['required'] | ||
| 35 | + ],[ | ||
| 36 | + 'id.required' => 'ID不能为空' | ||
| 37 | + ]); | ||
| 38 | + $info = $blogModel->read($this->param); | ||
| 39 | + if($info === false){ | ||
| 40 | + $this->response('error',Code::USER_ERROR); | ||
| 41 | + } | ||
| 42 | + $this->response('success',Code::SUCCESS,$info); | ||
| 43 | + } | ||
| 44 | + /** | ||
| 45 | + * @name :添加博客 | ||
| 46 | + * @return json | ||
| 47 | + * @author :liyuhang | ||
| 48 | + * @method | ||
| 49 | + */ | ||
| 50 | + public function add(BlogRequest $request,BlogModel $blogModel){ | ||
| 51 | + $request->validated(); | ||
| 52 | + $this->param['create_id'] = $this->uid; | ||
| 53 | + $this->param['Operator_id'] = $this->uid; | ||
| 54 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 55 | + //TODO::路由映射 | ||
| 56 | + $rs = $blogModel->add($this->param); | ||
| 57 | + if($rs === false){ | ||
| 58 | + $this->response('error',Code::USER_ERROR); | ||
| 59 | + } | ||
| 60 | + //TODO::写入日志 | ||
| 61 | + $this->response('success'); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * @name :编辑博客 | ||
| 66 | + * @return void | ||
| 67 | + * @author :liyuhang | ||
| 68 | + * @method | ||
| 69 | + */ | ||
| 70 | + public function edit(BlogRequest $request,BlogModel $blogModel){ | ||
| 71 | + $request->validate([ | ||
| 72 | + 'id'=>['required'] | ||
| 73 | + ],[ | ||
| 74 | + 'id.required' => 'ID不能为空' | ||
| 75 | + ]); | ||
| 76 | + $this->param['operator_id'] = $this->uid; | ||
| 77 | + $rs = $blogModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 78 | + //TODO::路由映射 | ||
| 79 | + if($rs === false){ | ||
| 80 | + $this->response('error',Code::USER_ERROR); | ||
| 81 | + } | ||
| 82 | + //TODO::写入日志 | ||
| 83 | + $this->response('success'); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * @name :编辑博客状态/排序 | ||
| 88 | + * @return void | ||
| 89 | + * @author :liyuhang | ||
| 90 | + * @method | ||
| 91 | + */ | ||
| 92 | + public function status(Request $request,BlogModel $blogModel){ | ||
| 93 | + $request->validate([ | ||
| 94 | + 'id'=>['required'], | ||
| 95 | + ],[ | ||
| 96 | + 'id.required' => 'ID不能为空', | ||
| 97 | + ]); | ||
| 98 | + $this->param['Operator_id'] = $this->uid; | ||
| 99 | + $rs = $blogModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 100 | + if($rs === false){ | ||
| 101 | + $this->response('error',Code::USER_ERROR); | ||
| 102 | + } | ||
| 103 | + //TODO::写入日志 | ||
| 104 | + $this->response('success'); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * @name :删除博客(批量逻辑删除) | ||
| 109 | + * @return void | ||
| 110 | + * @author :liyuhang | ||
| 111 | + * @method | ||
| 112 | + */ | ||
| 113 | + public function del(Request $request,BlogModel $blogModel){ | ||
| 114 | + $request->validate([ | ||
| 115 | + 'id'=>['required'], | ||
| 116 | + ],[ | ||
| 117 | + 'id.required' => 'ID不能为空', | ||
| 118 | + ]); | ||
| 119 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 120 | + $rs = $blogModel->edit(['status'=>2],$this->param); | ||
| 121 | + if($rs === false){ | ||
| 122 | + $this->response('error',Code::USER_ERROR); | ||
| 123 | + } | ||
| 124 | + $this->response('success'); | ||
| 125 | + } | ||
| 126 | +} |
| @@ -3,15 +3,13 @@ | @@ -3,15 +3,13 @@ | ||
| 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\Models\Project; | ||
| 6 | use App\Models\Project as ProjectModel; | 7 | use App\Models\Project as ProjectModel; |
| 7 | use App\Models\ProjectMenu as ProjectMenuModel; | 8 | use App\Models\ProjectMenu as ProjectMenuModel; |
| 8 | use App\Models\ProjectRole as ProjectRoleModel; | 9 | use App\Models\ProjectRole as ProjectRoleModel; |
| 9 | use App\Models\User as UserModel; | 10 | use App\Models\User as UserModel; |
| 10 | use Illuminate\Http\Request; | 11 | use Illuminate\Http\Request; |
| 11 | use Illuminate\Support\Facades\Cache; | 12 | use Illuminate\Support\Facades\Cache; |
| 12 | -use Illuminate\Support\Facades\DB; | ||
| 13 | -use Illuminate\Support\Facades\Validator; | ||
| 14 | - | ||
| 15 | /*** | 13 | /*** |
| 16 | * 当前为公共类 所有方法均不需要验证登录token | 14 | * 当前为公共类 所有方法均不需要验证登录token |
| 17 | */ | 15 | */ |
| @@ -73,8 +71,7 @@ class ComController extends BaseController | @@ -73,8 +71,7 @@ class ComController extends BaseController | ||
| 73 | * @author :liyuhang | 71 | * @author :liyuhang |
| 74 | * @method | 72 | * @method |
| 75 | */ | 73 | */ |
| 76 | - public function get_project(){ | ||
| 77 | - $projectModel = new ProjectModel(); | 74 | + public function get_project(ProjectModel $projectModel){ |
| 78 | $info = $projectModel->read(['id'=>$this->user['project_id']]); | 75 | $info = $projectModel->read(['id'=>$this->user['project_id']]); |
| 79 | if(empty($info)){ | 76 | if(empty($info)){ |
| 80 | $this->response('error',Code::USER_ERROR); | 77 | $this->response('error',Code::USER_ERROR); |
| @@ -48,27 +48,27 @@ class NewsCategoryController extends BaseController | @@ -48,27 +48,27 @@ class NewsCategoryController extends BaseController | ||
| 48 | * @author :liyuhang | 48 | * @author :liyuhang |
| 49 | * @method | 49 | * @method |
| 50 | */ | 50 | */ |
| 51 | - public function add(NewsCategoryRequest $request,NewsCategoryModel $newsCategory,NewsModel $news){ | 51 | + public function add(NewsCategoryRequest $request,NewsCategoryModel $newsCategoryModel,NewsModel $newsModel){ |
| 52 | $request->validated(); | 52 | $request->validated(); |
| 53 | $this->param['project_id'] = $this->user['project_id']; | 53 | $this->param['project_id'] = $this->user['project_id']; |
| 54 | $this->param['Operator_id'] = $this->uid; | 54 | $this->param['Operator_id'] = $this->uid; |
| 55 | $this->param['create_id'] = $this->uid; | 55 | $this->param['create_id'] = $this->uid; |
| 56 | DB::beginTransaction(); | 56 | DB::beginTransaction(); |
| 57 | - $rs = $newsCategory->add($this->param); | ||
| 58 | - if($rs === false){ | 57 | + $rs = $newsCategoryModel->add($this->param); |
| 58 | + if($rs === false){ | ||
| 59 | DB::rollBack(); | 59 | DB::rollBack(); |
| 60 | $this->response('error',Code::USER_ERROR); | 60 | $this->response('error',Code::USER_ERROR); |
| 61 | } | 61 | } |
| 62 | - //TODO::判断当前分内是否为一级分类 | 62 | + //判断当前分内是否为一级分类 |
| 63 | if(isset($this->param['pid']) && !empty($this->param['pid'])){ | 63 | if(isset($this->param['pid']) && !empty($this->param['pid'])){ |
| 64 | //查看当前上级分类下是否有其他分类 | 64 | //查看当前上级分类下是否有其他分类 |
| 65 | - $cate_info = $newsCategory->read(['pid'=>$this->param['pid'],'id'=>['!=',$newsCategory->id]]); | 65 | + $cate_info = $newsCategoryModel->read(['pid'=>$this->param['pid'],'id'=>['!=',$newsCategoryModel->id]]); |
| 66 | if($cate_info === false){ | 66 | if($cate_info === false){ |
| 67 | //查看当前上一级分类下是否有商品 | 67 | //查看当前上一级分类下是否有商品 |
| 68 | - $news_info = $news->read(['category_id'=>$this->param['pid'],'pid'=>0]); | 68 | + $news_info = $newsModel->read(['category_id'=>$this->param['pid'],'pid'=>0]); |
| 69 | if($news_info !== false){ | 69 | if($news_info !== false){ |
| 70 | //更新所有商品到当前分类 | 70 | //更新所有商品到当前分类 |
| 71 | - $rs = $news->edit(['category_id'=>$newsCategory->id],['category_id'=>$this->param['pid']]); | 71 | + $rs = $newsModel->edit(['category_id'=>$newsCategoryModel->id],['category_id'=>$this->param['pid']]); |
| 72 | if($rs === false){ | 72 | if($rs === false){ |
| 73 | DB::rollBack(); | 73 | DB::rollBack(); |
| 74 | $this->response('error',Code::USER_ERROR); | 74 | $this->response('error',Code::USER_ERROR); |
| @@ -77,6 +77,7 @@ class NewsCategoryController extends BaseController | @@ -77,6 +77,7 @@ class NewsCategoryController extends BaseController | ||
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | DB::commit(); | 79 | DB::commit(); |
| 80 | + //TODO::写入日志 | ||
| 80 | $this->response('success',Code::SUCCESS); | 81 | $this->response('success',Code::SUCCESS); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| @@ -97,12 +98,12 @@ class NewsCategoryController extends BaseController | @@ -97,12 +98,12 @@ class NewsCategoryController extends BaseController | ||
| 97 | if($rs === false){ | 98 | if($rs === false){ |
| 98 | $this->response('error',Code::USER_ERROR); | 99 | $this->response('error',Code::USER_ERROR); |
| 99 | } | 100 | } |
| 100 | - //写入日志 | 101 | + //TODO::写入日志 |
| 101 | $this->response('success',Code::SUCCESS); | 102 | $this->response('success',Code::SUCCESS); |
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | /** | 105 | /** |
| 105 | - * @name :编辑状态 | 106 | + * @name :编辑状态/排序 |
| 106 | * @return void | 107 | * @return void |
| 107 | * @author :liyuhang | 108 | * @author :liyuhang |
| 108 | * @method | 109 | * @method |
| @@ -110,10 +111,8 @@ class NewsCategoryController extends BaseController | @@ -110,10 +111,8 @@ class NewsCategoryController extends BaseController | ||
| 110 | public function status(Request $request,NewsCategoryModel $newsCategory){ | 111 | public function status(Request $request,NewsCategoryModel $newsCategory){ |
| 111 | $request->validate([ | 112 | $request->validate([ |
| 112 | 'id'=>['required'], | 113 | 'id'=>['required'], |
| 113 | - 'status'=>['required'], | ||
| 114 | ],[ | 114 | ],[ |
| 115 | 'id.required' => 'ID不能为空', | 115 | 'id.required' => 'ID不能为空', |
| 116 | - 'status.required' => 'status不能为空' | ||
| 117 | ]); | 116 | ]); |
| 118 | $this->param['Operator_id'] = $this->uid; | 117 | $this->param['Operator_id'] = $this->uid; |
| 119 | $rs = $newsCategory->edit($this->param,['id'=>$this->param['id']]); | 118 | $rs = $newsCategory->edit($this->param,['id'=>$this->param['id']]); |
| @@ -22,15 +22,36 @@ class NewsController extends BaseController | @@ -22,15 +22,36 @@ class NewsController extends BaseController | ||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | - * @name :添加分类 | 25 | + * @name :获取详情 |
| 26 | + * @return void | ||
| 27 | + * @author :liyuhang | ||
| 28 | + * @method | ||
| 29 | + */ | ||
| 30 | + public function info(Request $request,NewsModel $news){ | ||
| 31 | + $request->validate([ | ||
| 32 | + 'id'=>['required'], | ||
| 33 | + ],[ | ||
| 34 | + 'id.required' => 'ID不能为空', | ||
| 35 | + ]); | ||
| 36 | + $rs = $news->read($this->param); | ||
| 37 | + if($rs === false){ | ||
| 38 | + $this->response('error',Code::USER_ERROR); | ||
| 39 | + } | ||
| 40 | + //TODO::清空相关资源 | ||
| 41 | + $this->response('success'); | ||
| 42 | + } | ||
| 43 | + /** | ||
| 44 | + * @name :添加新闻 | ||
| 26 | * @return json | 45 | * @return json |
| 27 | * @author :liyuhang | 46 | * @author :liyuhang |
| 28 | * @method | 47 | * @method |
| 29 | */ | 48 | */ |
| 30 | public function add(NewsRequest $newsRequest,NewsModel $news){ | 49 | public function add(NewsRequest $newsRequest,NewsModel $news){ |
| 31 | $newsRequest->validated(); | 50 | $newsRequest->validated(); |
| 32 | - $this->param['user_id'] = $this->uid; | 51 | + $this->param['create_id'] = $this->uid; |
| 33 | $this->param['Operator_id'] = $this->uid; | 52 | $this->param['Operator_id'] = $this->uid; |
| 53 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 54 | + //TODO::路由映射 | ||
| 34 | $rs = $news->add($this->param); | 55 | $rs = $news->add($this->param); |
| 35 | if($rs === false){ | 56 | if($rs === false){ |
| 36 | $this->response('error',Code::USER_ERROR); | 57 | $this->response('error',Code::USER_ERROR); |
| @@ -39,7 +60,7 @@ class NewsController extends BaseController | @@ -39,7 +60,7 @@ class NewsController extends BaseController | ||
| 39 | } | 60 | } |
| 40 | 61 | ||
| 41 | /** | 62 | /** |
| 42 | - * @name :编辑分类 | 63 | + * @name :编辑 |
| 43 | * @return void | 64 | * @return void |
| 44 | * @author :liyuhang | 65 | * @author :liyuhang |
| 45 | * @method | 66 | * @method |
| @@ -79,7 +100,7 @@ class NewsController extends BaseController | @@ -79,7 +100,7 @@ class NewsController extends BaseController | ||
| 79 | $this->response('success'); | 100 | $this->response('success'); |
| 80 | } | 101 | } |
| 81 | /** | 102 | /** |
| 82 | - * @name :删除分类 | 103 | + * @name :删除 |
| 83 | * @return void | 104 | * @return void |
| 84 | * @author :liyuhang | 105 | * @author :liyuhang |
| 85 | * @method | 106 | * @method |
| @@ -28,6 +28,24 @@ class ProjectGroupController extends BaseController | @@ -28,6 +28,24 @@ class ProjectGroupController extends BaseController | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | + * @name :详情 | ||
| 32 | + * @return json | ||
| 33 | + * @author :liyuhang | ||
| 34 | + * @method | ||
| 35 | + */ | ||
| 36 | + public function info(Request $request,ProjectGroupModel $projectGroupModel){ | ||
| 37 | + $request->validate([ | ||
| 38 | + 'id'=>['required', new Ids()], | ||
| 39 | + ],[ | ||
| 40 | + 'id.required' => 'ID不能为空', | ||
| 41 | + ]); | ||
| 42 | + $rs = $projectGroupModel->read($this->param); | ||
| 43 | + if($rs === false){ | ||
| 44 | + $this->response('error',Code::USER_ERROR); | ||
| 45 | + } | ||
| 46 | + $this->response('success'); | ||
| 47 | + } | ||
| 48 | + /** | ||
| 31 | * @name:添加用户组获取用户列表 | 49 | * @name:添加用户组获取用户列表 |
| 32 | * @return void | 50 | * @return void |
| 33 | * @author :liyuhang | 51 | * @author :liyuhang |
| @@ -14,7 +14,7 @@ class ProjectRoleController extends BaseController | @@ -14,7 +14,7 @@ class ProjectRoleController extends BaseController | ||
| 14 | { | 14 | { |
| 15 | /** | 15 | /** |
| 16 | * @name :用户角色列表() | 16 | * @name :用户角色列表() |
| 17 | - * @return void | 17 | + * @return json |
| 18 | * @author :liyuhang | 18 | * @author :liyuhang |
| 19 | * @method | 19 | * @method |
| 20 | */ | 20 | */ |
| @@ -27,18 +27,33 @@ class ProjectRoleController extends BaseController | @@ -27,18 +27,33 @@ class ProjectRoleController extends BaseController | ||
| 27 | $lists = $projectRoleModel->lists($this->map,$this->page,$this->row,$this->order); | 27 | $lists = $projectRoleModel->lists($this->map,$this->page,$this->row,$this->order); |
| 28 | $this->response('success',Code::SUCCESS,$lists); | 28 | $this->response('success',Code::SUCCESS,$lists); |
| 29 | } | 29 | } |
| 30 | - | 30 | + /** |
| 31 | + * @name :详情 | ||
| 32 | + * @return json | ||
| 33 | + * @author :liyuhang | ||
| 34 | + * @method | ||
| 35 | + */ | ||
| 36 | + public function info(Request $request,ProjectRoleModel $projectRoleModel){ | ||
| 37 | + $request->validate([ | ||
| 38 | + 'id'=>['required', new Ids()], | ||
| 39 | + ],[ | ||
| 40 | + 'id.required' => 'ID不能为空', | ||
| 41 | + ]); | ||
| 42 | + $rs = $projectRoleModel->read($this->param); | ||
| 43 | + if($rs === false){ | ||
| 44 | + $this->response('error',Code::USER_ERROR); | ||
| 45 | + } | ||
| 46 | + $this->response('success'); | ||
| 47 | + } | ||
| 31 | /** | 48 | /** |
| 32 | * @name :添加/编辑角色时获取菜单列表 | 49 | * @name :添加/编辑角色时获取菜单列表 |
| 33 | * @return void | 50 | * @return void |
| 34 | * @author :liyuhang | 51 | * @author :liyuhang |
| 35 | * @method | 52 | * @method |
| 36 | */ | 53 | */ |
| 37 | - public function get_role_menu(){ | 54 | + public function get_role_menu(ProjectRoleModel $projectRoleModel,ProjectMenuModel $projectMenuModel){ |
| 38 | //根据当前登录用户角色返回用户菜单列表 | 55 | //根据当前登录用户角色返回用户菜单列表 |
| 39 | - $projectRoleModel = new ProjectRoleModel(); | ||
| 40 | $info = $projectRoleModel->read(['id'=>$this->user['role_id']]); | 56 | $info = $projectRoleModel->read(['id'=>$this->user['role_id']]); |
| 41 | - $projectMenuModel = new ProjectMenuModel(); | ||
| 42 | $info['role_menu'] = trim($info['role_menu'],','); | 57 | $info['role_menu'] = trim($info['role_menu'],','); |
| 43 | $lists = $projectMenuModel->where(['status'=>0])->whereIn('id',explode(',',$info['role_menu']))->get(); | 58 | $lists = $projectMenuModel->where(['status'=>0])->whereIn('id',explode(',',$info['role_menu']))->get(); |
| 44 | $lists = $lists->toArray(); | 59 | $lists = $lists->toArray(); |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside\Blog; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class BlogCategoryRequest 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|max:100', | ||
| 28 | + ]; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public function messages() | ||
| 32 | + { | ||
| 33 | + return [ | ||
| 34 | + 'name.required'=>'请填写名称', | ||
| 35 | + 'name.max'=>'名称最大100字', | ||
| 36 | + ]; | ||
| 37 | + } | ||
| 38 | +} |
app/Http/Requests/Bside/Blog/BlogRequest.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside\Blog; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class BlogRequest 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|max:100', | ||
| 28 | + 'remark'=>'required|max:100', | ||
| 29 | + 'text'=>'required|min:10', | ||
| 30 | + ]; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public function messages() | ||
| 34 | + { | ||
| 35 | + return [ | ||
| 36 | + 'name.required'=>'请填写名称', | ||
| 37 | + 'remark.required'=>'请填写简介', | ||
| 38 | + 'text.required'=>'内容不能为空', | ||
| 39 | + 'name.max'=>'名称最大100字', | ||
| 40 | + 'remark.max'=>'简介最大100字', | ||
| 41 | + 'text.max'=>'内容最小100字', | ||
| 42 | + ]; | ||
| 43 | + } | ||
| 44 | +} |
| @@ -24,14 +24,15 @@ class NewsCategoryRequest extends FormRequest | @@ -24,14 +24,15 @@ class NewsCategoryRequest extends FormRequest | ||
| 24 | public function rules() | 24 | public function rules() |
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | - 'name'=>'required', | 27 | + 'name'=>'required|max:100', |
| 28 | ]; | 28 | ]; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | public function messages() | 31 | public function messages() |
| 32 | { | 32 | { |
| 33 | return [ | 33 | return [ |
| 34 | - 'name.required'=>'名称必须填写', | ||
| 35 | - ]; | 34 | + 'name.required'=>'请填写名称', |
| 35 | + 'name.max'=>'名称最大100字', | ||
| 36 | + ]; | ||
| 36 | } | 37 | } |
| 37 | } | 38 | } |
| @@ -24,14 +24,21 @@ class NewsRequest extends FormRequest | @@ -24,14 +24,21 @@ class NewsRequest extends FormRequest | ||
| 24 | public function rules() | 24 | public function rules() |
| 25 | { | 25 | { |
| 26 | return [ | 26 | return [ |
| 27 | - 'name'=>'required', | 27 | + 'name'=>'required|max:100', |
| 28 | + 'remark'=>'required|max:100', | ||
| 29 | + 'text'=>'required|min:10', | ||
| 28 | ]; | 30 | ]; |
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | public function messages() | 33 | public function messages() |
| 32 | { | 34 | { |
| 33 | return [ | 35 | return [ |
| 34 | - 'name.required'=>'名称必须填写', | 36 | + 'name.required'=>'请填写名称', |
| 37 | + 'remark.required'=>'请填写简介', | ||
| 38 | + 'text.required'=>'内容不能为空', | ||
| 39 | + 'name.max'=>'名称最大100字', | ||
| 40 | + 'remark.max'=>'简介最大100字', | ||
| 41 | + 'text.max'=>'内容最小100字', | ||
| 35 | ]; | 42 | ]; |
| 36 | } | 43 | } |
| 37 | } | 44 | } |
app/Models/Blog/Blog.php
0 → 100644
app/Models/Blog/BlogCategory.php
0 → 100644
| @@ -43,6 +43,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -43,6 +43,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 43 | Route::any('/del', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'del'])->name('project_group_del'); | 43 | Route::any('/del', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'del'])->name('project_group_del'); |
| 44 | Route::any('/get_user_lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists'); | 44 | Route::any('/get_user_lists', [\App\Http\Controllers\Bside\ProjectGroupController::class, 'get_user_lists'])->name('project_group_get_user_lists'); |
| 45 | }); | 45 | }); |
| 46 | + | ||
| 46 | //新闻相关路由 | 47 | //新闻相关路由 |
| 47 | Route::prefix('news')->group(function () { | 48 | Route::prefix('news')->group(function () { |
| 48 | //分类 | 49 | //分类 |
| @@ -62,7 +63,24 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -62,7 +63,24 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 62 | Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_category_status'); | 63 | Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_category_status'); |
| 63 | }); | 64 | }); |
| 64 | 65 | ||
| 66 | + //博客相关路由 | ||
| 67 | + Route::prefix('blog')->group(function () { | ||
| 68 | + //分类 | ||
| 69 | + Route::any('/category/add', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'add'])->name('news_category_add'); | ||
| 70 | + Route::any('/category/info', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'info'])->name('news_category_info'); | ||
| 71 | + Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'edit'])->name('news_category_edit'); | ||
| 72 | + Route::any('/category/lists', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'lists'])->name('news_category_lists'); | ||
| 73 | + Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); | ||
| 74 | + Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status'); | ||
| 65 | 75 | ||
| 76 | + //新闻 | ||
| 77 | + Route::any('/add', [\App\Http\Controllers\Bside\News\NewsController::class, 'add'])->name('news_category_add'); | ||
| 78 | + Route::any('/info', [\App\Http\Controllers\Bside\News\NewsController::class, 'info'])->name('news_category_info'); | ||
| 79 | + Route::any('/edit', [\App\Http\Controllers\Bside\News\NewsController::class, 'edit'])->name('news_category_edit'); | ||
| 80 | + Route::any('/lists', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('news_category_lists'); | ||
| 81 | + Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('news_category_del'); | ||
| 82 | + Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_category_status'); | ||
| 83 | + }); | ||
| 66 | 84 | ||
| 67 | //产品 | 85 | //产品 |
| 68 | Route::prefix('product')->group(function () { | 86 | Route::prefix('product')->group(function () { |
-
请 注册 或 登录 后发表评论