fix:用户昵称作为一校验,用户新增、编辑和导入都增加校验
This commit is contained in:
parent
b8b709b019
commit
effd939522
@ -123,6 +123,10 @@ public class SysUserController extends BaseController
|
|||||||
{
|
{
|
||||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
}
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(user.getNickName())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkNickNameUnique(user))) {
|
||||||
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,昵称已存在");
|
||||||
|
}
|
||||||
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
|
||||||
{
|
{
|
||||||
@ -153,6 +157,10 @@ public class SysUserController extends BaseController
|
|||||||
{
|
{
|
||||||
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
}
|
}
|
||||||
|
else if (StringUtils.isNotEmpty(user.getNickName())
|
||||||
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkNickNameUnique(user))) {
|
||||||
|
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,昵称已存在");
|
||||||
|
}
|
||||||
else if (StringUtils.isNotEmpty(user.getEmail())
|
else if (StringUtils.isNotEmpty(user.getEmail())
|
||||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="selectWmStorageLocationVo"/>
|
<include refid="selectWmStorageLocationVo"/>
|
||||||
where location_name = #{locationName} and warehouse_id = #{warehouseId} limit 1
|
where location_name = #{locationName} and warehouse_id = #{warehouseId} limit 1
|
||||||
</select>
|
</select>
|
||||||
<select id="selectByLocationIds" resultType="com.ktg.mes.wm.domain.WmStorageLocation">
|
<select id="selectByLocationIds" resultType="com.ktg.mes.wm.domain.WmStorageLocation" resultMap="WmStorageLocationResult">
|
||||||
<include refid="selectWmStorageLocationVo"/>
|
<include refid="selectWmStorageLocationVo"/>
|
||||||
where location_id in
|
where location_id in
|
||||||
<foreach collection="ids" item="item" separator="," open="(" close=")">
|
<foreach collection="ids" item="item" separator="," open="(" close=")">
|
||||||
|
@ -131,4 +131,6 @@ public interface SysUserMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysUser checkEmailUnique(String email);
|
public SysUser checkEmailUnique(String email);
|
||||||
|
|
||||||
|
int checkUserNickNameUnique(SysUser user);
|
||||||
}
|
}
|
||||||
|
@ -210,4 +210,11 @@ public interface ISysUserService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验昵称是否存在
|
||||||
|
* @param user
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String checkNickNameUnique(SysUser user);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.validation.Validator;
|
import javax.validation.Validator;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -521,6 +523,16 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (ObjectUtil.isEmpty(user.getNickName())) {
|
||||||
|
failureNum++;
|
||||||
|
failureMsg.append("<br/>" + "必填项未填写");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (UserConstants.NOT_UNIQUE.equals(checkNickNameUnique(user))) {
|
||||||
|
failureNum++;
|
||||||
|
failureMsg.append("<br/>" + "昵称重复");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// 验证是否存在这个用户
|
// 验证是否存在这个用户
|
||||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||||
if (StringUtils.isNull(u))
|
if (StringUtils.isNull(u))
|
||||||
@ -567,4 +579,14 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
}
|
}
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String checkNickNameUnique(SysUser user) {
|
||||||
|
int count = userMapper.checkUserNickNameUnique(user);
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
return UserConstants.NOT_UNIQUE;
|
||||||
|
}
|
||||||
|
return UserConstants.UNIQUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
select user_id, email from sys_user where email = #{email} limit 1
|
select user_id, email from sys_user where email = #{email} limit 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="checkUserNickNameUnique" resultType="java.lang.Integer">
|
||||||
|
select count(1) from sys_user where nick_name = #{nickName} limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
insert into sys_user(
|
insert into sys_user(
|
||||||
|
Loading…
Reference in New Issue
Block a user