正在显示
7 个修改的文件
包含
220 行增加
和
16 行删除
| 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\BlogLabelRequest; | ||
| 8 | +use App\Models\Blog\BlogLabel as BlogLabelModel; | ||
| 9 | +use Illuminate\Http\Request; | ||
| 10 | + | ||
| 11 | +class BlogLabelController extends BaseController | ||
| 12 | +{ | ||
| 13 | + /** | ||
| 14 | + * @name :博客标签列表 | ||
| 15 | + * @return json | ||
| 16 | + * @author :liyuhang | ||
| 17 | + * @method | ||
| 18 | + */ | ||
| 19 | + public function lists(BlogLabelModel $blogLabelModel){ | ||
| 20 | + $lists = $blogLabelModel->lists($this->map,$this->page,$this->row,$this->order); | ||
| 21 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * @name :添加标签 | ||
| 26 | + * @return void | ||
| 27 | + * @author :liyuhang | ||
| 28 | + * @method | ||
| 29 | + */ | ||
| 30 | + public function add(BlogLabelRequest $request,BlogLabelModel $blogLabelModel){ | ||
| 31 | + $request->validated(); | ||
| 32 | + $this->param['create_id'] = $this->uid; | ||
| 33 | + $this->param['Operator_id'] = $this->uid; | ||
| 34 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 35 | + $rs = $blogLabelModel->add($this->param); | ||
| 36 | + if($rs === false){ | ||
| 37 | + $this->response('error',Code::USER_ERROR); | ||
| 38 | + } | ||
| 39 | + //TODO::写入日志 | ||
| 40 | + $this->response('success'); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * @name :编辑标签 | ||
| 45 | + * @return void | ||
| 46 | + * @author :liyuhang | ||
| 47 | + * @method | ||
| 48 | + */ | ||
| 49 | + public function edit(BlogLabelRequest $request,BlogLabelModel $blogLabelModel){ | ||
| 50 | + $request->validate([ | ||
| 51 | + 'id'=>['required'] | ||
| 52 | + ],[ | ||
| 53 | + 'id.required' => 'ID不能为空' | ||
| 54 | + ]); | ||
| 55 | + $this->param['operator_id'] = $this->uid; | ||
| 56 | + $rs = $blogLabelModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 57 | + //TODO::路由映射 | ||
| 58 | + if($rs === false){ | ||
| 59 | + $this->response('error',Code::USER_ERROR); | ||
| 60 | + } | ||
| 61 | + //TODO::写入日志 | ||
| 62 | + $this->response('success'); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * @name :编辑标签状态/排序 | ||
| 67 | + * @return void | ||
| 68 | + * @author :liyuhang | ||
| 69 | + * @method | ||
| 70 | + */ | ||
| 71 | + public function status(Request $request,BlogLabelModel $blogLabelModel){ | ||
| 72 | + $request->validate([ | ||
| 73 | + 'id'=>['required'], | ||
| 74 | + ],[ | ||
| 75 | + 'id.required' => 'ID不能为空', | ||
| 76 | + ]); | ||
| 77 | + $this->param['Operator_id'] = $this->uid; | ||
| 78 | + $rs = $blogLabelModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 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 del(Request $request,BlogLabelModel $blogLabelModel){ | ||
| 93 | + $request->validate([ | ||
| 94 | + 'id'=>['required'], | ||
| 95 | + ],[ | ||
| 96 | + 'id.required' => 'ID不能为空', | ||
| 97 | + ]); | ||
| 98 | + $this->param['id'] = ['in',$this->param['id']]; | ||
| 99 | + $rs = $blogLabelModel->del($this->param); | ||
| 100 | + if($rs === false){ | ||
| 101 | + $this->response('error',Code::USER_ERROR); | ||
| 102 | + } | ||
| 103 | + $this->response('success'); | ||
| 104 | + } | ||
| 105 | +} |
| @@ -56,6 +56,7 @@ class NewsController extends BaseController | @@ -56,6 +56,7 @@ class NewsController extends BaseController | ||
| 56 | if($rs === false){ | 56 | if($rs === false){ |
| 57 | $this->response('error',Code::USER_ERROR); | 57 | $this->response('error',Code::USER_ERROR); |
| 58 | } | 58 | } |
| 59 | + //TODO::写入日志 | ||
| 59 | $this->response('success'); | 60 | $this->response('success'); |
| 60 | } | 61 | } |
| 61 | 62 | ||
| @@ -76,7 +77,7 @@ class NewsController extends BaseController | @@ -76,7 +77,7 @@ class NewsController extends BaseController | ||
| 76 | if($rs === false){ | 77 | if($rs === false){ |
| 77 | $this->response('error',Code::USER_ERROR); | 78 | $this->response('error',Code::USER_ERROR); |
| 78 | } | 79 | } |
| 79 | - //写入日志 | 80 | + //TODO::写入日志 |
| 80 | $this->response('success',Code::SUCCESS); | 81 | $this->response('success',Code::SUCCESS); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| @@ -97,10 +98,11 @@ class NewsController extends BaseController | @@ -97,10 +98,11 @@ class NewsController 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 | } |
| 101 | + //TODO::写入日志 | ||
| 100 | $this->response('success'); | 102 | $this->response('success'); |
| 101 | } | 103 | } |
| 102 | /** | 104 | /** |
| 103 | - * @name :删除 | 105 | + * @name :删除新闻(逻辑删除) |
| 104 | * @return void | 106 | * @return void |
| 105 | * @author :liyuhang | 107 | * @author :liyuhang |
| 106 | * @method | 108 | * @method |
| @@ -112,11 +114,11 @@ class NewsController extends BaseController | @@ -112,11 +114,11 @@ class NewsController extends BaseController | ||
| 112 | 'id.required' => 'ID不能为空', | 114 | 'id.required' => 'ID不能为空', |
| 113 | ]); | 115 | ]); |
| 114 | $this->param['id'] = ['in',$this->param['id']]; | 116 | $this->param['id'] = ['in',$this->param['id']]; |
| 115 | - $rs = $news->del($this->param); | 117 | + $rs = $news->edit(['status'=>2],$this->param); |
| 116 | if($rs === false){ | 118 | if($rs === false){ |
| 117 | $this->response('error',Code::USER_ERROR); | 119 | $this->response('error',Code::USER_ERROR); |
| 118 | } | 120 | } |
| 119 | - //TODO::清空相关资源 | 121 | + //TODO::清空相关资源/写入日志 |
| 120 | $this->response('success'); | 122 | $this->response('success'); |
| 121 | } | 123 | } |
| 122 | } | 124 | } |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside\Blog; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class BlogLabelRequest 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 | + } | ||
| 39 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Requests\Bside\News; | ||
| 4 | + | ||
| 5 | +use Illuminate\Foundation\Http\FormRequest; | ||
| 6 | + | ||
| 7 | +class NewsLabelRequest 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/Models/Blog/BlogLabel.php
0 → 100644
app/Models/News/NewsLabel.php
0 → 100644
| @@ -66,20 +66,20 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -66,20 +66,20 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 66 | //博客相关路由 | 66 | //博客相关路由 |
| 67 | Route::prefix('blog')->group(function () { | 67 | Route::prefix('blog')->group(function () { |
| 68 | //分类 | 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'); | 69 | + Route::any('/category/', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'lists'])->name('blog_category_lists'); |
| 70 | + Route::any('/category/add', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'add'])->name('blog_category_add'); | ||
| 71 | + Route::any('/category/info', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'info'])->name('blog_category_info'); | ||
| 72 | + Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'edit'])->name('blog_category_edit'); | ||
| 73 | + Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('blog_category_del'); | ||
| 74 | + Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('blog_category_status'); | ||
| 75 | 75 | ||
| 76 | //新闻 | 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'); | 77 | + Route::any('/', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('blog_lists'); |
| 78 | + Route::any('/add', [\App\Http\Controllers\Bside\News\NewsController::class, 'add'])->name('blog_add'); | ||
| 79 | + Route::any('/info', [\App\Http\Controllers\Bside\News\NewsController::class, 'info'])->name('blog_info'); | ||
| 80 | + Route::any('/edit', [\App\Http\Controllers\Bside\News\NewsController::class, 'edit'])->name('blog_edit'); | ||
| 81 | + Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('blog_del'); | ||
| 82 | + Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('blog_status'); | ||
| 83 | }); | 83 | }); |
| 84 | 84 | ||
| 85 | //产品 | 85 | //产品 |
-
请 注册 或 登录 后发表评论