Browse Source

禁用功能细粒度

master
nili 2 months ago
parent
commit
8ff3004d60
  1. 1
      game-dao/src/main/java/awesome/group/game/dao/bean/MatrixAdmin.java
  2. 1
      game-dao/src/main/java/awesome/group/game/dao/bean/MatrixApp.java
  3. 4
      game-service/src/main/java/awesome/group/game/service/cache/CacheKey.java
  4. 2
      game-service/src/main/java/awesome/group/game/service/citrus/CitrusAppService.java
  5. 16
      game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java
  6. 19
      game-web/src/main/java/awesome/group/game/web/filter/AdminLoginFilter.java
  7. 7
      game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java

1
game-dao/src/main/java/awesome/group/game/dao/bean/MatrixAdmin.java

@ -18,4 +18,5 @@ public class MatrixAdmin {
private String userIds;//绑定代理账号的用户id
private Integer incomeRate;
private Integer hide;
private Integer disable;
}

1
game-dao/src/main/java/awesome/group/game/dao/bean/MatrixApp.java

@ -19,6 +19,7 @@ public class MatrixApp {
private Integer hide;
private String secret;
private Integer version;
private Integer disable;
private String umeng;//友盟的配置数据
private String aliPay;//支付宝的配置数据

4
game-service/src/main/java/awesome/group/game/service/cache/CacheKey.java

@ -15,8 +15,4 @@ public class CacheKey {
public static final String activateTryTimes(Integer uid) {
return String.format("vip_activate_times_%s", uid);
}
public static final String disableChannel() {
return "disable_channel";
}
}

2
game-service/src/main/java/awesome/group/game/service/citrus/CitrusAppService.java

@ -26,7 +26,7 @@ public class CitrusAppService {
public AppBasicInfo getAppDetail(String appCode) {
MatrixApp app = appMapper.queryByCode(appCode);
AppBasicInfo res = AppBasicInfo.getBasic(app);
res.disable = jedisManager.exist("disable_" + appCode);
res.disable = app.getDisable() > 0;
return res;
}

16
game-service/src/main/java/awesome/group/game/service/matrix/SuperAdminService.java

@ -128,22 +128,6 @@ public class SuperAdminService {
}
}
public void disableByChannel(String channel) {
List<MatrixApp> 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<MatrixApp> list = appMapper.selectByChannel(channel);
for (MatrixApp app : list) {
jedisManager.del("disable_" + app.getCode());
}
}
public void changeInnerUser(Integer userId, int status) {
innerUserMapper.updateStatus(userId, status);
}

19
game-web/src/main/java/awesome/group/game/web/filter/AdminLoginFilter.java

@ -1,11 +1,12 @@
package awesome.group.game.web.filter;
import awesome.group.game.service.cache.CacheKey;
import awesome.group.game.dao.bean.MatrixAdmin;
import awesome.group.game.dao.mapper.MatrixAdminMapper;
import awesome.group.game.service.cache.JedisManager;
import awesome.group.game.web.RequestContext;
import awesome.group.game.service.common.log.L;
import awesome.group.game.service.common.response.R;
import awesome.group.game.service.util.JwtUtils;
import awesome.group.game.web.RequestContext;
import com.auth0.jwt.exceptions.TokenExpiredException;
import com.google.gson.Gson;
import jakarta.servlet.*;
@ -28,6 +29,9 @@ public class AdminLoginFilter implements Filter {
@Autowired
private JedisManager jedisManager;
@Autowired
private MatrixAdminMapper adminMapper;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
@ -70,11 +74,12 @@ public class AdminLoginFilter implements Filter {
}
if (pass) {
RequestContext.initAdmin(httpRequest, (HttpServletResponse) response, adminId);
String channel = RequestContext.getRequestChannel();
String cacheKey = CacheKey.disableChannel();
if (adminId != null && adminId != 1 && jedisManager.sIsMember(cacheKey, channel)) {
channelDisable(response);
return;
if (adminId != null) {
MatrixAdmin admin = adminMapper.selectById(adminId);
if (admin != null && admin.getDisable() > 0) {
channelDisable(response);
return;
}
}
chain.doFilter(request, response);
} else {

7
game-web/src/main/java/awesome/group/game/web/rest/matrix/SuperAdminController.java

@ -92,11 +92,4 @@ public class SuperAdminController {
superAdminService.addMockSchedule(bo, RequestContext.getAdminID());
return new R<>(R.CODE_SUCCESS, "ok", null);
}
@GetMapping("/disableByChannel")
@RestApi
public R<Void> disableByChannel(@RequestParam String channel) {
superAdminService.disableByChannel(channel);
return new R<>(R.CODE_SUCCESS, "ok", null);
}
}

Loading…
Cancel
Save