mirror of
https://gitee.com/wxd-gaming/wxdgaming.spring.boot.git
synced 2026-05-07 01:00:44 +08:00
【优化】基础模型跑通,包括日志查询
This commit is contained in:
@@ -20,7 +20,7 @@ import wxdgaming.game.server.script.bag.cost.CostScript;
|
||||
import wxdgaming.game.server.script.bag.gain.GainScript;
|
||||
import wxdgaming.game.server.script.bag.log.ItemLog;
|
||||
import wxdgaming.game.server.script.bag.use.UseItemAction;
|
||||
import wxdgaming.game.server.script.log.LogService;
|
||||
import wxdgaming.game.server.module.slog.SLogService;
|
||||
import wxdgaming.game.server.script.mail.MailService;
|
||||
import wxdgaming.game.server.script.tips.TipsService;
|
||||
import wxdgaming.spring.boot.core.HoldRunApplication;
|
||||
@@ -49,9 +49,9 @@ public class BagService extends HoldRunApplication implements InitPrint {
|
||||
final TipsService tipsService;
|
||||
final DataRepository dataRepository;
|
||||
final MailService mailService;
|
||||
final LogService logService;
|
||||
final SLogService logService;
|
||||
|
||||
public BagService(DataCenterService dataCenterService, TipsService tipsService, DataRepository dataRepository, MailService mailService, LogService logService) {
|
||||
public BagService(DataCenterService dataCenterService, TipsService tipsService, DataRepository dataRepository, MailService mailService, SLogService logService) {
|
||||
this.dataCenterService = dataCenterService;
|
||||
this.tipsService = tipsService;
|
||||
this.dataRepository = dataRepository;
|
||||
|
||||
@@ -4,7 +4,7 @@ import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import wxdgaming.game.server.bean.role.Player;
|
||||
import wxdgaming.game.server.script.log.AbstractRoleLog;
|
||||
import wxdgaming.game.server.module.slog.AbstractRoleLog;
|
||||
|
||||
/**
|
||||
* 背包日志
|
||||
@@ -22,18 +22,18 @@ public class ItemLog extends AbstractRoleLog {
|
||||
private int itemCfgId;
|
||||
private String itemName;
|
||||
private long oldNum;
|
||||
private long num;
|
||||
private long change;
|
||||
private long newNum;
|
||||
private String reason;
|
||||
|
||||
public ItemLog(Player player, String bagType, String changeType, int itemCfgId, String itemName, long oldNum, long num, long newNum, String reason) {
|
||||
public ItemLog(Player player, String bagType, String changeType, int itemCfgId, String itemName, long oldNum, long change, long newNum, String reason) {
|
||||
super(player);
|
||||
this.bagType = bagType;
|
||||
this.changeType = changeType;
|
||||
this.itemCfgId = itemCfgId;
|
||||
this.itemName = itemName;
|
||||
this.oldNum = oldNum;
|
||||
this.num = num;
|
||||
this.change = change;
|
||||
this.newNum = newNum;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import wxdgaming.game.server.bean.role.Player;
|
||||
import wxdgaming.game.server.event.OnLevelUp;
|
||||
import wxdgaming.game.server.event.OnTask;
|
||||
import wxdgaming.game.server.module.data.DataCenterService;
|
||||
import wxdgaming.game.server.module.slog.SLogService;
|
||||
import wxdgaming.game.server.script.inner.InnerService;
|
||||
import wxdgaming.game.server.script.role.log.RoleLvLog;
|
||||
import wxdgaming.spring.boot.core.HoldRunApplication;
|
||||
import wxdgaming.spring.boot.core.lang.condition.Condition;
|
||||
import wxdgaming.spring.boot.net.SocketSession;
|
||||
@@ -28,10 +30,12 @@ public class PlayerService extends HoldRunApplication {
|
||||
|
||||
final InnerService innerService;
|
||||
final DataCenterService dataCenterService;
|
||||
final SLogService slogService;
|
||||
|
||||
public PlayerService(InnerService innerService, DataCenterService dataCenterService) {
|
||||
public PlayerService(InnerService innerService, DataCenterService dataCenterService, SLogService slogService) {
|
||||
this.innerService = innerService;
|
||||
this.dataCenterService = dataCenterService;
|
||||
this.slogService = slogService;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +94,10 @@ public class PlayerService extends HoldRunApplication {
|
||||
runApplication.executorWithMethodAnnotatedIgnoreException(OnTask.class, player, new Condition("level", player.getLevel()));
|
||||
/*触发提升等级*/
|
||||
runApplication.executorWithMethodAnnotatedIgnoreException(OnTask.class, player, new Condition("levelup", lv));
|
||||
|
||||
RoleLvLog roleLvLog = new RoleLvLog(player, reasonArgs.getReasonText());
|
||||
slogService.addLog(roleLvLog);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import wxdgaming.game.server.event.OnLogout;
|
||||
import wxdgaming.game.server.module.data.DataCenterService;
|
||||
import wxdgaming.game.server.module.data.GlobalDbDataCenterService;
|
||||
import wxdgaming.game.server.module.drive.PlayerDriveService;
|
||||
import wxdgaming.game.server.script.log.LogService;
|
||||
import wxdgaming.game.server.module.slog.SLogService;
|
||||
import wxdgaming.game.server.script.role.log.RoleLoginLog;
|
||||
import wxdgaming.spring.boot.core.HoldRunApplication;
|
||||
import wxdgaming.spring.boot.core.ann.ThreadParam;
|
||||
@@ -36,11 +36,11 @@ public class ReqChooseRoleHandler extends HoldRunApplication {
|
||||
final DataCenterService dataCenterService;
|
||||
final GlobalDbDataCenterService globalDbDataCenterService;
|
||||
final PlayerDriveService playerDriveService;
|
||||
final LogService logService;
|
||||
final SLogService logService;
|
||||
|
||||
public ReqChooseRoleHandler(DataCenterService dataCenterService,
|
||||
GlobalDbDataCenterService globalDbDataCenterService,
|
||||
PlayerDriveService playerDriveService, LogService logService) {
|
||||
PlayerDriveService playerDriveService, SLogService logService) {
|
||||
this.dataCenterService = dataCenterService;
|
||||
this.globalDbDataCenterService = globalDbDataCenterService;
|
||||
this.playerDriveService = playerDriveService;
|
||||
|
||||
@@ -8,7 +8,9 @@ import wxdgaming.game.server.GameServiceBootstrapConfig;
|
||||
import wxdgaming.game.server.bean.ClientSessionMapping;
|
||||
import wxdgaming.game.server.module.data.ClientSessionService;
|
||||
import wxdgaming.game.server.module.data.DataCenterService;
|
||||
import wxdgaming.game.server.module.slog.SLogService;
|
||||
import wxdgaming.game.server.script.role.PlayerService;
|
||||
import wxdgaming.game.server.script.role.log.AccountLoginSLog;
|
||||
import wxdgaming.game.server.script.tips.TipsService;
|
||||
import wxdgaming.spring.boot.core.HoldRunApplication;
|
||||
import wxdgaming.spring.boot.core.executor.ThreadContext;
|
||||
@@ -32,17 +34,19 @@ public class ReqLoginHandler extends HoldRunApplication {
|
||||
private final ClientSessionService clientSessionService;
|
||||
private final PlayerService playerService;
|
||||
private final TipsService tipsService;
|
||||
final SLogService sLogService;
|
||||
|
||||
public ReqLoginHandler(DataCenterService dataCenterService,
|
||||
ClientSessionService clientSessionService,
|
||||
PlayerService playerService,
|
||||
TipsService tipsService,
|
||||
GameServiceBootstrapConfig gameServiceBootstrapConfig) {
|
||||
GameServiceBootstrapConfig gameServiceBootstrapConfig, SLogService sLogService) {
|
||||
this.dataCenterService = dataCenterService;
|
||||
this.clientSessionService = clientSessionService;
|
||||
this.playerService = playerService;
|
||||
this.tipsService = tipsService;
|
||||
this.gameServiceBootstrapConfig = gameServiceBootstrapConfig;
|
||||
this.sLogService = sLogService;
|
||||
}
|
||||
|
||||
@ProtoRequest
|
||||
@@ -74,10 +78,12 @@ public class ReqLoginHandler extends HoldRunApplication {
|
||||
clientSessionMapping.setGatewayId(gatewayId);
|
||||
clientSessionMapping.setClientSessionId(clientSessionId);
|
||||
clientSessionMapping.setClientParams((ArrayList<MapBean>) req.getClientParams());
|
||||
|
||||
playerService.sendPlayerList(socketSession, clientSessionId, sid, account);
|
||||
|
||||
log.info("登录完成:{}", clientSessionMapping);
|
||||
AccountLoginSLog accountLoginSLog = new AccountLoginSLog(platformUserId, account, platform, null, clientIp, req.getClientParams().toString());
|
||||
sLogService.addLog(accountLoginSLog);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("登录失败 {}", req, e);
|
||||
tipsService.tips(socketSession, clientSessionId, "服务器异常");
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package wxdgaming.game.server.script.role.log;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import wxdgaming.game.server.module.slog.AbstractSLog;
|
||||
|
||||
/**
|
||||
* 角色登录日志
|
||||
*
|
||||
* @author wxd-gaming(無心道, 15388152619)
|
||||
* @version 2025-08-12 19:46
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class AccountLoginSLog extends AbstractSLog {
|
||||
|
||||
private String openId;
|
||||
private String account;
|
||||
private String platform;
|
||||
private String channel;
|
||||
private String ip;
|
||||
private String clientData;
|
||||
|
||||
public AccountLoginSLog(String openId, String account, String platform, String channel, String ip, String clientData) {
|
||||
this.openId = openId;
|
||||
this.account = account;
|
||||
this.platform = platform;
|
||||
this.channel = channel;
|
||||
this.ip = ip;
|
||||
this.clientData = clientData;
|
||||
}
|
||||
|
||||
@Override public String logType() {
|
||||
return "accountloginlog";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package wxdgaming.game.server.script.role.log;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import wxdgaming.game.server.bean.role.Player;
|
||||
import wxdgaming.game.server.script.log.AbstractRoleLog;
|
||||
import wxdgaming.game.server.module.slog.AbstractRoleLog;
|
||||
|
||||
/**
|
||||
* 角色登录日志
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package wxdgaming.game.server.script.role.log;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import wxdgaming.game.server.bean.role.Player;
|
||||
import wxdgaming.game.server.module.slog.AbstractRoleLog;
|
||||
|
||||
/**
|
||||
* 角色登录日志
|
||||
*
|
||||
* @author wxd-gaming(無心道, 15388152619)
|
||||
* @version 2025-08-12 19:46
|
||||
**/
|
||||
@Getter
|
||||
@Setter
|
||||
public class RoleLvLog extends AbstractRoleLog {
|
||||
|
||||
private String reason;
|
||||
|
||||
public RoleLvLog(Player player, String reason) {
|
||||
super(player);
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
@Override public String logType() {
|
||||
return "rolelvlog";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,6 +55,7 @@ public class RoleEntity extends EntityLongUID {
|
||||
name = player.getName();
|
||||
account = player.getAccount();
|
||||
del = player.isDel();
|
||||
lv = player.getLevel();
|
||||
lastLoginTime = player.getOnlineInfo().getLastLoginTime();
|
||||
lastLogoutTime = player.getOnlineInfo().getLastLogoutTime();
|
||||
totalOnlineMills = player.getOnlineInfo().getOnlineTotalMills();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GlobalDbDataCenterService {
|
||||
final SqlDataHelper globalDbHelper;
|
||||
final DataCenterService dataCenterService;
|
||||
|
||||
public GlobalDbDataCenterService(@Qualifier("db.sql.mysql-second") MysqlDataHelper globalDbHelper, DataCenterService dataCenterService) {
|
||||
public GlobalDbDataCenterService(@Qualifier("mysqlSecond") MysqlDataHelper globalDbHelper, DataCenterService dataCenterService) {
|
||||
this.globalDbHelper = globalDbHelper;
|
||||
this.dataCenterService = dataCenterService;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package wxdgaming.game.server.script.log;
|
||||
package wxdgaming.game.server.module.slog;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -0,0 +1,30 @@
|
||||
package wxdgaming.game.server.module.slog;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import wxdgaming.game.server.bean.role.Player;
|
||||
import wxdgaming.spring.boot.core.lang.ObjectBase;
|
||||
|
||||
/**
|
||||
* 角色日志
|
||||
*
|
||||
* @author wxd-gaming(無心道, 15388152619)
|
||||
* @version 2025-08-12 19:22
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public abstract class AbstractSLog extends ObjectBase {
|
||||
|
||||
private int sid;
|
||||
private int curSid;
|
||||
|
||||
public AbstractSLog(int sid, int curSid) {
|
||||
this.sid = sid;
|
||||
this.curSid = curSid;
|
||||
}
|
||||
|
||||
public abstract String logType();
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package wxdgaming.game.server.script.log;
|
||||
package wxdgaming.game.server.module.slog;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -18,13 +18,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
**/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LogService implements InitPrint {
|
||||
public class SLogService implements InitPrint {
|
||||
|
||||
final GameServiceBootstrapConfig gameServiceBootstrapConfig;
|
||||
final LogBusService logBusService;
|
||||
final ConcurrentHashMap<String, HexId> logHexIdMap = new ConcurrentHashMap<>();
|
||||
|
||||
public LogService(GameServiceBootstrapConfig gameServiceBootstrapConfig, LogBusService logBusService) {
|
||||
public SLogService(GameServiceBootstrapConfig gameServiceBootstrapConfig, LogBusService logBusService) {
|
||||
this.gameServiceBootstrapConfig = gameServiceBootstrapConfig;
|
||||
this.logBusService = logBusService;
|
||||
}
|
||||
@@ -39,6 +39,22 @@ public class LogService implements InitPrint {
|
||||
logEntity.setCreateTime(System.currentTimeMillis());
|
||||
logEntity.setLogType(abstractRoleLog.logType());
|
||||
logEntity.getLogData().putAll(abstractRoleLog.toJSONObject());
|
||||
|
||||
abstractRoleLog.setCurSid(gameServiceBootstrapConfig.getSid());
|
||||
|
||||
logBusService.addLog(logEntity);
|
||||
}
|
||||
|
||||
public void addLog(AbstractSLog abstractSLog) {
|
||||
LogEntity logEntity = new LogEntity();
|
||||
logEntity.setUid(newLogId(abstractSLog.logType()));
|
||||
logEntity.setCreateTime(System.currentTimeMillis());
|
||||
logEntity.setLogType(abstractSLog.logType());
|
||||
logEntity.getLogData().putAll(abstractSLog.toJSONObject());
|
||||
|
||||
abstractSLog.setSid(gameServiceBootstrapConfig.getSid());
|
||||
abstractSLog.setCurSid(gameServiceBootstrapConfig.getSid());
|
||||
|
||||
logBusService.addLog(logEntity);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import java.util.function.Function;
|
||||
@Setter
|
||||
public class LogMappingInfo extends ObjectBase {
|
||||
|
||||
private String group = "";
|
||||
private String sort = "1";
|
||||
private String logName;
|
||||
/** 表注释 */
|
||||
private String logComment;
|
||||
|
||||
@@ -21,7 +21,9 @@ import wxdgaming.spring.logserver.bean.LogMappingInfo;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -38,6 +40,7 @@ public class DataCenterService implements InitPrint {
|
||||
|
||||
final PgsqlDataHelper sqlDataHelper;
|
||||
Map<String, LogMappingInfo> logMappingInfoMap = Map.of();
|
||||
List<LogMappingInfo> logMappingInfoList = List.of();
|
||||
|
||||
@Autowired
|
||||
public DataCenterService(PgsqlDataHelper sqlDataHelper) {
|
||||
@@ -67,6 +70,7 @@ public class DataCenterService implements InitPrint {
|
||||
checkSLogTable(sqlDataHelper, dbTableMap, tableStructMap, tableMapping, logMappingInfo.isPartition(), tableName, tableComment);
|
||||
tmp.put(logMappingInfo.getLogName(), logMappingInfo);
|
||||
});
|
||||
logMappingInfoList = tmp.values().stream().sorted(Comparator.comparing(LogMappingInfo::getSort)).toList();
|
||||
logMappingInfoMap = tmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import wxdgaming.spring.boot.core.lang.RunResult;
|
||||
import wxdgaming.spring.boot.core.timer.MyClock;
|
||||
import wxdgaming.spring.boot.core.util.NumberUtil;
|
||||
import wxdgaming.spring.logserver.bean.LogEntity;
|
||||
import wxdgaming.spring.logserver.bean.LogField;
|
||||
import wxdgaming.spring.logserver.bean.LogMappingInfo;
|
||||
import wxdgaming.spring.logserver.bean.LogTableContext;
|
||||
import wxdgaming.spring.logserver.module.data.DataCenterService;
|
||||
@@ -22,8 +21,6 @@ import wxdgaming.spring.logserver.module.data.DataCenterService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
@@ -67,7 +64,7 @@ public class LogService implements InitPrint {
|
||||
}
|
||||
|
||||
public List<JSONObject> nav() {
|
||||
return dataCenterService.getLogMappingInfoMap().values().stream()
|
||||
return dataCenterService.getLogMappingInfoList().stream()
|
||||
.map(li -> {
|
||||
JSONObject jsonObject = MapOf.newJSONObject();
|
||||
jsonObject.put("name", li.getLogName());
|
||||
@@ -78,18 +75,12 @@ public class LogService implements InitPrint {
|
||||
}
|
||||
|
||||
public List<JSONObject> logTitle(String tableName) {
|
||||
return dataCenterService.getLogMappingInfoMap().values().stream()
|
||||
.filter(li -> li.getLogName().equals(tableName))
|
||||
.mapMulti(new BiConsumer<LogMappingInfo, Consumer<JSONObject>>() {
|
||||
@Override public void accept(LogMappingInfo li, Consumer<JSONObject> consumer) {
|
||||
List<LogField> fieldList = li.getFieldList();
|
||||
for (LogField logField : fieldList) {
|
||||
JSONObject jsonObject = MapOf.newJSONObject();
|
||||
jsonObject.put("name", logField.getFieldName());
|
||||
jsonObject.put("comment", logField.getFieldComment());
|
||||
consumer.accept(jsonObject);
|
||||
}
|
||||
}
|
||||
return dataCenterService.getLogMappingInfoMap().get(tableName).getFieldList().stream()
|
||||
.map(logField -> {
|
||||
JSONObject jsonObject = MapOf.newJSONObject();
|
||||
jsonObject.put("name", logField.getFieldName());
|
||||
jsonObject.put("comment", logField.getFieldComment());
|
||||
return jsonObject;
|
||||
})
|
||||
.toList();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"logName": "itemlog",
|
||||
"logComment": "背包日志",
|
||||
"sort": "3-1",
|
||||
"partition": true,
|
||||
"fieldList": [
|
||||
{
|
||||
@@ -29,18 +30,28 @@
|
||||
"fieldType": "string"
|
||||
},
|
||||
{
|
||||
"fieldName": "itemId",
|
||||
"fieldComment": "道具id",
|
||||
"fieldType": "long"
|
||||
},
|
||||
{
|
||||
"fieldName": "itemCfg",
|
||||
"fieldName": "itemCfgId",
|
||||
"fieldComment": "道具id",
|
||||
"fieldType": "int"
|
||||
},
|
||||
{
|
||||
"fieldName": "num",
|
||||
"fieldComment": "数量",
|
||||
"fieldName": "itemName",
|
||||
"fieldComment": "道具名字",
|
||||
"fieldType": "int"
|
||||
},
|
||||
{
|
||||
"fieldName": "oldNum",
|
||||
"fieldComment": "变更前",
|
||||
"fieldType": "long"
|
||||
},
|
||||
{
|
||||
"fieldName": "change",
|
||||
"fieldComment": "变更量",
|
||||
"fieldType": "long"
|
||||
},
|
||||
{
|
||||
"fieldName": "newNum",
|
||||
"fieldComment": "变更后",
|
||||
"fieldType": "long"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"logName": "login",
|
||||
"logName": "accountloginlog",
|
||||
"logComment": "登录日志",
|
||||
"sort": "1-1",
|
||||
"partition": true,
|
||||
"fieldList": [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"logName": "logout",
|
||||
"logComment": "登出日志",
|
||||
"sort": "1-2",
|
||||
"partition": true,
|
||||
"fieldList": [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"logName": "recharge",
|
||||
"logComment": "充值日志",
|
||||
"sort": "2-1",
|
||||
"partition": true,
|
||||
"fieldList": [
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"logName": "roleloginlog",
|
||||
"logComment": "角色登录日志",
|
||||
"sort": "1-3",
|
||||
"partition": true,
|
||||
"fieldList": [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"logName": "rolelvlog",
|
||||
"logComment": "角色升级日志",
|
||||
"sort": "4-1",
|
||||
"partition": true,
|
||||
"fieldList": [
|
||||
{
|
||||
"fieldName": "uid",
|
||||
"fieldComment": "UID",
|
||||
"fieldType": "long"
|
||||
},
|
||||
{
|
||||
"fieldName": "createTime",
|
||||
"fieldComment": "日期",
|
||||
"fieldType": "long"
|
||||
},
|
||||
{
|
||||
"fieldName": "account",
|
||||
"fieldComment": "账号",
|
||||
"fieldType": "string"
|
||||
},
|
||||
{
|
||||
"fieldName": "roleId",
|
||||
"fieldComment": "角色ID",
|
||||
"fieldType": "long"
|
||||
},
|
||||
{
|
||||
"fieldName": "roleName",
|
||||
"fieldComment": "角色名字",
|
||||
"fieldType": "string"
|
||||
},
|
||||
{
|
||||
"fieldName": "lv",
|
||||
"fieldComment": "角色等级",
|
||||
"fieldType": "int"
|
||||
},
|
||||
{
|
||||
"fieldName": "reason",
|
||||
"fieldComment": "原因",
|
||||
"fieldType": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -31,7 +31,8 @@
|
||||
</style>
|
||||
<script>
|
||||
function changeContent(url) {
|
||||
$('#content_body').attr('data', url);
|
||||
let obj = `<object id="content_body" data="${url}">loading ...</object>`;
|
||||
$('.content').html(obj);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
@@ -43,7 +44,7 @@
|
||||
<object data="nav.html">1</object>
|
||||
</td>
|
||||
<td class="content">
|
||||
<object id="content_body" data="log-table.html?tableName=login">1</object>
|
||||
<object id="content_body">loading ...</object>
|
||||
<td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -37,18 +37,54 @@
|
||||
pageView.remoteGetData(urlQuery);
|
||||
}
|
||||
|
||||
// 用于显示的格式化版本
|
||||
function formatForDisplay(str) {
|
||||
if (typeof str === "string") {
|
||||
return str;
|
||||
}
|
||||
return JSON.stringify(str, null, 2); // 会保留换行和缩进
|
||||
}
|
||||
|
||||
function formatJsonWithNewlines(obj) {
|
||||
if (typeof obj === 'string') {
|
||||
try {
|
||||
obj = JSON.parse(obj);
|
||||
} catch (e) {
|
||||
// 如果解析失败,直接格式化字符串
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
// 使用2个空格进行缩进,自动包含换行符
|
||||
return JSON.stringify(obj, null, 2);
|
||||
}
|
||||
|
||||
function escapeJSString(str) {
|
||||
return formatForDisplay(str).replace(/\\/g, "\\\\")
|
||||
.replace(/'/g, "\\'")
|
||||
.replace(/"/g, "\\\"")
|
||||
.replace(/\n/g, "\\n")
|
||||
.replace(/\r/g, "\\r")
|
||||
.replace(/\t/g, "\\t");
|
||||
}
|
||||
|
||||
function createRow(index, row) {
|
||||
let tr = `<tr>`;
|
||||
for (let i = 0; i < pageView.columnNames.length; i++) {
|
||||
let columnName = pageView.columnNames[i];
|
||||
let columnComment = pageView.columnComments[i];
|
||||
tr += `<td ondblclick="wxd.message.alert('${row[columnName]}', '${columnComment}');">${row[columnName]}</td>`;
|
||||
tr += `<td ondblclick="alertShow(this,'${row[columnComment]}');">${row[columnName]}</td>`;
|
||||
}
|
||||
tr += `</tr>`;
|
||||
return tr;
|
||||
}
|
||||
|
||||
function alertShow(self, title) {
|
||||
let content = $(self).text();
|
||||
content = formatJsonWithNewlines(content);
|
||||
console.log(typeof content, content);
|
||||
wxd.message.alert(`<pre>${content}</pre>`, title);
|
||||
}
|
||||
|
||||
$(() => {
|
||||
wxd.loading();
|
||||
let urlQuery = new wxd.Map().loadSearch();
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import wxdgaming.spring.boot.batis.sql.SqlConfig;
|
||||
import wxdgaming.spring.boot.core.CoreConfiguration;
|
||||
@@ -23,7 +22,6 @@ import wxdgaming.spring.boot.core.InitPrint;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ComponentScan(basePackageClasses = {CoreConfiguration.class})
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "db.sql")
|
||||
@EnableConfigurationProperties
|
||||
@@ -46,10 +44,10 @@ public class MysqlConfiguration implements InitPrint {
|
||||
return new MysqlDataHelper(mysql);
|
||||
}
|
||||
|
||||
@Bean("db.sql.mysql-second")
|
||||
@Bean("mysqlSecond")
|
||||
@ConditionalOnProperty(name = "db.sql.mysql-second.url")
|
||||
public MysqlDataHelper mysqlSecond() {
|
||||
return new MysqlDataHelper(mysql);
|
||||
return new MysqlDataHelper(mysqlSecond);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user