TbIndentSmsController.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.sqx.modules.errand.controller;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.sqx.common.exception.SqxException;
  4. import com.sqx.common.utils.PageUtils;
  5. import com.sqx.common.utils.Result;
  6. import com.sqx.modules.errand.dto.SmsCountQueryDTO;
  7. import com.sqx.modules.errand.dto.SmsLogQueryDTO;
  8. import com.sqx.modules.errand.dto.SmsTemplateDTO;
  9. import com.sqx.modules.errand.dto.SmsTemplateQueryDTO;
  10. import com.sqx.modules.errand.service.TbIndentSmsSendLogService;
  11. import com.sqx.modules.errand.service.TbIndentSmsTemplateService;
  12. import io.swagger.annotations.Api;
  13. import io.swagger.annotations.ApiOperation;
  14. import lombok.RequiredArgsConstructor;
  15. import org.springframework.web.bind.annotation.DeleteMapping;
  16. import org.springframework.web.bind.annotation.GetMapping;
  17. import org.springframework.web.bind.annotation.PostMapping;
  18. import org.springframework.web.bind.annotation.PutMapping;
  19. import org.springframework.web.bind.annotation.RequestBody;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RestController;
  22. import javax.validation.Valid;
  23. import java.util.Arrays;
  24. @RestController
  25. @RequestMapping("admin/tb-indent-sms")
  26. @Api(value = "管理端-跑腿确认送达短信", tags = {"管理端-跑腿确认送达短信"})
  27. @RequiredArgsConstructor
  28. public class TbIndentSmsController {
  29. private final TbIndentSmsSendLogService smsSendLogService;
  30. private final TbIndentSmsTemplateService smsTemplateService;
  31. @ApiOperation("模板分页")
  32. @GetMapping(value = "template")
  33. public Result templatePage(SmsTemplateQueryDTO queryDTO) {
  34. PageUtils pageUtils = smsTemplateService.templatePage(queryDTO);
  35. return Result.success().put("data", pageUtils);
  36. }
  37. @ApiOperation("新增模板")
  38. @PostMapping(value = "template")
  39. public Result addTemplate(@Valid @RequestBody SmsTemplateDTO template) {
  40. smsTemplateService.saveTemplate(template);
  41. return Result.success();
  42. }
  43. @ApiOperation("修改模板")
  44. @PutMapping(value = "template")
  45. public Result updateTemplate(@Valid @RequestBody SmsTemplateDTO template) {
  46. if (ObjectUtil.isNull(template.getId())) {
  47. throw new SqxException("模板id不能为空");
  48. }
  49. smsTemplateService.updateTemplate(template);
  50. return Result.success();
  51. }
  52. @ApiOperation("删除模板")
  53. @DeleteMapping(value = "template")
  54. public Result delTemplates(@RequestBody Long[] ids) {
  55. smsTemplateService.removeByIds(Arrays.asList(ids));
  56. return Result.success();
  57. }
  58. @ApiOperation("短信发送记录分页")
  59. @GetMapping(value = "log")
  60. public Result logPage(SmsLogQueryDTO queryDTO) {
  61. PageUtils pageUtils = smsSendLogService.logPage(queryDTO);
  62. return Result.success().put("data", pageUtils);
  63. }
  64. @ApiOperation("短信发送成功数量统计")
  65. @GetMapping(value = "count-of-send-success")
  66. public Result countOfSendSuccess(SmsCountQueryDTO queryDTO) {
  67. int count = smsSendLogService.countOfSendSuccess(queryDTO);
  68. return Result.success().put("data", count);
  69. }
  70. @ApiOperation("删除短信发送记录")
  71. @DeleteMapping(value = "log")
  72. public Result delLogs(@RequestBody Long[] ids) {
  73. smsSendLogService.removeByIds(Arrays.asList(ids));
  74. return Result.success();
  75. }
  76. }