nili 9 months ago
parent
commit
f851634bbe
  1. 22
      game-service/src/main/java/awesome/group/game/service/AdminService.java

22
game-service/src/main/java/awesome/group/game/service/AdminService.java

@ -50,6 +50,7 @@ public class AdminService {
public static final int SUPER_ADMIN = 1;//超级管理员 public static final int SUPER_ADMIN = 1;//超级管理员
public static final int NORMAL_ADMIN = 2;//普通管理员 public static final int NORMAL_ADMIN = 2;//普通管理员
public static final int OTHER = 3;//普通账号 public static final int OTHER = 3;//普通账号
public static final int DEVICE_OWNER = 4; //设备主
public MatrixAdmin login(String name, String pwd, String channel) { public MatrixAdmin login(String name, String pwd, String channel) {
MatrixAdmin admin = adminMapper.query(name); MatrixAdmin admin = adminMapper.query(name);
@ -70,9 +71,8 @@ public class AdminService {
return adminMapper.selectById(id); return adminMapper.selectById(id);
} }
public PageResult<MatrixAdvRecordBo> advList(AdvRecordQuery param, Integer ownerId) { public PageResult<MatrixAdvRecordBo> advList(AdvRecordQuery param, Integer adminId) {
MatrixAdmin admin = adminMapper.selectById(ownerId); List<MatrixApp> appList = appList(adminId);
List<MatrixApp> appList = appMapper.selectList(null);
LambdaQueryWrapper<MatrixAdvRecord> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<MatrixAdvRecord> wrapper = Wrappers.lambdaQuery();
Optional<MatrixApp> app = appList.stream().filter(x -> x.getCode().equals(param.code)).findFirst(); Optional<MatrixApp> app = appList.stream().filter(x -> x.getCode().equals(param.code)).findFirst();
@ -80,7 +80,6 @@ public class AdminService {
return null; return null;
} }
wrapper.eq(MatrixAdvRecord::getAppId, app.get().getId()); wrapper.eq(MatrixAdvRecord::getAppId, app.get().getId());
if (param.advType != null) { if (param.advType != null) {
wrapper.eq(MatrixAdvRecord::getAdvType, param.advType); wrapper.eq(MatrixAdvRecord::getAdvType, param.advType);
} }
@ -101,13 +100,6 @@ public class AdminService {
} }
wrapper.orderByDesc(MatrixAdvRecord::getId); wrapper.orderByDesc(MatrixAdvRecord::getId);
if (admin.getRole() != SUPER_ADMIN) {
List<Integer> appIds = Arrays.stream(admin.getAppIds().split(",")).map(Integer::parseInt).toList();
if (CollectionUtils.isEmpty(appIds)) {
return new PageResult<>(new ArrayList<>(), 0);
}
wrapper.in(MatrixAdvRecord::getAppId, appIds);
}
int page = param.current; int page = param.current;
int pageSize = param.pageSize; int pageSize = param.pageSize;
IPage<MatrixAdvRecord> iPage = advRecordMapper.selectPage(new Page<>(page, pageSize), wrapper); IPage<MatrixAdvRecord> iPage = advRecordMapper.selectPage(new Page<>(page, pageSize), wrapper);
@ -123,12 +115,12 @@ public class AdminService {
} }
public List<MatrixApp> appList(Integer adminId) { public List<MatrixApp> appList(Integer adminId) {
MatrixAdmin admin = adminMapper.selectById(adminId); List<Integer> appIds = getAdminAppIds(adminId);
if (adminId == SUPER_ADMIN) { if (CollectionUtils.isEmpty(appIds)) {
return appMapper.selectList(null); return new ArrayList<>();
} }
LambdaQueryWrapper<MatrixApp> query = Wrappers.lambdaQuery(); LambdaQueryWrapper<MatrixApp> query = Wrappers.lambdaQuery();
query.in(MatrixApp::getId, Arrays.stream(admin.getAppIds().split(",")).map(Integer::parseInt).toList()); query.in(MatrixApp::getId, appIds);
return appMapper.selectList(query); return appMapper.selectList(query);
} }

Loading…
Cancel
Save