|
...
|
...
|
@@ -15,6 +15,7 @@ use App\Models\Blog\BlogCategory; |
|
|
|
use App\Models\News\NewsCategory;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Ticket\TicketUploadData;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Http\Request;
|
|
...
|
...
|
@@ -167,6 +168,12 @@ class TicketUploadDataController extends BaseController |
|
|
|
'type.required' => '上传类型不能为空',
|
|
|
|
'text' => '数据详情不为空'
|
|
|
|
]);
|
|
|
|
if(empty($this->param['text']['image'])){
|
|
|
|
$this->response('参数错误',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
if(empty($this->param['text']['title'])){
|
|
|
|
$this->response('参数错误,标题不能为空',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
//验证当前数据是否已提交
|
|
|
|
$this->param['text'] = json_encode($this->param['text'], true);
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
...
|
...
|
@@ -202,20 +209,38 @@ class TicketUploadDataController extends BaseController |
|
|
|
$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) {
|
|
|
|
ProjectServer::useProject($this->map['project_id']);
|
|
|
|
if ($this->map['type'] == 1) {
|
|
|
|
//todo::搜索获取分类
|
|
|
|
$productCateModel = new Category();
|
|
|
|
$data = $productCateModel->lists(['title' => ['like','%' . $this->param['search'] . '%']], 1, 20,'id',['id','title as name']);
|
|
|
|
if(!empty($this->map['search']) && isset($this->map['search'])){
|
|
|
|
$this->map['name'] = ['like' , '%' . $this->map['search'] . '%'];
|
|
|
|
unset($this->param['search']);
|
|
|
|
}
|
|
|
|
unset($this->map['type']);
|
|
|
|
$cate_list = $productCateModel->list($this->map, 'sort',['id','title','pid']);
|
|
|
|
if ($cate_list === false) {
|
|
|
|
$this->response('无分类');
|
|
|
|
}
|
|
|
|
$data = [];
|
|
|
|
foreach ($cate_list as $v) {
|
|
|
|
$v = (array)$v;
|
|
|
|
if ($v['pid'] == 0) {
|
|
|
|
$v['sub'] = _get_child($v['id'], $cate_list);
|
|
|
|
$data[] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$data = $keywordModel->lists(['title' => ['like','%' . $this->param['search'] . '%']], 1, 20,'id',['id','title as name']);
|
|
|
|
if(!isset($this->map['search']) || empty($this->map['search'])){
|
|
|
|
$data = $keywordModel->lists([], 1, 20,'id',['id','title as name']);
|
|
|
|
}else{
|
|
|
|
$data = $keywordModel->lists(['title' => ['like','%' . $this->map['search'] . '%']], 1, 20,'id',['id','title as name']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
$this->response('success', Code::SUCCESS, $data);
|
|
...
|
...
|
@@ -232,16 +257,29 @@ class TicketUploadDataController extends BaseController |
|
|
|
{
|
|
|
|
$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,'id',['id','name']);
|
|
|
|
ProjectServer::useProject($this->map['project_id']);
|
|
|
|
$newsCateModel = new NewsCategory();
|
|
|
|
if(!empty($this->map['search']) && isset($this->map['search'])){
|
|
|
|
$this->map['name'] = ['like' , '%' . $this->map['search'] . '%'];
|
|
|
|
unset($this->map['search']);
|
|
|
|
}
|
|
|
|
$cate_list = $newsCateModel->list($this->map, 'sort',['id','name as title','pid']);
|
|
|
|
if ($cate_list === false) {
|
|
|
|
$this->response('error', Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
$list = [];
|
|
|
|
foreach ($cate_list as $v) {
|
|
|
|
$v = (array)$v;
|
|
|
|
if ($v['pid'] == 0) {
|
|
|
|
$v['sub'] = _get_child($v['id'], $cate_list);
|
|
|
|
$list[] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
$this->response('success', Code::SUCCESS, $data);
|
|
|
|
$this->response('success', Code::SUCCESS, $list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -255,15 +293,142 @@ class TicketUploadDataController extends BaseController |
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'project_id' => 'required',
|
|
|
|
'search' => 'required'
|
|
|
|
], [
|
|
|
|
'project_id.required' => 'project_id不能为空',
|
|
|
|
'search.required' => '搜索参数不能为空',
|
|
|
|
]);
|
|
|
|
ProjectServer::useProject($this->param['project_id']);
|
|
|
|
ProjectServer::useProject($this->map['project_id']);
|
|
|
|
$newsCateModel = new NewsCategory();
|
|
|
|
$data = $newsCateModel->lists(['name' => ['like' , '%' . $this->param['search'] . '%']], 1, 20,'id',['id','name']);
|
|
|
|
if(!empty($this->map['search']) && isset($this->map['search'])){
|
|
|
|
$this->map['name'] = ['like' , '%' . $this->map['search'] . '%'];
|
|
|
|
unset($this->map['search']);
|
|
|
|
}
|
|
|
|
$cate_list = $newsCateModel->list($this->map, 'sort',['id','name as title','pid']);
|
|
|
|
if ($cate_list === false) {
|
|
|
|
$this->response('error', Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
$list = [];
|
|
|
|
foreach ($cate_list as $v) {
|
|
|
|
$v = (array)$v;
|
|
|
|
if ($v['pid'] == 0) {
|
|
|
|
$v['sub'] = _get_child($v['id'], $cate_list);
|
|
|
|
$list[] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->response('success', Code::SUCCESS, $list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存关键字
|
|
|
|
* @name :saveKeyword
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/10 10:50
|
|
|
|
*/
|
|
|
|
public function saveKeyword()
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'project_id' => 'required',
|
|
|
|
'title' => 'required'
|
|
|
|
], [
|
|
|
|
'project_id.required' => 'project_id不能为空',
|
|
|
|
'title.required' => '分类标题不能为空',
|
|
|
|
]);
|
|
|
|
ProjectServer::useProject($this->param['project_id']);
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$id = $keywordModel->addReturnId(['project_id' => $this->param['project_id'], 'title' => $this->param['title']]);
|
|
|
|
$route = RouteMap::setRoute($this->param['title'],RouteMap::SOURCE_PRODUCT_KEYWORD,$id,$this->param['project_id']);
|
|
|
|
$keywordModel->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
$this->response('success', Code::SUCCESS, $data);
|
|
|
|
$this->response('success', Code::SUCCESS, ['id'=>$id,'title'=>$this->param['title']]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增分类
|
|
|
|
* @name :saveCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/10 10:13
|
|
|
|
*/
|
|
|
|
public function saveCategory()
|
|
|
|
{
|
|
|
|
$this->request->validate([
|
|
|
|
'project_id' => 'required',
|
|
|
|
'type' => 'required',
|
|
|
|
'title' => 'required'
|
|
|
|
], [
|
|
|
|
'project_id.required' => 'project_id不能为空',
|
|
|
|
'type.required' => '类型不能为空',
|
|
|
|
'title.required' => '分类标题不能为空',
|
|
|
|
]);
|
|
|
|
ProjectServer::useProject($this->param['project_id']);
|
|
|
|
if($this->param['type'] == 1){//增加产品分类
|
|
|
|
$data = $this->addProductCategory($this->param['title'],$this->param['project_id'],$this->param['pid'] ?? 0);
|
|
|
|
}elseif ($this->param['type'] == 2){//增加blog分类
|
|
|
|
$data = $this->addBlogCategory($this->param['title'],$this->param['project_id'],$this->param['pid'] ?? 0);
|
|
|
|
}else{
|
|
|
|
$data = $this->addNewsCategory($this->param['title'],$this->param['project_id'],$this->param['pid'] ?? 0);
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
$this->response('success',Code::SUCCESS, $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增分类
|
|
|
|
* @name :addProductCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/10 10:43
|
|
|
|
*/
|
|
|
|
public function addProductCategory($title,$project_id,$pid){
|
|
|
|
$productCateModel = new Category();
|
|
|
|
$info = $productCateModel->read(['title'=>$title],['id','title']);
|
|
|
|
if($info !== false){
|
|
|
|
return $info;
|
|
|
|
}else{
|
|
|
|
$id = $productCateModel->addReturnId(['title'=>$title,'project_id'=>$project_id,'pid'=>$pid]);
|
|
|
|
$route = RouteMap::setRoute($title,RouteMap::SOURCE_PRODUCT_CATE,$id,$project_id);
|
|
|
|
$productCateModel->edit(['route'=>$route],['id'=>$id]);
|
|
|
|
return ['id'=>$id,'title'=>$title];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增blog分类
|
|
|
|
* @name :addBlogCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/10 10:44
|
|
|
|
*/
|
|
|
|
public function addBlogCategory($title,$project_id,$pid){
|
|
|
|
$blogCateModel = new BlogCategory();
|
|
|
|
$info = $blogCateModel->read(['name'=>$title],['id','name as title']);
|
|
|
|
if($info !== false){
|
|
|
|
return $info;
|
|
|
|
}else{
|
|
|
|
$id = $blogCateModel->addReturnId(['name'=>$title,'project_id'=>$project_id,'pid'=>$pid]);
|
|
|
|
$route = RouteMap::setRoute($title,RouteMap::SOURCE_BLOG_CATE,$id,$project_id);
|
|
|
|
$blogCateModel->edit(['alias'=>$route],['id'=>$id]);
|
|
|
|
return ['id'=>$id,'title'=>$title];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :新增news分类
|
|
|
|
* @name :addNewsCategory
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/10 10:46
|
|
|
|
*/
|
|
|
|
public function addNewsCategory($title,$project_id,$pid){
|
|
|
|
$newsCateModel = new NewsCategory();//增加新闻分类
|
|
|
|
$info = $newsCateModel->read(['name'=>$title],['id','name as title']);
|
|
|
|
if($info !== false){
|
|
|
|
return $info;
|
|
|
|
}else{
|
|
|
|
$id = $newsCateModel->addReturnId(['name'=>$title,'project_id'=>$project_id,'pid'=>$pid]);
|
|
|
|
$route = RouteMap::setRoute($title,RouteMap::SOURCE_NEWS_CATE,$id,$project_id);
|
|
|
|
$newsCateModel->edit(['alias'=>$route],['id'=>$id]);
|
|
|
|
return ['id'=>$id,'title'=>$title];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|