OCT 1. 增加游戏数据上传接口

2. 增加启动脚本
3. 增加打包脚本
This commit is contained in:
黄昕 2023-11-10 11:09:47 +08:00
parent 751417a2b8
commit 16b3872f63
18 changed files with 292 additions and 146 deletions

View File

@ -11,7 +11,7 @@
<directory>${project.build.directory}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>BeiDouPlatform.jar</include>
<include>GameDatabaseService.jar</include>
</includes>
</fileSet>
<fileSet>

3
bin/log_clean.sh Normal file
View File

@ -0,0 +1,3 @@
# 把下面语句编辑到crontab里定时清理日志每天凌晨1点清理日志保留7天日志
0 1 * * * find /apprun/phoenix_ddos_handle/logs -mtime +7 -name "*.log.*" -exec rm -rf {} \;

26
bin/processor_check.sh Normal file
View File

@ -0,0 +1,26 @@
# crontab里加上进程自动拉起任务做个简单的监控
# */1 * * * * source /etc/profile;sh /apprun/${YOUR_APP_NAME}/bin/processor_check.sh
# processor_check.sh脚本内容如下
#!/bin/bash
APP_NAME=dispose_platform.jar
WORK_PATH=$(cd `dirname $0`; pwd)
pids=`ps -ef | grep $APP_NAME | grep -v grep | wc -l`
if [ "$pids" -le 0 ]
then
echo "start $APP_NAME processor ......"
cd $WORK_PATH
cd ..
nohup sh bin/start.sh >/dev/null 2>&1 &
sleep 5
pids=`ps -ef | grep $APP_NAME | grep -v grep | wc -l`
if [ "$pids" -gt 0 ]
then
echo "$APP_NAME processor started"
else
echo "Failed to start $APP_NAME processor"
fi
else
echo "$APP_NAME processor is running ......"
fi

8
bin/start.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8003,server=y,suspend=n "
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=9998 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false "
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -server -Xms512M -Xmx512M -Xss256K -XX:MetaspaceSize=16M -XX:MaxMetaspaceSize=128M -XX:MaxDirectMemorySize=1g -XX:SurvivorRatio=8 -XX:+UseG1GC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heapdump.hprof"
WORK_PATH=$(cd `dirname $0`; pwd)
cd $WORK_PATH
cd ..
$JAVA_HOME/bin/java $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS $JAVA_OPTS -jar GameDatabaseService.jar &

15
bin/stop.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
APP_NAME=GameDatabaseService.jar
pids=`ps -ef | grep $APP_NAME | grep -v grep | awk '{print $2}'`
for pid in $pids
do
echo stop $APP_NAME java process: $pid
kill -9 $pid
done
nr_pids=`ps -ef | grep $APP_NAME | grep -v grep | wc -l`
while [ $nr_pids -gt 0 ]
do
nr_pids=`ps -ef | grep $APP_NAME | grep -v grep | wc -l`
done

View File

@ -1,4 +1,4 @@
server.port=9276
server.port=9278
server.servlet.context-path=/cmhi
# mysql

View File

@ -142,6 +142,11 @@
<artifactId>reactor-core</artifactId>
<version>3.4.16</version>
</dependency>
<dependency>
<groupId>org.jboss.xnio</groupId>
<artifactId>xnio-nio</artifactId>
<version>3.8.10.Final</version>
</dependency>
</dependencies>
<build>

View File

@ -107,7 +107,7 @@ public enum ErrorCode implements BaseEnum {
/**
* The Err nosuchtype.
*/
ERR_NOSUCHTYPE(24, "没有这个类型的处置设备"),
ERR_NOSUCHTYPE(24, "没有这个类型的设备"),
/**
* The Err removemore.
*/
@ -144,30 +144,22 @@ public enum ErrorCode implements BaseEnum {
* The Err unabledisposeip.
*/
ERR_UNABLEDISPOSEIP(33, "无法处置该IP"),
/**
* The Err haohan error.
*/
ERR_HAOHAN_ERROR(34, "浩瀚设备返回错误"),
/**
* The Err database.
*/
ERR_DATABASE(35, "操作数据库失败"),
/**
* The Err ipnodevice.
*/
ERR_IPNODEVICE(36, "找不到处置该IP的设备"),
ERR_DATABASE(34, "操作数据库失败"),
/**
* The Err untrusthost.
*/
ERR_UNTRUSTHOST(37, "未经授权的客户端"),
ERR_UNTRUSTHOST(35, "未经授权的客户端"),
/**
* The Err untrusttoken.
*/
ERR_UNTRUSTTOKEN(38, "未经授权的Token"),
ERR_UNTRUSTTOKEN(36, "未经授权的Token"),
/**
* The Err unknowninterface.
*/
ERR_UNKNOWNINTERFACE(39, "未提供该接口"),
ERR_UNKNOWNINTERFACE(37, "未提供该接口"),
/**
* The Err decrypt base 64.
*/
@ -219,7 +211,7 @@ public enum ErrorCode implements BaseEnum {
/**
* The Err nodevice areacode.
*/
ERR_NODEVICE_AREACODE(112, "区域无该设备"),
ERR_NOSUCH_GAME(112, "该游戏不存在"),
/**
* The Err specifiedip exists.
*/
@ -232,71 +224,6 @@ public enum ErrorCode implements BaseEnum {
* The Err server processreq.
*/
ERR_SERVER_PROCESSREQ(115, "服务器处理请求错误"),
/**
* The Err huawei error.
*/
ERR_HUAWEI_ERROR(116, "华为设备返回错误"),
/**
* The Err pengxin error.
*/
ERR_PENGXIN_ERROR(117, "鹏信设备返回错误"),
/**
* The Err upf error.
*/
ERR_UPF_ERROR(118, "UPF设备返回错误"),
/**
* The Err nosuchumcprotectobject.
*/
ERR_NOSUCHUMCPROTECTOBJECT(200, "没有找到UMC防护对象"),
/**
* The Err protectobjectexists.
*/
ERR_PROTECTOBJECTEXISTS(201, "该防护对象已经存在"),
/**
* The Err tractionstrategyrunning.
*/
ERR_TRACTIONSTRATEGYRUNNING(201, "该防护策略正在运行"),
/**
* The Err nosuchprotectstrategy.
*/
ERR_NOSUCHPROTECTSTRATEGY(202, "没有该防护策略"),
/**
* The Err businessexists.
*/
ERR_BUSINESSEXISTS(300, "该业务已经存在"),
/**
* Err businessnotexists error code.
*/
ERR_BUSINESSNOTEXISTS(301, "该业务不存在"),
/**
* Err addbusiness error code.
*/
ERR_ADDBUSINESS(302, "添加客户业务失败"),
/**
* Err delbusiness error code.
*/
ERR_DELBUSINESS(303, "删除客户业务失败"),
/**
* Err not found device error code.
*/
ERR_NOTFOUNDDEVICE(304, "找不到设备先添加设备"),
/**
* The Err huawei firewall error.
*/
ERR_HUAWEIFIREWALL_ERROR(305, "华为防火墙返回错误"),
/**
* The Err emos create message error.
*/
EMOS_CREATEMESSAGE_ERROR(306, "EMOS发送信息错误"),
;
/**

View File

@ -6,6 +6,7 @@ import com.cmhi.gds.pojo.dto.protocol.base.ProtocolRespDTO;
import com.cmhi.gds.pojo.dto.protocol.info.GameInfoContent;
import com.cmhi.gds.pojo.dto.protocol.info.GameInfoDetail;
import com.cmhi.gds.pojo.dto.protocol.info.GameListSummary;
import com.cmhi.gds.pojo.dto.protocol.info.GameServerRet;
import com.cmhi.gds.pojo.dto.protocol.info.GameServerRsp;
import com.cmhi.gds.pojo.dto.protocol.info.GetGameInfoDetailReq;
import com.cmhi.gds.pojo.dto.protocol.info.GetGamesInfoRsp;
@ -32,6 +33,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@ -51,8 +53,8 @@ public class GameDatabaseInfoController {
@ResponseBody
public ProtocolRespDTO<GetGamesSummaryRsp> getGameListSummary() {
GetGamesSummaryRsp rspInfo = GetGamesSummaryRsp.builder()
.items(new ArrayList<>())
.build();
.items(new ArrayList<>())
.build();
List<GameTableItemsSummary> gameList = gameDatabaseServiceService.getGameTableSummaryItems();
@ -60,8 +62,8 @@ public class GameDatabaseInfoController {
for (GameTableItemsSummary v : gameList) {
GameListSummary item = GameListSummary.builder()
.gameId(v.getGameId())
.build();
.gameId(v.getGameId())
.build();
if (!v.getGameFilename().isEmpty()) {
item.setGamesFilename(new ArrayList<>());
@ -77,11 +79,17 @@ public class GameDatabaseInfoController {
}
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
rspInfo.setMessage(new String[] {ErrorCode.ERR_OK.getMsg()});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
@PostMapping("gamelistsummary2")
@ResponseBody
public ProtocolRespDTO<GetGamesSummaryRsp> getGameListSummary2(@RequestBody ProtocolReqDTO<Object> mr) {
return getGameListSummary();
}
@PostMapping("gamelistDetails")
@ResponseBody
public ProtocolRespDTO<GetGamesInfoRsp> getGameInfoDetails(@Validated(ValidGroups.AddGameServiceValid.class)
@ -90,54 +98,54 @@ public class GameDatabaseInfoController {
List<GameInfoContent> gameContent = new ArrayList<>();
//获取TaskId列表
List<Long> reqTaskIds = Optional.ofNullable(mr.getMsgContent().getItems())
.orElse(new ArrayList<>());
List<Long> reqIds = Optional.ofNullable(mr.getMsgContent().getItems())
.orElse(new ArrayList<>());
List<GameTableItemsDetail> ret = gameDatabaseServiceService.getGameTableItems(reqTaskIds);
List<GameTableItemsDetail> ret = gameDatabaseServiceService.getGameTableItems(reqIds);
// 不存在的ID
reqTaskIds.stream()
.filter(v -> ret.stream().noneMatch(k -> k.getGameId().equals(v)))
.forEach(v -> {
GameInfoContent gi = GameInfoContent.builder().build();
gi.setGameId(v);
gi.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
gi.setMessage(new String[]{ErrorCode.ERR_NOSUCHTASK.getMsg()});
gameContent.add(gi);
});
reqIds.stream()
.filter(v -> ret.stream().noneMatch(k -> k.getGameId().equals(v)))
.forEach(v -> {
GameInfoContent gi = GameInfoContent.builder().build();
gi.setGameId(v);
gi.setStatus(ErrorCode.ERR_NOSUCHTASK.getCode());
gi.setMessage(new String[] {ErrorCode.ERR_NOSUCHTASK.getMsg()});
gameContent.add(gi);
});
for (GameTableItemsDetail v : ret) {
GameInfoContent gi = GameInfoContent.builder()
.gameId(v.getGameId())
.company(v.getCompany())
.name(v.getName())
.gamesInfo(new ArrayList<>())
.build();
.gameId(v.getGameId())
.company(v.getCompany())
.name(v.getName())
.gamesInfo(new ArrayList<>())
.build();
gi.setStatus(ErrorCode.ERR_OK.getCode());
gi.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
gi.setMessage(new String[] {ErrorCode.ERR_OK.getMsg()});
v.getGameDetails()
.stream()
.sorted(Comparator.comparingLong(GameDetail::getGameInfoId))
.forEach(k -> {
GameInfoDetail gd = GameInfoDetail.builder()
.gameInfoId(k.getGameInfoId())
.version(k.getVersion())
.gameFileName(k.getFilename())
.md5sum(k.getMd5sum())
.build();
.stream()
.sorted(Comparator.comparingLong(GameDetail::getGameInfoId))
.forEach(k -> {
GameInfoDetail gd = GameInfoDetail.builder()
.gameInfoId(k.getGameInfoId())
.version(k.getVersion())
.gameFileName(k.getFilename())
.md5sum(k.getMd5sum())
.build();
gi.getGamesInfo().add(gd);
});
gi.getGamesInfo().add(gd);
});
gameContent.add(gi);
}
rspInfo.getItems().addAll(gameContent.stream().sorted(Comparator.comparingLong(GameInfoContent::getGameId))
.collect(Collectors.toList()));
.collect(Collectors.toList()));
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()});
rspInfo.setMessage(new String[] {ErrorCode.ERR_OK.getMsg()});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
@ -147,33 +155,20 @@ public class GameDatabaseInfoController {
public ProtocolRespDTO<GameServerRsp> reportGameServiceData(
@Validated(ValidGroups.AddGameServiceValid.class)
@RequestBody ProtocolReqDTO<ReportGameServerReq> 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);
// });
//
GameServerRsp rspInfo = GameServerRsp.builder().items(new ArrayList<>()).build();
List<GameServerRet> gameServer = new ArrayList<>();
Map<Long, ErrorCode> ret = gameDatabaseServiceService.addGameServerInfo(mr.getMsgContent().getItems());
ret.forEach((key, value) -> {
GameServerRet gs = new GameServerRet();
gs.setGameId(key);
gs.setStatus(value.getValue());
gs.setMessage(new String[] {value.getMsg()});
gameServer.add(gs);
});
rspInfo.getItems().addAll(gameServer);
rspInfo.setStatus(ErrorCode.ERR_OK.getCode());
rspInfo.setMessage(new String[] {ErrorCode.ERR_OK.getMsg()});
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspInfo);
}
}

View File

@ -1,5 +1,6 @@
package com.cmhi.gds.manager;
import com.cmhi.gds.pojo.entry.GameServer;
import com.cmhi.gds.pojo.vo.GameTableItemsDetail;
import com.cmhi.gds.pojo.vo.GameTableSummary;
@ -9,4 +10,8 @@ public interface GameDatabaseServiceManager {
List<GameTableSummary> getGameTableSummary();
List<GameTableItemsDetail> getGameTableDetails(List<Long> gameId);
List<GameServer> getGameServerInfoByGameInfoId(List<Long> gameInfoId);
int addGameServerInfo(List<GameServer> gsList);
}

View File

@ -4,6 +4,7 @@ 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.GameServer;
import com.cmhi.gds.pojo.vo.GameTableItemsDetail;
import com.cmhi.gds.pojo.vo.GameTableSummary;
import lombok.extern.slf4j.Slf4j;
@ -33,4 +34,14 @@ public class GameDatabaseServiceManagerImpl implements GameDatabaseServiceManage
public List<GameTableItemsDetail> getGameTableDetails(List<Long> gameId) {
return gameTableMapper.selectAllGameDetailById(gameId);
}
@Override
public List<GameServer> getGameServerInfoByGameInfoId(List<Long> gameInfoId) {
return gameServerMapper.selectAllByGameInfoId(gameInfoId);
}
@Override
public int addGameServerInfo(List<GameServer> gsList) {
return gameServerMapper.addGameServerInfoList(gsList);
}
}

View File

@ -1,6 +1,8 @@
package com.cmhi.gds.mapper;
import com.cmhi.gds.pojo.entry.GameInfo;
import com.cmhi.gds.pojo.entry.GameServer;
import org.apache.ibatis.annotations.Param;
import java.util.List;

View File

@ -1,9 +1,15 @@
package com.cmhi.gds.mapper;
import com.cmhi.gds.pojo.entry.GameInfo;
import com.cmhi.gds.pojo.entry.GameServer;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface GameServerMapper {
List<GameServer> selectAll();
List<GameServer> selectAllByGameInfoId(@Param("idList") List<Long> idList);
int addGameServerInfoList(@Param("gameSvrInfo") List<GameServer> gameSvrInfo);
}

View File

@ -1,11 +1,16 @@
package com.cmhi.gds.misc;
import inet.ipaddr.HostName;
import inet.ipaddr.HostNameException;
import inet.ipaddr.IPAddress;
import inet.ipaddr.IPAddressString;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import java.time.LocalDateTime;
@ -92,7 +97,7 @@ public class Helper {
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,
StandardCharsets.UTF_8))) {
StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line);
@ -103,4 +108,57 @@ public class Helper {
return sb.toString();
}
public static Boolean ipAddressIsHostname(String hostStr) {
HostName host = new HostName(hostStr);
try {
host.validate();
return !host.isAddress();
} catch (HostNameException e) {
return null;
}
}
public static boolean ipAddressIsIpv6(String ipAddr) {
IPAddress loopback = new IPAddressString(ipAddr).getAddress();
if (loopback.isIPAddress()) {
return loopback.isIPv6();
} else {
return false;
}
}
public static boolean isIpAddressEqual(String ip1, String ip2) {
if (ipAddressIsHostname(ip1) == null || ipAddressIsHostname(ip1) == null) {
return false;
}
if (ipAddressIsHostname(ip1) == ipAddressIsHostname(ip2)) {
if (Boolean.TRUE.equals(ipAddressIsHostname(ip1))) {
return ip1.equals(ip2);
} else {
BigInteger v1 = ipAddressToBigInteger(ip1);
BigInteger v2 = ipAddressToBigInteger(ip2);
if (ipAddressIsIpv6(ip1) == ipAddressIsIpv6(ip2)) {
return (v1 != null && v1.equals(v2));
} else {
return false;
}
}
} else {
return false;
}
}
public static BigInteger ipAddressToBigInteger(String ipAddr) {
IPAddress loopback = new IPAddressString(ipAddr).getAddress();
if (loopback.isIPAddress()) {
return loopback.getValue();
} else {
return null;
}
}
}

View File

@ -1,18 +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 GameServerRsp {
public class GameServerRsp extends BaseRespStatus {
List<GameServerRet> items;
}

View File

@ -1,13 +1,18 @@
package com.cmhi.gds.service;
import com.cmhi.gds.common.ErrorCode;
import com.cmhi.gds.pojo.dto.protocol.info.GameServerContent;
import com.cmhi.gds.pojo.vo.GameTableItemsDetail;
import com.cmhi.gds.pojo.vo.GameTableItemsSummary;
import java.util.List;
import java.util.Map;
public interface GameDatabaseServiceService {
List<GameTableItemsSummary> getGameTableSummaryItems();
List<GameTableItemsDetail> getGameTableItems(List<Long> gameIds);
Map<Long, ErrorCode> addGameServerInfo(List<GameServerContent> gameServerContents);
}

View File

@ -1,6 +1,12 @@
package com.cmhi.gds.service.impl;
import com.cmhi.gds.common.CommonEnumHandler;
import com.cmhi.gds.common.ErrorCode;
import com.cmhi.gds.common.TransportProtocolType;
import com.cmhi.gds.manager.GameDatabaseServiceManager;
import com.cmhi.gds.misc.Helper;
import com.cmhi.gds.pojo.dto.protocol.info.GameServerContent;
import com.cmhi.gds.pojo.entry.GameServer;
import com.cmhi.gds.pojo.vo.GameSummary;
import com.cmhi.gds.pojo.vo.GameTableItemsDetail;
import com.cmhi.gds.pojo.vo.GameTableItemsSummary;
@ -12,7 +18,11 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
@Slf4j
@ -52,4 +62,52 @@ public class GameDatabaseServiceServiceImpl implements GameDatabaseServiceServic
public List<GameTableItemsDetail> getGameTableItems(List<Long> gameIds) {
return gameDatabaseServiceManager.getGameTableDetails(gameIds);
}
@Override
public Map<Long, ErrorCode> addGameServerInfo(List<GameServerContent> gameServerContents) {
Map<Long, ErrorCode> ret = new HashMap<>();
List<Long> gameInfoIds = new ArrayList<>();
List<GameServer> gsAddList = new ArrayList<>();
for (GameServerContent v : gameServerContents) {
gameInfoIds.add(v.getGameId());
}
// GAME ID 不存在
List<GameTableItemsDetail> allInfo = getGameTableItems(gameInfoIds);
gameInfoIds.stream()
.filter(v -> allInfo.stream().noneMatch(k -> k.getGameId().equals(v)))
.forEach(v -> {
ret.put(v, ErrorCode.ERR_NOSUCH_GAME);
});
// 当前GAME所有已经存在的游戏信息
List<GameServer> gsList = gameDatabaseServiceManager.getGameServerInfoByGameInfoId(gameInfoIds);
gameServerContents.forEach(k -> {
List<GameServer> f = gsList.stream().filter(v -> Objects.equals(v.getGameInfoId(), k.getGameId()))
.collect(Collectors.toList());
k.getServices().forEach(v -> {
if (f.stream().noneMatch(m -> Helper.isIpAddressEqual(m.getIpaddr(), v.getIpAddr())
&& m.getPort().equals(Integer.parseInt(v.getIpPort()))
&& m.getProtocol().getValue().equals(v.getProtoType()))) {
// 添加
GameServer gs = GameServer.builder()
.gameInfoId(k.getGameId())
.ipaddr(v.getIpAddr())
.port(Integer.parseInt(v.getIpPort()))
.protocol(CommonEnumHandler.codeOf(TransportProtocolType.class, v.getProtoType()))
.build();
gsAddList.add(gs);
//log.info("");
ret.put(k.getGameId(), ErrorCode.ERR_OK);
} else {
ret.put(k.getGameId(), ErrorCode.ERR_SPECIFIEDIP_EXISTS);
}
});
});
// 更新数据库
gameDatabaseServiceManager.addGameServerInfo(gsAddList);
return ret;
}
}

View File

@ -14,4 +14,21 @@
SELECT *
FROM game_server
</select>
<select id="selectAllByGameInfoId" resultMap="game_tables">
SELECT gameInfoId, ipaddr, port, protocol
FROM game_server WHERE gameInfoId IN
<foreach collection="idList" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<insert id="addGameServerInfoList" useGeneratedKeys="true" keyProperty="id"
parameterType="com.cmhi.gds.pojo.entry.GameServer">
INSERT IGNORE INTO game_server(gameInfoId, ipaddr, port, protocol)
VALUES
<foreach collection="gameSvrInfo" item="item" separator=",">
(#{item.gameInfoId}, #{item.ipaddr}, #{item.port}, #{item.protocol})
</foreach>
</insert>
</mapper>