DefaultController.java 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package com.yc.ship.server.controller;
  2. import com.yc.ship.framework.common.pojo.CommonResult;
  3. import com.yc.ship.framework.common.util.servlet.ServletUtils;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RestController;
  7. import javax.annotation.security.PermitAll;
  8. import javax.servlet.http.HttpServletRequest;
  9. import static com.yc.ship.framework.common.exception.enums.GlobalErrorCodeConstants.NOT_IMPLEMENTED;
  10. /**
  11. * 默认 Controller,解决部分 module 未开启时的 404 提示。
  12. * 例如说,/bpm/** 路径,工作流
  13. *
  14. * @author 豪华游轮
  15. */
  16. @RestController
  17. @Slf4j
  18. public class DefaultController {
  19. @RequestMapping("/admin-api/bpm/**")
  20. public CommonResult<Boolean> bpm404() {
  21. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  22. "[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]");
  23. }
  24. @RequestMapping("/admin-api/mp/**")
  25. public CommonResult<Boolean> mp404() {
  26. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  27. "[微信公众号 yudao-module-mp - 已禁用][参考 https://doc.iocoder.cn/mp/build/ 开启]");
  28. }
  29. // @RequestMapping(value = { "/admin-api/product/**", // 商品中心
  30. // "/admin-api/trade/**", // 交易中心
  31. // "/admin-api/promotion/**" }) // 营销中心
  32. // public CommonResult<Boolean> mall404() {
  33. // return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  34. // "[商城系统 yudao-module-mall - 已禁用][参考 https://doc.iocoder.cn/mall/build/ 开启]");
  35. // }
  36. @RequestMapping("/admin-api/erp/**")
  37. public CommonResult<Boolean> erp404() {
  38. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  39. "[ERP 模块 yudao-module-erp - 已禁用][参考 https://doc.iocoder.cn/erp/build/ 开启]");
  40. }
  41. @RequestMapping("/admin-api/crm/**")
  42. public CommonResult<Boolean> crm404() {
  43. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  44. "[CRM 模块 yudao-module-crm - 已禁用][参考 https://doc.iocoder.cn/crm/build/ 开启]");
  45. }
  46. @RequestMapping(value = { "/admin-api/report/**"})
  47. public CommonResult<Boolean> report404() {
  48. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  49. "[报表模块 yudao-module-report - 已禁用][参考 https://doc.iocoder.cn/report/ 开启]");
  50. }
  51. @RequestMapping(value = { "/admin-api/pay/**"})
  52. public CommonResult<Boolean> pay404() {
  53. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  54. "[支付模块 yudao-module-pay - 已禁用][参考 https://doc.iocoder.cn/pay/build/ 开启]");
  55. }
  56. @RequestMapping(value = { "/admin-api/ai/**"})
  57. public CommonResult<Boolean> ai404() {
  58. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  59. "[AI 大模型 yudao-module-ai - 已禁用][参考 https://doc.iocoder.cn/ai/build/ 开启]");
  60. }
  61. @RequestMapping(value = { "/ota-api/iot/**"})
  62. public CommonResult<Boolean> iot404() {
  63. return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  64. "[IoT 物联网 yudao-module-iot - 已禁用][参考 https://doc.iocoder.cn/iot/build/ 开启]");
  65. }
  66. /**
  67. * 测试接口:打印 query、header、body
  68. */
  69. @RequestMapping(value = { "/test" })
  70. @PermitAll
  71. public CommonResult<Boolean> test(HttpServletRequest request) {
  72. // 打印查询参数
  73. log.info("Query: {}", ServletUtils.getParamMap(request));
  74. // 打印请求头
  75. log.info("Header: {}", ServletUtils.getHeaderMap(request));
  76. // 打印请求体
  77. log.info("Body: {}", ServletUtils.getBody(request));
  78. return CommonResult.success(true);
  79. }
  80. }