|
|
@ -17,7 +17,6 @@ import com.elink.esua.epdc.commons.tools.constant.Constant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.enums.SuperAdminEnum; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.password.PasswordUtils; |
|
|
@ -103,14 +102,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(SysUserDTO dto) { |
|
|
|
// 保存用户之前,用户名判重
|
|
|
|
QueryWrapper<SysUserEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("username", dto.getUsername()) |
|
|
|
.eq(FieldConstant.DEL_FLAG, DelFlagEnum.NORMAL.value()); |
|
|
|
Integer selectCount = this.baseDao.selectCount(wrapper); |
|
|
|
if (selectCount > NumConstant.ZERO) { |
|
|
|
throw new RenException(ErrorCode.DB_RECORD_EXISTS); |
|
|
|
} |
|
|
|
|
|
|
|
this.verifyUsernameAndMobile(dto); |
|
|
|
|
|
|
|
SysUserEntity entity = ConvertUtils.sourceToTarget(dto, SysUserEntity.class); |
|
|
|
|
|
|
@ -129,6 +122,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(SysUserDTO dto) { |
|
|
|
|
|
|
|
this.verifyUsernameAndMobile(dto); |
|
|
|
|
|
|
|
SysUserEntity entity = ConvertUtils.sourceToTarget(dto, SysUserEntity.class); |
|
|
|
|
|
|
|
//密码加密
|
|
|
@ -146,6 +142,26 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户名与手机号查重 |
|
|
|
* |
|
|
|
* @param dto 用户新增或修改时的提交数据 |
|
|
|
* @return void |
|
|
|
* @author work@yujt.net.cn |
|
|
|
* @date 2019/11/4 14:01 |
|
|
|
*/ |
|
|
|
private void verifyUsernameAndMobile(SysUserDTO dto) { |
|
|
|
QueryWrapper<SysUserEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(FieldConstant.DEL_FLAG, DelFlagEnum.NORMAL.value()) |
|
|
|
.and(i -> i.eq(StringUtils.isNotBlank(dto.getMobile()), "mobile", dto.getMobile()) |
|
|
|
.or() |
|
|
|
.eq("username", dto.getUsername())); |
|
|
|
Integer selectCount = this.baseDao.selectCount(wrapper); |
|
|
|
if (selectCount > NumConstant.ZERO) { |
|
|
|
throw new RenException("保存失败,用户名或手机号重复"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(Long[] ids) { |
|
|
@ -176,8 +192,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
.eq(FieldConstant.DEL_FLAG, DelFlagEnum.NORMAL.value()); |
|
|
|
|
|
|
|
Integer selectCount = baseDao.selectCount(wrapper); |
|
|
|
if (selectCount != NumConstant.ONE) { |
|
|
|
return new Result().error("校验网格长手机号失败"); |
|
|
|
if (selectCount == NumConstant.ZERO) { |
|
|
|
return new Result().error("匹配网格长手机号失败"); |
|
|
|
} |
|
|
|
|
|
|
|
SysUserEntity sysUserEntity = baseDao.selectOne(wrapper); |
|
|
@ -185,7 +201,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit |
|
|
|
|
|
|
|
List<String> gridIdList = this.baseDao.selectListLeaderGridId(mobile); |
|
|
|
if (CollUtil.isEmpty(gridIdList)) { |
|
|
|
return new Result().error("校验网格长数据权限失败"); |
|
|
|
return new Result().error("匹配网格长数据权限失败"); |
|
|
|
} |
|
|
|
|
|
|
|
List<GridForLeaderRegisterDTO> gridForLeaderList = sysDeptService.selectListGridForLeader(gridIdList); |
|
|
|