作者 lyh

变更数据

... ... @@ -11,8 +11,14 @@ namespace App\Http\Controllers\Api\WorkOrder;
use App\Enums\Common\Code;
use App\Http\Controllers\Api\BaseController;
use App\Models\Blog\BlogCategory;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\Keyword;
use App\Models\Ticket\TicketUploadData;
use App\Services\ProjectServer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
/**
* @remark :上传产品/博客/新闻模块
... ... @@ -39,12 +45,12 @@ class TicketUploadDataController extends BaseController
public function lists()
{
$this->request->validate([
'project_id'=>'required',
],[
'project_id' => 'required',
], [
'project_id.required' => 'project_id不能为空',
]);
$data = $this->model->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$data);
$data = $this->model->lists($this->map, $this->page, $this->row, $this->order);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -54,14 +60,15 @@ class TicketUploadDataController extends BaseController
* @method :post
* @time :2025/9/25 10:35
*/
public function info(){
public function info()
{
$this->request->validate([
'id'=>'required',
],[
'id' => 'required',
], [
'id.required' => 'id不能为空',
]);
$data = $this->model->read($this->param);
$this->response('success',Code::SUCCESS,$data);
$this->response('success', Code::SUCCESS, $data);
}
/**
... ... @@ -74,23 +81,100 @@ class TicketUploadDataController extends BaseController
public function save()
{
$this->request->validate([
'project_id'=>'required',
'type'=>'required',
'text'=>'required'
],[
'project_id' => 'required',
'type' => 'required',
'text' => 'required'
], [
'project_id.required' => 'project_id不能为空',
'type.required' => '上传类型不能为空',
'text'=>'数据详情不为空'
'text' => '数据详情不为空'
]);
//验证当前数据是否已提交
$this->param['text'] = json_encode($this->param['text'],true);
$info = $this->model->read(['project_id'=>$this->$this->param['project_id'],'type'=>$this->param['type'],'text'=>$this->param['text'],'status'=>0]);
if($info === false){
$this->param['text'] = json_encode($this->param['text'], true);
$info = $this->model->read(['project_id' => $this->$this->param['project_id'], 'type' => $this->param['type'], 'text' => $this->param['text'], 'status' => 0]);
if ($info === false) {
$id = $this->model->addReturnId($this->param);
}else{
} else {
$id = $info['id'];
}
$data = ['id'=>$id];
$this->response('success',Code::SUCCESS,$data);
$data = ['id' => $id];
$this->response('success', Code::SUCCESS, $data);
}
/**
* @remark :根据项目获取分类
* @name :getProductCate
* @author :lyh
* @method :post
* @time :2025/9/25 15:41
*/
public function getProductCate()
{
$this->request->validate([
'project_id' => 'required',
'type' => 'required',
'search' => 'required'
], [
'project_id.required' => 'project_id不能为空',
'type.required' => 'type不能为空',
'search.required' => '搜索参数不能为空',
]);
ProjectServer::useProject($this->param['project_id']);
if ($this->param['type'] == 1) {
//todo::搜索获取分类
$productCateModel = new Category();
$data = $productCateModel->lists(['title' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
} else {
$keywordModel = new Keyword();
$data = $keywordModel->lists(['title' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
}
DB::disconnect('custom_mysql');
$this->response('success', Code::SUCCESS, $data);
}
/**
* @remark :获取博客分类
* @name :getBlogCate
* @author :lyh
* @method :post
* @time :2025/9/25 15:42
*/
public function getBlogCate()
{
$this->request->validate([
'project_id' => 'required',
'search' => 'required'
], [
'project_id.required' => 'project_id不能为空',
'search.required' => '搜索参数不能为空',
]);
ProjectServer::useProject($this->param['project_id']);
$blogCateModel = new BlogCategory();
$data = $blogCateModel->lists(['name' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
DB::disconnect('custom_mysql');
$this->response('success', Code::SUCCESS, $data);
}
/**
* @remark :获取新闻分类
* @name :getNewsCate
* @author :lyh
* @method :post
* @time :2025/9/25 15:43
*/
public function getNewsCate()
{
$this->request->validate([
'project_id' => 'required',
'search' => 'required'
], [
'project_id.required' => 'project_id不能为空',
'search.required' => '搜索参数不能为空',
]);
ProjectServer::useProject($this->param['project_id']);
$newsCateModel = new NewsCategory();
$data = $newsCateModel->lists(['name' => ['like' => '%' . $this->param['search'] . '%']], 1, 20);
DB::disconnect('custom_mysql');
$this->response('success', Code::SUCCESS, $data);
}
}
... ...
<?php
/**
* @remark :
* @name :TicketUploadDataController.php
* @author :lyh
* @method :post
* @time :2025/9/25 14:00
*/
namespace App\Http\Controllers\Aside\Ticket;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Ticket\TicketUploadDataLogic;
use Illuminate\Http\Request;
/**
* @remark :工单上传列表审核功能
* @name :TicketUploadDataController
* @author :lyh
* @method :post
* @time :2025/9/25 14:01
*/
class TicketUploadDataController extends BaseController
{
public function __construct(Request $request)
{
parent::__construct($request);
$this->logic = new TicketUploadDataLogic();
}
/**
* @remark :获取审核列表
* @name :lists
* @author :lyh
* @method :post
* @time :2025/9/25 14:02
*/
public function lists(){
if(isset($this->map['text']) && !empty($this->map['text'])){
$this->map['text'] = ['like','%'.$this->map['text'].'%'];
}
$data = $this->logic->getDataList($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :人工审核
* @name :save
* @author :lyh
* @method :post
* @time :2025/9/25 14:14
*/
public function save()
{
$this->request->validate([
'status'=>'required',
'id'=>'required'
],[
'status.required' => '提交状态不能为空',
'id.required' => '主键ID不能为空',
]);
$data = $this->logic->saveData($this->param);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?php
/**
* @remark :
* @name :TicketUploadDataLogic.php
* @author :lyh
* @method :post
* @time :2025/9/25 14:03
*/
namespace App\Http\Logic\Aside\Ticket;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\Blog;
use App\Models\News\News;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Ticket\TicketUploadData;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
class TicketUploadDataLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new TicketUploadData();
}
/**
* @remark :获取审核列表
* @name :getDataList
* @author :lyh
* @method :post
* @time :2025/9/25 14:17
*/
public function getDataList($map = [],$page = 1,$row = 20,$order = 'id'){
if(isset($this->map['text']) && !empty($this->map['text'])){
$this->map['text'] = ['like','%'.$this->map['text'].'%'];
}
$data = $this->model->lists($map,$page,$row,$order);
return $this->success($data);
}
/**
* @remark :保存数据详情
* @name :saveData
* @author :lyh
* @method :post
* @time :2025/9/25 14:17
*/
public function saveData(){
//获取当前数据详情
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
ProjectServer::useProject($info['project_id']);
if($info['type'] == 1){
//产品
$productModel = new Product();
$data = [
'project_id' => $info['project_id'],
'title' => $info['text']['title'],
'thumb'=>json_encode($info['text']['gallery'][0] ?? [],true),
'gallery'=>json_encode($info['text']['gallery'] ?? [],true),
'intro'=>$info['text']['remark'],
'category_id'=>$info['text']['category_id'],
'keyword_id'=>$info['text']['keyword_id'],
'status'=>0,
];
$id = $productModel->addReturnId($data);
RouteMap::setRoute($data['title'],RouteMap::SOURCE_PRODUCT,$id,$info['project_id']);
}elseif ($info['type'] == 2){
//博客
$blogModel = new Blog();
}else{
//新闻
$newsModel = new News();
}
DB::disconnect('custom_mysql');
}
}
... ...
... ... @@ -99,5 +99,8 @@ Route::prefix('ticket_upload')->group(function () {
Route::any('/', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'lists'])->name('ticket_upload.lists');
Route::any('/info', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'info'])->name('ticket_upload.info');
Route::any('/save', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'save'])->name('ticket_upload.save');
Route::any('/getProductCate', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'getProductCate'])->name('ticket_upload.getProductCate');
Route::any('/getBlogCate', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'getBlogCate'])->name('ticket_upload.getBlogCate');
Route::any('/getNewsCate', [\App\Http\Controllers\Api\WorkOrder\TicketUploadDataController::class, 'getNewsCate'])->name('ticket_upload.getNewsCate');
});
... ...