|
@@ -598,5 +598,39 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改违禁词
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function upBlackWord(array $data) :array
|
|
|
+ {
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ $checkInfo = BlackWord::where(['name'=>$data['name']])->first();
|
|
|
+ if($checkInfo){
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error("该违禁词已经存在", 0);
|
|
|
+ }
|
|
|
+ $blackWordInfo = BlackWord::where(['id'=>$data['id']])->first();
|
|
|
+ if($blackWordInfo){
|
|
|
+ //先删除redis
|
|
|
+ $blackWordInfo = $blackWordInfo->toArray();
|
|
|
+ $redisKey = 'black_word';
|
|
|
+ $this->redis->sRem($redisKey, $blackWordInfo['name']);
|
|
|
+ $this->redis->sAdd($redisKey, $data['name']);
|
|
|
+ BlackWord::where(['id'=>$data['id']])->update(['name'=>$data['name']]);
|
|
|
+ Db::commit();
|
|
|
+ return Result::success([]);
|
|
|
+ }else{
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error("系统错误", 0);
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollBack();
|
|
|
+ return Result::error("修改失败".$e->getMessage(), 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|