Browse Source

广告列表返回user

master
nili 6 months ago
parent
commit
ae4e56e197
  1. 19
      game-service/src/main/java/awesome/group/game/service/AdminService.java
  2. 23
      game-service/src/main/java/awesome/group/game/service/bo/MatrixAdvRecordBo.java
  3. 8
      game-service/src/main/java/awesome/group/game/service/bo/PageResult.java
  4. 2
      game-service/src/main/java/awesome/group/game/service/citrus/UserService.java

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

@ -67,6 +67,9 @@ public class AdminService {
@Autowired @Autowired
private AdminDeviceService deviceService; private AdminDeviceService deviceService;
@Autowired
private MatrixUserMapper userMapper;
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;//普通账号
@ -141,14 +144,24 @@ public class AdminService {
List<MatrixAdmin> adminList = adminMapper.selectList(null); List<MatrixAdmin> adminList = adminMapper.selectList(null);
Map<Integer, String> adminMap = adminList.stream().collect(Collectors.toMap(MatrixAdmin::getId, MatrixAdmin::getName)); Map<Integer, String> adminMap = adminList.stream().collect(Collectors.toMap(MatrixAdmin::getId, MatrixAdmin::getName));
res.total = iPage.getTotal(); res.total = iPage.getTotal();
res.data = iPage.getRecords().stream().map(x -> { List<MatrixAdvRecord> records = iPage.getRecords();
List<Integer> uids = records.stream().map(MatrixAdvRecord::getUserId).toList();
Map<Integer, MatrixUser> uMap = new HashMap<>();
if (!CollectionUtils.isEmpty(uids)) {
List<MatrixUser> uList = userMapper.selectBatchIds(uids);
uMap = uList.stream().collect(Collectors.toMap(MatrixUser::getId, x -> x));
}
for(MatrixAdvRecord x: records) {
MatrixAdvRecordBo bo = new MatrixAdvRecordBo(x, appMap.get(x.getAppId())); MatrixAdvRecordBo bo = new MatrixAdvRecordBo(x, appMap.get(x.getAppId()));
BeanUtils.copyProperties(x, bo); BeanUtils.copyProperties(x, bo);
if (x.getAdminId() != null) { if (x.getAdminId() != null) {
bo.adminName = adminMap.get(x.getAdminId()); bo.adminName = adminMap.get(x.getAdminId());
} }
return bo; if (x.getUserId() != null) {
}).toList(); bo.setUser(uMap.get(x.getUserId()));
}
res.addData(bo);
}
return res; return res;
} }

23
game-service/src/main/java/awesome/group/game/service/bo/MatrixAdvRecordBo.java

@ -2,6 +2,9 @@ package awesome.group.game.service.bo;
import awesome.group.game.dao.bean.MatrixAdvRecord; import awesome.group.game.dao.bean.MatrixAdvRecord;
import awesome.group.game.dao.bean.MatrixApp; import awesome.group.game.dao.bean.MatrixApp;
import awesome.group.game.dao.bean.MatrixUser;
import awesome.group.game.service.bo.citrus.UserBo;
import org.springframework.util.StringUtils;
public class MatrixAdvRecordBo extends MatrixAdvRecordEditBo { public class MatrixAdvRecordBo extends MatrixAdvRecordEditBo {
public String appName; public String appName;
@ -9,6 +12,8 @@ public class MatrixAdvRecordBo extends MatrixAdvRecordEditBo {
public long createdAt; public long createdAt;
public Integer id; public Integer id;
public UserBo user;
public String adminName; public String adminName;
public MatrixAdvRecordBo(MatrixAdvRecord r, MatrixApp app) { public MatrixAdvRecordBo(MatrixAdvRecord r, MatrixApp app) {
@ -25,4 +30,22 @@ public class MatrixAdvRecordBo extends MatrixAdvRecordEditBo {
this.createdAt = r.getCreatedAt().getTime(); this.createdAt = r.getCreatedAt().getTime();
this.id = r.getId(); this.id = r.getId();
} }
public void setUser(MatrixUser u) {
UserBo bo = new UserBo(u);
bo.mobile = replaceWithX(bo.mobile);
bo.aliPayAccount = replaceWithX(bo.aliPayAccount);
bo.wxOpenId = replaceWithX(bo.wxOpenId);
this.user = bo;
}
public static String replaceWithX(String str) {
if (!StringUtils.hasText(str)) {
return str;
}
int mid = str.length() / 2;
StringBuilder sb = new StringBuilder(str);
sb.replace(mid, sb.length(), "x".repeat(mid));
return sb.toString();
}
} }

8
game-service/src/main/java/awesome/group/game/service/bo/PageResult.java

@ -1,5 +1,6 @@
package awesome.group.game.service.bo; package awesome.group.game.service.bo;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PageResult<T> { public class PageResult<T> {
@ -15,4 +16,11 @@ public class PageResult<T> {
this.data = data; this.data = data;
this.total = total; this.total = total;
} }
public void addData(T t) {
if (data == null) {
data = new ArrayList<>();
}
data.add(t);
}
} }

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

@ -122,7 +122,7 @@ public class UserService {
return res; return res;
} }
public void bindAliPay(Integer uid, String name, String aliPayAccount) { public void bindAliPay(Integer uid, String aliPayAccount, String name) {
Assert.isTrue(StringUtils.hasText(aliPayAccount), "支付宝账号不能为空"); Assert.isTrue(StringUtils.hasText(aliPayAccount), "支付宝账号不能为空");
Assert.isTrue(StringUtils.hasText(name), "支付宝账号姓名不能为空"); Assert.isTrue(StringUtils.hasText(name), "支付宝账号姓名不能为空");
MatrixUser u = userMapper.selectById(uid); MatrixUser u = userMapper.selectById(uid);

Loading…
Cancel
Save