|
@@ -4,14 +4,18 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.zanxiang.game.module.base.pojo.dto.GameDTO;
|
|
|
import com.zanxiang.game.module.base.rpc.IGameRpc;
|
|
|
import com.zanxiang.game.module.manage.service.IGameService;
|
|
|
+import com.zanxiang.game.module.manage.service.IGameSupperService;
|
|
|
import com.zanxiang.game.module.mybatis.entity.Game;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameSupper;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -22,15 +26,32 @@ import java.util.stream.Collectors;
|
|
|
@DubboService
|
|
|
public class GameRpcImpl implements IGameRpc {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGameSupperService gameSupperService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IGameService gameService;
|
|
|
|
|
|
@Override
|
|
|
- public ResultVO<List<GameDTO>> getAllGameList() {
|
|
|
+ public ResultVO<GameDTO> getAllGameList() {
|
|
|
+ //超父游戏列表
|
|
|
+ List<GameSupper> gameSupperList = gameSupperService.list();
|
|
|
+ //游戏列表
|
|
|
List<Game> gameList = gameService.list();
|
|
|
- if (CollectionUtils.isEmpty(gameList)) {
|
|
|
- return ResultVO.ok(Collections.emptyList());
|
|
|
+ //不存在数据
|
|
|
+ if (CollectionUtils.isEmpty(gameSupperList) || CollectionUtils.isEmpty(gameList)) {
|
|
|
+ return ResultVO.ok(GameDTO.builder().gameSupperList(Collections.emptyList()).build());
|
|
|
}
|
|
|
- return ResultVO.ok(gameList.stream().map(game -> BeanUtil.copy(game, GameDTO.class)).collect(Collectors.toList()));
|
|
|
+ List<GameDTO.GameSupperBean> gameSupperBeanList = new ArrayList<>();
|
|
|
+ gameSupperList.forEach(gameSupper -> {
|
|
|
+ List<GameDTO.GameBean> gameBeanList = gameList.stream()
|
|
|
+ .filter(game -> Objects.equals(game.getSuperGameId(), gameSupper.getId()))
|
|
|
+ .map(game -> BeanUtil.copy(game, GameDTO.GameBean.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ GameDTO.GameSupperBean gameSupperBean = BeanUtil.copy(gameSupper, GameDTO.GameSupperBean.class);
|
|
|
+ gameSupperBean.setGameList(gameBeanList);
|
|
|
+ gameSupperBeanList.add(gameSupperBean);
|
|
|
+ });
|
|
|
+ return ResultVO.ok(GameDTO.builder().gameSupperList(gameSupperBeanList).build());
|
|
|
}
|
|
|
}
|