cloudroam
2024-12-30 b9903ead016b8b1aa68eb04b48fca3b53fdab0d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.mzl.flower.web.v2.sms;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.dto.request.sms.SmsTaskDTO;
import com.mzl.flower.dto.request.sms.SmsTaskQueryDTO;
import com.mzl.flower.dto.response.coupon.CouponTemplateUserVO;
import com.mzl.flower.dto.response.coupon.CouponTemplateVO;
import com.mzl.flower.dto.response.sms.SmsSelectVO;
import com.mzl.flower.dto.response.sms.SmsTaskVO;
import com.mzl.flower.service.sms.SmsTaskService;
import com.mzl.flower.utils.ConverterUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.constraints.NotNull;
import java.io.IOException;
 
 
/**
* @author @TaoJie
* @since 2024-12-25
*/
@Api(value = "短信任务管理", tags = "短信任务管理")
@RestController
@RequestMapping("/v2/sms-task")
@RequiredArgsConstructor
public class SmsTaskController extends BaseController {
 
    private final SmsTaskService smsTaskService;
 
    @PostMapping("/new")
    @ApiOperation(value = "保存短信任务", httpMethod = "POST")
    public ResponseEntity<ReturnDataDTO> create(@RequestBody SmsTaskDTO smsTaskDTO) throws IOException {
        smsTaskService.saveSmsTask(smsTaskDTO);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @PostMapping(value = "/edit")
    @ApiOperation(value = "更新短信任务", httpMethod = "POST")
    public ResponseEntity<ReturnDataDTO> update(@RequestBody SmsTaskDTO smsTaskDTO) throws IOException {
        smsTaskService.updateSmsTask(smsTaskDTO);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping(value = "/delete")
    @ApiOperation(value = "删除短信任务 ", httpMethod = "GET", notes = "ID")
    public ResponseEntity<ReturnDataDTO> delete(@NotNull(message = "id不能为空") Long id) {
        smsTaskService.deleteSmsTask(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list")
    @ApiOperation(value = "短信任务列表", httpMethod = "GET")
    public ResponseEntity<ReturnDataDTO<Page<SmsTaskVO>>> getSmsTaskList(Page page, SmsTaskQueryDTO dto) {
        return returnData(R.SUCCESS.getCode(), smsTaskService.queryPage(dto, page));
    }
 
    @PostMapping("/publish")
    @ApiOperation(value = "发布短信任务", httpMethod = "POST")
    public ResponseEntity<ReturnDataDTO> publish(@RequestBody SmsTaskDTO smsTaskDTO) {
        smsTaskService.publishSmsTask(smsTaskDTO);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/select/{id}")
    @ApiOperation(value = "任务筛选详情列表", httpMethod = "GET")
    public ResponseEntity<ReturnDataDTO<SmsSelectVO>> selectList(@PathVariable(name = "id") Long id) {
        return returnData(R.SUCCESS.getCode(), smsTaskService.getSelectList(id));
    }
 
 
    @GetMapping("/{id}")
    @ApiOperation(value = "详情", notes = "详情")
    public ResponseEntity<ReturnDataDTO> get(@PathVariable Long id) {
        SmsTaskVO smsTaskVO = smsTaskService.getDetailById(id);
        return returnData(R.SUCCESS.getCode(), smsTaskVO);
    }
 
}