作者 lyh

gx

@@ -13,22 +13,21 @@ use App\Models\RouteMap\RouteMap; @@ -13,22 +13,21 @@ use App\Models\RouteMap\RouteMap;
13 class BlogCategoryController extends BaseController 13 class BlogCategoryController extends BaseController
14 { 14 {
15 /** 15 /**
16 - * @name :博客分类列表  
17 - * @author :liyuhang  
18 - * @method 16 + * @remark :博客分类列表
  17 + * @name :lists
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2023/10/18 11:06
19 */ 21 */
20 public function lists(BlogCategoryModel $blogCategoryModel){ 22 public function lists(BlogCategoryModel $blogCategoryModel){
21 //搜索条件 23 //搜索条件
22 $this->map['project_id'] = $this->user['project_id']; 24 $this->map['project_id'] = $this->user['project_id'];
23 - $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order,  
24 - ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at']); 25 + $filed = ['id','pid','name','num','alias','status','sort','remark','created_at','updated_at'];
  26 + $lists = $blogCategoryModel->lists($this->map,$this->page,$this->row,$this->order,$filed);
25 if(!empty($lists['list'])){ 27 if(!empty($lists['list'])){
26 - $blogModel = new BlogModel();  
27 foreach ($lists['list'] as $k => $v){ 28 foreach ($lists['list'] as $k => $v){
28 - $v['num'] = $blogModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();  
29 - $v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG_CATE, $v['id'], $this->user['project_id']); 29 + $v['num'] = 0;
30 $v['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $v['alias']; 30 $v['url'] = $this->user['domain'] . RouteMap::PATH_BLOG_CATE . '/' . $v['alias'];
31 - $v['hasChildren'] = (($blogCategoryModel->read(['pid'=>$v['id']])) != false) ? true : false;  
32 $lists['list'][$k] = $v; 31 $lists['list'][$k] = $v;
33 } 32 }
34 } 33 }
@@ -36,20 +35,23 @@ class BlogCategoryController extends BaseController @@ -36,20 +35,23 @@ class BlogCategoryController extends BaseController
36 } 35 }
37 36
38 /** 37 /**
39 - * @name :(添加/编辑时获取顶级分类)topList 38 + * @remark :添加/编辑时获取分类
  39 + * @name :categoryTopList
40 * @author :lyh 40 * @author :lyh
41 * @method :post 41 * @method :post
42 - * @time :2023/6/13 9:03 42 + * @time :2023/10/18 11:05
43 */ 43 */
44 public function categoryTopList(BlogCategoryLogic $blogCategoryLogic){ 44 public function categoryTopList(BlogCategoryLogic $blogCategoryLogic){
45 - $list = $blogCategoryLogic->categoryTopList(); 45 + $list = $blogCategoryLogic->getCateAllList();
46 $this->response('success',Code::SUCCESS,$list); 46 $this->response('success',Code::SUCCESS,$list);
47 } 47 }
48 48
49 /** 49 /**
50 - * @name :获取当前分类详情  
51 - * @author :liyuhang  
52 - * @method 50 + * @remark :获取详情
  51 + * @name :info
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2023/10/18 11:05
53 */ 55 */
54 public function info(BlogCategoryLogic $blogCategoryLogic){ 56 public function info(BlogCategoryLogic $blogCategoryLogic){
55 $this->request->validate([ 57 $this->request->validate([
@@ -57,8 +59,7 @@ class BlogCategoryController extends BaseController @@ -57,8 +59,7 @@ class BlogCategoryController extends BaseController
57 ],[ 59 ],[
58 'id.required' => 'ID不能为空' 60 'id.required' => 'ID不能为空'
59 ]); 61 ]);
60 - $info = $blogCategoryLogic->info_blog_category();  
61 - $info['url'] = $this->user['domain'] . $info['alias']; 62 + $info = $blogCategoryLogic->info();
62 $this->response('success',Code::SUCCESS,$info); 63 $this->response('success',Code::SUCCESS,$info);
63 } 64 }
64 65
@@ -77,9 +78,11 @@ class BlogCategoryController extends BaseController @@ -77,9 +78,11 @@ class BlogCategoryController extends BaseController
77 78
78 79
79 /** 80 /**
80 - * @name :编辑状态/与排序  
81 - * @author :liyuhang  
82 - * @method 81 + * @remark :修改状态
  82 + * @name :status
  83 + * @author :lyh
  84 + * @method :post
  85 + * @time :2023/10/18 15:55
83 */ 86 */
84 public function status(BlogCategoryLogic $blogCategoryLogic){ 87 public function status(BlogCategoryLogic $blogCategoryLogic){
85 $this->request->validate([ 88 $this->request->validate([
@@ -87,7 +90,7 @@ class BlogCategoryController extends BaseController @@ -87,7 +90,7 @@ class BlogCategoryController extends BaseController
87 ],[ 90 ],[
88 'id.required' => 'ID不能为空', 91 'id.required' => 'ID不能为空',
89 ]); 92 ]);
90 - $blogCategoryLogic->status_blog_category(); 93 + $blogCategoryLogic->cateStatus();
91 $this->response('success'); 94 $this->response('success');
92 } 95 }
93 96
@@ -4,13 +4,10 @@ namespace App\Http\Controllers\Bside\Blog; @@ -4,13 +4,10 @@ namespace App\Http\Controllers\Bside\Blog;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Http\Controllers\Bside\BaseController; 6 use App\Http\Controllers\Bside\BaseController;
7 -use App\Http\Logic\Bside\Blog\BlogCategoryLogic;  
8 -use App\Http\Logic\Bside\Blog\BlogLabelLogic;  
9 use App\Http\Logic\Bside\Blog\BlogLogic; 7 use App\Http\Logic\Bside\Blog\BlogLogic;
10 use App\Http\Requests\Bside\Blog\BlogRequest; 8 use App\Http\Requests\Bside\Blog\BlogRequest;
11 -use App\Models\Blog\Blog as BlogModel;  
12 use App\Models\Blog\BlogCategory; 9 use App\Models\Blog\BlogCategory;
13 -use App\Models\RouteMap\RouteMap; 10 +use App\Models\Com\AssociationCate;
14 use App\Models\User\User; 11 use App\Models\User\User;
15 12
16 class BlogController extends BaseController 13 class BlogController extends BaseController
@@ -23,15 +20,15 @@ class BlogController extends BaseController @@ -23,15 +20,15 @@ class BlogController extends BaseController
23 * @method :post 20 * @method :post
24 * @time :2023/9/14 10:45 21 * @time :2023/9/14 10:45
25 */ 22 */
26 - public function lists(BlogModel $blogModel,BlogCategoryLogic $blogCategoryLogic,BlogLabelLogic $blogLabelLogic){ 23 + public function lists(BlogLogic $blogLogic){
27 $this->map = $this->searchParam(); 24 $this->map = $this->searchParam();
28 - $lists = $blogModel->lists($this->map,$this->page,$this->row,$this->order = 'sort', ['id','category_id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url']); 25 + $filed = ['id','operator_id','status','created_at','label_id','image','updated_at','name','sort','url'];
  26 + $lists = $blogLogic->lists($this->map,$this->page,$this->row,$this->order = 'sort', $filed);
29 if(!empty($lists) && !empty($lists['list'])){ 27 if(!empty($lists) && !empty($lists['list'])){
30 - //获取当前项目的所有分类  
31 - $data = $this->getCategoryList(); 28 + //获取当前数据的分类
32 $user = new User(); 29 $user = new User();
33 foreach ($lists['list'] as $k => $v){ 30 foreach ($lists['list'] as $k => $v){
34 - $v['category_name'] = $this->categoryName($v['category_id'],$data); 31 + $v['category_name'] = $this->getCateName($v['category_id']);
35 $v['url'] = $this->user['domain'] .$v['url']; 32 $v['url'] = $this->user['domain'] .$v['url'];
36 $v['image_link'] = getImageUrl($v['image']); 33 $v['image_link'] = getImageUrl($v['image']);
37 $v['operator_name'] = $user->getName($v['operator_id']); 34 $v['operator_name'] = $user->getName($v['operator_id']);
@@ -51,49 +48,57 @@ class BlogController extends BaseController @@ -51,49 +48,57 @@ class BlogController extends BaseController
51 public function searchParam(){ 48 public function searchParam(){
52 $this->map['project_id'] = $this->user['project_id']; 49 $this->map['project_id'] = $this->user['project_id'];
53 if(isset($this->map['category_id']) && !empty($this->map['category_id'])){ 50 if(isset($this->map['category_id']) && !empty($this->map['category_id'])){
54 - $this->map['category_id'] = ['like','%,'.$this->map['category_id'].',%']; 51 + //获取当前分类下的所有子集
  52 + $str = $this->getAllSub($this->map['category_id'],$str);
  53 + //根据分类获取所有子集
  54 + $assCateModel = new AssociationCate();
  55 + $type_id = $assCateModel->formatQuery(['category_id'=>['in',$str],'type'=>$assCateModel::BLOG_CATE])->pluck('type_id')->toArray();
  56 + $this->map['id'] = ['in',$type_id];
  57 + unset($this->map['category_id']);
55 } 58 }
56 return $this->map; 59 return $this->map;
57 } 60 }
58 61
59 /** 62 /**
60 - * @remark :获取所有分类  
61 - * @name :getCategoryList 63 + * @remark :获取当前id下的所有子集
  64 + * @name :getAllSub
62 * @author :lyh 65 * @author :lyh
63 * @method :post 66 * @method :post
64 - * @time :2023/9/14 13:56 67 + * @time :2023/10/18 15:10
65 */ 68 */
66 - public function getCategoryList(){  
67 - $categoryModel = new BlogCategory();  
68 - $data = [];  
69 - $cateList = $categoryModel->list(['project_id'=>$this->user['project_id']],['id','name']);  
70 - if(!empty($cateList)){  
71 - foreach ($cateList as $value){  
72 - $data[$value['id']] = $value['name']; 69 + public function getAllSub($id,&$str = []){
  70 + $cateModel = new BlogCategory();
  71 + $str[] = $id;
  72 + $list = $cateModel->list(['pid'=>$id,'status'=>0],['id','pid']);
  73 + if(!empty($list)){
  74 + foreach ($list as $v){
  75 + $str[] = $v['id'];
  76 + $this->getAllSub($v['id'],$str);
73 } 77 }
74 } 78 }
75 - return $data; 79 + return $str;
76 } 80 }
77 81
78 /** 82 /**
79 - * @remark :获取分类名称  
80 - * @name :categoryName 83 + * @remark :获取分类名
  84 + * @name :getCateName
81 * @author :lyh 85 * @author :lyh
82 * @method :post 86 * @method :post
83 - * @time :2023/9/14 13:58 87 + * @time :2023/10/18 16:43
84 */ 88 */
85 - public function categoryName($category_id,$data){  
86 - $category_name = '';  
87 - if(!empty($category_id) && !empty($data)){  
88 - $arr = explode(',',trim($category_id,','));  
89 - foreach ($arr as $v){  
90 - if(isset($data[$v])){  
91 - $category_name .= $data[$v].',';  
92 - } 89 + public function getCateName($id){
  90 + //根据分类获取所有子集
  91 + $str = '';
  92 + if(!empty($id)){
  93 + $assCateModel = new AssociationCate();
  94 + $category_id = $assCateModel->formatQuery(['type_id'=>$id,'type'=>$assCateModel::BLOG_CATE])->pluck('category_id')->toArray();
  95 + if(!empty($category_id)){
  96 + $categoryModel = new BlogCategory();
  97 + $category_name_arr = $categoryModel->formatQuery(['category_id'=>['in',$category_id]])->pluck('name')->toArray();
93 } 98 }
94 - $category_name = trim($category_name,','); 99 + $str = explode(',',$category_name_arr);
95 } 100 }
96 - return $category_name; 101 + return $str;
97 } 102 }
98 103
99 /** 104 /**
@@ -109,20 +114,23 @@ class BlogController extends BaseController @@ -109,20 +114,23 @@ class BlogController extends BaseController
109 } 114 }
110 115
111 /** 116 /**
112 - * @name :获取分页列表  
113 - * @throws \App\Exceptions\BsideGlobalException  
114 - * @author :liyuhang  
115 - * @method 117 + * @remark :添加博客时获取分类列表
  118 + * @name :get_category_list
  119 + * @author :lyh
  120 + * @method :post
  121 + * @time :2023/10/18 16:51
116 */ 122 */
117 - public function get_category_list(BlogLogic $blogLogic){  
118 - $list = $blogLogic->blog_get_category_list(); 123 + public function getCategoryList(BlogLogic $blogLogic){
  124 + $list = $blogLogic->getCategoryList();
119 $this->response('success',Code::SUCCESS,$list); 125 $this->response('success',Code::SUCCESS,$list);
120 } 126 }
121 127
122 /** 128 /**
123 - * @name :获取当前博客详情  
124 - * @author :liyuhang  
125 - * @method 129 + * @remark :获取详情
  130 + * @name :info
  131 + * @author :lyh
  132 + * @method :post
  133 + * @time :2023/10/18 16:58
126 */ 134 */
127 public function info(BlogLogic $blogLogic){ 135 public function info(BlogLogic $blogLogic){
128 $this->request->validate([ 136 $this->request->validate([
@@ -26,9 +26,7 @@ class NewsCategoryController extends BaseController @@ -26,9 +26,7 @@ class NewsCategoryController extends BaseController
26 $newsModel = new NewsModel(); 26 $newsModel = new NewsModel();
27 foreach ($lists['list'] as $k => $v){ 27 foreach ($lists['list'] as $k => $v){
28 $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); 28 $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count();
29 - $v['alias'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS_CATE, $v['id'], $this->user['project_id']);  
30 $v['url'] = $this->user['domain'] . RouteMap::PATH_NEWS_CATE . '/' . $v['alias']; 29 $v['url'] = $this->user['domain'] . RouteMap::PATH_NEWS_CATE . '/' . $v['alias'];
31 - $v['hasChildren'] = (($newsCategory->read(['pid'=>$v['id']])) != false) ? true : false;  
32 $lists['list'][$k] = $v; 30 $lists['list'][$k] = $v;
33 } 31 }
34 } 32 }
@@ -36,13 +34,14 @@ class NewsCategoryController extends BaseController @@ -36,13 +34,14 @@ class NewsCategoryController extends BaseController
36 } 34 }
37 35
38 /** 36 /**
39 - * @name :(添加/编辑时获取顶级分类)topList 37 + * @remark :添加/编辑时获取分类
  38 + * @name :categoryTopList
40 * @author :lyh 39 * @author :lyh
41 * @method :post 40 * @method :post
42 - * @time :2023/6/13 9:03 41 + * @time :2023/10/18 11:05
43 */ 42 */
44 public function categoryTopList(NewsCategoryLogic $newsCategoryLogic){ 43 public function categoryTopList(NewsCategoryLogic $newsCategoryLogic){
45 - $list = $newsCategoryLogic->categoryTopList(); 44 + $list = $newsCategoryLogic->getCateAllList();
46 $this->response('success',Code::SUCCESS,$list); 45 $this->response('success',Code::SUCCESS,$list);
47 } 46 }
48 47
@@ -57,8 +56,7 @@ class NewsCategoryController extends BaseController @@ -57,8 +56,7 @@ class NewsCategoryController extends BaseController
57 ],[ 56 ],[
58 'id.required' => 'ID不能为空' 57 'id.required' => 'ID不能为空'
59 ]); 58 ]);
60 - $info = $newsCategoryLogic->info_news_category();  
61 - $info['url'] = $this->user['domain'] . $info['alias']; 59 + $info = $newsCategoryLogic->cateInfo();
62 $this->response('success',Code::SUCCESS,$info); 60 $this->response('success',Code::SUCCESS,$info);
63 } 61 }
64 62
@@ -71,7 +69,7 @@ class NewsCategoryController extends BaseController @@ -71,7 +69,7 @@ class NewsCategoryController extends BaseController
71 */ 69 */
72 public function save(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){ 70 public function save(NewsCategoryRequest $request,NewsCategoryLogic $newsCategoryLogic){
73 $request->validated(); 71 $request->validated();
74 - $newsCategoryLogic->newsCategorySave(); 72 + $newsCategoryLogic->categorySave();
75 $this->response('success'); 73 $this->response('success');
76 } 74 }
77 75
@@ -94,9 +94,6 @@ class FileController @@ -94,9 +94,6 @@ class FileController
94 if ($type == 'multi') { 94 if ($type == 'multi') {
95 return $this->multi($files); 95 return $this->multi($files);
96 } else { 96 } else {
97 - $size = $files->getSize();  
98 - $file_type = $files->getClientOriginalExtension();  
99 - $mime = $files->getMimeType();  
100 return $this->single($files); 97 return $this->single($files);
101 } 98 }
102 } 99 }
@@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Blog; @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Blog;
5 use App\Http\Logic\Bside\BaseLogic; 5 use App\Http\Logic\Bside\BaseLogic;
6 use App\Models\Blog\Blog as BlogModel; 6 use App\Models\Blog\Blog as BlogModel;
7 use App\Models\Blog\BlogCategory as BlogCategoryModel; 7 use App\Models\Blog\BlogCategory as BlogCategoryModel;
  8 +use App\Models\Com\AssociationCate;
8 use App\Models\RouteMap\RouteMap; 9 use App\Models\RouteMap\RouteMap;
9 use Illuminate\Support\Facades\DB; 10 use Illuminate\Support\Facades\DB;
10 11
@@ -13,12 +14,71 @@ class BlogCategoryLogic extends BaseLogic @@ -13,12 +14,71 @@ class BlogCategoryLogic extends BaseLogic
13 public function __construct() 14 public function __construct()
14 { 15 {
15 parent::__construct(); 16 parent::__construct();
16 -  
17 $this->model = new BlogCategoryModel(); 17 $this->model = new BlogCategoryModel();
18 $this->param = $this->requestAll; 18 $this->param = $this->requestAll;
19 } 19 }
20 20
21 /** 21 /**
  22 + * @remark :添加/编辑时获取分类
  23 + * @name :categoryTopList
  24 + * @author :lyh
  25 + * @method :post
  26 + * @time :2023/10/18 11:05
  27 + */
  28 + public function getCateAllList(){
  29 + $this->param['project_id'] = $this->user['project_id'];
  30 + $this->param['status'] = 0;
  31 + if(isset($this->param['id']) && !empty($this->param['id'])){
  32 + //排序掉当前id下所有子集
  33 + $str = $this->getAllSub($this->param['id'],$str);
  34 + $this->param['id'] = ['!=',$str];
  35 + }
  36 + $list = $this->model->list($this->param);
  37 + if(!empty($list)){
  38 + foreach ($list as $k => $v){
  39 + $v['sub'] = _get_child($v['id'],$list);
  40 + $list[$k] = $v;
  41 + }
  42 + }
  43 + $this->success($list);
  44 + }
  45 +
  46 + /**
  47 + * @remark :获取当前id下所有子集
  48 + * @name :getAllSub
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2023/10/18 15:10
  52 + */
  53 + public function getAllSub($id,&$str = []){
  54 + $str[] = $id;
  55 + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
  56 + if(!empty($list)){
  57 + foreach ($list as $v){
  58 + $str[] = $v['id'];
  59 + $this->getAllSub($v['id'],$str);
  60 + }
  61 + }
  62 + return $this->success($str);
  63 + }
  64 +
  65 + /**
  66 + * @remark :获取数据详情
  67 + * @name :info
  68 + * @author :lyh
  69 + * @method :post
  70 + * @time :2023/10/18 15:37
  71 + */
  72 + public function info(){
  73 + $info = $this->model->read($this->param);
  74 + if($info === false){
  75 + $this->fail('当前数据不存在或者已被删除');
  76 + }
  77 + $info['url'] = $this->user['domain'] . $info['alias'];
  78 + return $this->success($info);
  79 + }
  80 +
  81 + /**
22 * @param $v 82 * @param $v
23 * @name :获取分类名称 83 * @name :获取分类名称
24 * @return void 84 * @return void
@@ -46,38 +106,75 @@ class BlogCategoryLogic extends BaseLogic @@ -46,38 +106,75 @@ class BlogCategoryLogic extends BaseLogic
46 public function categorySave(){ 106 public function categorySave(){
47 //验证名称是否存在 107 //验证名称是否存在
48 $this->verifyParamName($this->param['name']); 108 $this->verifyParamName($this->param['name']);
49 - DB::beginTransaction();  
50 - try {  
51 - if(isset($this->param['id']) && !empty($this->param['id'])){  
52 - //验证参数是否可编辑  
53 - $this->verifyParamEdit($this->param['id'],$this->param['pid']);  
54 - //查看路由是否更新  
55 - $id = $this->editCategoryRoute($this->param['id'],  
56 - isset($this->param['alias']) ?? RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],  
57 - RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']));  
58 - $this->param['operator_id'] = $this->user['id'];  
59 - $this->edit($this->param,['id'=>$this->param['id']]);  
60 - }else{  
61 - //拼接参数  
62 - $this->param = $this->addParamProcessing($this->param);  
63 - $id = $this->model->addReturnId($this->param);  
64 - //处理子集  
65 - $this->addProcessingSon($id);  
66 - }  
67 - $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],  
68 - RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);  
69 - $this->edit(['alias'=>$route],['id'=>$id]);  
70 - DB::commit();  
71 - }catch (\Exception $e){  
72 - DB::rollBack();  
73 - $this->fail('系统错误,请联系管理'); 109 + if(isset($this->param['id']) && !empty($this->param['id'])){
  110 + $id = $this->cateEdit();
  111 + }else{
  112 + $id = $this->cateAdd();
74 } 113 }
  114 + //更新路由
  115 + $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
  116 + RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
  117 + $this->model->edit(['alias'=>$route],['id'=>$id]);
75 //通知更新 118 //通知更新
76 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]); 119 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
77 return $this->success(); 120 return $this->success();
78 } 121 }
79 122
80 /** 123 /**
  124 + * @remark :添加数据
  125 + * @name :add
  126 + * @author :lyh
  127 + * @method :post
  128 + * @time :2023/10/18 11:07
  129 + */
  130 + public function cateAdd(){
  131 + //拼接参数
  132 + $this->param = $this->addParamProcessing($this->param);
  133 + try {
  134 + $id = $this->model->addReturnId($this->param);
  135 + //非顶级菜单处理子集
  136 + if($this->param['pid'] != 0){
  137 + //把所有上级博客移动到下级
  138 + $associationCateModel = new AssociationCate();
  139 + $associationCateModel->edit(['category_id'=>$id],['category_id'=>$this->param['pid'],$associationCateModel::BLOG_CATE]);
  140 + }
  141 + }catch (\Exception $e){
  142 + $this->fail('系统错误请联系管理员');
  143 + }
  144 + return $this->success($id);
  145 + }
  146 +
  147 + /**
  148 + * @remark :修改数据
  149 + * @name :edit
  150 + * @author :lyh
  151 + * @method :post
  152 + * @time :2023/10/18 11:08
  153 + */
  154 + public function cateEdit(){
  155 + $this->param['operator_id'] = $this->user['id'];
  156 + try {
  157 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  158 + if($this->param['pid'] != 0){
  159 + //查看当前上级分类下是否有博客
  160 + $associationCateModel = new AssociationCate();
  161 + $num = $associationCateModel->where(['category_id'=>$this->param['pid'],'type'=>$associationCateModel::BLOG_CATE])->count();
  162 + if($num > 0){
  163 + //获取当前分类下的最后一级
  164 + $lastId = $this->getLastCateId($this->param['id']);
  165 + //更新所有博客到当前分类下
  166 + $associationCateModel->edit(['category_id'=>$lastId],['category_id'=>$this->param['pid'],'type'=>$associationCateModel::BLOG_CATE]);
  167 + }
  168 + }
  169 + }catch (\Exception $e){
  170 + $this->fail('系统错误请联系管理员');
  171 + }
  172 + //查看路由是否更新
  173 + $id = $this->editCategoryRoute($this->param['id'],$this->param['alias']);
  174 + return $this->success($id);
  175 + }
  176 +
  177 + /**
81 * @remark :编辑路由时生成路由记录 178 * @remark :编辑路由时生成路由记录
82 * @name :editCategoryRoute 179 * @name :editCategoryRoute
83 * @author :lyh 180 * @author :lyh
@@ -97,43 +194,20 @@ class BlogCategoryLogic extends BaseLogic @@ -97,43 +194,20 @@ class BlogCategoryLogic extends BaseLogic
97 return $this->success(); 194 return $this->success();
98 } 195 }
99 196
100 -  
101 /** 197 /**
102 - * @remark :查看参数是否可编辑  
103 - * @name :verifyParamEdit 198 + * @remark :获取当前分类下最后一级分类的id
  199 + * @name :getLastCateId
104 * @author :lyh 200 * @author :lyh
105 * @method :post 201 * @method :post
106 - * @time :2023/7/31 16:31 202 + * @time :2023/10/18 14:37
107 */ 203 */
108 - public function verifyParamEdit($id,$pid){  
109 - $info = $this->model->read(['id'=>$id]);  
110 - if($info['id'] == $pid){  
111 - $this->fail('不能成为自己的上级');  
112 - }  
113 - if($info['pid'] != $pid){  
114 - $info = $this->model->read(['pid'=>$id]);  
115 - if($info !== false){  
116 - $this->fail('当前分类拥有子分类不允许修改父级');  
117 - }  
118 - //查询当前分类下是否有商品  
119 - $blogModel = new BlogModel();  
120 - $info = $blogModel->read(['id'=>['like','%,'.$id.',%']]);  
121 - if($info !== false){  
122 - $this->fail('当前分类下已存在博客,不允许修改上级');  
123 - } 204 + public function getLastCateId($id){
  205 + $info = $this->model->read(['pid'=>$id],['id']);
  206 + if($info === false){
  207 + return $this->success($id);
  208 + }else{
  209 + $this->getLastCateId($info['id']);
124 } 210 }
125 - return $this->success();  
126 - }  
127 -  
128 - /**  
129 - * @name :详情  
130 - * @return array  
131 - * @author :liyuhang  
132 - * @method  
133 - */  
134 - public function info_blog_category(){  
135 - $info = $this->model->read($this->param);  
136 - return $this->success($info);  
137 } 211 }
138 212
139 /** 213 /**
@@ -142,7 +216,7 @@ class BlogCategoryLogic extends BaseLogic @@ -142,7 +216,7 @@ class BlogCategoryLogic extends BaseLogic
142 * @author :liyuhang 216 * @author :liyuhang
143 * @method 217 * @method
144 */ 218 */
145 - public function status_blog_category(){ 219 + public function cateStatus(){
146 $this->param['operator_id'] = $this->user['id']; 220 $this->param['operator_id'] = $this->user['id'];
147 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 221 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
148 if($rs === false){ 222 if($rs === false){
@@ -188,21 +262,6 @@ class BlogCategoryLogic extends BaseLogic @@ -188,21 +262,6 @@ class BlogCategoryLogic extends BaseLogic
188 return $this->success(); 262 return $this->success();
189 } 263 }
190 264
191 - /**  
192 - * @name :(添加分类时获取1级分类)categoryTopList  
193 - * @author :lyh  
194 - * @method :post  
195 - * @time :2023/6/13 9:09  
196 - */  
197 - public function categoryTopList(){  
198 - $map = [  
199 - 'project_id'=>$this->user['project_id'],  
200 - 'pid'=>0,  
201 - 'status'=>0,  
202 - ];  
203 - $list = $this->model->list($map);  
204 - return $this->success($list);  
205 - }  
206 265
207 /** 266 /**
208 * @name :(参数处理)paramProcessing 267 * @name :(参数处理)paramProcessing
@@ -240,37 +299,6 @@ class BlogCategoryLogic extends BaseLogic @@ -240,37 +299,6 @@ class BlogCategoryLogic extends BaseLogic
240 } 299 }
241 300
242 /** 301 /**
243 - * @param $cate_id  
244 - * @name :(处理子集)addProcessingSon  
245 - * @author :lyh  
246 - * @method :post  
247 - * @time :2023/6/13 11:59  
248 - */  
249 - public function addProcessingSon($cate_id){  
250 - if(!isset($this->param['pid'])){  
251 - $this->param['pid'] = 0;  
252 - }  
253 - //判断为子分类时  
254 - if($this->param['pid'] != 0){  
255 - //查看当前上级分类下是否有其他子分类  
256 - $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);  
257 - if ($cate_info === false) {  
258 - //查看当前上一级分类下是否有新闻  
259 - $blogModel = new BlogModel();  
260 - $blog_count = $blogModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();  
261 - if ($blog_count > 0) {  
262 - $replacement = ','. $this->param['pid'] . ',' . $cate_id . ',';  
263 - $old = ',' . $this->param['pid'] . ',';  
264 - //更新所有商品到当前分类  
265 - $blogModel->where('category_id', 'like', '%' . $old . '%')  
266 - ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);  
267 - }  
268 - }  
269 - }  
270 - return $this->success();  
271 - }  
272 -  
273 - /**  
274 * @remark :删除路由 302 * @remark :删除路由
275 * @name :delRoute 303 * @name :delRoute
276 * @author :lyh 304 * @author :lyh
@@ -7,37 +7,33 @@ use App\Helper\Common; @@ -7,37 +7,33 @@ use App\Helper\Common;
7 use App\Http\Logic\Bside\BaseLogic; 7 use App\Http\Logic\Bside\BaseLogic;
8 use App\Models\Blog\Blog; 8 use App\Models\Blog\Blog;
9 use App\Models\Blog\BlogCategory as BlogCategoryModel; 9 use App\Models\Blog\BlogCategory as BlogCategoryModel;
  10 +use App\Models\Com\AssociationCate;
10 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
11 use App\Services\CosService; 12 use App\Services\CosService;
12 use Illuminate\Support\Facades\DB; 13 use Illuminate\Support\Facades\DB;
13 14
14 class BlogLogic extends BaseLogic 15 class BlogLogic extends BaseLogic
15 { 16 {
16 - const STATUS_TWO = 2;  
17 17
18 public function __construct() 18 public function __construct()
19 { 19 {
20 parent::__construct(); 20 parent::__construct();
21 -  
22 $this->model = new Blog(); 21 $this->model = new Blog();
23 $this->param = $this->requestAll; 22 $this->param = $this->requestAll;
24 } 23 }
25 24
26 /** 25 /**
27 - * @name :获取分类列表  
28 - * @return array  
29 - * @throws \App\Exceptions\BsideGlobalException  
30 - * @author :liyuhang  
31 - * @method 26 + * @remark :添加时获取分类数据
  27 + * @name :getCategoryList
  28 + * @author :lyh
  29 + * @method :post
  30 + * @time :2023/10/18 17:00
32 */ 31 */
33 - public function blog_get_category_list(){ 32 + public function getCategoryList(){
34 $this->map['status'] = 0; 33 $this->map['status'] = 0;
35 $this->map['project_id'] = $this->user['project_id']; 34 $this->map['project_id'] = $this->user['project_id'];
36 $blogCategoryModel = new BlogCategoryModel(); 35 $blogCategoryModel = new BlogCategoryModel();
37 $cate_list = $blogCategoryModel->list($this->map,'sort'); 36 $cate_list = $blogCategoryModel->list($this->map,'sort');
38 - if($cate_list === false){  
39 - $this->fail('error',Code::USER_ERROR);  
40 - }  
41 $list = []; 37 $list = [];
42 foreach ($cate_list as $v){ 38 foreach ($cate_list as $v){
43 $v = (array)$v; 39 $v = (array)$v;
@@ -60,16 +56,18 @@ class BlogLogic extends BaseLogic @@ -60,16 +56,18 @@ class BlogLogic extends BaseLogic
60 //拼接参数 56 //拼接参数
61 DB::beginTransaction(); 57 DB::beginTransaction();
62 try { 58 try {
  59 + $category = $this->param['category_id'];
63 $this->param = $this->paramProcessing($this->param); 60 $this->param = $this->paramProcessing($this->param);
64 if(isset($this->param['id']) && !empty($this->param['id'])){ 61 if(isset($this->param['id']) && !empty($this->param['id'])){
65 //是否更新路由 62 //是否更新路由
66 $id = $this->editNewsRoute($this->param['id'],$this->param['url']); 63 $id = $this->editNewsRoute($this->param['id'],$this->param['url']);
67 - $this->edit($this->param,['id'=>$this->param['id']]); 64 + $this->model->edit($this->param,['id'=>$this->param['id']]);
68 }else{ 65 }else{
69 $id = $this->model->addReturnId($this->param); 66 $id = $this->model->addReturnId($this->param);
70 } 67 }
71 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); 68 $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
72 - $this->edit(['url'=>$route],['id'=>$id]); 69 + $this->model->edit(['url'=>$route],['id'=>$id]);
  70 + $this->saveAssociationCate($id,$category);
73 DB::commit(); 71 DB::commit();
74 }catch (\Exception $e){ 72 }catch (\Exception $e){
75 DB::rollBack(); 73 DB::rollBack();
@@ -81,6 +79,28 @@ class BlogLogic extends BaseLogic @@ -81,6 +79,28 @@ class BlogLogic extends BaseLogic
81 } 79 }
82 80
83 /** 81 /**
  82 + * @remark :保存分类数据
  83 + * @name :saveAssociationCate
  84 + * @author :lyh
  85 + * @method :post
  86 + * @time :2023/10/18 17:01
  87 + */
  88 + public function saveAssociationCate($id,$category_arr){
  89 + //先删除产品与分类关联表
  90 + $assCateModel = new AssociationCate();
  91 + $assCateModel->del(['type_id'=>$id]);
  92 + $data = [];
  93 + foreach ($category_arr as $v){
  94 + $data[] = [
  95 + 'type'=>$assCateModel::BLOG_CATE,
  96 + 'type_id'=> $id,
  97 + 'category_id'=>$v
  98 + ];
  99 + }
  100 + return $assCateModel->insert($data);
  101 + }
  102 +
  103 + /**
84 * @remark :查看是否编辑路由 104 * @remark :查看是否编辑路由
85 * @name :editCategoryRoute 105 * @name :editCategoryRoute
86 * @author :lyh 106 * @author :lyh
@@ -123,23 +143,14 @@ class BlogLogic extends BaseLogic @@ -123,23 +143,14 @@ class BlogLogic extends BaseLogic
123 * @method 143 * @method
124 */ 144 */
125 public function blogInfo(){ 145 public function blogInfo(){
126 - //读取缓存  
127 - $info = Common::get_user_cache($this->model->getTable(),$this->param['id']);  
128 - if(empty($info)){  
129 - $info = $this->model->read($this->param);  
130 - if($info === false){  
131 - $this->fail('error');  
132 - }  
133 - //获取分类名称  
134 - $blogCategoryLogic = new BlogCategoryLogic();  
135 - $info = $blogCategoryLogic->get_category_name($info);  
136 - //获取标签名称  
137 - $blogLabelLogic = new BlogLabelLogic();  
138 - $info = $blogLabelLogic->get_label_name($info);  
139 - $info['image_link'] = getImageUrl($info['image']);  
140 - //写入缓存  
141 - Common::set_user_cache($info,$this->model->getTable(),$this->param['id']); 146 + $info = $this->model->read($this->param);
  147 + if($info === false){
  148 + $this->fail('error');
142 } 149 }
  150 + //获取所有分类
  151 + $assCateModel = new AssociationCate();
  152 + $info['category_id'] = $assCateModel->where(['type_id'=>$info['id']])->pluck('category_id')->toArray();
  153 + $info['image_link'] = getImageUrl($info['image']);
143 return $this->success($info); 154 return $this->success($info);
144 } 155 }
145 156
@@ -209,17 +220,12 @@ class BlogLogic extends BaseLogic @@ -209,17 +220,12 @@ class BlogLogic extends BaseLogic
209 public function paramProcessing($param){ 220 public function paramProcessing($param){
210 if(isset($this->param['id'])){ 221 if(isset($this->param['id'])){
211 $param['operator_id'] = $this->user['id']; 222 $param['operator_id'] = $this->user['id'];
212 - if(isset($param['category_id']) && !empty($param['category_id'])){  
213 - $param['category_id'] = ','.trim($param['category_id'],',').',';  
214 - }  
215 }else{ 223 }else{
216 $param['create_id'] = $this->user['id']; 224 $param['create_id'] = $this->user['id'];
217 $param['operator_id'] = $this->user['id']; 225 $param['operator_id'] = $this->user['id'];
218 $param['project_id'] = $this->user['project_id']; 226 $param['project_id'] = $this->user['project_id'];
219 - if(isset($param['category_id']) && !empty($param['category_id'])){  
220 - $param['category_id'] = ','.$param['category_id'].',';  
221 - }  
222 } 227 }
  228 + unset($this->param['category_id']);
223 return $this->success($param); 229 return $this->success($param);
224 } 230 }
225 231
@@ -18,6 +18,50 @@ class NewsCategoryLogic extends BaseLogic @@ -18,6 +18,50 @@ class NewsCategoryLogic extends BaseLogic
18 } 18 }
19 19
20 /** 20 /**
  21 + * @remark :添加/编辑时获取分类
  22 + * @name :categoryTopList
  23 + * @author :lyh
  24 + * @method :post
  25 + * @time :2023/10/18 11:05
  26 + */
  27 + public function getCateAllList(){
  28 + $this->param['project_id'] = $this->user['project_id'];
  29 + $this->param['status'] = 0;
  30 + if(isset($this->param['id']) && !empty($this->param['id'])){
  31 + //排序掉当前id下所有子集
  32 + $str = $this->getAllSub($this->param['id'],$str);
  33 + $this->param['id'] = ['!=',$str];
  34 + }
  35 + $list = $this->model->list($this->param);
  36 + if(!empty($list)){
  37 + foreach ($list as $k => $v){
  38 + $v['sub'] = _get_child($v['id'],$list);
  39 + $list[$k] = $v;
  40 + }
  41 + }
  42 + $this->success($list);
  43 + }
  44 +
  45 + /**
  46 + * @remark :获取当前id下所有子集
  47 + * @name :getAllSub
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2023/10/18 15:10
  51 + */
  52 + public function getAllSub($id,&$str = []){
  53 + $str[] = $id;
  54 + $list = $this->model->list(['pid'=>$id,'status'=>0],['id','pid']);
  55 + if(!empty($list)){
  56 + foreach ($list as $v){
  57 + $str[] = $v['id'];
  58 + $this->getAllSub($v['id'],$str);
  59 + }
  60 + }
  61 + return $this->success($str);
  62 + }
  63 +
  64 + /**
21 * @param $v 65 * @param $v
22 * @name :获取分类名称 66 * @name :获取分类名称
23 * @return void 67 * @return void
@@ -39,53 +83,97 @@ class NewsCategoryLogic extends BaseLogic @@ -39,53 +83,97 @@ class NewsCategoryLogic extends BaseLogic
39 } 83 }
40 84
41 /** 85 /**
42 - * @name :详情  
43 - * @return array  
44 - * @throws \App\Exceptions\BsideGlobalException  
45 - * @author :liyuhang  
46 - * @method 86 + * @remark :获取详情
  87 + * @name :cateInfo
  88 + * @author :lyh
  89 + * @method :post
  90 + * @time :2023/10/18 14:50
47 */ 91 */
48 - public function info_news_category(){ 92 + public function cateInfo(){
49 $info = $this->model->read($this->param); 93 $info = $this->model->read($this->param);
  94 + if($info === false){
  95 + $this->fail('当前数据不存在或者已被删除');
  96 + }
  97 + $info['url'] = $this->user['domain'] . $info['alias'];
50 return $this->success($info); 98 return $this->success($info);
51 } 99 }
52 100
53 /** 101 /**
54 * @remark :保存数据 102 * @remark :保存数据
55 - * @name :newsCategorySave 103 + * @name :categorySave
56 * @author :lyh 104 * @author :lyh
57 * @method :post 105 * @method :post
58 - * @time :2023/9/7 14:53 106 + * @time :2023/9/7 13:42
59 */ 107 */
60 - public function newsCategorySave(){ 108 + public function categorySave(){
61 //验证名称是否存在 109 //验证名称是否存在
62 $this->verifyParamName($this->param['name']); 110 $this->verifyParamName($this->param['name']);
63 - DB::beginTransaction(); 111 + if(isset($this->param['id']) && !empty($this->param['id'])){
  112 + $id = $this->cateEdit();
  113 + }else{
  114 + $id = $this->cateAdd();
  115 + }
  116 + //更新路由
  117 + $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
  118 + RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
  119 + $this->model->edit(['alias'=>$route],['id'=>$id]);
  120 + //通知更新
  121 + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);
  122 + return $this->success();
  123 + }
  124 +
  125 + /**
  126 + * @remark :添加数据
  127 + * @name :add
  128 + * @author :lyh
  129 + * @method :post
  130 + * @time :2023/10/18 11:07
  131 + */
  132 + public function cateAdd(){
  133 + //拼接参数
  134 + $this->param = $this->addParamProcessing($this->param);
64 try { 135 try {
65 - if(isset($this->param['id']) && !empty($this->param['id'])){  
66 - //验证是否可编辑  
67 - $this->verifyEditParam($this->param['id'],$this->param['pid']);  
68 - $this->param['operator_id'] = $this->user['id'];  
69 - //查看路由是否更新  
70 - $id = $this->editCategoryRoute($this->param['id'],$this->param['alias'] ?? RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],  
71 - RouteMap::SOURCE_NEWS_CATE, $this->param['id'], $this->user['project_id']));  
72 - $this->edit($this->param,['id'=>$this->param['id']]);  
73 - }else{  
74 - $this->param = $this->addParamProcessing($this->param);  
75 - $id = $this->model->addReturnId($this->param);  
76 - //当父级分类拥有产品时,处理子集  
77 - $this->addProcessingSon($id); 136 + $id = $this->model->addReturnId($this->param);
  137 + //非顶级菜单处理子集
  138 + if($this->param['pid'] != 0){
  139 + //把所有上级博客移动到下级
  140 + $newsModel = new NewsModel();
  141 + $newsModel->edit(['category_id'=>$id],['category_id'=>$this->param['pid']]);
78 } 142 }
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]);  
81 - DB::commit();  
82 }catch (\Exception $e){ 143 }catch (\Exception $e){
83 - DB::rollBack();  
84 - $this->fail('error'); 144 + $this->fail('系统错误请联系管理员');
85 } 145 }
86 - //更新通知记录表  
87 - $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_NEWS_CATE, 'route'=>$route]);  
88 - return $this->success(); 146 + return $this->success($id);
  147 + }
  148 +
  149 + /**
  150 + * @remark :修改数据
  151 + * @name :edit
  152 + * @author :lyh
  153 + * @method :post
  154 + * @time :2023/10/18 11:08
  155 + */
  156 + public function cateEdit(){
  157 + $this->param['operator_id'] = $this->user['id'];
  158 + try {
  159 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  160 + if($this->param['pid'] != 0){
  161 + //查看当前上级分类下是否有博客
  162 + $newsModel = new NewsModel();
  163 + $num = $newsModel->where(['category_id'=>$this->param['pid']])->count();
  164 + if($num > 0){
  165 + //获取当前分类下的最后一级
  166 + $lastId = $this->getLastCateId($this->param['id']);
  167 + //更新所有博客到当前分类下
  168 + $newsModel->edit(['category_id'=>$lastId],['category_id'=>$this->param['pid']]);
  169 + }
  170 + }
  171 + }catch (\Exception $e){
  172 + $this->fail('系统错误请联系管理员');
  173 + }
  174 + //查看路由是否更新
  175 + $id = $this->editCategoryRoute($this->param['id'],$this->param['alias']);
  176 + return $this->success($id);
89 } 177 }
90 178
91 179
@@ -106,34 +194,23 @@ class NewsCategoryLogic extends BaseLogic @@ -106,34 +194,23 @@ class NewsCategoryLogic extends BaseLogic
106 ]; 194 ];
107 $this->setRouteDeleteSave($data); 195 $this->setRouteDeleteSave($data);
108 } 196 }
109 - return $id; 197 + return $this->success($id);
110 } 198 }
111 199
112 /** 200 /**
113 - * @remark :验证是否可编辑  
114 - * @name :verifyEditParam 201 + * @remark :获取当前分类下最后一级分类的id
  202 + * @name :getLastCateId
115 * @author :lyh 203 * @author :lyh
116 * @method :post 204 * @method :post
117 - * @time :2023/7/31 15:41 205 + * @time :2023/10/18 14:37
118 */ 206 */
119 - public function verifyEditParam($id,$pid){  
120 - $info = $this->model->read(['id'=>$id]);  
121 - if($info['id'] == $pid){  
122 - $this->fail('不能成为自己的上级');  
123 - }  
124 - if($info['pid'] != $pid){  
125 - $info = $this->model->read(['pid'=>$id]);  
126 - if($info !== false){  
127 - $this->fail('当前分类拥有子分类不允许修改父级');  
128 - }  
129 - //查询当前分类下是否有商品  
130 - $newsModel = new NewsModel();  
131 - $info = $newsModel->read(['id'=>['like','%,'.$id.',%']]);  
132 - if($info !== false){  
133 - $this->fail('当前分类下已存在新闻,不允许修改上级');  
134 - } 207 + public function getLastCateId($id){
  208 + $info = $this->model->read(['pid'=>$id],['id']);
  209 + if($info === false){
  210 + return $this->success($id);
  211 + }else{
  212 + $this->getLastCateId($info['id']);
135 } 213 }
136 - return $this->success();  
137 } 214 }
138 215
139 /** 216 /**
@@ -175,22 +252,6 @@ class NewsCategoryLogic extends BaseLogic @@ -175,22 +252,6 @@ class NewsCategoryLogic extends BaseLogic
175 } 252 }
176 253
177 /** 254 /**
178 - * @name :(添加分类时获取1级分类)categoryTopList  
179 - * @author :lyh  
180 - * @method :post  
181 - * @time :2023/6/13 9:09  
182 - */  
183 - public function categoryTopList(){  
184 - $map = [  
185 - 'project_id'=>$this->user['project_id'],  
186 - 'pid'=>0,  
187 - 'status'=>0,  
188 - ];  
189 - $list = $this->model->list($map);  
190 - return $this->success($list);  
191 - }  
192 -  
193 - /**  
194 * @name :(验证名称是否存在)verifyParamName 255 * @name :(验证名称是否存在)verifyParamName
195 * @author :lyh 256 * @author :lyh
196 * @method :post 257 * @method :post
@@ -223,36 +284,6 @@ class NewsCategoryLogic extends BaseLogic @@ -223,36 +284,6 @@ class NewsCategoryLogic extends BaseLogic
223 } 284 }
224 285
225 /** 286 /**
226 - * @name :(添加分类时处理子集分类)addProcessingSon  
227 - * @author :lyh  
228 - * @method :post  
229 - * @time :2023/6/13 11:34  
230 - */  
231 - public function addProcessingSon($cate_id){  
232 - if(isset($this->param['pid']) && !empty($this->param['pid'])) {  
233 - $this->param['pid'] = 0;  
234 - }  
235 - //判断为子分类时  
236 - if($this->param['pid'] != 0) {  
237 - //查看当前上级分类下是否有其他分类  
238 - $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);  
239 - if ($cate_info === false) {  
240 - //查看当前上一级分类下是否有新闻  
241 - $newsModel = new NewsModel();  
242 - $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();  
243 - if ($news_count > 0) {  
244 - $replacement = ','. $this->param['pid'] .','. $cate_id . ',';  
245 - $old = ',' . $this->param['pid'] . ',';  
246 - //更新所有商品到当前分类  
247 - $newsModel->where('category_id', 'like', '%' . $old . '%')  
248 - ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);  
249 - }  
250 - }  
251 - }  
252 - return $this->success();  
253 - }  
254 -  
255 - /**  
256 * @remark :删除路由 287 * @remark :删除路由
257 * @name :delRoute 288 * @name :delRoute
258 * @author :lyh 289 * @author :lyh
@@ -35,6 +35,7 @@ class ProjectCountryLogic extends BaseLogic @@ -35,6 +35,7 @@ class ProjectCountryLogic extends BaseLogic
35 * @time :2023/4/28 17:42 35 * @time :2023/4/28 17:42
36 */ 36 */
37 public function country_save(){ 37 public function country_save(){
  38 + //处理数据
38 if(!isset($this->param['country_lists']) || empty($this->param['country_lists'])){ 39 if(!isset($this->param['country_lists']) || empty($this->param['country_lists'])){
39 $this->param['country_lists'] = ''; 40 $this->param['country_lists'] = '';
40 } 41 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AssociationCate.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/10/18 15:47
  8 + */
  9 +
  10 +namespace App\Models\Com;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +/**
  15 + * @remark :分类关联表
  16 + * @name :AssociationCate
  17 + * @author :lyh
  18 + * @method :post
  19 + * @time :2023/10/18 15:48
  20 + */
  21 +class AssociationCate extends Base
  22 +{
  23 + const BLOG_CATE = 1;//博客
  24 + const NEWS_CATE = 2;//博客
  25 +
  26 + protected $table = 'gl_association_cate';
  27 + //连接数据库
  28 + protected $connection = 'custom_mysql';
  29 +}
@@ -25,7 +25,7 @@ return [ @@ -25,7 +25,7 @@ return [
25 //默认视频 25 //默认视频
26 'default_file' =>[ 26 'default_file' =>[
27 'size' => [ 27 'size' => [
28 - 'max' => 1024*1024*20, // 20M 28 + 'max' => 1024*1024*50, // 50M
29 ], 29 ],
30 'path_b' => '/upload/p', 30 'path_b' => '/upload/p',
31 'path_a' => '/upload/m', 31 'path_a' => '/upload/m',
@@ -74,7 +74,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -74,7 +74,7 @@ Route::middleware(['bloginauth'])->group(function () {
74 Route::prefix('blog')->group(function () { 74 Route::prefix('blog')->group(function () {
75 //博客 75 //博客
76 Route::any('/', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'lists'])->name('blog_lists'); 76 Route::any('/', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'lists'])->name('blog_lists');
77 - Route::any('/get_category_list', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'get_category_list'])->name('blog_get_category_list'); 77 + Route::any('/get_category_list', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'getCategoryList'])->name('blog_get_category_list');
78 Route::any('/add', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'save'])->name('blog_add'); 78 Route::any('/add', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'save'])->name('blog_add');
79 Route::any('/info', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'info'])->name('blog_info'); 79 Route::any('/info', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'info'])->name('blog_info');
80 Route::any('/edit', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'save'])->name('blog_edit'); 80 Route::any('/edit', [\App\Http\Controllers\Bside\Blog\BlogController::class, 'save'])->name('blog_edit');