正在显示
3 个修改的文件
包含
47 行增加
和
2 行删除
| @@ -92,10 +92,11 @@ class KeywordController extends BaseController | @@ -92,10 +92,11 @@ class KeywordController extends BaseController | ||
| 92 | */ | 92 | */ |
| 93 | public function batchAdd(KeywordLogic $logic){ | 93 | public function batchAdd(KeywordLogic $logic){ |
| 94 | $this->request->validate([ | 94 | $this->request->validate([ |
| 95 | - 'title'=>['required','array'] | 95 | + 'title'=>['required','array', 'max:1000'] |
| 96 | ],[ | 96 | ],[ |
| 97 | 'title.required' => 'title不能为空', | 97 | 'title.required' => 'title不能为空', |
| 98 | - 'title.array' => 'title为数组' | 98 | + 'title.array' => 'title为数组', |
| 99 | + 'title.max' => '批量操作不能超过1000条数据' | ||
| 99 | ]); | 100 | ]); |
| 100 | $logic->batchAdd(); | 101 | $logic->batchAdd(); |
| 101 | $this->response('success'); | 102 | $this->response('success'); |
| @@ -119,4 +120,22 @@ class KeywordController extends BaseController | @@ -119,4 +120,22 @@ class KeywordController extends BaseController | ||
| 119 | $this->response('success'); | 120 | $this->response('success'); |
| 120 | } | 121 | } |
| 121 | 122 | ||
| 123 | + /** | ||
| 124 | + * 批量删除 | ||
| 125 | + * @param KeywordLogic $logic | ||
| 126 | + * @author zbj | ||
| 127 | + * @date 2023/11/22 | ||
| 128 | + */ | ||
| 129 | + public function batchDel(KeywordLogic $logic){ | ||
| 130 | + $this->request->validate([ | ||
| 131 | + 'title'=>['required','array', 'max:1000'] | ||
| 132 | + ],[ | ||
| 133 | + 'title.required' => 'title不能为空', | ||
| 134 | + 'title.array' => 'title为数组', | ||
| 135 | + 'title.max' => '批量操作不能超过1000条数据' | ||
| 136 | + ]); | ||
| 137 | + $logic->batchDel(); | ||
| 138 | + $this->response('success'); | ||
| 139 | + } | ||
| 140 | + | ||
| 122 | } | 141 | } |
| @@ -209,4 +209,29 @@ class KeywordLogic extends BaseLogic | @@ -209,4 +209,29 @@ class KeywordLogic extends BaseLogic | ||
| 209 | Common::del_user_cache('product_keyword',$project_id); | 209 | Common::del_user_cache('product_keyword',$project_id); |
| 210 | return ','.implode(',',$return).','; | 210 | return ','.implode(',',$return).','; |
| 211 | } | 211 | } |
| 212 | + | ||
| 213 | + /** | ||
| 214 | + * 批量删除 | ||
| 215 | + * @return array | ||
| 216 | + * @throws BsideGlobalException | ||
| 217 | + * @throws \App\Exceptions\AsideGlobalException | ||
| 218 | + * @author zbj | ||
| 219 | + * @date 2023/11/22 | ||
| 220 | + */ | ||
| 221 | + public function batchDel(){ | ||
| 222 | + try { | ||
| 223 | + foreach ($this->param['title'] as $v){ | ||
| 224 | + $info = $this->model->read(['title'=>$v]); | ||
| 225 | + if($info){ | ||
| 226 | + $this->delRoute($info['id']); | ||
| 227 | + $this->model->del(['id'=>$info['id']]); | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + //清除缓存 | ||
| 231 | + Common::del_user_cache('product_keyword',$this->user['project_id']); | ||
| 232 | + }catch (\Exception $e){ | ||
| 233 | + $this->fail('error'); | ||
| 234 | + } | ||
| 235 | + return $this->success(); | ||
| 236 | + } | ||
| 212 | } | 237 | } |
| @@ -219,6 +219,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -219,6 +219,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 219 | Route::get('keyword/info', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'info'])->name('product_keyword_info'); | 219 | Route::get('keyword/info', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'info'])->name('product_keyword_info'); |
| 220 | Route::post('keyword/save', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'save'])->name('product_keyword_save'); | 220 | Route::post('keyword/save', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'save'])->name('product_keyword_save'); |
| 221 | Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); | 221 | Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); |
| 222 | + Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel'); | ||
| 222 | Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); | 223 | Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); |
| 223 | 224 | ||
| 224 | //产品参数 | 225 | //产品参数 |
-
请 注册 或 登录 后发表评论