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

Loading…
Cancel
Save