|
@@ -92,6 +92,11 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
private FileUploadConfig fileUploadConfig;
|
|
private FileUploadConfig fileUploadConfig;
|
|
|
@Resource
|
|
@Resource
|
|
|
private ISysOssService sysOssService;
|
|
private ISysOssService sysOssService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IGameEventConfigService gameEventConfigService;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${game-event.large-screen-url:http://localhost:5173/}")
|
|
|
|
|
+ private String largeScreenUrlPrefix;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 更新赛事小程序码
|
|
* 更新赛事小程序码
|
|
@@ -233,16 +238,49 @@ public class GameEventServiceImpl implements IGameEventService {
|
|
|
@Override
|
|
@Override
|
|
|
public Long insertByBo(GameEventBo bo) {
|
|
public Long insertByBo(GameEventBo bo) {
|
|
|
GameEvent add = MapstructUtils.convert(bo, GameEvent.class);
|
|
GameEvent add = MapstructUtils.convert(bo, GameEvent.class);
|
|
|
|
|
+ if (add == null) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
if (flag) {
|
|
|
// 生成微信小程序二维码并设置到赛事链接
|
|
// 生成微信小程序二维码并设置到赛事链接
|
|
|
generateEventQrCode(add);
|
|
generateEventQrCode(add);
|
|
|
|
|
+ // 自动生成赛事大屏网址配置
|
|
|
|
|
+ saveLargeScreenUrlConfig(add.getEventId());
|
|
|
return add.getEventId();
|
|
return add.getEventId();
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 自动生成并保存赛事大屏网址配置项
|
|
|
|
|
+ * @param eventId 赛事ID
|
|
|
|
|
+ */
|
|
|
|
|
+ private void saveLargeScreenUrlConfig(Long eventId) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ GameEventConfigBo configBo = new GameEventConfigBo();
|
|
|
|
|
+ configBo.setEventId(eventId);
|
|
|
|
|
+ configBo.setConfigType("API");
|
|
|
|
|
+ configBo.setConfigKey("large_screen_url");
|
|
|
|
|
+ configBo.setConfigDesc("赛事大屏网页地址");
|
|
|
|
|
+
|
|
|
|
|
+ // 规范化前缀,确保以 / 结尾
|
|
|
|
|
+ String prefix = largeScreenUrlPrefix;
|
|
|
|
|
+ if (prefix != null && !prefix.endsWith("/")) {
|
|
|
|
|
+ prefix += "/";
|
|
|
|
|
+ }
|
|
|
|
|
+ configBo.setConfigValue(prefix + "?tournament_id=" + eventId);
|
|
|
|
|
+ configBo.setIsEnabled("0");
|
|
|
|
|
+ configBo.setStatus("0");
|
|
|
|
|
+
|
|
|
|
|
+ gameEventConfigService.insertByBo(configBo);
|
|
|
|
|
+ log.info("成功为赛事[{}]生成默认大屏网页地址配置", eventId);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("生成默认大屏网页地址配置失败: {}", e.getMessage(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 微信相关常量
|
|
// 微信相关常量
|
|
|
private static final String ACCESS_TOKEN_KEY = "wechat:access_token";
|
|
private static final String ACCESS_TOKEN_KEY = "wechat:access_token";
|
|
|
@Value("${wechat.miniapp.access-token-expires:}")
|
|
@Value("${wechat.miniapp.access-token-expires:}")
|