|
@@ -3,13 +3,20 @@ package com.tianhu.system.controller;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.keao.tianhu.core.entity.R;
|
|
|
import com.tianhu.common.core.web.controller.BaseController;
|
|
|
-import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.common.core.web.domain.AjaxResult;
|
|
|
+import com.tianhu.common.log.annotation.Log;
|
|
|
+import com.tianhu.common.log.enums.BusinessType;
|
|
|
+import com.tianhu.common.redis.common.RedisUtils;
|
|
|
import com.tianhu.system.common.IMessageUtilsService;
|
|
|
+import com.tianhu.system.common.ValidateCodeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -24,6 +31,8 @@ public class MessageController extends BaseController
|
|
|
{
|
|
|
@Autowired
|
|
|
private IMessageUtilsService iMessageUtilsService;
|
|
|
+ @Autowired
|
|
|
+ private ValidateCodeService validateCodeService;
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -40,4 +49,18 @@ public class MessageController extends BaseController
|
|
|
iMessageUtilsService.sendMessageCode(mobileNo, templateCode, param, random);
|
|
|
return R.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Log(title = "发送短信", businessType = BusinessType.INSERT)
|
|
|
+ @Transactional(rollbackFor=Exception.class)
|
|
|
+ @PostMapping("/sendShortMessage")
|
|
|
+ public AjaxResult sendShortMessage(@RequestBody Map<String, String> requestBody) throws Exception {
|
|
|
+ validateCodeService.checkCapcha(requestBody.get("imgCode"), requestBody.get("uuid"), false);
|
|
|
+ String random = iMessageUtilsService.genRandomNum(6);
|
|
|
+ Map<String, String> param = new HashMap<>();
|
|
|
+ param.put("code", random);
|
|
|
+ // 获取注册模板ID
|
|
|
+ String templateCode = RedisUtils.getDictValue("aliyun_message_code", "zhuce");
|
|
|
+ iMessageUtilsService.sendMessageCode(requestBody.get("phone"), templateCode, param, random);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
}
|