CompanySmsController.java 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package com.fs.company.controller;
  2. import java.util.List;
  3. import com.alibaba.fastjson.JSON;
  4. import com.fs.common.annotation.RepeatSubmit;
  5. import com.fs.company.domain.CompanySmsOrder;
  6. import com.fs.company.dto.CompBuySmsDTO;
  7. import com.fs.company.vo.CompanySmsListVO;
  8. import org.apache.commons.lang.exception.ExceptionUtils;
  9. import org.apache.http.util.Asserts;
  10. import org.springframework.security.access.prepost.PreAuthorize;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.GetMapping;
  13. import org.springframework.web.bind.annotation.PostMapping;
  14. import org.springframework.web.bind.annotation.PutMapping;
  15. import org.springframework.web.bind.annotation.DeleteMapping;
  16. import org.springframework.web.bind.annotation.PathVariable;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RestController;
  20. import com.fs.common.annotation.Log;
  21. import com.fs.common.core.controller.BaseController;
  22. import com.fs.common.core.domain.AjaxResult;
  23. import com.fs.common.enums.BusinessType;
  24. import com.fs.company.domain.CompanySms;
  25. import com.fs.company.service.ICompanySmsService;
  26. import com.fs.common.utils.poi.ExcelUtil;
  27. import com.fs.common.core.page.TableDataInfo;
  28. /**
  29. * 公司短信Controller
  30. *
  31. * @author fs
  32. * @date 2023-01-09
  33. */
  34. @RestController
  35. @RequestMapping("/company/companySms")
  36. public class CompanySmsController extends BaseController
  37. {
  38. @Autowired
  39. private ICompanySmsService companySmsService;
  40. /**
  41. * 查询公司短信列表
  42. */
  43. @PreAuthorize("@ss.hasPermi('company:companySms:list')")
  44. @PostMapping("/buySms")
  45. @RepeatSubmit
  46. public AjaxResult buySms(CompBuySmsDTO compBuySmsDTO){
  47. logger.info("开始执行购买短信接口,请求参数:{}", compBuySmsDTO);
  48. Asserts.notNull(compBuySmsDTO,"充值短信参数不能为空");
  49. Asserts.notNull(compBuySmsDTO.getCompanyId(),"公司id不能为空!");
  50. Asserts.notNull(compBuySmsDTO.getPackageId(),"短信套餐id不能为空!");
  51. CompanySmsOrder companySmsOrder=null;
  52. try{
  53. companySmsOrder = companySmsService.buySms(compBuySmsDTO);
  54. }catch (Exception e){
  55. logger.error("购买短信接口异常,异常信息:{}", ExceptionUtils.getFullStackTrace(e));
  56. throw e;
  57. }
  58. return AjaxResult.success(companySmsOrder);
  59. }
  60. /**
  61. * 查询公司短信列表
  62. */
  63. @PreAuthorize("@ss.hasPermi('company:companySms:list')")
  64. @GetMapping("/list")
  65. public TableDataInfo list(CompanySms companySms)
  66. {
  67. startPage();
  68. List<CompanySmsListVO> list = companySmsService.selectCompanySmsList(companySms);
  69. return getDataTable(list);
  70. }
  71. /**
  72. * 导出公司短信列表
  73. */
  74. @PreAuthorize("@ss.hasPermi('company:companySms:export')")
  75. @Log(title = "公司短信", businessType = BusinessType.EXPORT)
  76. @GetMapping("/export")
  77. public AjaxResult export(CompanySms companySms)
  78. {
  79. List<CompanySmsListVO> list = companySmsService.selectCompanySmsList(companySms);
  80. ExcelUtil<CompanySmsListVO> util = new ExcelUtil<CompanySmsListVO>(CompanySmsListVO.class);
  81. return util.exportExcel(list, "companySms");
  82. }
  83. /**
  84. * 获取公司短信详细信息
  85. */
  86. @PreAuthorize("@ss.hasPermi('company:companySms:query')")
  87. @GetMapping(value = "/{smsId}")
  88. public AjaxResult getInfo(@PathVariable("smsId") Long smsId)
  89. {
  90. return AjaxResult.success(companySmsService.selectCompanySmsById(smsId));
  91. }
  92. /**
  93. * 新增公司短信
  94. */
  95. @PreAuthorize("@ss.hasPermi('company:companySms:add')")
  96. @Log(title = "公司短信", businessType = BusinessType.INSERT)
  97. @PostMapping
  98. public AjaxResult add(@RequestBody CompanySms companySms)
  99. {
  100. return toAjax(companySmsService.insertCompanySms(companySms));
  101. }
  102. /**
  103. * 修改公司短信
  104. */
  105. @PreAuthorize("@ss.hasPermi('company:companySms:edit')")
  106. @Log(title = "公司短信", businessType = BusinessType.UPDATE)
  107. @PutMapping
  108. public AjaxResult edit(@RequestBody CompanySms companySms)
  109. {
  110. return toAjax(companySmsService.updateCompanySms(companySms));
  111. }
  112. /**
  113. * 删除公司短信
  114. */
  115. @PreAuthorize("@ss.hasPermi('company:companySms:remove')")
  116. @Log(title = "公司短信", businessType = BusinessType.DELETE)
  117. @DeleteMapping("/{smsIds}")
  118. public AjaxResult remove(@PathVariable Long[] smsIds)
  119. {
  120. return toAjax(companySmsService.deleteCompanySmsByIds(smsIds));
  121. }
  122. }