CommonApi.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package com.ydd.app.controller;
  2. import com.ydd.app.dto.FeedbackDto;
  3. import com.ydd.app.service.ApiExplainService;
  4. import com.ydd.app.service.ApiFeedbackService;
  5. import com.ydd.common.annotation.AccessToken;
  6. import com.ydd.common.annotation.NoSign;
  7. import com.ydd.common.core.controller.BaseController;
  8. import com.ydd.common.core.domain.BaseResult;
  9. import com.ydd.common.oss.cloud.CloudStorageConfig;
  10. import com.ydd.common.oss.cloud.OSSFactory;
  11. import com.ydd.module.domain.Help;
  12. import com.ydd.module.domain.Version;
  13. import com.ydd.module.dto.HelpDetailDto;
  14. import com.ydd.module.dto.HelpDto;
  15. import com.ydd.module.service.IHelpColumnService;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiImplicitParam;
  18. import io.swagger.annotations.ApiImplicitParams;
  19. import io.swagger.annotations.ApiOperation;
  20. import lombok.RequiredArgsConstructor;
  21. import org.apache.commons.io.FilenameUtils;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.web.bind.annotation.*;
  24. import org.springframework.web.multipart.MultipartFile;
  25. import java.util.HashMap;
  26. import java.util.List;
  27. import java.util.Map;
  28. import static com.ydd.module.enums.ExceptionEnum.FILE_UPLOAD_ERROR;
  29. /**
  30. * 通用接口
  31. * @author douya
  32. */
  33. @Api(value = "通用接口", tags = {"通用接口"})
  34. @RestController
  35. @RequestMapping("/app/common")
  36. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  37. @NoSign
  38. public class CommonApi extends BaseController {
  39. private final CloudStorageConfig cloudStorageConfig;
  40. private final ApiFeedbackService apiFeedbackService;
  41. private final ApiExplainService apiExplainService;
  42. private final IHelpColumnService iHelpColumnService;
  43. /**
  44. * 通用上传请求
  45. */
  46. @ApiOperation("通用上传请求")
  47. @PostMapping("/upload")
  48. public BaseResult<Map<String,Object>> uploadFile(MultipartFile file) {
  49. try {
  50. String suffix = FilenameUtils.getExtension(file.getOriginalFilename());
  51. String url = OSSFactory.build(cloudStorageConfig).uploadSuffix(file.getInputStream(), "." + suffix);
  52. Map<String,Object> result = new HashMap<>();
  53. result.put("fileName", file.getOriginalFilename());
  54. result.put("url", url);
  55. return BaseResult.success(result);
  56. } catch (Exception e) {
  57. logger.error("上传异常",e);
  58. return BaseResult.error(FILE_UPLOAD_ERROR.MSG);
  59. }
  60. }
  61. /**
  62. * 意见反馈
  63. */
  64. @ApiOperation("意见反馈")
  65. @RequestMapping(value = "/feedback", method = RequestMethod.POST)
  66. @AccessToken
  67. public BaseResult feedback(FeedbackDto feedbackDto) {
  68. apiFeedbackService.feedback(getLoginId(), feedbackDto);
  69. return BaseResult.success();
  70. }
  71. /**
  72. * 系统设置说明
  73. */
  74. @ApiOperation("系统设置说明")
  75. @ApiImplicitParams({
  76. @ApiImplicitParam(required = true, paramType = "query", name = "type", value = "类型【1 招商合作配置(富文本)】【2 客服企业微信(图片上传)】【3 客服电话(文本框)】【4 《用户协议》】【5 《隐私政策》】【6 《充值协议》】")
  77. })
  78. @RequestMapping(value = "/explain", method = RequestMethod.GET)
  79. public BaseResult<String> explain(@RequestParam("type") Integer type) {
  80. return BaseResult.success("OK",apiExplainService.explain(type));
  81. }
  82. @ApiOperation("版本控制")
  83. @ApiImplicitParams({
  84. @ApiImplicitParam(required = true, paramType = "query", name = "type", value = "类型【1 Android】【2 ios】")
  85. })
  86. @RequestMapping(value = "/version", method = RequestMethod.GET)
  87. public BaseResult<Version> version(@RequestParam("type") Integer type) {
  88. return BaseResult.success("ok", apiExplainService.selectVersion(type));
  89. }
  90. /**
  91. * 帮助中心
  92. */
  93. @ApiOperation("帮助中心栏目")
  94. @RequestMapping(value = "/help", method = RequestMethod.GET)
  95. public BaseResult<List<HelpDto>> help(@RequestParam("type") Integer type) {
  96. return BaseResult.success("OK",iHelpColumnService.getAll(type));
  97. }
  98. /**
  99. * 帮助中心
  100. */
  101. @ApiOperation("帮助中心")
  102. @RequestMapping(value = "/help_detail", method = RequestMethod.GET)
  103. @ApiImplicitParams({
  104. @ApiImplicitParam(required = true, paramType = "query", name = "secondColumnId", value = "二级栏目id"),
  105. @ApiImplicitParam(required = false, paramType = "query", name = "'platformType", value = "PC/APP")
  106. })
  107. public BaseResult<List<HelpDetailDto>> helpDetail(@RequestParam("secondColumnId")Integer secondColumnId,
  108. @RequestHeader(name = "platformType",required = false)String platformType) {
  109. return BaseResult.success("OK",iHelpColumnService.getHelpDetail(secondColumnId,platformType));
  110. }
  111. }