OCT 1. 更新获取游戏详细信息接口

This commit is contained in:
黄昕 2023-10-30 19:59:27 +08:00
parent e24e1216f1
commit 751417a2b8
4 changed files with 58 additions and 7 deletions

View File

@ -0,0 +1,48 @@
package com.cmhi.gds.controller;
import com.cmhi.gds.common.ErrorCode;
import com.cmhi.gds.exception.ControllerNotSupportException;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* The type Error controller.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Controller
public class ErrorController extends BasicErrorController {
/**
* Instantiates a new Error controller.
*
* @param serverProperties the server properties
*/
public ErrorController(ServerProperties serverProperties) {
super(new DefaultErrorAttributes(), serverProperties.getError());
}
/**
* Error response entity.
*
* @param request the request
* @return the response entity
*/
@Override
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
HttpStatus status = getStatus(request);
if (status.value() == HttpServletResponse.SC_NOT_FOUND) {
throw new ControllerNotSupportException(ErrorCode.ERR_UNKNOWNINTERFACE);
}
return super.error(request);
}
}

View File

@ -11,6 +11,7 @@ import com.cmhi.gds.pojo.dto.protocol.info.GetGameInfoDetailReq;
import com.cmhi.gds.pojo.dto.protocol.info.GetGamesInfoRsp;
import com.cmhi.gds.pojo.dto.protocol.info.GetGamesSummaryRsp;
import com.cmhi.gds.pojo.dto.protocol.info.ReportGameServerReq;
import com.cmhi.gds.pojo.vo.GameDetail;
import com.cmhi.gds.pojo.vo.GameTableItemsDetail;
import com.cmhi.gds.pojo.vo.GameTableItemsSummary;
import com.cmhi.gds.security.annotation.Decryption;
@ -85,7 +86,7 @@ public class GameDatabaseInfoController {
@ResponseBody
public ProtocolRespDTO<GetGamesInfoRsp> getGameInfoDetails(@Validated(ValidGroups.AddGameServiceValid.class)
@RequestBody ProtocolReqDTO<GetGameInfoDetailReq> mr) {
GetGamesInfoRsp rspInfo = GetGamesInfoRsp.builder().build();
GetGamesInfoRsp rspInfo = GetGamesInfoRsp.builder().items(new ArrayList<>()).build();
List<GameInfoContent> gameContent = new ArrayList<>();
//获取TaskId列表
@ -116,7 +117,10 @@ public class GameDatabaseInfoController {
gi.setStatus(ErrorCode.ERR_OK.getCode());
gi.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
v.getGameDetails().forEach(k -> {
v.getGameDetails()
.stream()
.sorted(Comparator.comparingLong(GameDetail::getGameInfoId))
.forEach(k -> {
GameInfoDetail gd = GameInfoDetail.builder()
.gameInfoId(k.getGameInfoId())
.version(k.getVersion())
@ -126,7 +130,6 @@ public class GameDatabaseInfoController {
gi.getGamesInfo().add(gd);
});
gameContent.add(gi);
}

View File

@ -24,7 +24,7 @@ public class BaseProtocolDTO<T> {
* 当前协议版本号
*/
@NotNull(message = "ver 字段不能为空", groups = ValidGroups.ProtocolCommonValid.class)
@Range(min = 3, max = 9999, message = "ver 字段最小值为 3", groups = ValidGroups.ProtocolCommonValid.class)
@Range(min = 1, max = 9999, message = "ver 字段最小值为 1", groups = ValidGroups.ProtocolCommonValid.class)
private Integer ver;
/**

View File

@ -20,7 +20,7 @@
<id column="name" property="name"/>
<id column="company" property="company"/>
<collection property="gameDetails" ofType="com.cmhi.gds.pojo.vo.GameDetail">
<result column="id" property="gameInfoId"/>
<result column="gameInfoId" property="gameInfoId"/>
<result column="filename" property="filename"/>
<result column="version" property="version"/>
<result column="md5sum" property="md5sum"/>
@ -39,8 +39,8 @@
</select>
<select id="selectAllGameDetailById" resultMap="game_table_detail">
SELECT t.id, t.company, t.name, i.filename, i.version, i.md5sum FROM game_tables t LEFT JOIN game_info i on t.id = i.gameId
WHERE i.id IN
SELECT t.id, t.company, t.name, i.id as gameInfoId, i.filename, i.version, i.md5sum FROM game_tables t LEFT JOIN game_info i on t.id = i.gameId
WHERE t.id IN
<foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>