作者 赵彬吉

update

... ... @@ -92,10 +92,11 @@ class KeywordController extends BaseController
*/
public function batchAdd(KeywordLogic $logic){
$this->request->validate([
'title'=>['required','array']
'title'=>['required','array', 'max:1000']
],[
'title.required' => 'title不能为空',
'title.array' => 'title为数组'
'title.array' => 'title为数组',
'title.max' => '批量操作不能超过1000条数据'
]);
$logic->batchAdd();
$this->response('success');
... ... @@ -119,4 +120,22 @@ class KeywordController extends BaseController
$this->response('success');
}
/**
* 批量删除
* @param KeywordLogic $logic
* @author zbj
* @date 2023/11/22
*/
public function batchDel(KeywordLogic $logic){
$this->request->validate([
'title'=>['required','array', 'max:1000']
],[
'title.required' => 'title不能为空',
'title.array' => 'title为数组',
'title.max' => '批量操作不能超过1000条数据'
]);
$logic->batchDel();
$this->response('success');
}
}
... ...
... ... @@ -209,4 +209,29 @@ class KeywordLogic extends BaseLogic
Common::del_user_cache('product_keyword',$project_id);
return ','.implode(',',$return).',';
}
/**
* 批量删除
* @return array
* @throws BsideGlobalException
* @throws \App\Exceptions\AsideGlobalException
* @author zbj
* @date 2023/11/22
*/
public function batchDel(){
try {
foreach ($this->param['title'] as $v){
$info = $this->model->read(['title'=>$v]);
if($info){
$this->delRoute($info['id']);
$this->model->del(['id'=>$info['id']]);
}
}
//清除缓存
Common::del_user_cache('product_keyword',$this->user['project_id']);
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
}
... ...
... ... @@ -219,6 +219,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::get('keyword/info', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'info'])->name('product_keyword_info');
Route::post('keyword/save', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'save'])->name('product_keyword_save');
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');
//产品参数
... ...