|
@@ -1,6 +1,7 @@
|
|
<?php
|
|
<?php
|
|
namespace App\JsonRpc;
|
|
namespace App\JsonRpc;
|
|
|
|
|
|
|
|
+use App\Model\BlackWord;
|
|
use App\Model\Department;
|
|
use App\Model\Department;
|
|
use App\Model\District;
|
|
use App\Model\District;
|
|
use App\Model\LetterOfComplaint;
|
|
use App\Model\LetterOfComplaint;
|
|
@@ -8,13 +9,17 @@ use App\Model\LetterType;
|
|
use App\Model\LevelUser;
|
|
use App\Model\LevelUser;
|
|
use App\Model\UserLevel;
|
|
use App\Model\UserLevel;
|
|
use App\Tools\Result;
|
|
use App\Tools\Result;
|
|
|
|
+use Hyperf\DbConnection\Db;
|
|
|
|
+use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use Hyperf\RpcServer\Annotation\RpcService;
|
|
use App\Service\MinioService;
|
|
use App\Service\MinioService;
|
|
|
|
+use Hyperf\Redis\Redis;
|
|
|
|
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
#[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
class PublicRpcService implements PublicRpcServiceInterface
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ #[Inject]
|
|
|
|
+ protected Redis $redis;
|
|
/**
|
|
/**
|
|
* @param array $data
|
|
* @param array $data
|
|
* @return array
|
|
* @return array
|
|
@@ -522,5 +527,76 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 黑名单管理
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function getBlackWordList(array $data) :array
|
|
|
|
+ {
|
|
|
|
+ $result = BlackWord::when($data, function ($query) use ($data) {
|
|
|
|
+ if (isset($data['name']) && $data['name']){
|
|
|
|
+ $query->where('black_word.name', 'like', '%'.$data['name'].'%');
|
|
|
|
+ }
|
|
|
|
+ })->orderBy('black_word.created_at','desc')
|
|
|
|
+ ->paginate(intval($data['pageSize']),
|
|
|
|
+ [
|
|
|
|
+ 'black_word.*',
|
|
|
|
+ ],
|
|
|
|
+ 'page', intval($data['page']));
|
|
|
|
+ $count = $result->total();
|
|
|
|
+ $returnData = [
|
|
|
|
+ 'rows'=>$result->items(),
|
|
|
|
+ 'count'=>$count
|
|
|
|
+ ];
|
|
|
|
+ return Result::success($returnData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加黑名单
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function addBlackWord(array $data) :array
|
|
|
|
+ {
|
|
|
|
+ Db::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ $info = BlackWord::where(['name'=>$data['name']])->first();
|
|
|
|
+ if($info){
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error("该黑名单已存在", 0);
|
|
|
|
+ }
|
|
|
|
+ $data['type'] = 10;
|
|
|
|
+ $result = BlackWord::insertGetId($data);
|
|
|
|
+ $redisKey = 'black_word';
|
|
|
|
+ $this->redis->sAdd($redisKey, $data['name']);
|
|
|
|
+ Db::commit();
|
|
|
|
+ return Result::success(["id" => $result]);
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error("创建失败".$e->getMessage(), 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 删除黑名单
|
|
|
|
+ * @param array $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
|
|
+ public function delBlackWord(array $data) :array
|
|
|
|
+ {
|
|
|
|
+ Db::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ BlackWord::where(['name'=>$data['name']])->delete();
|
|
|
|
+ $redisKey = 'black_word';
|
|
|
|
+ $this->redis->sRem($redisKey, $data['name']);
|
|
|
|
+ Db::commit();
|
|
|
|
+ return Result::success([]);
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
+ Db::rollBack();
|
|
|
|
+ return Result::error("删除失败".$e->getMessage(), 0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|