TbIndentSmsController.java 3.2 KB

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