parent
4b9ebf8c00
commit
517a9a70dc
|
@ -1,18 +1,12 @@
|
|||
server.port=9276
|
||||
server.servlet.context-path=/tunnel
|
||||
server.servlet.context-path=/cmhi
|
||||
|
||||
# mysql
|
||||
spring.datasource.url=jdbc:mysql://101.35.234.160:32306/beidou?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
||||
spring.datasource.url=jdbc:mysql://101.35.234.160:32306/GameDatabase?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.username=cmhi
|
||||
spring.datasource.password=cmHi10086!
|
||||
|
||||
# SQL Server
|
||||
#spring.datasource.url=jdbc:sqlserver://localhost:1433;database=BeiDouDataBase;integratedSecurity=true;encrypt=true;trustServerCertificate=true
|
||||
#spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
#spring.datasource.username=sa
|
||||
#spring.datasource.password=sa123456
|
||||
|
||||
#spring.datasource.type=org.apache.commons.dbcp2.BasicDataSource
|
||||
spring.datasource.dbcp2.max-total=128
|
||||
spring.datasource.dbcp2.max-wait-millis=10000
|
||||
|
@ -26,8 +20,8 @@ spring.datasource.dbcp2.connection-properties=characterEncoding=utf8
|
|||
#mybatis
|
||||
#mybatis.configuration.map-underscore-to-camel-case: true
|
||||
mybatis.mapper-locations=classpath*:mappers/*.xml
|
||||
mybatis.type-aliases-package=com.cmhi.game_database_service.pojo.entry
|
||||
mybatis.configuration.default-enum-type-handler=com.cmhi.game_database_service.common.CommonEnumHandler
|
||||
mybatis.type-aliases-package=com.cmhi.gds.pojo.entry
|
||||
mybatis.configuration.default-enum-type-handler=com.cmhi.gds.common.CommonEnumHandler
|
||||
#mybatis.configuration.log-impl=lombok.extern.slf4j.Slf4j
|
||||
|
||||
#pagehelper
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="com.cmhi.game_database_service.mapper" level="${LOG_LEVEL}" additivity="false">
|
||||
<logger name="com.cmhi.gds.mapper" level="${LOG_LEVEL}" additivity="false">
|
||||
<appender-ref ref="DATA"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
|
22
pom.xml
22
pom.xml
|
@ -112,6 +112,26 @@
|
|||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.seancfoley</groupId>
|
||||
<artifactId>ipaddress</artifactId>
|
||||
<version>5.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-core</artifactId>
|
||||
<version>1.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -160,7 +180,7 @@
|
|||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.cmhi.game_database_service.GameDatabaseServiceApplication</mainClass>
|
||||
<mainClass>com.cmhi.gds.GameDatabaseServiceApplication</mainClass>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
</manifest>
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package com.cmhi.game_database_service.common;
|
||||
|
||||
public class ConstValue {
|
||||
/**
|
||||
* The constant STRING_HTTP_AUTH_HEAD.
|
||||
*/
|
||||
public static final String STRING_HTTP_AUTH_HEAD = "Bearer ";
|
||||
|
||||
public static class Protocol {
|
||||
/**
|
||||
* The constant VERSION.
|
||||
*/
|
||||
public static final int VERSION = 1;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.cmhi.game_database_service.pojo.dto.protocol.base;
|
||||
|
||||
import com.cmhi.game_database_service.validation.ValidGroups;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* The type Id arrays req.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IdArraysReq {
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@NotNull(message = "id 字段不能为空",
|
||||
groups = {ValidGroups.IdArrayValid.class, ValidGroups.GetDevVerReqValid.class})
|
||||
@Size(min = 1, message = "id 字段必须指定明确id编号", groups = ValidGroups.ExplicitIdArrayValid.class)
|
||||
private String[] id;
|
||||
|
||||
/**
|
||||
* The Task id.
|
||||
*/
|
||||
@NotNull(message = "taskId 字段不能为空", groups = ValidGroups.TaskStopReqValid.class)
|
||||
@Size(min = 1, max = 20, message = "taskId 字段id个数取值范围为[1, 20]",
|
||||
groups = ValidGroups.TaskStopReqValid.class)
|
||||
private String[] taskId;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service;
|
||||
package com.cmhi.gds;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan(basePackages = {"com.cmhi.game_database_service.mapper"})
|
||||
@MapperScan(basePackages = {"com.cmhi.gds.mapper"})
|
||||
@EnableScheduling
|
||||
public class GameDatabaseServiceApplication {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.common;
|
||||
package com.cmhi.gds.common;
|
||||
|
||||
/**
|
||||
* The interface Base enum.
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.common;
|
||||
package com.cmhi.gds.common;
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
|
@ -0,0 +1,28 @@
|
|||
package com.cmhi.gds.common;
|
||||
|
||||
public class ConstValue {
|
||||
/**
|
||||
* The constant STRING_HTTP_AUTH_HEAD.
|
||||
*/
|
||||
public static final String STRING_HTTP_AUTH_HEAD = "Bearer ";
|
||||
|
||||
public static final String IP_ADDR_REG = "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}" +
|
||||
"(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$|^" +
|
||||
"([\\da-fA-F]{1,4}:){6}((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$|^::" +
|
||||
"([\\da-fA-F]{1,4}:){0,4}((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$|^" +
|
||||
"([\\da-fA-F]{1,4}:):([\\da-fA-F]{1,4}:){0,3}((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}" +
|
||||
"(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$|^([\\da-fA-F]{1,4}:){2}:([\\da-fA-F]{1,4}:){0,2}(" +
|
||||
"(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$|^([\\da-fA-F]{1,4}:){3}:" +
|
||||
"([\\da-fA-F]{1,4}:){0,1}((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$|^" +
|
||||
"([\\da-fA-F]{1,4}:){4}:((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$|^" +
|
||||
"([\\da-fA-F]{1,4}:){7}[\\da-fA-F]{1,4}$|^:((:[\\da-fA-F]{1,4}){1,6}|:)$|^[\\da-fA-F]{1,4}:((:[\\da-fA-F]{1," +
|
||||
"4}){1,5}|:)$|^([\\da-fA-F]{1,4}:){2}((:[\\da-fA-F]{1,4}){1,4}|:)$|^([\\da-fA-F]{1,4}:){3}((:[\\da-fA-F]{1," +
|
||||
"4}){1,3}|:)$|^([\\da-fA-F]{1,4}:){4}((:[\\da-fA-F]{1,4}){1,2}|:)$|^([\\da-fA-F]{1,4}:){5}:([\\da-fA-F]{1,4})" +
|
||||
"?$|^([\\da-fA-F]{1,4}:){6}:$";
|
||||
public static class Protocol {
|
||||
/**
|
||||
* The constant VERSION.
|
||||
*/
|
||||
public static final int VERSION = 1;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.common;
|
||||
package com.cmhi.gds.common;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.common;
|
||||
package com.cmhi.gds.common;
|
||||
|
||||
/**
|
||||
* The enum Proto crypto type.
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.common;
|
||||
package com.cmhi.gds.common;
|
||||
|
||||
/**
|
||||
* The type Security config value.
|
|
@ -0,0 +1,61 @@
|
|||
package com.cmhi.gds.common;
|
||||
|
||||
/**
|
||||
* The enum Dispose device type.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public enum TransportProtocolType implements BaseEnum {
|
||||
/**
|
||||
* The Dptech umc.
|
||||
*/
|
||||
TCP_PROTOCOL(0, "TCP"),
|
||||
/**
|
||||
* The Haohan platform.
|
||||
*/
|
||||
UDP_PROTOCOL(1, "UDP"),
|
||||
/**
|
||||
* The Pengxin platform.
|
||||
*/
|
||||
UNKNOWN_PROTOCOL(2, "UNKNOWN");
|
||||
|
||||
/**
|
||||
* The Code.
|
||||
*/
|
||||
private final int code;
|
||||
/**
|
||||
* The Readme.
|
||||
*/
|
||||
private final String readme;
|
||||
|
||||
/**
|
||||
* Instantiates a new Dispose device type.
|
||||
*
|
||||
* @param code the code
|
||||
* @param readme the readme
|
||||
*/
|
||||
TransportProtocolType(int code, String readme) {
|
||||
this.code = code;
|
||||
this.readme = readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets value.
|
||||
*
|
||||
* @return the value
|
||||
*/
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.cmhi.gds.controller;
|
||||
|
||||
import com.cmhi.gds.common.ErrorCode;
|
||||
import com.cmhi.gds.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.cmhi.gds.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.cmhi.gds.pojo.dto.protocol.info.GameListSummary;
|
||||
import com.cmhi.gds.pojo.dto.protocol.info.GameServerReq;
|
||||
import com.cmhi.gds.pojo.dto.protocol.info.GameServerRsp;
|
||||
import com.cmhi.gds.pojo.dto.protocol.info.GetGamesSummaryRsp;
|
||||
import com.cmhi.gds.pojo.vo.GameTableItems;
|
||||
import com.cmhi.gds.security.annotation.Decryption;
|
||||
import com.cmhi.gds.security.annotation.Encryption;
|
||||
import com.cmhi.gds.service.GameDatabaseServiceService;
|
||||
import com.cmhi.gds.validation.group.ValidGroups;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "/gameinfo")
|
||||
@Slf4j
|
||||
@Component
|
||||
@Validated
|
||||
@Encryption
|
||||
@Decryption
|
||||
public class GameDatabaseInfoController {
|
||||
|
||||
@Resource
|
||||
private GameDatabaseServiceService gameDatabaseServiceService;
|
||||
|
||||
@GetMapping("gamelistsummary")
|
||||
@ResponseBody
|
||||
|
||||
public ProtocolRespDTO<GetGamesSummaryRsp> getGameListSummary() {
|
||||
GetGamesSummaryRsp rspInfo = GetGamesSummaryRsp.builder()
|
||||
.items(new ArrayList<>())
|
||||
.build();
|
||||
|
||||
List<GameTableItems> gameList = gameDatabaseServiceService.getGameTableSummaryItems();
|
||||
|
||||
if (!gameList.isEmpty()) {
|
||||
|
||||
for (GameTableItems v : gameList) {
|
||||
GameListSummary item = GameListSummary.builder()
|
||||
.gameId(v.getGameId())
|
||||
.build();
|
||||
|
||||
if (!v.getGameFilename().isEmpty()) {
|
||||
item.setGamesFilename(new ArrayList<>());
|
||||
|
||||
for (String p : v.getGameFilename()) {
|
||||
item.getGamesFilename().add(p);
|
||||
}
|
||||
} else {
|
||||
item.setGamesFilename(new ArrayList<>());
|
||||
}
|
||||
rspInfo.getItems().add(item);
|
||||
}
|
||||
}
|
||||
|
||||
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
|
||||
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
|
||||
@PostMapping("/gamedata")
|
||||
@ResponseBody
|
||||
public ProtocolRespDTO<GameServerRsp> reportGameServiceData(
|
||||
@Validated(ValidGroups.AddGameServiceValid.class)
|
||||
@RequestBody ProtocolReqDTO<GameServerReq> mr) {
|
||||
GameServerRsp rspInfo = new GameServerRsp();
|
||||
rspInfo.setItems(new ArrayList<>());
|
||||
//
|
||||
// // 请求参数转换
|
||||
// List<DisposeDevice> devs = requestToDeviceList(mr.getMsgContent());
|
||||
//
|
||||
// // 更新设备信息
|
||||
// List<MulReturnType<ErrorCode, DisposeDevice>> ret = disposeDeviceManagerService.upgradeDisposeDevice(devs);
|
||||
//
|
||||
// CommDeviceListRsp rspInfo = new CommDeviceListRsp();
|
||||
// rspInfo.setItems(new ArrayList<>());
|
||||
//
|
||||
// ret.forEach(v -> {
|
||||
// DeviceInfoRsp rsp = new DeviceInfoRsp();
|
||||
// DisposeDevice dev = v.getSecondParam();
|
||||
//
|
||||
// disposeDeviceManagerService.getAllDisposeDevice().parallelStream()
|
||||
// .filter(k -> k.getId().equals(dev.getId()))
|
||||
// .findAny().ifPresent(device -> rsp.setDevStatus(device.getStatus().getValue()));
|
||||
//
|
||||
// rsp.setId(String.valueOf(dev.getId()));
|
||||
// rsp.setStatus(v.getFirstParam().getCode());
|
||||
// rsp.setMessage(new String[]{v.getFirstParam().getMsg()});
|
||||
//
|
||||
// rspInfo.getItems().add(rsp);
|
||||
// });
|
||||
//
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.cmhi.game_database_service.exception;
|
||||
package com.cmhi.gds.exception;
|
||||
|
||||
import com.cmhi.game_database_service.common.ErrorCode;
|
||||
import com.cmhi.gds.common.ErrorCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.cmhi.game_database_service.exception;
|
||||
package com.cmhi.gds.exception;
|
||||
|
||||
import com.cmhi.game_database_service.common.ErrorCode;
|
||||
import com.cmhi.gds.common.ErrorCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package com.cmhi.game_database_service.exception;
|
||||
package com.cmhi.gds.exception;
|
||||
|
||||
import com.cmhi.game_database_service.common.ConstValue;
|
||||
import com.cmhi.game_database_service.common.ErrorCode;
|
||||
import com.cmhi.game_database_service.misc.Helper;
|
||||
import com.cmhi.game_database_service.pojo.dto.protocol.base.BaseRespStatus;
|
||||
import com.cmhi.game_database_service.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.cmhi.gds.common.ConstValue;
|
||||
import com.cmhi.gds.common.ErrorCode;
|
||||
import com.cmhi.gds.misc.Helper;
|
||||
import com.cmhi.gds.pojo.dto.protocol.base.BaseRespStatus;
|
||||
import com.cmhi.gds.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
@ -1,6 +1,6 @@
|
|||
package com.cmhi.game_database_service.exception;
|
||||
package com.cmhi.gds.exception;
|
||||
|
||||
import com.cmhi.game_database_service.common.ErrorCode;
|
||||
import com.cmhi.gds.common.ErrorCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.cmhi.gds.manager;
|
||||
|
||||
import com.cmhi.gds.pojo.entry.GameInfo;
|
||||
import com.cmhi.gds.pojo.entry.GameTable;
|
||||
import com.cmhi.gds.pojo.entry.GameTableSummary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GameDatabaseServiceManager {
|
||||
List<GameTableSummary> getGameTableSummary();
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.cmhi.gds.manager.impl;
|
||||
|
||||
import com.cmhi.gds.manager.GameDatabaseServiceManager;
|
||||
import com.cmhi.gds.mapper.GameInfoMapper;
|
||||
import com.cmhi.gds.mapper.GameServerMapper;
|
||||
import com.cmhi.gds.mapper.GameTableMapper;
|
||||
import com.cmhi.gds.pojo.entry.GameTableSummary;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class GameDatabaseServiceManagerImpl implements GameDatabaseServiceManager {
|
||||
@Resource
|
||||
private GameInfoMapper gameInfoMapper;
|
||||
|
||||
@Resource
|
||||
private GameTableMapper gameTableMapper;
|
||||
|
||||
@Resource
|
||||
private GameServerMapper gameServerMapper;
|
||||
|
||||
@Override
|
||||
public List<GameTableSummary> getGameTableSummary() {
|
||||
return gameTableMapper.selectAllGameSummary();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.cmhi.gds.mapper;
|
||||
|
||||
import com.cmhi.gds.pojo.entry.GameInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GameInfoMapper {
|
||||
List<GameInfo> selectAll();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.cmhi.gds.mapper;
|
||||
|
||||
import com.cmhi.gds.pojo.entry.GameServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GameServerMapper {
|
||||
List<GameServer> selectAll();
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.cmhi.gds.mapper;
|
||||
|
||||
import com.cmhi.gds.pojo.entry.GameTable;
|
||||
import com.cmhi.gds.pojo.entry.GameTableSummary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GameTableMapper {
|
||||
List<GameTable> selectAll();
|
||||
|
||||
List<GameTableSummary> selectAllGameSummary();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.misc;
|
||||
package com.cmhi.gds.misc;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -10,11 +10,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The type Helper.
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.pojo.dto.protocol.base;
|
||||
package com.cmhi.gds.pojo.dto.protocol.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
|
@ -1,6 +1,6 @@
|
|||
package com.cmhi.game_database_service.pojo.dto.protocol.base;
|
||||
package com.cmhi.gds.pojo.dto.protocol.base;
|
||||
|
||||
import com.cmhi.game_database_service.validation.ValidGroups;
|
||||
import com.cmhi.gds.validation.group.ValidGroups;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.pojo.dto.protocol.base;
|
||||
package com.cmhi.gds.pojo.dto.protocol.base;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,6 +1,6 @@
|
|||
package com.cmhi.game_database_service.pojo.dto.protocol.base;
|
||||
package com.cmhi.gds.pojo.dto.protocol.base;
|
||||
|
||||
import com.cmhi.game_database_service.common.ConstValue;
|
||||
import com.cmhi.gds.common.ConstValue;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
|
@ -1,9 +1,9 @@
|
|||
package com.cmhi.game_database_service.pojo.dto.protocol.base;
|
||||
package com.cmhi.gds.pojo.dto.protocol.base;
|
||||
|
||||
|
||||
import com.cmhi.game_database_service.common.ConstValue;
|
||||
import com.cmhi.game_database_service.common.ErrorCode;
|
||||
import com.cmhi.game_database_service.common.SecurityConfigValue;
|
||||
import com.cmhi.gds.common.ConstValue;
|
||||
import com.cmhi.gds.common.ErrorCode;
|
||||
import com.cmhi.gds.common.SecurityConfigValue;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.AllArgsConstructor;
|
|
@ -0,0 +1,22 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"gameId", "gamesInfo"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameInfoContent {
|
||||
private Long gameId;
|
||||
|
||||
List<GameInfoDetail> gamesInfo;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"gameFileName", "md5sum", "version"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameInfoDetail {
|
||||
private String gameFileName;
|
||||
private String md5sum;
|
||||
private String version;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"gameId", "gamesFilename"})
|
||||
public class GameListSummary {
|
||||
List<String> gamesFilename;
|
||||
private Long gameId;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.cmhi.gds.validation.group.ValidGroups;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"gameId", "services"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameServerContent {
|
||||
@NotNull(message = "gameId 游戏ID不能为空", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@Min(message = "gameId > 0", groups = ValidGroups.AddGameServiceValid.class, value = 1L)
|
||||
private Long gameId;
|
||||
|
||||
@NotNull(message = "items 设备列表不能为空", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@Size(min = 1, message = "items 至少需要有一个元素", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@Valid
|
||||
private List<GameServerDetail> services;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.cmhi.gds.common.TransportProtocolType;
|
||||
import com.cmhi.gds.validation.group.ValidGroups;
|
||||
import com.cmhi.gds.validation.valids.ValidBaseEnum;
|
||||
import com.cmhi.gds.validation.valids.ValidIpAddr;
|
||||
import com.cmhi.gds.validation.valids.ValidIpPort;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"ipAddr", "ipPort", "protoType"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameServerDetail {
|
||||
@NotBlank(message = "ipAddr IP地址不能为空", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@ValidIpAddr(message = "disposeIp Ip地址格式错误", groups = ValidGroups.AddGameServiceValid.class)
|
||||
private String ipAddr;
|
||||
|
||||
@NotNull(message = "ipPort 端口不能为null, 默认端口用空字符串表示", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@ValidIpPort(message = "ipPort 端口取值范围为 [1, 65536]", groups = ValidGroups.AddGameServiceValid.class)
|
||||
private String ipPort;
|
||||
|
||||
@NotNull(message = "protoType 协议类型不能为空", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@ValidBaseEnum(enumClass = TransportProtocolType.class, groups = ValidGroups.AddGameServiceValid.class)
|
||||
private Integer protoType;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.cmhi.gds.validation.group.ValidGroups;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"gameId", "services"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameServerReq {
|
||||
@NotNull(message = "items 设备列表不能为空", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@Size(min = 1, message = "items 至少需要有一个元素", groups = ValidGroups.AddGameServiceValid.class)
|
||||
@Valid
|
||||
private List<GameServerContent> items;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.cmhi.gds.pojo.dto.protocol.base.BaseRespStatus;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"gameId", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameServerRet extends BaseRespStatus {
|
||||
private Long gameId;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameServerRsp {
|
||||
List<GameServerRet> items;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.cmhi.gds.pojo.dto.protocol.base.BaseRespStatus;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"items", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetGamesInfoRsp extends BaseRespStatus {
|
||||
List<GameInfoContent> items;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.cmhi.gds.pojo.dto.protocol.info;
|
||||
|
||||
import com.cmhi.gds.pojo.dto.protocol.base.BaseRespStatus;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"items", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GetGamesSummaryRsp extends BaseRespStatus {
|
||||
List<GameListSummary> items;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.cmhi.gds.pojo.entry;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import tk.mybatis.mapper.annotation.NameStyle;
|
||||
import tk.mybatis.mapper.code.Style;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder(alphabetic = true)
|
||||
@Table(name = "game_info")
|
||||
@NameStyle(Style.normal)
|
||||
public class GameInfo implements Serializable {
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
private Long gameId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String filename;
|
||||
|
||||
private String md5sum;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.cmhi.gds.pojo.entry;
|
||||
|
||||
import com.cmhi.gds.common.TransportProtocolType;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import tk.mybatis.mapper.annotation.NameStyle;
|
||||
import tk.mybatis.mapper.code.Style;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder(alphabetic = true)
|
||||
@Table(name = "game_server")
|
||||
@NameStyle(Style.normal)
|
||||
public class GameServer implements Serializable {
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
private Long gameInfoId;
|
||||
|
||||
private String ipaddr;
|
||||
|
||||
private Integer port;
|
||||
|
||||
private TransportProtocolType protocol;
|
||||
|
||||
private String add;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.cmhi.gds.pojo.entry;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GameSummary {
|
||||
private Long id;
|
||||
private String filename;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.cmhi.gds.pojo.entry;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import tk.mybatis.mapper.annotation.NameStyle;
|
||||
import tk.mybatis.mapper.code.Style;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder(alphabetic = true)
|
||||
@Table(name = "game_tables")
|
||||
@NameStyle(Style.normal)
|
||||
public class GameTable implements Serializable {
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String company;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.cmhi.gds.pojo.entry;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GameTableSummary {
|
||||
private Long id;
|
||||
private List<GameSummary> gameFilename;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.cmhi.gds.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class GameTableItems {
|
||||
private Long gameId;
|
||||
private List<String> gameFilename;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.cmhi.gds.security.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The interface Decryption.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Decryption {
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.cmhi.gds.security.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The interface Encryption.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Encryption {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.security.arithmetic;
|
||||
package com.cmhi.gds.security.arithmetic;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
|
@ -1,6 +1,6 @@
|
|||
package com.cmhi.game_database_service.security.configure;
|
||||
package com.cmhi.gds.security.configure;
|
||||
|
||||
import com.cmhi.game_database_service.security.arithmetic.CryptoHelper;
|
||||
import com.cmhi.gds.security.arithmetic.CryptoHelper;
|
||||
import com.ulisesbocchio.jasyptspringboot.EncryptablePropertyResolver;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.security.protocol;
|
||||
package com.cmhi.gds.security.protocol;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
|
@ -0,0 +1,10 @@
|
|||
package com.cmhi.gds.service;
|
||||
|
||||
import com.cmhi.gds.pojo.vo.GameTableItems;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GameDatabaseServiceService {
|
||||
|
||||
List<GameTableItems> getGameTableSummaryItems();
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.cmhi.gds.service.impl;
|
||||
|
||||
import com.cmhi.gds.manager.GameDatabaseServiceManager;
|
||||
import com.cmhi.gds.pojo.entry.GameSummary;
|
||||
import com.cmhi.gds.pojo.entry.GameTableSummary;
|
||||
import com.cmhi.gds.pojo.vo.GameTableItems;
|
||||
import com.cmhi.gds.service.GameDatabaseServiceService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class GameDatabaseServiceServiceImpl implements GameDatabaseServiceService {
|
||||
@Resource
|
||||
private GameDatabaseServiceManager gameDatabaseServiceManager;
|
||||
|
||||
|
||||
@Override
|
||||
public List<GameTableItems> getGameTableSummaryItems() {
|
||||
List<GameTableItems> items = new ArrayList<>();
|
||||
|
||||
List<GameTableSummary> gs = gameDatabaseServiceManager.getGameTableSummary();
|
||||
|
||||
if (!gs.isEmpty()) {
|
||||
for (GameTableSummary v : gs) {
|
||||
GameTableItems item = GameTableItems.builder()
|
||||
.gameId(v.getId())
|
||||
.build();
|
||||
|
||||
if (!v.getGameFilename().isEmpty()) {
|
||||
item.setGameFilename(new ArrayList<>());
|
||||
|
||||
for (GameSummary p : v.getGameFilename()) {
|
||||
item.getGameFilename().add(p.getFilename());
|
||||
}
|
||||
|
||||
item.getGameFilename().removeAll(Collections.singleton(null));
|
||||
}
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service.validation;
|
||||
package com.cmhi.gds.validation.group;
|
||||
|
||||
/**
|
||||
* The interface Valid groups.
|
||||
|
@ -35,7 +35,7 @@ public interface ValidGroups {
|
|||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
interface UpgradeDeviceValid extends ProtocolCommonValid {
|
||||
interface AddGameServiceValid extends ProtocolCommonValid {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ public interface ValidGroups {
|
|||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
interface AddDeviceValid extends UpgradeDeviceValid {
|
||||
interface AddDeviceValid extends AddGameServiceValid {
|
||||
}
|
||||
|
||||
/**
|
|
@ -0,0 +1,51 @@
|
|||
package com.cmhi.gds.validation.valids;
|
||||
|
||||
import com.cmhi.gds.common.TransportProtocolType;
|
||||
import com.cmhi.gds.validation.valids.impl.ValidBaseEnumImpl;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The interface Valid custom base enum.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {ValidBaseEnumImpl.class})
|
||||
public @interface ValidBaseEnum {
|
||||
/**
|
||||
* Enum class class.
|
||||
*
|
||||
* @return the class
|
||||
*/
|
||||
Class<TransportProtocolType> enumClass();
|
||||
|
||||
/**
|
||||
* Message string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
String message() default "";
|
||||
|
||||
/**
|
||||
* Groups class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
/**
|
||||
* Payload class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.cmhi.gds.validation.valids;
|
||||
|
||||
import com.cmhi.gds.validation.valids.impl.ValidIpAddrImpl;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The interface Valid ip addr.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {ValidIpAddrImpl.class})
|
||||
public @interface ValidIpAddr {
|
||||
/**
|
||||
* Message string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
String message();
|
||||
|
||||
/**
|
||||
* Groups class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
/**
|
||||
* Payload class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.cmhi.gds.validation.valids;
|
||||
|
||||
import com.cmhi.gds.validation.valids.impl.ValidIpPortImpl;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The interface Valid ip port.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {ValidIpPortImpl.class})
|
||||
public @interface ValidIpPort {
|
||||
/**
|
||||
* Message string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
String message();
|
||||
|
||||
/**
|
||||
* Groups class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
/**
|
||||
* Payload class [ ].
|
||||
*
|
||||
* @return the class [ ]
|
||||
*/
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.cmhi.gds.validation.valids.impl;
|
||||
|
||||
|
||||
import com.cmhi.gds.common.BaseEnum;
|
||||
import com.cmhi.gds.validation.valids.ValidBaseEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl;
|
||||
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Valid custom base enum.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Slf4j
|
||||
public class ValidBaseEnumImpl implements ConstraintValidator<ValidBaseEnum, Integer> {
|
||||
|
||||
/**
|
||||
* The Enum class.
|
||||
*/
|
||||
private Class<? extends BaseEnum> enumClass;
|
||||
|
||||
/**
|
||||
* The Message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @param constraintAnnotation the constraint annotation
|
||||
*/
|
||||
@Override
|
||||
public void initialize(ValidBaseEnum constraintAnnotation) {
|
||||
this.enumClass = constraintAnnotation.enumClass();
|
||||
this.message = constraintAnnotation.message();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is valid boolean.
|
||||
*
|
||||
* @param integer the integer
|
||||
* @param ctx the constraint validator context
|
||||
* @return the boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(Integer integer, ConstraintValidatorContext ctx) {
|
||||
|
||||
// null 由其它校验器处理
|
||||
if (integer == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<Integer> enumValues = Arrays.stream(enumClass.getEnumConstants())
|
||||
.map(BaseEnum::getValue).toList();
|
||||
|
||||
String errMsg = this.message + " 字段 " +
|
||||
((ConstraintValidatorContextImpl) ctx).getConstraintViolationCreationContexts()
|
||||
.get(0).getPath().getLeafNode().getName()
|
||||
+ " 值 {" + integer + "} 错误, 字段取值范围:" + enumValues;
|
||||
|
||||
// 重新设置消息
|
||||
ctx.disableDefaultConstraintViolation();
|
||||
ctx.buildConstraintViolationWithTemplate(errMsg).addConstraintViolation();
|
||||
|
||||
return enumValues.contains(integer);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.cmhi.gds.validation.valids.impl;
|
||||
|
||||
import com.cmhi.gds.common.ConstValue;
|
||||
import com.cmhi.gds.validation.valids.ValidIpAddr;
|
||||
import inet.ipaddr.IPAddress;
|
||||
import inet.ipaddr.IPAddressString;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The type Valid ip addr.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class ValidIpAddrImpl implements ConstraintValidator<ValidIpAddr, String> {
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @param constraintAnnotation the constraint annotation
|
||||
*/
|
||||
@Override
|
||||
public void initialize(ValidIpAddr constraintAnnotation) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Is valid boolean.
|
||||
*
|
||||
* @param s the s
|
||||
* @param constraintValidatorContext the constraint validator context
|
||||
* @return the boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||
|
||||
if (s == null || s.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Pattern.matches(ConstValue.IP_ADDR_REG, s)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IPAddressString addrString = new IPAddressString(s);
|
||||
|
||||
IPAddress addr = addrString.getAddress();
|
||||
|
||||
if (addr == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return addr.isIPv4() || addr.isIPv6();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.cmhi.gds.validation.valids.impl;
|
||||
|
||||
|
||||
|
||||
import com.cmhi.gds.validation.valids.ValidIpPort;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* The type Valid ip port.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public class ValidIpPortImpl implements ConstraintValidator<ValidIpPort, String> {
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @param constraintAnnotation the constraint annotation
|
||||
*/
|
||||
@Override
|
||||
public void initialize(ValidIpPort constraintAnnotation) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Is valid boolean.
|
||||
*
|
||||
* @param s the s
|
||||
* @param constraintValidatorContext the constraint validator context
|
||||
* @return the boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||
final int minSocketPort = 1;
|
||||
final int maxSocketPort = 65535;
|
||||
|
||||
if (s == null || s.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
int port = Integer.parseInt(s);
|
||||
|
||||
if (port >= minSocketPort && port <= maxSocketPort) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cmhi.gds.mapper.GameInfoMapper">
|
||||
<resultMap id="game_tables" type="com.cmhi.gds.pojo.entry.GameInfo">
|
||||
<id column="id" property="id"/>
|
||||
<result column="gameId" property="gameId"/>
|
||||
<result column="version" property="version"/>
|
||||
<result column="filename" property="filename"/>
|
||||
<result column="md5sum" property="md5sum"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAll" resultMap="game_tables">
|
||||
SELECT *
|
||||
FROM game_info
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cmhi.gds.mapper.GameServerMapper">
|
||||
<resultMap id="game_tables" type="com.cmhi.gds.pojo.entry.GameServer">
|
||||
<id column="id" property="id"/>
|
||||
<result column="gameInfoId" property="gameInfoId"/>
|
||||
<result column="ipaddr" property="ipaddr"/>
|
||||
<result column="port" property="port"/>
|
||||
<result column="protocol" property="protocol"/>
|
||||
<result column="add" property="add"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAll" resultMap="game_tables">
|
||||
SELECT *
|
||||
FROM game_server
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cmhi.gds.mapper.GameTableMapper">
|
||||
<resultMap id="game_tables" type="com.cmhi.gds.pojo.entry.GameTable">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="company" property="company"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="game_table_summary" type="com.cmhi.gds.pojo.entry.GameTableSummary">
|
||||
<id column="id" property="id"/>
|
||||
<collection property="gameFilename" ofType="com.cmhi.gds.pojo.entry.GameSummary">
|
||||
<result column="id" property="id"/>
|
||||
<result column="filename" property="filename"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAll" resultMap="game_tables">
|
||||
SELECT *
|
||||
FROM game_tables
|
||||
</select>
|
||||
|
||||
<select id="selectAllGameSummary" resultMap="game_table_summary">
|
||||
SELECT t.id, i.filename FROM game_tables t LEFT JOIN game_info i on t.id = i.gameId;
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,4 +1,4 @@
|
|||
package com.cmhi.game_database_service;
|
||||
package com.cmhi.gds;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
Loading…
Reference in New Issue