|
|
@@ -8,8 +8,10 @@ import java.util.UUID;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -21,6 +23,7 @@ import com.goafanti.cognizance.service.OrgRatepayService;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
+import com.goafanti.common.enums.UserIdentityFields;
|
|
|
import com.goafanti.common.model.AftUser;
|
|
|
import com.goafanti.common.model.OrgHumanResource;
|
|
|
import com.goafanti.common.model.OrganizationIdentity;
|
|
|
@@ -39,6 +42,7 @@ import com.goafanti.common.utils.TimeUtils;
|
|
|
import com.goafanti.common.utils.VerifyCodeUtils;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.techproject.service.TechWebsiteService;
|
|
|
+import com.goafanti.user.bo.InputUserIdentity;
|
|
|
import com.goafanti.user.bo.OrgIdentityBo;
|
|
|
import com.goafanti.user.bo.OrgProBo;
|
|
|
import com.goafanti.user.bo.UidAndTypeBo;
|
|
|
@@ -145,7 +149,27 @@ public class UserApiController extends BaseApiController {
|
|
|
this.cleanCodeSession();
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(newPwd)){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新密码"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(mobile)){
|
|
|
+ res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "", "mobile"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (1 != type || 0 != type){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_PATTERN_ERROR, "", "type"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
User user = userService.selectByMobieAndType(mobile, type);
|
|
|
+ if (null == user){
|
|
|
+ res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "", "mobile"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
user.setPassword(newPwd);
|
|
|
user.setPassword(passwordUtil.getEncryptPwd(user));
|
|
|
userService.updateByPrimaryKey(user);
|
|
|
@@ -162,6 +186,12 @@ public class UserApiController extends BaseApiController {
|
|
|
@RequestMapping(value = "/checkMCode", method = RequestMethod.POST)
|
|
|
public Result checkMCode(String mobileCode) {
|
|
|
Result res = new Result();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(mobileCode)){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "手机验证码"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
if (TimeUtils.checkOverTime("register")) {
|
|
|
res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
|
|
|
TokenManager.getSession().removeAttribute(VerifyCodeUtils.M_CODE);
|
|
|
@@ -191,6 +221,11 @@ public class UserApiController extends BaseApiController {
|
|
|
res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "手机号不能为空!"));
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(mobileCode)){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "手机验证码"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
// 验证码15分钟有效
|
|
|
if (TimeUtils.checkOverTime("register")) {
|
|
|
res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
|
|
|
@@ -220,22 +255,22 @@ public class UserApiController extends BaseApiController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/userIndentity", method = RequestMethod.POST)
|
|
|
- public Result basicInfo(UserIdentity userIdentity, BindingResult bindingResult) {
|
|
|
+ public Result basicInfo(@Valid InputUserIdentity userIdentity, BindingResult bindingResult) {
|
|
|
Result res = new Result();
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
- bindingResult.getFieldError().getField()));
|
|
|
+ UserIdentityFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
return res;
|
|
|
}
|
|
|
if (res.getError().isEmpty()) {
|
|
|
- UserIdentity identity = userIdentityService.selectUserIdentityByUserId(TokenManager.getUserId());
|
|
|
- if (identity == null) {
|
|
|
- userIdentity.setId(UUID.randomUUID().toString());
|
|
|
- userIdentity.setUid(TokenManager.getUserId());
|
|
|
- userIdentityService.insert(userIdentity);
|
|
|
+ UserIdentity ui = new UserIdentity();
|
|
|
+ BeanUtils.copyProperties(userIdentity, ui);
|
|
|
+ if (null == ui.getId()) {
|
|
|
+ ui.setId(UUID.randomUUID().toString());
|
|
|
+ ui.setUid(TokenManager.getUserId());
|
|
|
+ userIdentityService.insert(ui);
|
|
|
} else {
|
|
|
- userIdentity.setId(identity.getId());
|
|
|
- userIdentityService.updateByPrimaryKeySelective(userIdentity);
|
|
|
+ userIdentityService.updateByPrimaryKeySelective(ui);
|
|
|
}
|
|
|
}
|
|
|
res.setData(userIdentity);
|