diff --git a/game-service/src/main/java/awesome/group/game/service/cache/JedisManager.java b/game-service/src/main/java/awesome/group/game/service/cache/JedisManager.java index d3c3243..eeb0c81 100644 --- a/game-service/src/main/java/awesome/group/game/service/cache/JedisManager.java +++ b/game-service/src/main/java/awesome/group/game/service/cache/JedisManager.java @@ -109,6 +109,17 @@ public class JedisManager { } } + public void set(String key, String value) { + Assert.notNull(key, "key is null"); + Assert.notNull(value, "value is null"); + + try (Jedis jedis = getJedis()) { + jedis.set(key, value); + } catch (Exception e) { + throw e; + } + } + public void set(String key, String value, int expireSeconds) { Assert.notNull(key, "key is null"); Assert.notNull(value, "value is null"); diff --git a/game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java b/game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java index f27af00..3fae632 100644 --- a/game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java +++ b/game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java @@ -5,6 +5,8 @@ import awesome.group.game.dao.mapper.*; import awesome.group.game.service.bo.AddMockScheduleReq; import awesome.group.game.service.bo.matrix.AppNormalConfig; import awesome.group.game.service.bo.matrix.WhiteUserBo; +import awesome.group.game.service.cache.CacheKey; +import awesome.group.game.service.cache.JedisManager; import awesome.group.game.service.common.log.L; import awesome.group.game.service.util.Constants; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -57,6 +59,9 @@ public class SuperAdminService { @Autowired private SuperAdminService superAdminService; + @Autowired + private JedisManager jedisManager; + public List evilAppList() { List app = evilAppMapper.selectList(null); Collections.reverse(app); @@ -123,6 +128,22 @@ public class SuperAdminService { } } + public void disableByChannel(String channel) { + List list = appMapper.selectByChannel(channel); + for (MatrixApp app : list) { + jedisManager.set("disable_" + app.getCode(), "1"); + } + String cacheKey = CacheKey.disableChannel(); + jedisManager.sadd(cacheKey, channel); + } + + public void enableByChannel(String channel) { + List list = appMapper.selectByChannel(channel); + for (MatrixApp app : list) { + jedisManager.del("disable_" + app.getCode()); + } + } + public void changeInnerUser(Integer userId, int status) { innerUserMapper.updateStatus(userId, status); } diff --git a/game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java b/game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java index 1bfd84a..247d72c 100644 --- a/game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java +++ b/game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java @@ -92,4 +92,11 @@ public class SuperAdminController { superAdminService.addMockSchedule(bo, RequestContext.getAdminID()); return new R<>(R.CODE_SUCCESS, "ok", null); } + + @GetMapping("/disableByChannel") + @RestApi + public R disableByChannel(@RequestParam String channel) { + superAdminService.disableByChannel(channel); + return new R<>(R.CODE_SUCCESS, "ok", null); + } }