作者 lyh

变更数据

@@ -11,8 +11,14 @@ namespace App\Http\Controllers\Api\WorkOrder; @@ -11,8 +11,14 @@ namespace App\Http\Controllers\Api\WorkOrder;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Api\BaseController; 13 use App\Http\Controllers\Api\BaseController;
  14 +use App\Models\Blog\BlogCategory;
  15 +use App\Models\News\NewsCategory;
  16 +use App\Models\Product\Category;
  17 +use App\Models\Product\Keyword;
14 use App\Models\Ticket\TicketUploadData; 18 use App\Models\Ticket\TicketUploadData;
  19 +use App\Services\ProjectServer;
15 use Illuminate\Http\Request; 20 use Illuminate\Http\Request;
  21 +use Illuminate\Support\Facades\DB;
16 22
17 /** 23 /**
18 * @remark :上传产品/博客/新闻模块 24 * @remark :上传产品/博客/新闻模块
@@ -39,12 +45,12 @@ class TicketUploadDataController extends BaseController @@ -39,12 +45,12 @@ class TicketUploadDataController extends BaseController
39 public function lists() 45 public function lists()
40 { 46 {
41 $this->request->validate([ 47 $this->request->validate([
42 - 'project_id'=>'required',  
43 - ],[ 48 + 'project_id' => 'required',
  49 + ], [
44 'project_id.required' => 'project_id不能为空', 50 'project_id.required' => 'project_id不能为空',
45 ]); 51 ]);
46 - $data = $this->model->lists($this->map,$this->page,$this->row,$this->order);  
47 - $this->response('success',Code::SUCCESS,$data); 52 + $data = $this->model->lists($this->map, $this->page, $this->row, $this->order);
  53 + $this->response('success', Code::SUCCESS, $data);
48 } 54 }
49 55
50 /** 56 /**
@@ -54,14 +60,15 @@ class TicketUploadDataController extends BaseController @@ -54,14 +60,15 @@ class TicketUploadDataController extends BaseController
54 * @method :post 60 * @method :post
55 * @time :2025/9/25 10:35 61 * @time :2025/9/25 10:35
56 */ 62 */
57 - public function info(){ 63 + public function info()
  64 + {
58 $this->request->validate([ 65 $this->request->validate([
59 - 'id'=>'required',  
60 - ],[ 66 + 'id' => 'required',
  67 + ], [
61 'id.required' => 'id不能为空', 68 'id.required' => 'id不能为空',
62 ]); 69 ]);
63 $data = $this->model->read($this->param); 70 $data = $this->model->read($this->param);
64 - $this->response('success',Code::SUCCESS,$data); 71 + $this->response('success', Code::SUCCESS, $data);
65 } 72 }
66 73
67 /** 74 /**
@@ -74,23 +81,100 @@ class TicketUploadDataController extends BaseController @@ -74,23 +81,100 @@ class TicketUploadDataController extends BaseController
74 public function save() 81 public function save()
75 { 82 {
76 $this->request->validate([ 83 $this->request->validate([
77 - 'project_id'=>'required',  
78 - 'type'=>'required',  
79 - 'text'=>'required'  
80 - ],[ 84 + 'project_id' => 'required',
  85 + 'type' => 'required',
  86 + 'text' => 'required'
  87 + ], [
81 'project_id.required' => 'project_id不能为空', 88 'project_id.required' => 'project_id不能为空',
82 'type.required' => '上传类型不能为空', 89 'type.required' => '上传类型不能为空',
83 - 'text'=>'数据详情不为空' 90 + 'text' => '数据详情不为空'
84 ]); 91 ]);
85 //验证当前数据是否已提交 92 //验证当前数据是否已提交
86 - $this->param['text'] = json_encode($this->param['text'],true);  
87 - $info = $this->model->read(['project_id'=>$this->$this->param['project_id'],'type'=>$this->param['type'],'text'=>$this->param['text'],'status'=>0]);  
88 - if($info === false){ 93 + $this->param['text'] = json_encode($this->param['text'], true);
  94 + $info = $this->model->read(['project_id' => $this->$this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]);
  95 + if ($info === false) {
89 $id = $this->model->addReturnId($this->param); 96 $id = $this->model->addReturnId($this->param);
90 - }else{ 97 + } else {
91 $id = $info['id']; 98 $id = $info['id'];
92 } 99 }
93 - $data = ['id'=>$id];  
94 - $this->response('success',Code::SUCCESS,$data); 100 + $data = ['id' => $id];
  101 + $this->response('success', Code::SUCCESS, $data);
  102 + }
  103 +
  104 + /**
  105 + * @remark :根据项目获取分类
  106 + * @name :getProductCate
  107 + * @author :lyh
  108 + * @method :post
  109 + * @time :2025/9/25 15:41
  110 + */
  111 + public function getProductCate()
  112 + {
  113 + $this->request->validate([
  114 + 'project_id' => 'required',
  115 + 'type' => 'required',
  116 + 'search' => 'required'
  117 + ], [
  118 + 'project_id.required' => 'project_id不能为空',
  119 + 'type.required' => 'type不能为空',
  120 + 'search.required' => '搜索参数不能为空',
  121 + ]);
  122 + ProjectServer::useProject($this->param['project_id']);
  123 + if ($this->param['type'] == 1) {
  124 + //todo::搜索获取分类
  125 + $productCateModel = new Category();
  126 + $data = $productCateModel->lists(['title' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
  127 + } else {
  128 + $keywordModel = new Keyword();
  129 + $data = $keywordModel->lists(['title' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
  130 + }
  131 + DB::disconnect('custom_mysql');
  132 + $this->response('success', Code::SUCCESS, $data);
  133 + }
  134 +
  135 + /**
  136 + * @remark :获取博客分类
  137 + * @name :getBlogCate
  138 + * @author :lyh
  139 + * @method :post
  140 + * @time :2025/9/25 15:42
  141 + */
  142 + public function getBlogCate()
  143 + {
  144 + $this->request->validate([
  145 + 'project_id' => 'required',
  146 + 'search' => 'required'
  147 + ], [
  148 + 'project_id.required' => 'project_id不能为空',
  149 + 'search.required' => '搜索参数不能为空',
  150 + ]);
  151 + ProjectServer::useProject($this->param['project_id']);
  152 + $blogCateModel = new BlogCategory();
  153 + $data = $blogCateModel->lists(['name' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
  154 + DB::disconnect('custom_mysql');
  155 + $this->response('success', Code::SUCCESS, $data);
  156 + }
  157 +
  158 + /**
  159 + * @remark :获取新闻分类
  160 + * @name :getNewsCate
  161 + * @author :lyh
  162 + * @method :post
  163 + * @time :2025/9/25 15:43
  164 + */
  165 + public function getNewsCate()
  166 + {
  167 + $this->request->validate([
  168 + 'project_id' => 'required',
  169 + 'search' => 'required'
  170 + ], [
  171 + 'project_id.required' => 'project_id不能为空',
  172 + 'search.required' => '搜索参数不能为空',
  173 + ]);
  174 + ProjectServer::useProject($this->param['project_id']);
  175 + $newsCateModel = new NewsCategory();
  176 + $data = $newsCateModel->lists(['name' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
  177 + DB::disconnect('custom_mysql');
  178 + $this->response('success', Code::SUCCESS, $data);
95 } 179 }
96 } 180 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketUploadDataController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/9/25 14:00
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Aside\Ticket;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Aside\BaseController;
  14 +use App\Http\Logic\Aside\Ticket\TicketUploadDataLogic;
  15 +use Illuminate\Http\Request;
  16 +
  17 +/**
  18 + * @remark :工单上传列表审核功能
  19 + * @name :TicketUploadDataController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2025/9/25 14:01
  23 + */
  24 +class TicketUploadDataController extends BaseController
  25 +{
  26 + public function __construct(Request $request)
  27 + {
  28 + parent::__construct($request);
  29 + $this->logic = new TicketUploadDataLogic();
  30 + }
  31 +
  32 + /**
  33 + * @remark :获取审核列表
  34 + * @name :lists
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2025/9/25 14:02
  38 + */
  39 + public function lists(){
  40 + if(isset($this->map['text']) && !empty($this->map['text'])){
  41 + $this->map['text'] = ['like','%'.$this->map['text'].'%'];
  42 + }
  43 + $data = $this->logic->getDataList($this->map,$this->page,$this->row,$this->order);
  44 + $this->response('success',Code::SUCCESS,$data);
  45 + }
  46 +
  47 + /**
  48 + * @remark :人工审核
  49 + * @name :save
  50 + * @author :lyh
  51 + * @method :post
  52 + * @time :2025/9/25 14:14
  53 + */
  54 + public function save()
  55 + {
  56 + $this->request->validate([
  57 + 'status'=>'required',
  58 + 'id'=>'required'
  59 + ],[
  60 + 'status.required' => '提交状态不能为空',
  61 + 'id.required' => '主键ID不能为空',
  62 + ]);
  63 + $data = $this->logic->saveData($this->param);
  64 + $this->response('success',Code::SUCCESS,$data);
  65 + }
  66 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :TicketUploadDataLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/9/25 14:03
  8 + */
  9 +
  10 +namespace App\Http\Logic\Aside\Ticket;
  11 +
  12 +use App\Http\Logic\Bside\BaseLogic;
  13 +use App\Models\Blog\Blog;
  14 +use App\Models\News\News;
  15 +use App\Models\Product\Product;
  16 +use App\Models\RouteMap\RouteMap;
  17 +use App\Models\Ticket\TicketUploadData;
  18 +use App\Services\ProjectServer;
  19 +use Illuminate\Support\Facades\DB;
  20 +
  21 +class TicketUploadDataLogic extends BaseLogic
  22 +{
  23 + public function __construct()
  24 + {
  25 + parent::__construct();
  26 + $this->param = $this->requestAll;
  27 + $this->model = new TicketUploadData();
  28 + }
  29 +
  30 + /**
  31 + * @remark :获取审核列表
  32 + * @name :getDataList
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2025/9/25 14:17
  36 + */
  37 + public function getDataList($map = [],$page = 1,$row = 20,$order = 'id'){
  38 + if(isset($this->map['text']) && !empty($this->map['text'])){
  39 + $this->map['text'] = ['like','%'.$this->map['text'].'%'];
  40 + }
  41 + $data = $this->model->lists($map,$page,$row,$order);
  42 + return $this->success($data);
  43 + }
  44 +
  45 + /**
  46 + * @remark :保存数据详情
  47 + * @name :saveData
  48 + * @author :lyh
  49 + * @method :post
  50 + * @time :2025/9/25 14:17
  51 + */
  52 + public function saveData(){
  53 + //获取当前数据详情
  54 + $info = $this->model->read(['id'=>$this->param['id']]);
  55 + if($info === false){
  56 + $this->fail('当前数据不存在或已被删除');
  57 + }
  58 + ProjectServer::useProject($info['project_id']);
  59 + if($info['type'] == 1){
  60 + //产品
  61 + $productModel = new Product();
  62 + $data = [
  63 + 'project_id' => $info['project_id'],
  64 + 'title' => $info['text']['title'],
  65 + 'thumb'=>json_encode($info['text']['gallery'][0] ?? [],true),
  66 + 'gallery'=>json_encode($info['text']['gallery'] ?? [],true),
  67 + 'intro'=>$info['text']['remark'],
  68 + 'category_id'=>$info['text']['category_id'],
  69 + 'keyword_id'=>$info['text']['keyword_id'],
  70 + 'status'=>0,
  71 + ];
  72 + $id = $productModel->addReturnId($data);
  73 + RouteMap::setRoute($data['title'],RouteMap::SOURCE_PRODUCT,$id,$info['project_id']);
  74 + }elseif ($info['type'] == 2){
  75 + //博客
  76 + $blogModel = new Blog();
  77 + }else{
  78 + //新闻
  79 + $newsModel = new News();
  80 + }
  81 + DB::disconnect('custom_mysql');
  82 + }
  83 +
  84 +}
@@ -99,5 +99,8 @@ Route::prefix('ticket_upload')->group(function () { @@ -99,5 +99,8 @@ Route::prefix('ticket_upload')->group(function () {
99 Route::any('/', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'lists'])->name('ticket_upload.lists'); 99 Route::any('/', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'lists'])->name('ticket_upload.lists');
100 Route::any('/info', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'info'])->name('ticket_upload.info'); 100 Route::any('/info', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'info'])->name('ticket_upload.info');
101 Route::any('/save', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'save'])->name('ticket_upload.save'); 101 Route::any('/save', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'save'])->name('ticket_upload.save');
  102 + Route::any('/getProductCate', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'getProductCate'])->name('ticket_upload.getProductCate');
  103 + Route::any('/getBlogCate', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'getBlogCate'])->name('ticket_upload.getBlogCate');
  104 + Route::any('/getNewsCate', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'getNewsCate'])->name('ticket_upload.getNewsCate');
102 }); 105 });
103 106