Parcourir la source

Accept Merge Request #95 merge : (master -> test)

Merge Request: merge
Created By: @Antiloveg
Accepted By: @Antiloveg
URL: https://coding.net/t/aft/p/AFT/git/merge/95
Antiloveg il y a 9 ans
Parent
commit
5970142880

+ 16 - 8
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -80,6 +80,7 @@ import com.goafanti.common.enums.OrgTechCenterFields;
 import com.goafanti.common.enums.OrgTechProductFields;
 import com.goafanti.common.enums.OrganizationIdentityFields;
 import com.goafanti.common.enums.UserAbilityFields;
+import com.goafanti.common.enums.UserFields;
 import com.goafanti.common.enums.UserIdentityFields;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.OrgActivity;
@@ -107,6 +108,7 @@ import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.user.bo.InputOrganizationIdentity;
+import com.goafanti.user.bo.InputUser;
 import com.goafanti.user.bo.InputUserAbility;
 import com.goafanti.user.bo.InputUserIdentity;
 import com.goafanti.user.bo.OrgListBo;
@@ -434,20 +436,26 @@ public class AdminApiController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/addNewUser", method = RequestMethod.POST)
-	public Result addNewUser(String mobile, Integer type, String unitName) {
+	public Result addNewUser(@Valid InputUser inputUser, BindingResult bindingResult) {
 		Result res = new Result();
+		
+		if (bindingResult.hasErrors()) {
+			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
+					UserFields.getFieldDesc(bindingResult.getFieldError().getField())));
+			return res;
+		}
 
-		if (StringUtils.isBlank(mobile)) {
+		if (StringUtils.isBlank(inputUser.getMobile())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "mobile", "mobile"));
 			return res;
 		}
 
-		if (null == type) {
+		if (null == inputUser.getType()) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "type", "type"));
 			return res;
 		}
 
-		User user = userService.selectByMobieAndType(mobile.trim(), type);
+		User user = userService.selectByMobieAndType(inputUser.getMobile().trim(), inputUser.getType());
 		if (null != user) {
 			res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "当前用户已注册!"));
 			return res;
@@ -455,16 +463,16 @@ public class AdminApiController extends CertifyApiController {
 
 		User u = new User();
 		u.setId(UUID.randomUUID().toString());
-		u.setMobile(mobile.trim());
-		u.setPassword(mobile.trim());
-		u.setType(type);
+		u.setMobile(inputUser.getMobile().trim());
+		u.setPassword(inputUser.getMobile().trim());
+		u.setType(inputUser.getType());
 		Calendar now = Calendar.getInstance();
 		now.set(Calendar.MILLISECOND, 0);
 		u.setCreateTime(now.getTime());
 		u.setPassword(passwordUtil.getEncryptPwd(u));
 		u.setLvl(0);
 		u.setAid(TokenManager.getAdminId());
-		userService.insertRegister(u, "", unitName);
+		userService.insertRegister(u, "", inputUser.getUnitName());
 		return res;
 	}
 

+ 55 - 0
src/main/java/com/goafanti/common/enums/OrganizationTechFields.java

@@ -0,0 +1,55 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum OrganizationTechFields {
+	
+	UID("uid", "用户id"),
+	TECHNICALPEOPLENUM("technicalPeopleNum", "技术人员数量"),
+	SEARCHAREACATEGORY("searchAreaCategory", "重点研究领域类别"),
+	SEARCHAREADET("searchAreaDet", "重点研究领域明细"),
+	SPECIALTY("specialty", "擅长领域"),
+	
+	OTHER("", "未知参数");
+	
+	private String	code;
+	private String	desc;
+	
+	private static Map<String, OrganizationTechFields> status = new HashMap<String, OrganizationTechFields>();
+	
+	private OrganizationTechFields(String code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+	
+	static {
+		for (OrganizationTechFields value : OrganizationTechFields.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+	
+	public static OrganizationTechFields getField(String code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+	
+	public static String getFieldDesc(String code) {
+		return getField(code).getDesc();
+	}
+
+	public static boolean containsType(String code) {
+		return status.containsKey(code);
+	}
+	
+	public String getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+}

+ 52 - 0
src/main/java/com/goafanti/common/enums/UserFields.java

@@ -0,0 +1,52 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum UserFields {
+	MOBILE("mobile", "手机号"),
+	TYPE("type", "用户类别"),
+	UNITNAME("unitName", "公司名称"),
+	
+	OTHER("", "未知参数");
+	
+	private String	code;
+	private String	desc;
+	
+	private static Map<String, UserFields> status = new HashMap<String, UserFields>();
+	
+	private UserFields(String code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+	
+	static {
+		for (UserFields value : UserFields.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+	
+	public static UserFields getField(String code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+	
+	public static String getFieldDesc(String code) {
+		return getField(code).getDesc();
+	}
+
+	public static boolean containsType(String code) {
+		return status.containsKey(code);
+	}
+	
+	public String getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+}

+ 76 - 0
src/main/java/com/goafanti/user/bo/InputOrganizationTech.java

@@ -0,0 +1,76 @@
+package com.goafanti.user.bo;
+
+import javax.validation.constraints.Size;
+
+import com.goafanti.common.constant.ErrorConstants;
+
+public class InputOrganizationTech {
+	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	id;
+	
+	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	uid;
+
+	@Size(min = 0, max = 12, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	technicalPeopleNum;
+
+	@Size(min = 0, max = 255, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	searchAreaCategory;
+
+	@Size(min = 0, max = 32, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+
+	private String	searchAreaDet;
+
+	@Size(min = 0, max = 32, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String	specialty;
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	public String getTechnicalPeopleNum() {
+		return technicalPeopleNum;
+	}
+
+	public void setTechnicalPeopleNum(String technicalPeopleNum) {
+		this.technicalPeopleNum = technicalPeopleNum;
+	}
+
+	public String getSearchAreaCategory() {
+		return searchAreaCategory;
+	}
+
+	public void setSearchAreaCategory(String searchAreaCategory) {
+		this.searchAreaCategory = searchAreaCategory;
+	}
+
+	public String getSearchAreaDet() {
+		return searchAreaDet;
+	}
+
+	public void setSearchAreaDet(String searchAreaDet) {
+		this.searchAreaDet = searchAreaDet;
+	}
+
+	public String getSpecialty() {
+		return specialty;
+	}
+
+	public void setSpecialty(String specialty) {
+		this.specialty = specialty;
+	}
+	
+	
+}

+ 63 - 0
src/main/java/com/goafanti/user/bo/InputUser.java

@@ -0,0 +1,63 @@
+package com.goafanti.user.bo;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+import com.goafanti.common.constant.ErrorConstants;
+
+public class InputUser {
+	
+	@Size(min = 0, max = 11, message = "{" + ErrorConstants.MOBILE_SIZE_ERROR + "}")
+	@Pattern(regexp = "^([1-9])\\d{10}$", message = "{" + ErrorConstants.MOBILE_PATTERN_ERROR + "}")
+	private String mobile;
+	
+	@Max(value = 1, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer type;
+	
+	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String unitName;
+	
+	@Size(min = 0, max = 45, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
+	private String password;
+
+	public String getMobile() {
+		return mobile;
+	}
+
+	public void setMobile(String mobile) {
+		this.mobile = mobile;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public String getUnitName() {
+		return unitName;
+	}
+
+	public void setUnitName(String unitName) {
+		this.unitName = unitName;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	
+	
+	
+	
+
+}

+ 91 - 77
src/main/java/com/goafanti/user/controller/UserApiController.java

@@ -26,6 +26,7 @@ import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.enums.OrgProFields;
 import com.goafanti.common.enums.OrganizationIdentityFields;
+import com.goafanti.common.enums.OrganizationTechFields;
 import com.goafanti.common.enums.UserAbilityFields;
 import com.goafanti.common.enums.UserCareerFields;
 import com.goafanti.common.enums.UserEduFields;
@@ -49,6 +50,7 @@ import com.goafanti.common.utils.VerifyCodeUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.techproject.service.TechWebsiteService;
 import com.goafanti.user.bo.InputOrgPro;
+import com.goafanti.user.bo.InputOrganizationTech;
 import com.goafanti.user.bo.InputUserAbility;
 import com.goafanti.user.bo.InputUserCareer;
 import com.goafanti.user.bo.InputUserEdu;
@@ -100,9 +102,9 @@ public class UserApiController extends BaseApiController {
 	@Resource
 	private OrgHumanResourceService			orgHumanResourceService;
 	@Resource
-	private TechWebsiteService  techWebsiteService;
+	private TechWebsiteService				techWebsiteService;
 	@Resource
-	private OrgRatepayService  orgRatepayService;
+	private OrgRatepayService				orgRatepayService;
 
 	/**
 	 * 修改密码
@@ -159,24 +161,24 @@ public class UserApiController extends BaseApiController {
 			this.cleanCodeSession();
 			return res;
 		}
-		
-		if (StringUtils.isBlank(newPwd)){
+
+		if (StringUtils.isBlank(newPwd)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "新密码"));
 			return res;
 		}
-		
-		if (StringUtils.isBlank(mobile)){
+
+		if (StringUtils.isBlank(mobile)) {
 			res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "", "mobile"));
 			return res;
 		}
-		
-		if (1 != type || 0 != type){
+
+		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){
+		if (null == user) {
 			res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "", "mobile"));
 			return res;
 		}
@@ -196,12 +198,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)){
+
+		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);
@@ -231,8 +233,8 @@ public class UserApiController extends BaseApiController {
 			res.getError().add(buildError(ErrorConstants.MOBILE_EMPTY_ERROR, "手机号不能为空!"));
 			return res;
 		}
-		
-		if (StringUtils.isBlank(mobileCode)){
+
+		if (StringUtils.isBlank(mobileCode)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "", "手机验证码"));
 			return res;
 		}
@@ -343,7 +345,7 @@ public class UserApiController extends BaseApiController {
 			u.setNickname(userInfoBo.getNickname());
 			u.setEmail(userInfoBo.getEmail());
 			userService.updateByPrimaryKeySelective(u);
-			
+
 			UserInfo ui = new UserInfo();
 			BeanUtils.copyProperties(userInfoBo, ui);
 			if (StringUtils.isBlank(ui.getId())) {
@@ -372,10 +374,10 @@ public class UserApiController extends BaseApiController {
 					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());
@@ -404,7 +406,6 @@ public class UserApiController extends BaseApiController {
 		}
 		UserCareer uc = new UserCareer();
 		BeanUtils.copyProperties(userCareer, uc);
-		
 
 		if (StringUtils.isBlank(uc.getId())) {
 			uc.setId(UUID.randomUUID().toString());
@@ -489,7 +490,7 @@ public class UserApiController extends BaseApiController {
 					OrgProFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
 		}
-		
+
 		OrganizationInfo oi = new OrganizationInfo();
 		OrganizationProperties op = new OrganizationProperties();
 		BeanUtils.copyProperties(pro, oi);
@@ -508,17 +509,23 @@ public class UserApiController extends BaseApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/orgTech", method = RequestMethod.POST)
-	public Result tech(OrganizationTech orgTech, BindingResult bindingResult) {
+	public Result tech(@Valid InputOrganizationTech orgTech, BindingResult bindingResult) {
 		Result res = new Result();
-		OrganizationTech tech = organizationTechService.selectOrgTechByUserId(TokenManager.getUserId());
-		if (tech == null) {
-			orgTech.setId(UUID.randomUUID().toString());
-			orgTech.setUid(TokenManager.getUserId());
-			organizationTechService.insert(orgTech);
+		if (bindingResult.hasErrors()) {
+			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
+					OrganizationTechFields.getFieldDesc(bindingResult.getFieldError().getField())));
+			return res;
+		}
+
+		OrganizationTech ot = new OrganizationTech();
+		BeanUtils.copyProperties(orgTech, ot);
+		if (StringUtils.isBlank(ot.getId())) {
+			ot.setId(UUID.randomUUID().toString());
+			ot.setUid(TokenManager.getUserId());
+			organizationTechService.insert(ot);
 
 		} else {
-			orgTech.setId(tech.getId());
-			organizationTechService.updateByPrimaryKeySelective(orgTech);
+			organizationTechService.updateByPrimaryKeySelective(ot);
 		}
 		res.setData(orgTech);
 		return res;
@@ -533,7 +540,7 @@ public class UserApiController extends BaseApiController {
 	public Result basic() {
 		Result res = new Result();
 		UidAndTypeBo ub = basicInfo(userService);
-		if (ub.getType() == 0) {
+		if (null != ub && ub.getType() == 0) {
 			UserIdentityBo u = userIdentityService.selectUserIdentityBoByUserId(ub.getUid());
 			res.setData(u);
 		} else {
@@ -552,7 +559,7 @@ public class UserApiController extends BaseApiController {
 	public Result member() {
 		Result res = new Result();
 		UidAndTypeBo ub = basicInfo(userService);
-		if (ub.getType() == 0) {
+		if (null != ub && ub.getType() == 0) {
 			UserInfoBo u = userInfoService.selectUserInfoBoByUserId(ub.getUid());
 			res.setData(u);
 		} else {
@@ -573,8 +580,10 @@ public class UserApiController extends BaseApiController {
 	public Result educate() {
 		Result res = new Result();
 		UidAndTypeBo ub = basicInfo(userService);
-		UserEdu u = userEduService.selectUserEduByUserId(ub.getUid());
-		res.setData(u);
+		if (null != ub) {
+			UserEdu u = userEduService.selectUserEduByUserId(ub.getUid());
+			res.setData(u);
+		}
 		return res;
 	}
 
@@ -587,7 +596,7 @@ public class UserApiController extends BaseApiController {
 	public Result job() {
 		Result res = new Result();
 		UidAndTypeBo ub = basicInfo(userService);
-		if (ub.getType() == 0) {
+		if (null != ub && ub.getType() == 0) {
 			UserCareer u = userCareerService.selectUserCareerByUserId(ub.getUid());
 			res.setData(u);
 		} else {
@@ -606,18 +615,21 @@ public class UserApiController extends BaseApiController {
 	public Result ability() {
 		Result res = new Result();
 		UidAndTypeBo ub = basicInfo(userService);
-		UserAbility u = userAbilityService.selectUserAbilityByUserId(ub.getUid());
-		res.setData(u);
+		if (null != ub) {
+			UserAbility u = userAbilityService.selectUserAbilityByUserId(ub.getUid());
+			res.setData(u);
+		}
 		return res;
 	}
-    
+
 	/**
 	 * 团体人力资源情况入口
+	 * 
 	 * @return
 	 */
 	@RequestMapping(value = "/humanResource", method = RequestMethod.GET)
 	@ResponseBody
-	public Result humanResource(Integer year, String pageNo, String pageSize ) {
+	public Result humanResource(Integer year, String pageNo, String pageSize) {
 		Result res = new Result();
 		res = checkCertify(res);
 		if (res.getError().isEmpty()) {
@@ -633,18 +645,19 @@ public class UserApiController extends BaseApiController {
 		}
 		return res;
 	}
-	
+
 	/**
 	 * 团体人力资源情况修改保存(用户端)
+	 * 
 	 * @param orgHumanResource
 	 * @return
 	 */
 	@RequestMapping(value = "/SaveHumanResource", method = RequestMethod.POST)
-	public Result SaveHumanResource(OrgHumanResource orgHumanResource){
+	public Result SaveHumanResource(OrgHumanResource orgHumanResource) {
 		Result res = new Result();
-		if (null == orgHumanResource.getId()){
+		if (null == orgHumanResource.getId()) {
 			if (null != orgHumanResourceService.selectOrgHumanResourceByUidAndYear(orgHumanResource.getYear(),
-					orgHumanResource.getUid())){
+					orgHumanResource.getUid())) {
 				res.getError().add(buildError(ErrorConstants.DUPLICATE_DATA_ERROR, "当年度人力资源情况已录入!"));
 				return res;
 			}
@@ -657,12 +670,13 @@ public class UserApiController extends BaseApiController {
 		}
 		return res;
 	}
-	
+
 	/**
 	 * 删除团体人力资源
+	 * 
 	 * @return
 	 */
-	public Result deleteHumanResource(@RequestParam(name = "ids[]", required = true) String[] ids){
+	public Result deleteHumanResource(@RequestParam(name = "ids[]", required = true) String[] ids) {
 		Result res = new Result();
 		List<String> id = new ArrayList<String>();
 		for (String s : ids) {
@@ -754,7 +768,7 @@ public class UserApiController extends BaseApiController {
 			if (0 != (u.getAmountMoney().compareTo(userIdentity.getAmountMoney()))) {
 				int t = 3 - u.getWrongCount() - 1;
 				u.setWrongCount(u.getWrongCount() + 1);
-				
+
 				if (0 == t) {
 					u.setAuditStatus(4);
 					u.setProcess(5);
@@ -784,21 +798,21 @@ public class UserApiController extends BaseApiController {
 
 	/**
 	 * 团体实名认证流程下一步
-	 * @throws ParseException 
+	 * 
+	 * @throws ParseException
 	 */
 	@RequestMapping(value = "/orgNextPro", method = RequestMethod.POST)
-	public Result orgNextProcess(OrganizationIdentity orgIdentity, String listedDateFormattedDate, String verificationCode) throws ParseException {
+	public Result orgNextProcess(OrganizationIdentity orgIdentity, String listedDateFormattedDate,
+			String verificationCode) throws ParseException {
 		Result res = new Result();
 		if (1 == orgIdentity.getProcess()) {
 			if (!TokenManager.getSession().getAttribute(VerifyCodeUtils.V_CODE).equals(verificationCode)) {
 				res.getError().add(buildError(ErrorConstants.VCODE_ERROR, "验证码错误"));
 				return res;
 			}
-			if (!StringUtils.isBlank(listedDateFormattedDate)){
+			if (!StringUtils.isBlank(listedDateFormattedDate)) {
 				orgIdentity.setListedDate(DateUtils.parseDate(listedDateFormattedDate, AFTConstants.YYYYMMDD));
 			}
-			/*res.setData(organizationIdentityService.saveLastYearTaxReprotUrl(orgIdentity, TokenManager.getUserId()));
-			return res;*/
 		}
 		if (3 == orgIdentity.getProcess()) {
 			OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
@@ -859,36 +873,35 @@ public class UserApiController extends BaseApiController {
 	@RequestMapping(value = "/adminConfirmIdent", method = RequestMethod.POST)
 	public Result adminConfirmIdent(Integer auditStatus, BigDecimal money, String uid) {
 		Result res = new Result();
-		if (0 == userService.selectByPrimaryKey(uid).getType()) {
-			UserIdentity u = userIdentityService.selectUserIdentityByUserId(uid);
-			u.setAuditStatus(auditStatus);
-			u.setAmountMoney(money);
-			res.setData(userIdentityService.updateByPrimaryKeySelective(u));
-		} else {
-			OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(uid);
-			o.setAuditStatus(auditStatus);
-			o.setValidationAmount(money);
-			res.setData(organizationIdentityService.updateByPrimaryKeySelective(o));
+		User user = userService.selectByPrimaryKey(uid);
+		if (null != user) {
+			if (0 == user.getType()) {
+				UserIdentity u = userIdentityService.selectUserIdentityByUserId(uid);
+				u.setAuditStatus(auditStatus);
+				u.setAmountMoney(money);
+				res.setData(userIdentityService.updateByPrimaryKeySelective(u));
+			} else {
+				OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(uid);
+				o.setAuditStatus(auditStatus);
+				o.setValidationAmount(money);
+				res.setData(organizationIdentityService.updateByPrimaryKeySelective(o));
+			}
 		}
 		return res;
 	}
-	
-	
-	
-	
+
 	/**
 	 * 获取公司联系人
+	 * 
 	 * @param uid
 	 * @return
 	 */
 	@RequestMapping(value = "/getContacts", method = RequestMethod.GET)
-	public Result getContacts(){
+	public Result getContacts() {
 		Result res = new Result();
 		res.setData(organizationIdentityService.selectContactsByUserId(TokenManager.getUserId()));
 		return res;
 	}
-	
-	
 
 	// 认证失败清除相关认证信息
 	private Result dealFaild(Result res) {
@@ -938,20 +951,21 @@ public class UserApiController extends BaseApiController {
 	private UidAndTypeBo basicInfo(UserService userService) {
 		User u = userService.selectByPrimaryKey(TokenManager.getUserId());
 		UidAndTypeBo ub = new UidAndTypeBo();
-		ub.setType(u.getType());
-		ub.setUid(u.getId());
+		if (null != u) {
+			ub.setType(u.getType());
+			ub.setUid(u.getId());
+		}
 		return ub;
 	}
-	
+
 	// 判断用户是否通过认证
-		private Result checkCertify(Result res) {
-			OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
-			if (null == o || 5 != o.getAuditStatus()) {
-				res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
-			}
-			
-			return res;
+	private Result checkCertify(Result res) {
+		OrganizationIdentity o = organizationIdentityService.selectOrgIdentityByUserId(TokenManager.getUserId());
+		if (null == o || 5 != o.getAuditStatus()) {
+			res.getError().add(buildError(ErrorConstants.NON_CERTIFIED, "未通过实名认证,无法操作!"));
 		}
-	
+
+		return res;
+	}
 
 }

+ 18 - 13
src/main/java/com/goafanti/user/controller/UserRegisterController.java

@@ -4,6 +4,7 @@ import java.util.Calendar;
 import java.util.UUID;
 
 import javax.annotation.Resource;
+import javax.validation.Valid;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
@@ -17,11 +18,13 @@ import com.goafanti.admin.service.AdminService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseController;
+import com.goafanti.common.enums.UserFields;
 import com.goafanti.common.model.User;
 import com.goafanti.common.utils.PasswordUtil;
 import com.goafanti.common.utils.TimeUtils;
 import com.goafanti.common.utils.VerifyCodeUtils;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.user.bo.InputUser;
 import com.goafanti.user.service.UserService;
 
 @Controller
@@ -44,15 +47,14 @@ public class UserRegisterController extends BaseController {
 	 */
 	@RequestMapping(value = "/register", method = RequestMethod.POST)
 	@ResponseBody
-	public Result register(User user, String companyName, String contacts, String mobileCode,
+	public Result register(@Valid InputUser user, String companyName, String contacts, String mobileCode,
 			BindingResult bindingResult) {
 		Result res = new Result();
-		/*String sessVCode = (String) TokenManager.getSession().getAttribute(VerifyCodeUtils.V_CODE);
-		if (sessVCode == null || !sessVCode.equalsIgnoreCase(verificationCode)) {
-			logger.info("input vcode:" + verificationCode + "| sess vcode:" + sessVCode);
-			res.getError().add(buildError(ErrorConstants.VCODE_ERROR, "验证码错误"));
+		if (bindingResult.hasErrors()) {
+			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
+					UserFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
-		}*/
+		}
 		// 验证码15分钟有效
 		if (TimeUtils.checkOverTime("register")) {
 			res.getError().add(buildError(ErrorConstants.MCODE_OVERTIME_ERROR, "手机验证码超时失效"));
@@ -78,13 +80,16 @@ public class UserRegisterController extends BaseController {
 			}
 		}
 		if (res.getError().isEmpty()) {
-			user.setId(UUID.randomUUID().toString());
-			user.setMobile(user.getMobile().trim());
+			User us = new User();
+			us.setId(UUID.randomUUID().toString());
+			us.setMobile(user.getMobile().trim());
+			us.setType(user.getType());
+			us.setPassword(user.getPassword());
 			Calendar now = Calendar.getInstance();
 			now.set(Calendar.MILLISECOND, 0);
-			user.setCreateTime(now.getTime());
-			user.setPassword(passwordUtil.getEncryptPwd(user));
-			user.setLvl(0);
+			us.setCreateTime(now.getTime());
+			us.setPassword(passwordUtil.getEncryptPwd(us));
+			us.setLvl(0);
 			/*
 			List<Admin> admins = adminService.selectAllAdmin();
 			if (!admins.isEmpty()) {
@@ -92,8 +97,8 @@ public class UserRegisterController extends BaseController {
 				user.setAid(admins.get(0).getId());// 随机分配管理员
 			}
 			*/
-			user.setAid("2");//ID为"2"的管理员
-			userService.insertRegister(user, contacts, companyName);
+			us.setAid("2");//ID为"2"的管理员
+			userService.insertRegister(us, contacts, companyName);
 		}
 
 		return res;