作者 李宇航

合并分支 'master-server' 到 'master'

Master server



查看合并请求 !913
... ... @@ -257,4 +257,23 @@ class KeywordController extends BaseController
$id = $keywordPageModel->addReturnId($this->param);
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
/**
* @remark :删除关联关系
* @name :delRelated
* @author :lyh
* @method :post
* @time :2024/11/28 10:30
*/
public function delRelated(KeywordLogic $logic){
$this->request->validate([
'keyword_id'=>'required',
'product_id'=>'required',
],[
'keyword_id.required' => '关键词id不能为空',
'product_id.required' => '产品id不为空',
]);
$logic->delRelated($this->param['keyword'],$this->param['product_id']);
$this->response('success');
}
}
... ...
... ... @@ -42,6 +42,7 @@ class KeywordLogic extends BaseLogic
if($info !== false){
$info['url'] = $this->user['domain'] . $info['route'];
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
$info['product_list'] = $this->getProduct($info['id']);
}
return $this->success($info);
}
... ... @@ -298,4 +299,41 @@ class KeywordLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :根据关键字获取产品
* @name :getProduct
* @author :lyh
* @method :post
* @time :2024/11/28 9:26
*/
public function getProduct($keyword_id){
$productList = [];
$keywordRelatedModel = new KeywordRelated();
$productIdArr = $keywordRelatedModel->selectField(['keyword_id'=>$keyword_id],'product_id');
if(!empty($productIdArr)){
$productModel = new Product();
$productList = $productModel->list(['id'=>['in',$productIdArr]],['id','title']);
}
return $this->success($productList);
}
/**
* @remark :对应删除关联关系
* @name :delRelated
* @author :lyh
* @method :post
* @time :2024/11/28 9:46
*/
public function delRelated($keyword_id,$product_id){
$productModel = new Product();
$productModel->where('id', $product_id)
->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',$keyword_id,' , ',')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',$keyword_id,' , ',')")]);
$productModel->where('id', $product_id)->where('keyword_id',',')->orWhere('keyword_video_id',',')
->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',' , '')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',' , '')")]);
$keywordRelatedModel = new KeywordRelated();
$keywordRelatedModel->del(['product_id'=>$product_id,'keyword_id'=>$keyword_id]);
return $this->success();
}
}
... ...
... ... @@ -43,6 +43,7 @@ class ProductLogic extends BaseLogic
$extend = $this->handleExtent();
//单独处理分类
$category_ids = $this->handleCategory();
$keyword_arr = $this->param['keyword_id'] ?? [];
//处理其他字段
$this->param = $this->handleSaveParam($this->param);
try {
... ... @@ -66,7 +67,7 @@ class ProductLogic extends BaseLogic
}
//产品分类关联
CategoryRelated::saveRelated($id, $category_ids);
KeywordRelated::saveRelated($id,$category_ids);
KeywordRelated::saveRelated($id,$keyword_arr);
//更新产品新描述
$detailLogic = new DetailLogic();
$detailLogic->saveDetail($id,$this->param['data'] ?? []);
... ...
... ... @@ -296,4 +296,5 @@ class Base extends Model
$data = $this->filterRequestData($data);
return $this->formatQuery($data)->pluck($filed)->toArray();
}
}
... ...
... ... @@ -281,6 +281,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
Route::any('keyword/delRelated', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delRelated'])->name('product_keyword_delRelated');
Route::any('keyword/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword');
Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
... ...