|
|
@@ -24,8 +24,11 @@ import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
+import com.goafanti.common.enums.UserAbilityFields;
|
|
|
+import com.goafanti.common.enums.UserCareerFields;
|
|
|
+import com.goafanti.common.enums.UserEduFields;
|
|
|
import com.goafanti.common.enums.UserIdentityFields;
|
|
|
-import com.goafanti.common.model.AftUser;
|
|
|
+import com.goafanti.common.enums.UserInfoBoFields;
|
|
|
import com.goafanti.common.model.OrgHumanResource;
|
|
|
import com.goafanti.common.model.OrganizationIdentity;
|
|
|
import com.goafanti.common.model.OrganizationInfo;
|
|
|
@@ -43,6 +46,9 @@ 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.InputUserAbility;
|
|
|
+import com.goafanti.user.bo.InputUserCareer;
|
|
|
+import com.goafanti.user.bo.InputUserEdu;
|
|
|
import com.goafanti.user.bo.InputUserIdentity;
|
|
|
import com.goafanti.user.bo.OrgIdentityBo;
|
|
|
import com.goafanti.user.bo.OrgProBo;
|
|
|
@@ -322,43 +328,27 @@ public class UserApiController extends BaseApiController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/userInfo", method = RequestMethod.POST)
|
|
|
- public Result personalData(UserInfoBo userInfoBo, BindingResult bindingResult) {
|
|
|
+ public Result personalData(@Valid UserInfoBo userInfoBo, BindingResult bindingResult) {
|
|
|
Result res = new Result();
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
- bindingResult.getFieldError().getField()));
|
|
|
+ UserInfoBoFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
return res;
|
|
|
}
|
|
|
if (res.getError().isEmpty()) {
|
|
|
- UserInfo info = userInfoService.selectUserInfoByUserId(TokenManager.getUserId());
|
|
|
User u = userService.selectByPrimaryKey(TokenManager.getUserId());
|
|
|
u.setNickname(userInfoBo.getNickname());
|
|
|
u.setEmail(userInfoBo.getEmail());
|
|
|
userService.updateByPrimaryKeySelective(u);
|
|
|
- AftUser user = TokenManager.getToken();
|
|
|
- if(user instanceof User) {
|
|
|
- ((User)user).setNickname(userInfoBo.getNickname());
|
|
|
- }
|
|
|
- UserInfo userInfo = new UserInfo();
|
|
|
- userInfo.setResidenceProvince(userInfoBo.getResidenceProvince());
|
|
|
- userInfo.setResidenceCity(userInfoBo.getResidenceCity());
|
|
|
- userInfo.setResidenceArea(userInfoBo.getResidenceArea());
|
|
|
- userInfo.setPersonPortraitUrl(userInfoBo.getPersonPortraitUrl());
|
|
|
- userInfo.setPersonalProfile(userInfoBo.getPersonalProfile());
|
|
|
- userInfo.setLifePhotoUrl(userInfoBo.getLifePhotoUrl());
|
|
|
- userInfo.setFixedTelArea(userInfoBo.getFixedTelArea());
|
|
|
- userInfo.setFixedTel(userInfoBo.getFixedTel());
|
|
|
- userInfo.setFixedTelExtension(userInfoBo.getFixedTelExtension());
|
|
|
- userInfo.setQq(userInfoBo.getQq());
|
|
|
- userInfo.setPostalAddress(userInfoBo.getPostalAddress());
|
|
|
- userInfo.setPostcode(userInfoBo.getPostcode());
|
|
|
- if (info == null) {
|
|
|
- userInfo.setId(UUID.randomUUID().toString());
|
|
|
- userInfo.setUid(TokenManager.getUserId());
|
|
|
- userInfoService.insert(userInfo);
|
|
|
+
|
|
|
+ UserInfo ui = new UserInfo();
|
|
|
+ BeanUtils.copyProperties(userInfoBo, ui);
|
|
|
+ if (StringUtils.isBlank(ui.getId())) {
|
|
|
+ ui.setId(UUID.randomUUID().toString());
|
|
|
+ ui.setUid(TokenManager.getUserId());
|
|
|
+ userInfoService.insert(ui);
|
|
|
} else {
|
|
|
- userInfo.setId(info.getId());
|
|
|
- userInfoService.updateByPrimaryKeySelective(userInfo);
|
|
|
+ userInfoService.updateByPrimaryKeySelective(ui);
|
|
|
}
|
|
|
}
|
|
|
res.setData(userInfoBo);
|
|
|
@@ -372,17 +362,23 @@ public class UserApiController extends BaseApiController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/userEdu", method = RequestMethod.POST)
|
|
|
- public Result educationInfo(UserEdu userEdu) {
|
|
|
+ public Result educationInfo(@Valid InputUserEdu userEdu, BindingResult bindingResult) {
|
|
|
Result res = new Result();
|
|
|
- UserEdu edu = userEduService.selectUserEduByUserId(TokenManager.getUserId());
|
|
|
-
|
|
|
- if (edu == null) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ UserEduFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserEdu ue = new UserEdu();
|
|
|
+ BeanUtils.copyProperties(userEdu, ue);
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(ue.getId())) {
|
|
|
userEdu.setId(UUID.randomUUID().toString());
|
|
|
userEdu.setUid(TokenManager.getUserId());
|
|
|
- userEduService.insert(userEdu);
|
|
|
+ userEduService.insert(ue);
|
|
|
} else {
|
|
|
- userEdu.setId(edu.getId());
|
|
|
- userEduService.updateByPrimaryKeySelective(userEdu);
|
|
|
+ userEduService.updateByPrimaryKeySelective(ue);
|
|
|
}
|
|
|
res.setData(userEdu);
|
|
|
return res;
|
|
|
@@ -396,17 +392,23 @@ public class UserApiController extends BaseApiController {
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = "/userCareer", method = RequestMethod.POST)
|
|
|
- public Result careerInfo(UserCareer userCareer) {
|
|
|
+ public Result careerInfo(@Valid InputUserCareer userCareer, BindingResult bindingResult) {
|
|
|
Result res = new Result();
|
|
|
- UserCareer career = userCareerService.selectUserCareerByUserId(TokenManager.getUserId());
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ UserCareerFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ UserCareer uc = new UserCareer();
|
|
|
+ BeanUtils.copyProperties(userCareer, uc);
|
|
|
+
|
|
|
|
|
|
- if (career == null) {
|
|
|
- userCareer.setId(UUID.randomUUID().toString());
|
|
|
- userCareer.setUid(TokenManager.getUserId());
|
|
|
- userCareerService.insert(userCareer);
|
|
|
+ if (StringUtils.isBlank(uc.getId())) {
|
|
|
+ uc.setId(UUID.randomUUID().toString());
|
|
|
+ uc.setUid(TokenManager.getUserId());
|
|
|
+ userCareerService.insert(uc);
|
|
|
} else {
|
|
|
- userCareer.setId(career.getId());
|
|
|
- userCareerService.updateByPrimaryKeySelective(userCareer);
|
|
|
+ userCareerService.updateByPrimaryKeySelective(uc);
|
|
|
}
|
|
|
res.setData(userCareer);
|
|
|
return res;
|
|
|
@@ -420,16 +422,21 @@ public class UserApiController extends BaseApiController {
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = "/userAbility", method = RequestMethod.POST)
|
|
|
- public Result abilityLabel(UserAbility userAbility) {
|
|
|
+ public Result abilityLabel(@Valid InputUserAbility userAbility, BindingResult bindingResult) {
|
|
|
Result res = new Result();
|
|
|
- UserAbility ability = userAbilityService.selectUserAbilityByUserId(TokenManager.getUserId());
|
|
|
- if (ability == null) {
|
|
|
- userAbility.setId(UUID.randomUUID().toString());
|
|
|
- userAbility.setUid(TokenManager.getUserId());
|
|
|
- userAbilityService.insert(userAbility);
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
|
|
|
+ UserAbilityFields.getFieldDesc(bindingResult.getFieldError().getField())));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ UserAbility ua = new UserAbility();
|
|
|
+ BeanUtils.copyProperties(userAbility, ua);
|
|
|
+ if (StringUtils.isBlank(ua.getId())) {
|
|
|
+ ua.setId(UUID.randomUUID().toString());
|
|
|
+ ua.setUid(TokenManager.getUserId());
|
|
|
+ userAbilityService.insert(ua);
|
|
|
} else {
|
|
|
- userAbility.setId(ability.getId());
|
|
|
- userAbilityService.updateByPrimaryKeySelective(userAbility);
|
|
|
+ userAbilityService.updateByPrimaryKeySelective(ua);
|
|
|
}
|
|
|
res.setData(userAbility);
|
|
|
return res;
|