xiatian 2 năm trước cách đây
mục cha
commit
b0ec5e2529

+ 3 - 3
src/main/java/cn/com/qmth/mps/service/impl/AuthServiceImpl.java

@@ -54,7 +54,7 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 	@Override
 	public AdminLoginVo loginWxAppCode(String loginCode) {
 		JSONObject auth=getAuthorization(loginCode);
-		String openid=auth.getString("openid");
+		String openid=ByteUtil.toHexAscii(SHA256.encode(auth.getString("openid")));
 		WxappInfoEntity wi=wxappInfoService.getByOpenId(openid);
 		if(wi==null) {
 			throw ParameterExceptions.OPENID_NOT_FOUND;
@@ -168,7 +168,7 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 	@Override
 	public AdminLoginVo loginWxAppByEncryptedData(String loginCode, String encryptedData, String iv) {
 		JSONObject auth=getAuthorization(loginCode);
-		String openid=auth.getString("openid");
+		String openid=ByteUtil.toHexAscii(SHA256.encode(auth.getString("openid")));
 		JSONObject jo=decrypt(encryptedData, iv, auth.getString("session_key"));
 		String phone=jo.getString("purePhoneNumber");
 		UserEntity userEntity = userService.getByLoginName(phone);
@@ -283,7 +283,7 @@ public class AuthServiceImpl implements AuthorizationService<User>, AuthService
 			throw new StatusException("该用户不是科组长");
 		}
 		JSONObject auth=getAuthorization(loginCode);
-		String openid=auth.getString("openid");
+		String openid=ByteUtil.toHexAscii(SHA256.encode(auth.getString("openid")));
 		WxappInfoEntity wi=wxappInfoService.getByOpenId(openid);
 		if(wi==null) {
 			wi=new WxappInfoEntity();

+ 8 - 4
src/main/java/cn/com/qmth/mps/service/impl/UserServiceImpl.java

@@ -46,7 +46,7 @@ import cn.com.qmth.mps.vo.user.UserVo;
 
 @Service
 public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements UserService {
-	private static final String defPassWd = "123456";
+	private static final String DEFAULT_PASSWD = "123456";
 
 	@Autowired
 	private UserCourseRelationService userCourseRelationService;
@@ -70,12 +70,15 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(domain.getSchoolId())) {
 			throw new StatusException("非法操作");
 		}
-		if (domain.getName() == null) {
+		if (StringUtils.isBlank(domain.getName())) {
 			throw new StatusException("姓名不能为空");
 		}
-		if (domain.getLoginName() == null) {
+		if (StringUtils.isBlank(domain.getLoginName())) {
 			throw new StatusException("登录名不能为空");
 		}
+		if (domain.getId()== null&&StringUtils.isBlank(domain.getPasswd())) {
+			throw new StatusException("密码不能为空");
+		}
 		if (domain.getRole() == null) {
 			throw new StatusException("角色不能为空");
 		}
@@ -96,7 +99,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 				throw new StatusException("登录名已存在");
 			}
 			ue = new UserEntity();
-			ue.setPassword(ByteUtil.toHexAscii(SHA256.encode(defPassWd)));
+			ue.setPassword(ByteUtil.toHexAscii(SHA256.encode(domain.getPasswd())));
 			ue.setSchoolId(user.getSchoolId());
 			ue.setEnable(true);
 			ue.setLoginName(domain.getLoginName());
@@ -187,6 +190,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 			}
 			for (int i = 0; i < userList.size(); i++) {
 				UserDomain cur = userList.get(i);
+				cur.setPasswd(DEFAULT_PASSWD);
 				try {
 					saveUser(cur, user);
 				} catch (StatusException e) {

+ 10 - 0
src/main/java/cn/com/qmth/mps/vo/user/UserDomain.java

@@ -13,6 +13,8 @@ public class UserDomain {
 	private String name;
 	@ApiModelProperty("登录名")
 	private String loginName;
+	@ApiModelProperty("密码")
+	private String passwd;
 	@ApiModelProperty("科目代码集合")
 	private List<String> course;
 	@ApiModelProperty("角色")
@@ -65,6 +67,14 @@ public class UserDomain {
 	public void setId(Long id) {
 		this.id = id;
 	}
+
+	public String getPasswd() {
+		return passwd;
+	}
+
+	public void setPasswd(String passwd) {
+		this.passwd = passwd;
+	}