|
@@ -1,6 +1,8 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
@@ -54,7 +56,9 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
|
|
|
*/
|
|
|
@Override
|
|
|
public GameEventProjectVo queryById(Long projectId) {
|
|
|
- return baseMapper.selectVoById(projectId);
|
|
|
+ GameEventProjectVo vo = baseMapper.selectVoById(projectId);
|
|
|
+ vo.setRefereeIds(JSONUtil.toList(vo.getRefereeId(), String.class));
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -76,17 +80,26 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
|
|
|
}
|
|
|
LambdaQueryWrapper<GameEventProject> lqw = buildQueryWrapper(bo);
|
|
|
Page<GameEventProjectVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
- result.getRecords().stream()
|
|
|
- .map(vo -> {
|
|
|
- Optional.ofNullable(vo.getEventId())
|
|
|
- .filter(ObjectUtil::isNotEmpty)
|
|
|
- .ifPresent(projectValue -> {
|
|
|
- GameEvent gameEvent = gameEventMapper.selectById(vo.getEventId());
|
|
|
+
|
|
|
+ // 使用 forEach 直接修改原对象
|
|
|
+ result.getRecords().forEach(vo -> {
|
|
|
+ Optional.ofNullable(vo.getEventId())
|
|
|
+ .filter(ObjectUtil::isNotEmpty)
|
|
|
+ .ifPresent(eventId -> {
|
|
|
+ GameEvent gameEvent = gameEventMapper.selectById(eventId);
|
|
|
+ if (gameEvent != null) {
|
|
|
vo.setEventName(gameEvent.getEventName());
|
|
|
- });
|
|
|
- return vo;
|
|
|
- })
|
|
|
- .collect(Collectors.toList()); // 收集结果
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Optional.ofNullable(vo.getRefereeId())
|
|
|
+ .filter(ObjectUtil::isNotEmpty)
|
|
|
+ .ifPresent(refereeIdStr -> {
|
|
|
+ List<String> refereeList = JSONUtil.toList(refereeIdStr.toString(), String.class);
|
|
|
+ vo.setRefereeIds(refereeList);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
@@ -149,6 +162,9 @@ public class GameEventProjectServiceImpl implements IGameEventProjectService {
|
|
|
}
|
|
|
GameEventProject add = MapstructUtils.convert(bo, GameEventProject.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
+ if (StrUtil.isNotEmpty(bo.getRefereeId())) {
|
|
|
+ add.setRefereeId(JSONUtil.toJsonStr(bo.getRefereeIds()));
|
|
|
+ }
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setProjectId(add.getProjectId());
|