校验用户昵称
This commit is contained in:
parent
e2366a91a1
commit
d686a68afa
@ -23,4 +23,6 @@ public interface UserMapper extends Mapper<User> {
|
||||
Integer updateUserRole(@Param("idUser") Integer idUser, @Param("idRole") Integer idRole);
|
||||
|
||||
Integer updateStatus(@Param("idUser") Integer idUser, @Param("status") String status);
|
||||
|
||||
Integer selectCountByNickName(@Param("nickname") String nickname);
|
||||
}
|
@ -58,7 +58,9 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
} else {
|
||||
user = new User();
|
||||
user.setAccount(email);
|
||||
user.setNickname(email.split("@")[0]);
|
||||
String nickname = email.split("@")[0];
|
||||
nickname = checkNickname(nickname);
|
||||
user.setNickname(nickname);
|
||||
user.setEmail(email);
|
||||
user.setPassword(Utils.entryptPassword(password));
|
||||
user.setCreatedTime(new Date());
|
||||
@ -76,6 +78,14 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
||||
return map;
|
||||
}
|
||||
|
||||
private String checkNickname(String nickname) {
|
||||
Integer result = userMapper.selectCountByNickName(nickname);
|
||||
if (result > 0) {
|
||||
return checkNickname(nickname + System.currentTimeMillis());
|
||||
}
|
||||
return nickname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map login(String account, String password) {
|
||||
Map map = new HashMap(1);
|
||||
|
@ -63,5 +63,8 @@
|
||||
<select id="selectRoleWeightsByUser" resultType="java.lang.Integer">
|
||||
select vr.weights from vertical_role vr left join vertical_user_role vur on vr.id = vur.id_role where vur.id_user = #{idUser}
|
||||
</select>
|
||||
<select id="selectCountByNickName" resultType="java.lang.Integer">
|
||||
select count(*) from vertical_user where nickname = #{nickname}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user