|
@@ -2,6 +2,7 @@ package org.dromara.system.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+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;
|
|
@@ -139,7 +140,14 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
*/
|
|
|
@Override
|
|
|
public GameAthleteVo queryById(Long athleteId) {
|
|
|
- return baseMapper.selectVoById(athleteId);
|
|
|
+ GameAthleteVo vo = baseMapper.selectVoById(athleteId);
|
|
|
+ Optional.ofNullable(vo.getProjectValue())
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .ifPresent(projectValue -> {
|
|
|
+ List<String> projects = JSONUtil.toList(projectValue, String.class);
|
|
|
+ vo.setProjectList(projects);
|
|
|
+ });
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -166,15 +174,18 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
Optional.ofNullable(vo.getProjectValue())
|
|
|
.filter(StringUtils::isNotBlank)
|
|
|
.ifPresent(projectValue -> {
|
|
|
- String[] projectIds = projectValue.split(",");
|
|
|
- List<GameEventProjectVo> projects =
|
|
|
- gameEventProjectService.listProjectsByEventIdAndProjectIndex(
|
|
|
- vo.getEventId(),
|
|
|
- projectIds);
|
|
|
- vo.setProjectValue(projects.stream()
|
|
|
- .map(GameEventProjectVo::getProjectName)
|
|
|
- .filter(StringUtils::isNotBlank) // 过滤项目名为空的情况
|
|
|
- .collect(Collectors.joining(",")));
|
|
|
+// String[] projectIds = projectValue.split(",");
|
|
|
+ List<String> projectIds = JSONUtil.toList(projectValue, String.class);
|
|
|
+ if(CollUtil.isNotEmpty(projectIds)){
|
|
|
+ List<GameEventProjectVo> projects =
|
|
|
+ gameEventProjectService.listProjectsByEventIdAndProjectIndex(
|
|
|
+ vo.getEventId(), projectIds);
|
|
|
+ vo.setProjectList(projectIds);
|
|
|
+ }
|
|
|
+// vo.setProjectValue(projects.stream()
|
|
|
+// .map(GameEventProjectVo::getProjectName)
|
|
|
+// .filter(StringUtils::isNotBlank) // 过滤项目名为空的情况
|
|
|
+// .collect(Collectors.joining(",")));
|
|
|
});
|
|
|
Optional.ofNullable(vo.getEventId())
|
|
|
.filter(ObjectUtil::isNotEmpty)
|
|
@@ -205,7 +216,16 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
}
|
|
|
}
|
|
|
LambdaQueryWrapper<GameAthlete> lqw = buildQueryWrapper(bo);
|
|
|
- return baseMapper.selectVoList(lqw);
|
|
|
+ List<GameAthleteVo> athleteList =baseMapper.selectVoList(lqw);
|
|
|
+ athleteList.forEach(vo -> {
|
|
|
+ Optional.ofNullable(vo.getProjectValue())
|
|
|
+ .filter(StringUtils::isNotBlank)
|
|
|
+ .ifPresent(projectValue -> {
|
|
|
+ List<String> projects = JSONUtil.toList(projectValue, String.class);
|
|
|
+ vo.setProjectList(projects);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return athleteList;
|
|
|
}
|
|
|
|
|
|
private LambdaQueryWrapper<GameAthlete> buildQueryWrapper(GameAthleteBo bo) {
|
|
@@ -214,7 +234,7 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
lqw.orderByAsc(GameAthlete::getAthleteId);
|
|
|
lqw.eq(bo.getEventId() != null, GameAthlete::getEventId, bo.getEventId());
|
|
|
|
|
|
- // 通过名称模糊查询
|
|
|
+ // 通过赛事名称模糊查询
|
|
|
if (StringUtils.isNotBlank(bo.getEventName())) {
|
|
|
GameEventBo gameEventBo = new GameEventBo();
|
|
|
gameEventBo.setEventName(bo.getEventName());
|
|
@@ -231,7 +251,7 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
|
|
|
lqw.eq(bo.getTeamId() != null, GameAthlete::getTeamId, bo.getTeamId());
|
|
|
|
|
|
- // 通过名称模糊查询
|
|
|
+ // 通过队伍名称模糊查询
|
|
|
if (StringUtils.isNotBlank(bo.getTeamName())) {
|
|
|
GameTeamBo gameTeamBo = new GameTeamBo();
|
|
|
gameTeamBo.setTeamName(bo.getTeamName());
|
|
@@ -273,6 +293,9 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
}
|
|
|
GameAthlete add = MapstructUtils.convert(bo, GameAthlete.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
+ if(CollectionUtils.isNotEmpty(bo.getProjectList())){
|
|
|
+ add.setProjectValue(JSONUtil.toJsonStr(bo.getProjectList()));
|
|
|
+ }
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setAthleteId(add.getAthleteId());
|
|
@@ -297,6 +320,9 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
}
|
|
|
}
|
|
|
GameAthlete update = MapstructUtils.convert(bo, GameAthlete.class);
|
|
|
+ if(CollectionUtils.isNotEmpty(bo.getProjectList())){
|
|
|
+ update.setProjectValue(JSONUtil.toJsonStr(bo.getProjectList()));
|
|
|
+ }
|
|
|
validEntityBeforeSave(update);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
@@ -379,9 +405,15 @@ public class GameAthleteServiceImpl implements IGameAthleteService {
|
|
|
*/
|
|
|
@Override
|
|
|
public List<GameAthleteVo> listByIds(Collection<Long> athleteIds) {
|
|
|
- return baseMapper.selectVoList(
|
|
|
+ List<GameAthleteVo> list = baseMapper.selectVoList(
|
|
|
Wrappers.lambdaQuery(GameAthlete.class)
|
|
|
.in(GameAthlete::getAthleteId, athleteIds)
|
|
|
);
|
|
|
+ list.forEach(vo -> {
|
|
|
+ if (vo.getProjectValue() != null) {
|
|
|
+ vo.setProjectList(JSONUtil.toList(vo.getProjectValue(), String.class));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return list;
|
|
|
}
|
|
|
}
|