合并分支 'lyh-server' 到 'master'
Lyh server 查看合并请求 !2818
正在显示
11 个修改的文件
包含
240 行增加
和
15 行删除
| @@ -315,8 +315,8 @@ class BlogController extends BaseController | @@ -315,8 +315,8 @@ class BlogController extends BaseController | ||
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | /** | 317 | /** |
| 318 | - * @remark :复制新闻 | ||
| 319 | - * @name :copyNews | 318 | + * @remark :复制 |
| 319 | + * @name :copyBlog | ||
| 320 | * @author :lyh | 320 | * @author :lyh |
| 321 | * @method :post | 321 | * @method :post |
| 322 | * @time :2024/4/28 11:53 | 322 | * @time :2024/4/28 11:53 |
| 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\Logic\Bside\Blog\BlogExtendLogic; | ||
| 8 | +use Illuminate\Http\Request; | ||
| 9 | + | ||
| 10 | +class BlogExtendController extends BaseController | ||
| 11 | +{ | ||
| 12 | + public function __construct(Request $request) | ||
| 13 | + { | ||
| 14 | + parent::__construct($request); | ||
| 15 | + $this->logic = new BlogExtendLogic(); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @remark :获取所有扩展字段 | ||
| 20 | + * @name :lists | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2025/5/26 15:08 | ||
| 24 | + */ | ||
| 25 | + public function lists() | ||
| 26 | + { | ||
| 27 | + $lists = $this->logic->list($this->map); | ||
| 28 | + $this->response('success', Code::SUCCESS, $lists); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @remark :保存扩展字段 | ||
| 33 | + * @name :save | ||
| 34 | + * @author :lyh | ||
| 35 | + * @method :post | ||
| 36 | + * @time :2025/5/26 15:09 | ||
| 37 | + */ | ||
| 38 | + public function save() | ||
| 39 | + { | ||
| 40 | + $this->request->validate([ | ||
| 41 | + 'title' => 'required', | ||
| 42 | + 'type' => 'required', | ||
| 43 | + ], [ | ||
| 44 | + 'title.required' => '字段名称不能为空', | ||
| 45 | + 'type.required' => '字段类型不能为空', | ||
| 46 | + ]); | ||
| 47 | + $data = $this->logic->extendSave(); | ||
| 48 | + $this->response('success', Code::SUCCESS, $data); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @remark :修改状态 | ||
| 53 | + * @name :status | ||
| 54 | + * @author :lyh | ||
| 55 | + * @method :post | ||
| 56 | + * @time :2025/5/27 9:22 | ||
| 57 | + */ | ||
| 58 | + public function status(){ | ||
| 59 | + $this->request->validate([ | ||
| 60 | + 'id' => 'required', | ||
| 61 | + 'status' => 'required', | ||
| 62 | + ], [ | ||
| 63 | + 'id.required' => '字段名称不能为空', | ||
| 64 | + 'status.required' => '字段类型不能为空', | ||
| 65 | + ]); | ||
| 66 | + $data = $this->logic->extendStatus(); | ||
| 67 | + $this->response('success', Code::SUCCESS, $data); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * @remark :删除扩展字段 | ||
| 72 | + * @name :del | ||
| 73 | + * @author :lyh | ||
| 74 | + * @method :post | ||
| 75 | + * @time :2025/5/26 15:43 | ||
| 76 | + */ | ||
| 77 | + public function del(){ | ||
| 78 | + $this->request->validate([ | ||
| 79 | + 'id' => 'required', | ||
| 80 | + ], [ | ||
| 81 | + 'id.required' => '主键不能为空', | ||
| 82 | + ]); | ||
| 83 | + $data = $this->logic->extendDel(); | ||
| 84 | + $this->response('success', Code::SUCCESS, $data); | ||
| 85 | + } | ||
| 86 | +} |
| @@ -26,7 +26,7 @@ class NewsCategoryController extends BaseController | @@ -26,7 +26,7 @@ class NewsCategoryController extends BaseController | ||
| 26 | $data = []; | 26 | $data = []; |
| 27 | if(!empty($lists)){ | 27 | if(!empty($lists)){ |
| 28 | $newsModel = new NewsModel(); | 28 | $newsModel = new NewsModel(); |
| 29 | - $template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_LIST); | 29 | + $template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_LIST); |
| 30 | foreach ($lists as $k => $v){ | 30 | foreach ($lists as $k => $v){ |
| 31 | $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); | 31 | $v['num'] = $newsModel->formatQuery(['category_id'=>['like','%,' . $v['id'] . ',%']])->count(); |
| 32 | $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id'],$this->user['is_upgrade']); | 32 | $v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS_CATE,$v['id'],$this->user['is_upgrade']); |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside\Blog; | ||
| 4 | + | ||
| 5 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | +use App\Models\Blog\BlogExtend; | ||
| 7 | +use App\Models\Blog\BlogExtendInfo; | ||
| 8 | + | ||
| 9 | +class BlogExtendLogic extends BaseLogic | ||
| 10 | +{ | ||
| 11 | + public function __construct() | ||
| 12 | + { | ||
| 13 | + parent::__construct(); | ||
| 14 | + $this->model = new BlogExtend(); | ||
| 15 | + $this->param = $this->requestAll; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @remark :列表页 | ||
| 20 | + * @name :list | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2025/5/26 15:17 | ||
| 24 | + */ | ||
| 25 | + public function list($map){ | ||
| 26 | + $map['status'] = 1; | ||
| 27 | + $data = $this->model->list($map); | ||
| 28 | + return $this->success($data); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @remark :保存扩展字段 | ||
| 33 | + * @name :extendSave | ||
| 34 | + * @author :lyh | ||
| 35 | + * @method :post | ||
| 36 | + * @time :2025/5/26 15:13 | ||
| 37 | + * @param :id->主键;title->名称 | ||
| 38 | + */ | ||
| 39 | + public function extendSave(){ | ||
| 40 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 41 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 42 | + }else{ | ||
| 43 | + $info = $this->model->read(['title'=>$this->param['title']]); | ||
| 44 | + if($info !== false){ | ||
| 45 | + $this->fail('当前扩展名称已存在'); | ||
| 46 | + } | ||
| 47 | + $this->param['key'] = $this->model->getKey(); | ||
| 48 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 49 | + $rs = $this->model->add($this->param); | ||
| 50 | + } | ||
| 51 | + if($rs === false){ | ||
| 52 | + $this->fail('error'); | ||
| 53 | + } | ||
| 54 | + return $this->success($this->param); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * @remark :修改状态 | ||
| 59 | + * @name :extendStatus | ||
| 60 | + * @author :lyh | ||
| 61 | + * @method :post | ||
| 62 | + * @time :2025/5/27 9:20 | ||
| 63 | + */ | ||
| 64 | + public function extendStatus(){ | ||
| 65 | + $result = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]); | ||
| 66 | + return $this->success(['result'=>$result]); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * @remark :删除字段 | ||
| 71 | + * @name :extendDel | ||
| 72 | + * @author :lyh | ||
| 73 | + * @method :post | ||
| 74 | + * @time :2025/5/26 15:45 | ||
| 75 | + * @param :id->主键 | ||
| 76 | + */ | ||
| 77 | + public function extendDel(){ | ||
| 78 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 79 | + //查看当前扩展字段是否设置了值 | ||
| 80 | + $extendInfoModel = new BlogExtendInfo(); | ||
| 81 | + $extendInfo = $extendInfoModel->read(['key'=>$info['key']]); | ||
| 82 | + if($extendInfo !== false){ | ||
| 83 | + $this->fail('当前扩展字段已有产品在使用,不允许删除'); | ||
| 84 | + } | ||
| 85 | + $this->model->del(['id'=>$this->param['id']]); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | +} |
| @@ -41,7 +41,7 @@ class BlogLogic extends BaseLogic | @@ -41,7 +41,7 @@ class BlogLogic extends BaseLogic | ||
| 41 | $this->edit($this->param,['id'=>$id]); | 41 | $this->edit($this->param,['id'=>$id]); |
| 42 | $this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['url'] ?? '']); | 42 | $this->curlDelRoute(['new_route'=>$route ?? '','old_route'=>$info['url'] ?? '']); |
| 43 | }else{ | 43 | }else{ |
| 44 | - $this->param['sort'] = $this->setNewsSort(); | 44 | + $this->param['sort'] = $this->setBlogSort(); |
| 45 | $id = $this->model->addReturnId($this->param); | 45 | $id = $this->model->addReturnId($this->param); |
| 46 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); | 46 | $route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); |
| 47 | $this->edit(['url'=>$route],['id'=>$id]); | 47 | $this->edit(['url'=>$route],['id'=>$id]); |
| @@ -53,12 +53,12 @@ class BlogLogic extends BaseLogic | @@ -53,12 +53,12 @@ class BlogLogic extends BaseLogic | ||
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | * @remark :设置最新产品的sort排序 | 55 | * @remark :设置最新产品的sort排序 |
| 56 | - * @name :setNewsSort | 56 | + * @name :setBlogSort |
| 57 | * @author :lyh | 57 | * @author :lyh |
| 58 | * @method :post | 58 | * @method :post |
| 59 | * @time :2023/12/25 9:27 | 59 | * @time :2023/12/25 9:27 |
| 60 | */ | 60 | */ |
| 61 | - public function setNewsSort(){ | 61 | + public function setBlogSort(){ |
| 62 | $info = $this->model->orderBy('sort','desc')->first(); | 62 | $info = $this->model->orderBy('sort','desc')->first(); |
| 63 | if(empty($info)){ | 63 | if(empty($info)){ |
| 64 | return 1; | 64 | return 1; |
| @@ -435,8 +435,8 @@ class BlogLogic extends BaseLogic | @@ -435,8 +435,8 @@ class BlogLogic extends BaseLogic | ||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | /** | 437 | /** |
| 438 | - * @remark :复制新闻 | ||
| 439 | - * @name :copyNewsInfo | 438 | + * @remark :复制 |
| 439 | + * @name :copyBlogInfo | ||
| 440 | * @author :lyh | 440 | * @author :lyh |
| 441 | * @method :post | 441 | * @method :post |
| 442 | * @time :2024/4/28 14:51 | 442 | * @time :2024/4/28 14:51 |
| @@ -11,7 +11,7 @@ namespace App\Http\Logic\Bside\News; | @@ -11,7 +11,7 @@ namespace App\Http\Logic\Bside\News; | ||
| 11 | 11 | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | use App\Models\News\NewsExtend; | 13 | use App\Models\News\NewsExtend; |
| 14 | -use App\Models\Product\ExtendInfo; | 14 | +use App\Models\News\NewsExtendInfo; |
| 15 | 15 | ||
| 16 | class NewsExtendLogic extends BaseLogic | 16 | class NewsExtendLogic extends BaseLogic |
| 17 | { | 17 | { |
| @@ -84,7 +84,7 @@ class NewsExtendLogic extends BaseLogic | @@ -84,7 +84,7 @@ class NewsExtendLogic extends BaseLogic | ||
| 84 | public function extendDel(){ | 84 | public function extendDel(){ |
| 85 | $info = $this->model->read(['id'=>$this->param['id']]); | 85 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 86 | //查看当前扩展字段是否设置了值 | 86 | //查看当前扩展字段是否设置了值 |
| 87 | - $extendInfoModel = new ExtendInfo(); | 87 | + $extendInfoModel = new NewsExtendInfo(); |
| 88 | $extendInfo = $extendInfoModel->read(['key'=>$info['key']]); | 88 | $extendInfo = $extendInfoModel->read(['key'=>$info['key']]); |
| 89 | if($extendInfo !== false){ | 89 | if($extendInfo !== false){ |
| 90 | $this->fail('当前扩展字段已有产品在使用,不允许删除'); | 90 | $this->fail('当前扩展字段已有产品在使用,不允许删除'); |
| @@ -3,12 +3,9 @@ | @@ -3,12 +3,9 @@ | ||
| 3 | namespace App\Http\Logic\Bside\News; | 3 | namespace App\Http\Logic\Bside\News; |
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | -use App\Helper\Arr; | ||
| 7 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 8 | use App\Models\News\News; | 7 | use App\Models\News\News; |
| 9 | -use App\Models\News\NewsCategory; | ||
| 10 | use App\Models\News\NewsCategory as NewsCategoryModel; | 8 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 11 | -use App\Models\News\NewsExtend; | ||
| 12 | use App\Models\News\NewsExtendInfo; | 9 | use App\Models\News\NewsExtendInfo; |
| 13 | use App\Models\RouteMap\RouteMap; | 10 | use App\Models\RouteMap\RouteMap; |
| 14 | use App\Models\Template\BTemplate; | 11 | use App\Models\Template\BTemplate; |
app/Models/Blog/BlogExtend.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :BlogExtend.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 15:08 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Blog; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class BlogExtend extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_blog_extend'; | ||
| 17 | + protected $connection = 'custom_mysql'; | ||
| 18 | + | ||
| 19 | + const EXTEND_KEY = 'pd_extended_field_'; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * @remark :添加扩展字段 | ||
| 23 | + * @name :getKey | ||
| 24 | + * @author :lyh | ||
| 25 | + * @method :post | ||
| 26 | + * @time :2025/5/26 15:39 | ||
| 27 | + */ | ||
| 28 | + public function getKey($key = self::EXTEND_KEY,$i = 1){ | ||
| 29 | + $info = $this->read(['key'=>$key.$i]); | ||
| 30 | + if($info !== false){ | ||
| 31 | + return $this->getKey($key,$i+1); | ||
| 32 | + }else{ | ||
| 33 | + return $key.$i; | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +} |
app/Models/Blog/BlogExtendInfo.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :BlogExtendInfo.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 15:49 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Blog; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class BlogExtendInfo extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_blog_extend_info'; | ||
| 17 | + protected $connection = 'custom_mysql'; | ||
| 18 | +} |
-
请 注册 或 登录 后发表评论