正在显示
8 个修改的文件
包含
109 行增加
和
13 行删除
| @@ -79,7 +79,6 @@ class OptimizeController extends BaseController | @@ -79,7 +79,6 @@ class OptimizeController extends BaseController | ||
| 79 | $item['product_num'] = $data['product'] ?? 0; | 79 | $item['product_num'] = $data['product'] ?? 0; |
| 80 | $item['keyword_num'] = $item['key'] ?? 0; | 80 | $item['keyword_num'] = $item['key'] ?? 0; |
| 81 | $item['autologin_code'] = getAutoLoginCode($item['id']); | 81 | $item['autologin_code'] = getAutoLoginCode($item['id']); |
| 82 | -// $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0); | ||
| 83 | return $item; | 82 | return $item; |
| 84 | } | 83 | } |
| 85 | /** | 84 | /** |
| @@ -92,6 +92,25 @@ class BlogCategoryController extends BaseController | @@ -92,6 +92,25 @@ class BlogCategoryController extends BaseController | ||
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | /** | 94 | /** |
| 95 | + * @remark :排序 | ||
| 96 | + * @name :sort | ||
| 97 | + * @author :lyh | ||
| 98 | + * @method :post | ||
| 99 | + * @time :2023/9/26 17:40 | ||
| 100 | + */ | ||
| 101 | + public function sort(BlogCategoryLogic $blogCategoryLogic){ | ||
| 102 | + $this->request->validate([ | ||
| 103 | + 'id'=>'required', | ||
| 104 | + 'sort'=>'required' | ||
| 105 | + ],[ | ||
| 106 | + 'id.required' => '产品ID不能为空', | ||
| 107 | + 'sort.required'=>'排序字段不能为空' | ||
| 108 | + ]); | ||
| 109 | + $blogCategoryLogic->setSort(); | ||
| 110 | + $this->response('success'); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /** | ||
| 95 | * @name :删除分类 | 114 | * @name :删除分类 |
| 96 | * @author :liyuhang | 115 | * @author :liyuhang |
| 97 | * @method | 116 | * @method |
| @@ -20,7 +20,7 @@ class NewsCategoryController extends BaseController | @@ -20,7 +20,7 @@ class NewsCategoryController extends BaseController | ||
| 20 | public function lists(NewsCategoryModel $newsCategory){ | 20 | public function lists(NewsCategoryModel $newsCategory){ |
| 21 | //搜索条件 | 21 | //搜索条件 |
| 22 | $this->map['project_id'] = $this->user['project_id']; | 22 | $this->map['project_id'] = $this->user['project_id']; |
| 23 | - $lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order, | 23 | + $lists = $newsCategory->lists($this->map,$this->page,$this->row,$this->order = 'sort', |
| 24 | ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']); | 24 | ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']); |
| 25 | if(!empty($lists['list'])){ | 25 | if(!empty($lists['list'])){ |
| 26 | $newsModel = new NewsModel(); | 26 | $newsModel = new NewsModel(); |
| @@ -91,6 +91,23 @@ class NewsCategoryController extends BaseController | @@ -91,6 +91,23 @@ class NewsCategoryController extends BaseController | ||
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | /** | 93 | /** |
| 94 | + * @remark :排序 | ||
| 95 | + * @name :sort | ||
| 96 | + * @author :lyh | ||
| 97 | + * @method :post | ||
| 98 | + * @time :2023/9/26 17:35 | ||
| 99 | + */ | ||
| 100 | + public function sort(NewsCategoryLogic $newsCategoryLogic){ | ||
| 101 | + $this->request->validate([ | ||
| 102 | + 'id'=>['required'], | ||
| 103 | + ],[ | ||
| 104 | + 'id.required' => 'ID不能为空', | ||
| 105 | + ]); | ||
| 106 | + $newsCategoryLogic->categorySort(); | ||
| 107 | + $this->response('success'); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + /** | ||
| 94 | * @name :删除分类 | 111 | * @name :删除分类 |
| 95 | * @author :liyuhang | 112 | * @author :liyuhang |
| 96 | * @method | 113 | * @method |
| @@ -113,6 +113,23 @@ class CategoryController extends BaseController | @@ -113,6 +113,23 @@ class CategoryController extends BaseController | ||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | /** | 115 | /** |
| 116 | + * @remark :排序 | ||
| 117 | + * @name :sort | ||
| 118 | + * @author :lyh | ||
| 119 | + * @method :post | ||
| 120 | + * @time :2023/9/26 17:35 | ||
| 121 | + */ | ||
| 122 | + public function sort(CategoryLogic $logic){ | ||
| 123 | + $this->request->validate([ | ||
| 124 | + 'id'=>['required'], | ||
| 125 | + ],[ | ||
| 126 | + 'id.required' => 'ID不能为空', | ||
| 127 | + ]); | ||
| 128 | + $logic->categorySort(); | ||
| 129 | + $this->response('success'); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 116 | * @remark :删除数据 | 133 | * @remark :删除数据 |
| 117 | * @name :delete | 134 | * @name :delete |
| 118 | * @author :lyh | 135 | * @author :lyh |
| @@ -330,7 +330,21 @@ class BlogCategoryLogic extends BaseLogic | @@ -330,7 +330,21 @@ class BlogCategoryLogic extends BaseLogic | ||
| 330 | } | 330 | } |
| 331 | $return[] = $c_id; | 331 | $return[] = $c_id; |
| 332 | } | 332 | } |
| 333 | - | ||
| 334 | return ','.implode(',',$return).','; | 333 | return ','.implode(',',$return).','; |
| 335 | } | 334 | } |
| 335 | + | ||
| 336 | + /** | ||
| 337 | + * @remark :排序 | ||
| 338 | + * @name :setSort | ||
| 339 | + * @author :lyh | ||
| 340 | + * @method :post | ||
| 341 | + * @time :2023/8/19 11:16 | ||
| 342 | + */ | ||
| 343 | + public function setSort(){ | ||
| 344 | + $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); | ||
| 345 | + if($rs === false){ | ||
| 346 | + $this->fail('error'); | ||
| 347 | + } | ||
| 348 | + return $this->success(); | ||
| 349 | + } | ||
| 336 | } | 350 | } |
| @@ -59,9 +59,9 @@ class NewsCategoryLogic extends BaseLogic | @@ -59,9 +59,9 @@ class NewsCategoryLogic extends BaseLogic | ||
| 59 | */ | 59 | */ |
| 60 | public function newsCategorySave(){ | 60 | public function newsCategorySave(){ |
| 61 | //验证名称是否存在 | 61 | //验证名称是否存在 |
| 62 | -// $this->verifyParamName($this->param['name']); | ||
| 63 | -// DB::beginTransaction(); | ||
| 64 | -// try { | 62 | + $this->verifyParamName($this->param['name']); |
| 63 | + DB::beginTransaction(); | ||
| 64 | + try { | ||
| 65 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 65 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 66 | //验证是否可编辑 | 66 | //验证是否可编辑 |
| 67 | $this->verifyEditParam($this->param['id'],$this->param['pid']); | 67 | $this->verifyEditParam($this->param['id'],$this->param['pid']); |
| @@ -78,11 +78,11 @@ class NewsCategoryLogic extends BaseLogic | @@ -78,11 +78,11 @@ class NewsCategoryLogic extends BaseLogic | ||
| 78 | } | 78 | } |
| 79 | $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); | 79 | $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); |
| 80 | $this->model->edit(['alias'=>$route],['id'=>$id]); | 80 | $this->model->edit(['alias'=>$route],['id'=>$id]); |
| 81 | -// DB::commit(); | ||
| 82 | -// }catch (\Exception $e){ | ||
| 83 | -// DB::rollBack(); | ||
| 84 | -// $this->fail('error'); | ||
| 85 | -// } | 81 | + DB::commit(); |
| 82 | + }catch (\Exception $e){ | ||
| 83 | + DB::rollBack(); | ||
| 84 | + $this->fail('error'); | ||
| 85 | + } | ||
| 86 | //更新通知记录表 | 86 | //更新通知记录表 |
| 87 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]); | 87 | $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]); |
| 88 | return $this->success(); | 88 | return $this->success(); |
| @@ -312,7 +312,21 @@ class NewsCategoryLogic extends BaseLogic | @@ -312,7 +312,21 @@ class NewsCategoryLogic extends BaseLogic | ||
| 312 | } | 312 | } |
| 313 | $return[] = $c_id; | 313 | $return[] = $c_id; |
| 314 | } | 314 | } |
| 315 | - | ||
| 316 | return ','.implode(',',$return).','; | 315 | return ','.implode(',',$return).','; |
| 317 | } | 316 | } |
| 317 | + | ||
| 318 | + /** | ||
| 319 | + * @remark :排序 | ||
| 320 | + * @name :categorySort | ||
| 321 | + * @author :lyh | ||
| 322 | + * @method :post | ||
| 323 | + * @time :2023/9/26 17:38 | ||
| 324 | + */ | ||
| 325 | + public function categorySort(){ | ||
| 326 | + $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); | ||
| 327 | + if($rs === false){ | ||
| 328 | + $this->fail('系统错误,请联系管理员'); | ||
| 329 | + } | ||
| 330 | + return $this->success(); | ||
| 331 | + } | ||
| 318 | } | 332 | } |
| @@ -229,7 +229,21 @@ class CategoryLogic extends BaseLogic | @@ -229,7 +229,21 @@ class CategoryLogic extends BaseLogic | ||
| 229 | 229 | ||
| 230 | //清除缓存 | 230 | //清除缓存 |
| 231 | Common::del_user_cache('product_category',$project_id); | 231 | Common::del_user_cache('product_category',$project_id); |
| 232 | - | ||
| 233 | return ','.implode(',',$return).','; | 232 | return ','.implode(',',$return).','; |
| 234 | } | 233 | } |
| 234 | + | ||
| 235 | + /** | ||
| 236 | + * @remark :排序 | ||
| 237 | + * @name :categorySort | ||
| 238 | + * @author :lyh | ||
| 239 | + * @method :post | ||
| 240 | + * @time :2023/9/26 17:38 | ||
| 241 | + */ | ||
| 242 | + public function categorySort(){ | ||
| 243 | + $rs = $this->model->edit(['sort'=>$this->param['sort']],['id'=>$this->param['id']]); | ||
| 244 | + if($rs === false){ | ||
| 245 | + $this->fail('系统错误,请联系管理员'); | ||
| 246 | + } | ||
| 247 | + return $this->success(); | ||
| 248 | + } | ||
| 235 | } | 249 | } |
| @@ -55,6 +55,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -55,6 +55,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 55 | Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_edit'); | 55 | Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_edit'); |
| 56 | Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); | 56 | Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); |
| 57 | Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status'); | 57 | Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status'); |
| 58 | + Route::any('/category/sort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'sort'])->name('news_category_sort'); | ||
| 58 | Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'categoryTopList'])->name('news_category_categoryTopList'); | 59 | Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'categoryTopList'])->name('news_category_categoryTopList'); |
| 59 | //新闻 | 60 | //新闻 |
| 60 | Route::any('/', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('news_category_lists'); | 61 | Route::any('/', [\App\Http\Controllers\Bside\News\NewsController::class, 'lists'])->name('news_category_lists'); |
| @@ -89,6 +90,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -89,6 +90,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 89 | Route::any('/category/edit', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'save'])->name('blog_category_edit'); | 90 | Route::any('/category/edit', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'save'])->name('blog_category_edit'); |
| 90 | Route::any('/category/del', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'del'])->name('blog_category_del'); | 91 | Route::any('/category/del', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'del'])->name('blog_category_del'); |
| 91 | Route::any('/category/status', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'status'])->name('blog_category_status'); | 92 | Route::any('/category/status', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'status'])->name('blog_category_status'); |
| 93 | + Route::any('/category/sort', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'sort'])->name('blog_category_sort'); | ||
| 92 | Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'categoryTopList'])->name('blog_category_categoryTopList'); | 94 | Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\Blog\BlogCategoryController::class, 'categoryTopList'])->name('blog_category_categoryTopList'); |
| 93 | //博客标签 | 95 | //博客标签 |
| 94 | Route::any('/label/', [\App\Http\Controllers\Bside\Blog\BlogLabelController::class, 'lists'])->name('blog_lists'); | 96 | Route::any('/label/', [\App\Http\Controllers\Bside\Blog\BlogLabelController::class, 'lists'])->name('blog_lists'); |
-
请 注册 或 登录 后发表评论