hjl
2024-07-05 428519bd1056dd90cd4589dbf85b380e403ff254
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
86
87
88
89
90
91
92
93
94
95
package com.ruoyi.admin.controller;
 
import com.ruoyi.admin.entity.Order;
import com.ruoyi.admin.service.OrderService;
import com.ruoyi.admin.service.SendSmsService;
import com.ruoyi.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
 
/**
 * @author HJL
 * @version 1.0
 * @since 2024-05-30 15:28
 */
@RestController
@RequestMapping("/sendSms")
@Api(tags = {"发送短信"})
public class SendSmsController {
 
    @Resource
    private SendSmsService sendSmsService;
    @Resource
    private OrderService orderService;
 
    /**
     * 发送派单短信给用户
     *
     * @param orderId 订单记录id
     */
    @ApiOperation(value = "后台-发送派单短信", tags = {"发送短信"})
    @GetMapping(value = "/dispatchSms")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单记录id", name = "orderId", dataType = "Integer", required = true)
    })
    public R<Object> dispatchSms(@RequestParam Integer orderId) {
        Order order = orderService.lambdaQuery()
                .eq(Order::getId, orderId)
                .eq(Order::getIsDelete, 0).one();
        if (null == order) {
            return R.fail("订单不存在或已删除!");
        }
        return R.ok(sendSmsService.dispatchOrder(order));
    }
 
    /**
     * 用户端-发送登录验证码短信
     *
     * @param phone 订单记录id
     */
    @ApiOperation(value = "用户端-发送登录验证码短信", tags = {"发送短信"})
    @GetMapping(value = "/userLoginSms")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号", name = "phone", dataType = "String", required = true)
    })
    public R<Object> userLoginSms(@RequestParam String phone) {
        return R.ok(sendSmsService.userLoginSms(phone));
    }
 
    /**
     * 师傅端-找回密码/验证手机号/验证码登录
     *
     * @param phone 订单记录id
     */
    @ApiOperation(value = "师傅端-找回密码/验证手机号/验证码登录短信", tags = {"发送短信"})
    @GetMapping(value = "/workerLoginSms")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号", name = "phone", dataType = "String", required = true)
    })
    public R<String> workerLoginSms(@RequestParam String phone) {
        return R.ok(sendSmsService.workerLoginSms(phone));
    }
 
    /**
     * 师傅端-发送登录验证码短信
     *
     * @param phone 订单记录id
     */
    @ApiOperation(value = "师傅端-发送入驻验证码短信", tags = {"发送短信"})
    @GetMapping(value = "/workerSettleSms")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "手机号", name = "phone", dataType = "String", required = true)
    })
    public R<String> workerSettleSms(@RequestParam String phone) {
        return R.ok(sendSmsService.workerSettleSms(phone));
    }
 
}