TicketUploadDataLogic.php 2.5 KB
<?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');
    }

}