Commit 20884119b08f227fe2f7f98d5e0523c23d445cb1

Authored by 云中非
1 parent b6e996f2

fix(DEFECT-762): 邮件发送失败弹出提示框

... ... @@ -10,6 +10,8 @@ import org.thingsboard.server.common.data.yunteng.common.AddGroup;
10 10 import org.thingsboard.server.common.data.yunteng.common.DeleteGroup;
11 11 import org.thingsboard.server.common.data.yunteng.common.UpdateGroup;
12 12 import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
  13 +import org.thingsboard.server.common.data.yunteng.core.exception.YtDataValidationException;
  14 +import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
13 15 import org.thingsboard.server.common.data.yunteng.dto.DeleteDTO;
14 16 import org.thingsboard.server.common.data.yunteng.dto.MessageTemplateDTO;
15 17 import org.thingsboard.server.common.data.yunteng.dto.request.EmailReqDTO;
... ... @@ -92,15 +94,19 @@ public class YtMessageTemplateController extends BaseController {
92 94 public ResponseResult<String> sendSms(
93 95 @Validated({AddGroup.class}) @RequestBody SmsReqDTO smsReqDTO) {
94 96 boolean result = smsService.sendSms(smsReqDTO);
95   - String message = result ? ResponseCodeEnum.SUCCESS.name() : ResponseCodeEnum.FAILED.name();
96   - return ResponseResult.success(message);
  97 + if(!result){
  98 + throw new YtDataValidationException(ErrorMessage.MESSAGE_SEND_FAILED.getMessage());
  99 + }
  100 + return ResponseResult.success(ResponseCodeEnum.SUCCESS.name() );
97 101 }
98 102
99 103 @PostMapping("/send_email")
100 104 public ResponseResult<String> sendEmail(
101 105 @Validated({AddGroup.class}) @RequestBody EmailReqDTO emailReqDTO) {
102 106 boolean result = mailService.sendEmail(emailReqDTO);
103   - String message = result ? ResponseCodeEnum.SUCCESS.name() : ResponseCodeEnum.FAILED.name();
104   - return ResponseResult.success(message);
  107 + if(!result){
  108 + throw new YtDataValidationException(ErrorMessage.MESSAGE_SEND_FAILED.getMessage());
  109 + }
  110 + return ResponseResult.success(ResponseCodeEnum.SUCCESS.name() );
105 111 }
106 112 }
... ...
... ... @@ -80,6 +80,7 @@ public enum ErrorMessage {
80 80 DATA_BOARD_IS_PRIVATE(400057,"该数据看板不是公有视图"),
81 81 MESSAGE_SEND_TOO_FAST(400058,"1分钟内请求次数过多,请休息一下!"),
82 82 PASSWORD_INCORRECT(4010059, "密码错误!"),
  83 + MESSAGE_SEND_FAILED(4010059, "消息发送失败!"),
83 84 HAVE_NO_PERMISSION(500002,"没有修改权限");
84 85 private final int code;
85 86 private String message;
... ...