Commit 105f1a27076119afbc4ca917987ed99b7597ff19
1 parent
1f3794db
fix: banner 日志打印
Showing
4 changed files
with
77 additions
and
9 deletions
yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/core/BannerApplicationRunner.java
| ... | ... | @@ -17,20 +17,18 @@ import java.util.concurrent.TimeUnit; |
| 17 | 17 | public class BannerApplicationRunner implements ApplicationRunner { |
| 18 | 18 | |
| 19 | 19 | @Override |
| 20 | - public void run(ApplicationArguments args) throws Exception { | |
| 20 | + public void run(ApplicationArguments args) { | |
| 21 | 21 | ThreadUtil.execute(() -> { |
| 22 | 22 | ThreadUtil.sleep(1, TimeUnit.SECONDS); // 延迟 1 秒,保证输出到结尾 |
| 23 | 23 | log.info("\n----------------------------------------------------------\n\t" + |
| 24 | 24 | "项目启动成功!\n\t" + |
| 25 | 25 | "接口文档: \t{} \n\t" + |
| 26 | 26 | "开发文档: \t{} \n\t" + |
| 27 | - "视频教程: \t{} \n\t" + | |
| 28 | - "源码解析: \t{} \n" + | |
| 27 | + "视频教程: \t{} \n" + | |
| 29 | 28 | "----------------------------------------------------------", |
| 30 | 29 | "https://doc.iocoder.cn/api-doc/", |
| 31 | 30 | "https://doc.iocoder.cn", |
| 32 | - "https://t.zsxq.com/02Yf6M7Qn", | |
| 33 | - "https://t.zsxq.com/02B6ujIee"); | |
| 31 | + "https://t.zsxq.com/02Yf6M7Qn"); | |
| 34 | 32 | |
| 35 | 33 | // 数据报表 |
| 36 | 34 | if (isNotPresent("cn.iocoder.yudao.module.report.framework.security.config.SecurityConfiguration")) { |
| ... | ... | @@ -44,11 +42,11 @@ public class BannerApplicationRunner implements ApplicationRunner { |
| 44 | 42 | if (isNotPresent("cn.iocoder.yudao.module.mp.framework.mp.config.MpConfiguration")) { |
| 45 | 43 | System.out.println("[微信公众号 yudao-module-mp - 已禁用][参考 https://doc.iocoder.cn/mp/build/ 开启]"); |
| 46 | 44 | } |
| 47 | - // 商城 | |
| 45 | + // 商城系统 | |
| 48 | 46 | if (isNotPresent("cn.iocoder.yudao.module.trade.framework.web.config.TradeWebConfiguration")) { |
| 49 | 47 | System.out.println("[商城系统 yudao-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]"); |
| 50 | 48 | } |
| 51 | - // 支付 | |
| 49 | + // 支付平台 | |
| 52 | 50 | if (isNotPresent("cn.iocoder.yudao.module.pay.framework.pay.config.PayConfiguration")) { |
| 53 | 51 | System.out.println("[支付系统 yudao-module-pay - 已禁用][参考 https://doc.iocoder.cn/pay/build/ 开启]"); |
| 54 | 52 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.web.core.handler; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.exceptions.ExceptionUtil; |
| 4 | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | +import cn.hutool.core.util.StrUtil; | |
| 5 | 6 | import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog; |
| 6 | 7 | import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| ... | ... | @@ -219,6 +220,13 @@ public class GlobalExceptionHandler { |
| 219 | 220 | */ |
| 220 | 221 | @ExceptionHandler(value = Exception.class) |
| 221 | 222 | public CommonResult<?> defaultExceptionHandler(HttpServletRequest req, Throwable ex) { |
| 223 | + // 情况一:处理表不存在的异常 | |
| 224 | + CommonResult<?> tableNotExistsResult = handleTableNotExists(ex); | |
| 225 | + if (tableNotExistsResult != null) { | |
| 226 | + return tableNotExistsResult; | |
| 227 | + } | |
| 228 | + | |
| 229 | + // 情况二:处理异常 | |
| 222 | 230 | log.error("[defaultExceptionHandler]", ex); |
| 223 | 231 | // 插入异常日志 |
| 224 | 232 | this.createExceptionLog(req, ex); |
| ... | ... | @@ -269,4 +277,48 @@ public class GlobalExceptionHandler { |
| 269 | 277 | errorLog.setExceptionTime(LocalDateTime.now()); |
| 270 | 278 | } |
| 271 | 279 | |
| 280 | + /** | |
| 281 | + * 处理 Table 不存在的异常情况 | |
| 282 | + * | |
| 283 | + * @param ex 异常 | |
| 284 | + * @return 如果是 Table 不存在的异常,则返回对应的 CommonResult | |
| 285 | + */ | |
| 286 | + private CommonResult<?> handleTableNotExists(Throwable ex) { | |
| 287 | + String message = ExceptionUtil.getRootCauseMessage(ex); | |
| 288 | + if (!message.contains("doesn't exist")) { | |
| 289 | + return null; | |
| 290 | + } | |
| 291 | + // 1. 数据报表 | |
| 292 | + if (message.contains("report_")) { | |
| 293 | + log.error("[报表模块 yudao-module-report - 表结构未导入][参考 https://doc.iocoder.cn/report/ 开启]"); | |
| 294 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), | |
| 295 | + "[报表模块 yudao-module-report - 表结构未导入][参考 https://doc.iocoder.cn/report/ 开启]"); | |
| 296 | + } | |
| 297 | + // 2. 工作流 | |
| 298 | + if (message.contains("bpm_")) { | |
| 299 | + log.error("[工作流模块 yudao-module-bpm - 表结构未导入][参考 https://doc.iocoder.cn/bpm/ 开启]"); | |
| 300 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), | |
| 301 | + "[工作流模块 yudao-module-bpm - 表结构未导入][参考 https://doc.iocoder.cn/bpm/ 开启]"); | |
| 302 | + } | |
| 303 | + // 3. 微信公众号 | |
| 304 | + if (message.contains("mp_")) { | |
| 305 | + log.error("[微信公众号 yudao-module-mp - 表结构未导入][参考 https://doc.iocoder.cn/mp/build/ 开启]"); | |
| 306 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), | |
| 307 | + "[微信公众号 yudao-module-mp - 表结构未导入][参考 https://doc.iocoder.cn/mp/build/ 开启]"); | |
| 308 | + } | |
| 309 | + // 4. 商城系统 | |
| 310 | + if (StrUtil.containsAny(message, "product_", "promotion_", "trade_")) { | |
| 311 | + log.error("[商城系统 yudao-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]"); | |
| 312 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), | |
| 313 | + "[商城系统 yudao-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]"); | |
| 314 | + } | |
| 315 | + // 5. 支付平台 | |
| 316 | + if (message.contains("pay_")) { | |
| 317 | + log.error("[支付模块 yudao-module-pay - 表结构未导入][参考 https://doc.iocoder.cn/pay/build/ 开启]"); | |
| 318 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), | |
| 319 | + "[支付模块 yudao-module-pay - 表结构未导入][参考 https://doc.iocoder.cn/pay/build/ 开启]"); | |
| 320 | + } | |
| 321 | + return null; | |
| 322 | + } | |
| 323 | + | |
| 272 | 324 | } | ... | ... |
yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/account/MpAccountServiceImpl.java
| ... | ... | @@ -27,6 +27,7 @@ import org.springframework.validation.annotation.Validated; |
| 27 | 27 | import javax.annotation.PostConstruct; |
| 28 | 28 | import javax.annotation.Resource; |
| 29 | 29 | import java.time.LocalDateTime; |
| 30 | +import java.util.Collections; | |
| 30 | 31 | import java.util.List; |
| 31 | 32 | import java.util.Map; |
| 32 | 33 | import java.util.concurrent.TimeUnit; |
| ... | ... | @@ -68,7 +69,15 @@ public class MpAccountServiceImpl implements MpAccountService { |
| 68 | 69 | // 注意:忽略自动多租户,因为要全局初始化缓存 |
| 69 | 70 | TenantUtils.executeIgnore(() -> { |
| 70 | 71 | // 第一步:查询数据 |
| 71 | - List<MpAccountDO> accounts = mpAccountMapper.selectList(); | |
| 72 | + List<MpAccountDO> accounts = Collections.emptyList(); | |
| 73 | + try { | |
| 74 | + accounts = mpAccountMapper.selectList(); | |
| 75 | + } catch (Throwable ex) { | |
| 76 | + if (!ex.getMessage().contains("doesn't exist")) { | |
| 77 | + throw ex; | |
| 78 | + } | |
| 79 | + log.error("[微信公众号 yudao-module-mp - 表结构未导入][参考 https://doc.iocoder.cn/mp/build/ 开启]"); | |
| 80 | + } | |
| 72 | 81 | log.info("[initLocalCacheIfUpdate][缓存公众号账号,数量为:{}]", accounts.size()); |
| 73 | 82 | |
| 74 | 83 | // 第二步:构建缓存。创建或更新支付 Client | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java
| ... | ... | @@ -27,6 +27,7 @@ import javax.annotation.Resource; |
| 27 | 27 | import javax.validation.Validator; |
| 28 | 28 | import java.time.LocalDateTime; |
| 29 | 29 | import java.util.Collection; |
| 30 | +import java.util.Collections; | |
| 30 | 31 | import java.util.List; |
| 31 | 32 | import java.util.concurrent.TimeUnit; |
| 32 | 33 | |
| ... | ... | @@ -64,7 +65,15 @@ public class PayChannelServiceImpl implements PayChannelService { |
| 64 | 65 | // 注意:忽略自动多租户,因为要全局初始化缓存 |
| 65 | 66 | TenantUtils.executeIgnore(() -> { |
| 66 | 67 | // 第一步:查询数据 |
| 67 | - List<PayChannelDO> channels = channelMapper.selectList(); | |
| 68 | + List<PayChannelDO> channels = Collections.emptyList(); | |
| 69 | + try { | |
| 70 | + channels = channelMapper.selectList(); | |
| 71 | + } catch (Throwable ex) { | |
| 72 | + if (!ex.getMessage().contains("doesn't exist")) { | |
| 73 | + throw ex; | |
| 74 | + } | |
| 75 | + log.error("[支付模块 yudao-module-pay - 表结构未导入][参考 https://doc.iocoder.cn/pay/build/ 开启]"); | |
| 76 | + } | |
| 68 | 77 | log.info("[initLocalCache][缓存支付渠道,数量为:{}]", channels.size()); |
| 69 | 78 | |
| 70 | 79 | // 第二步:构建缓存:创建或更新支付 Client | ... | ... |