|
@@ -10,6 +10,7 @@ import com.jpsoft.smart.modules.common.utils.SMSUtil;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -23,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/mobile/personInfoApi")
|
|
@@ -83,8 +85,6 @@ public class PersonInfoApiController {
|
|
|
return messageResult;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@PostMapping("getVerifyCode")
|
|
|
@ApiOperation(value="获取短信验证码")
|
|
|
@ApiImplicitParams({
|
|
@@ -97,14 +97,23 @@ public class PersonInfoApiController {
|
|
|
PersonInfo personInfo = personInfoService.get(personId);
|
|
|
|
|
|
if(personInfo!=null){
|
|
|
- throw new Exception("人员编号不存在@");
|
|
|
+ throw new Exception("人员编号不存在!");
|
|
|
}
|
|
|
|
|
|
- String verifyCode = SMSUtil.generateNumberString(6);
|
|
|
- JSONObject verifyCodeJSON = new JSONObject();
|
|
|
- verifyCodeJSON.put("code", verifyCode);
|
|
|
+ String key = "SMS_" + personId;
|
|
|
+
|
|
|
+ String verifyCode = (String)valueOperations.get(key);
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(verifyCode)) {
|
|
|
+ verifyCode = SMSUtil.generateNumberString(6);
|
|
|
+ JSONObject verifyCodeJSON = new JSONObject();
|
|
|
+ verifyCodeJSON.put("code", verifyCode);
|
|
|
|
|
|
- messageResult = SMSUtil.send(personInfo.getPhone(), "SMS_49390047", verifyCodeJSON.toString());
|
|
|
+ messageResult = SMSUtil.send(personInfo.getPhone(), "SMS_49390047", verifyCodeJSON.toString());
|
|
|
+
|
|
|
+ //设置当前用户的验证码,60秒后过期
|
|
|
+ valueOperations.set(key, verifyCode, 60000, TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex){
|
|
|
messageResult.setResult(false);
|
|
@@ -138,4 +147,33 @@ public class PersonInfoApiController {
|
|
|
|
|
|
return messageResult;
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("save")
|
|
|
+ @ApiOperation(value="保存照片信息")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="personId",value = "人员编号",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name="openId",value = "微信openId",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name="photoUrl",value = "照片地址",required = true,paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<String> save(Long personId,String photoUrl){
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ PersonInfo personInfo = personInfoService.get(personId);
|
|
|
+
|
|
|
+ if (personInfo==null){
|
|
|
+ throw new Exception("人员信息不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error(e.getMessage(),e);
|
|
|
+
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
}
|