|
@@ -1,6 +1,7 @@
|
|
package org.dromara.service.impl;
|
|
package org.dromara.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
import cn.dev33.satoken.secure.BCrypt;
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -17,10 +18,13 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
import org.dromara.common.tenant.helper.TenantHelper;
|
|
import org.dromara.common.tenant.helper.TenantHelper;
|
|
import org.dromara.domain.houseInfo.HouseInfo;
|
|
import org.dromara.domain.houseInfo.HouseInfo;
|
|
|
|
+import org.dromara.domain.houseInfo.HouseInfoRedident;
|
|
|
|
+import org.dromara.domain.houseInfo.vo.HouseInfoRedidentVo;
|
|
import org.dromara.domain.residentInfo.ResidentInfo;
|
|
import org.dromara.domain.residentInfo.ResidentInfo;
|
|
import org.dromara.domain.residentInfo.bo.ResidentInfoBo;
|
|
import org.dromara.domain.residentInfo.bo.ResidentInfoBo;
|
|
import org.dromara.domain.residentInfo.vo.ResidentInfoVo;
|
|
import org.dromara.domain.residentInfo.vo.ResidentInfoVo;
|
|
import org.dromara.mapper.HouseInfoMapper;
|
|
import org.dromara.mapper.HouseInfoMapper;
|
|
|
|
+import org.dromara.mapper.HouseInfoRedidentMapper;
|
|
import org.dromara.mapper.ResidentInfoMapper;
|
|
import org.dromara.mapper.ResidentInfoMapper;
|
|
import org.dromara.service.IResidentInfoService;
|
|
import org.dromara.service.IResidentInfoService;
|
|
import org.dromara.system.domain.SysRole;
|
|
import org.dromara.system.domain.SysRole;
|
|
@@ -38,6 +42,7 @@ import org.dromara.system.service.ISysUserService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -61,6 +66,7 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
private final SysRoleMapper sysRoleMapper;
|
|
private final SysRoleMapper sysRoleMapper;
|
|
private final SysUserRoleMapper userRoleMapper;
|
|
private final SysUserRoleMapper userRoleMapper;
|
|
private final HouseInfoMapper houseInfoMapper;
|
|
private final HouseInfoMapper houseInfoMapper;
|
|
|
|
+ private final HouseInfoRedidentMapper houseInfoRedidentMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -71,7 +77,19 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ResidentInfoVo queryById(Long residentId) {
|
|
public ResidentInfoVo queryById(Long residentId) {
|
|
- return baseMapper.selectVoById(residentId);
|
|
|
|
|
|
+ ResidentInfoVo residentInfoVo = baseMapper.selectVoById(residentId);
|
|
|
|
+ String residentType = residentInfoVo.getResidentType();
|
|
|
|
+ if (ONE.equals(residentType)) {
|
|
|
|
+ Long houseId = residentInfoVo.getHouseId();
|
|
|
|
+ //去查询房本信息
|
|
|
|
+ HouseInfoRedidentVo houseInfoRedidentVo = houseInfoRedidentMapper.selectVoById(houseId);
|
|
|
|
+ //HouseInfo convert = MapstructUtils.convert(houseInfoRedidentVo, HouseInfo.class);
|
|
|
|
+ HouseInfoRedident convert = BeanUtil.toBean(houseInfoRedidentVo, HouseInfoRedident.class);
|
|
|
|
+ List<HouseInfoRedident> houseInfoRedidentList = new ArrayList<>();
|
|
|
|
+ houseInfoRedidentList.add(convert);
|
|
|
|
+ residentInfoVo.setHouseInfoRedidentList(houseInfoRedidentList);
|
|
|
|
+ }
|
|
|
|
+ return residentInfoVo;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -82,8 +100,19 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
@Override
|
|
@Override
|
|
public ResidentInfoVo getAuthenticationInfo(Long residentId) {
|
|
public ResidentInfoVo getAuthenticationInfo(Long residentId) {
|
|
return TenantHelper.ignore(() -> {
|
|
return TenantHelper.ignore(() -> {
|
|
- return
|
|
|
|
- baseMapper.selectVoById(residentId);
|
|
|
|
|
|
+ ResidentInfoVo residentInfoVo = baseMapper.selectVoById(residentId);
|
|
|
|
+ String residentType = residentInfoVo.getResidentType();
|
|
|
|
+ if (ONE.equals(residentType)) {
|
|
|
|
+ Long houseId = residentInfoVo.getHouseId();
|
|
|
|
+ //去查询房本信息
|
|
|
|
+ HouseInfoRedidentVo houseInfoRedidentVo = houseInfoRedidentMapper.selectVoById(houseId);
|
|
|
|
+ //HouseInfo convert = MapstructUtils.convert(houseInfoRedidentVo, HouseInfo.class);
|
|
|
|
+ HouseInfoRedident convert = BeanUtil.toBean(houseInfoRedidentVo, HouseInfoRedident.class);
|
|
|
|
+ List<HouseInfoRedident> houseInfoRedidentList = new ArrayList<>();
|
|
|
|
+ houseInfoRedidentList.add(convert);
|
|
|
|
+ residentInfoVo.setHouseInfoRedidentList(houseInfoRedidentList);
|
|
|
|
+ }
|
|
|
|
+ return residentInfoVo;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -94,7 +123,7 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public ResidentInfoVo getInfoByUserId(Long userId) {
|
|
|
|
|
|
+ public List<ResidentInfoVo> getInfoByUserId(Long userId) {
|
|
return baseMapper.getInfoByUserId(userId);
|
|
return baseMapper.getInfoByUserId(userId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -181,24 +210,23 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
add.setUserId(userId);
|
|
add.setUserId(userId);
|
|
String residentType = add.getResidentType();
|
|
String residentType = add.getResidentType();
|
|
String isHouseholder = add.getIsHouseholder();
|
|
String isHouseholder = add.getIsHouseholder();
|
|
- //必须是业主和户主才能去修改房本信息
|
|
|
|
|
|
+ //必须是业主和户主才能去新增房本信息
|
|
if (ONE.equals(residentType) && Y.equals(isHouseholder)) {
|
|
if (ONE.equals(residentType) && Y.equals(isHouseholder)) {
|
|
- List<HouseInfo> houseInfoList = bo.getHouseInfoList();
|
|
|
|
- if (houseInfoList != null && !houseInfoList.isEmpty()) {
|
|
|
|
- //修改房屋信息
|
|
|
|
- return TenantHelper.ignore(() -> {
|
|
|
|
- return houseInfoMapper.updateBatchById(houseInfoList);
|
|
|
|
|
|
+ List<HouseInfoRedident> houseInfoRedidentList = bo.getHouseInfoRedidentList();
|
|
|
|
+ if (houseInfoRedidentList != null && !houseInfoRedidentList.isEmpty()) {
|
|
|
|
+ //新增房屋信息到房屋用户表中
|
|
|
|
+ TenantHelper.ignore(() -> {
|
|
|
|
+ return houseInfoRedidentMapper.insertBatch(houseInfoRedidentList);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (THR.equals(residentType)){
|
|
|
|
|
|
+ if (THR.equals(residentType)) {
|
|
SysUserBo user = new SysUserBo();
|
|
SysUserBo user = new SysUserBo();
|
|
user.setUserId(userId);
|
|
user.setUserId(userId);
|
|
user.setTenantId(tenantId);
|
|
user.setTenantId(tenantId);
|
|
user.setResidentType(residentType);
|
|
user.setResidentType(residentType);
|
|
//默认审核通过
|
|
//默认审核通过
|
|
add.setExamine(TWO);
|
|
add.setExamine(TWO);
|
|
- //赋予角色
|
|
|
|
//sys_user_tenant表中
|
|
//sys_user_tenant表中
|
|
SysUserTenant sysUserTenant = new SysUserTenant();
|
|
SysUserTenant sysUserTenant = new SysUserTenant();
|
|
sysUserTenant.setUserId(userId);
|
|
sysUserTenant.setUserId(userId);
|
|
@@ -217,8 +245,13 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
Long[] longArray = new Long[1];
|
|
Long[] longArray = new Long[1];
|
|
longArray[0] = sysRoleVo.getRoleId();
|
|
longArray[0] = sysRoleVo.getRoleId();
|
|
user.setRoleIds(longArray);
|
|
user.setRoleIds(longArray);
|
|
|
|
+ //判断该用户是否有游客角色
|
|
|
|
+ SysUserVo sysUserVo = userService.selectUserById(user.getUserId());
|
|
|
|
+ Long roleId = sysUserVo.getRoleId();
|
|
|
|
+ if (roleId != null && !roleId.equals(sysRoleVo.getRoleId())) {
|
|
|
|
+ userService.insertUserRole(user, false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- userService.insertUserRole(user, false);
|
|
|
|
|
|
|
|
if (TenantHelper.isEnable()) {
|
|
if (TenantHelper.isEnable()) {
|
|
//把租户id更新到sys_user表/sys_user_tenant表中
|
|
//把租户id更新到sys_user表/sys_user_tenant表中
|
|
@@ -290,11 +323,26 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
add.setExamine(TWO);
|
|
add.setExamine(TWO);
|
|
add.setUserId(userId);
|
|
add.setUserId(userId);
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
+
|
|
|
|
+ String residentType = add.getResidentType();
|
|
|
|
+ String isHouseholder = add.getIsHouseholder();
|
|
|
|
+ //必须是业主和户主才能去修改房本信息
|
|
|
|
+ if (ONE.equals(residentType) && Y.equals(isHouseholder)) {
|
|
|
|
+ List<HouseInfoRedident> houseInfoRedidentList = bo.getHouseInfoRedidentList();
|
|
|
|
+ if (houseInfoRedidentList != null && !houseInfoRedidentList.isEmpty()) {
|
|
|
|
+ //更新房屋信息到房屋用户表中
|
|
|
|
+ TenantHelper.ignore(() -> {
|
|
|
|
+ List<HouseInfo> convert = BeanUtil.copyToList(houseInfoRedidentList, HouseInfo.class);
|
|
|
|
+ //List<HouseInfo> convert = MapstructUtils.convert(houseInfoRedidentList, HouseInfo.class);
|
|
|
|
+ return houseInfoMapper.updateBatchById(convert);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//sys_user_tenant表中
|
|
//sys_user_tenant表中
|
|
SysUserTenant sysUserTenant = new SysUserTenant();
|
|
SysUserTenant sysUserTenant = new SysUserTenant();
|
|
sysUserTenant.setUserId(userId);
|
|
sysUserTenant.setUserId(userId);
|
|
sysUserTenant.setTenantId(tenantId);
|
|
sysUserTenant.setTenantId(tenantId);
|
|
- sysUserTenantMapper.insert(sysUserTenant);
|
|
|
|
|
|
+ sysUserTenantMapper.insertOrUpdate(sysUserTenant);
|
|
//给该userId赋予角色
|
|
//给该userId赋予角色
|
|
// 新增用户与角色管理
|
|
// 新增用户与角色管理
|
|
//根据权限字符去查询角色id
|
|
//根据权限字符去查询角色id
|
|
@@ -308,8 +356,14 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
Long[] longArray = new Long[1];
|
|
Long[] longArray = new Long[1];
|
|
longArray[0] = sysRoleVo.getRoleId();
|
|
longArray[0] = sysRoleVo.getRoleId();
|
|
user.setRoleIds(longArray);
|
|
user.setRoleIds(longArray);
|
|
|
|
+ //判断该用户是否有住户角色
|
|
|
|
+ SysUserVo sysUserVo = userService.selectUserById(user.getUserId());
|
|
|
|
+ Long roleId = sysUserVo.getRoleId();
|
|
|
|
+ if (roleId != null && !roleId.equals(sysRoleVo.getRoleId())) {
|
|
|
|
+ userService.insertUserRole(user, false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- userService.insertUserRole(user, false);
|
|
|
|
|
|
+
|
|
if (flag) {
|
|
if (flag) {
|
|
bo.setResidentId(add.getResidentId());
|
|
bo.setResidentId(add.getResidentId());
|
|
}
|
|
}
|
|
@@ -330,15 +384,16 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
if (checkIdCardUnique(update)) {
|
|
if (checkIdCardUnique(update)) {
|
|
throw new UserException("resident.register.save.error", update.getResidentName());
|
|
throw new UserException("resident.register.save.error", update.getResidentName());
|
|
}*/
|
|
}*/
|
|
|
|
+ update.setExamine(ONE);
|
|
String residentType = update.getResidentType();
|
|
String residentType = update.getResidentType();
|
|
String isHouseholder = update.getIsHouseholder();
|
|
String isHouseholder = update.getIsHouseholder();
|
|
//必须是业主和户主才能去修改房本信息
|
|
//必须是业主和户主才能去修改房本信息
|
|
if (ONE.equals(residentType) && Y.equals(isHouseholder)) {
|
|
if (ONE.equals(residentType) && Y.equals(isHouseholder)) {
|
|
- List<HouseInfo> houseInfoList = bo.getHouseInfoList();
|
|
|
|
- if (houseInfoList != null && !houseInfoList.isEmpty()) {
|
|
|
|
- //修改房屋信息
|
|
|
|
- TenantHelper.ignore(() -> {
|
|
|
|
- return houseInfoMapper.updateBatchById(houseInfoList);
|
|
|
|
|
|
+ List<HouseInfoRedident> houseInfoRedidentList = bo.getHouseInfoRedidentList();
|
|
|
|
+ if (houseInfoRedidentList != null && !houseInfoRedidentList.isEmpty()) {
|
|
|
|
+ //新增房屋信息到房屋用户表中
|
|
|
|
+ TenantHelper.ignore(() -> {
|
|
|
|
+ return houseInfoRedidentMapper.updateBatchById(houseInfoRedidentList);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -411,6 +466,8 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
public Boolean examineResident(ResidentInfoBo bo) {
|
|
public Boolean examineResident(ResidentInfoBo bo) {
|
|
ResidentInfo residentInfo = MapstructUtils.convert(bo, ResidentInfo.class);
|
|
ResidentInfo residentInfo = MapstructUtils.convert(bo, ResidentInfo.class);
|
|
String tenantId = residentInfo.getTenantId();
|
|
String tenantId = residentInfo.getTenantId();
|
|
|
|
+ String residentType = residentInfo.getResidentType();
|
|
|
|
+ String isHouseholder = residentInfo.getIsHouseholder();
|
|
if (TWO.equals(residentInfo.getExamine())) {
|
|
if (TWO.equals(residentInfo.getExamine())) {
|
|
SysUserBo sysUser = new SysUserBo();
|
|
SysUserBo sysUser = new SysUserBo();
|
|
sysUser.setUserId(bo.getUserId());
|
|
sysUser.setUserId(bo.getUserId());
|
|
@@ -422,7 +479,7 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
SysUserTenant sysUserTenant = new SysUserTenant();
|
|
SysUserTenant sysUserTenant = new SysUserTenant();
|
|
sysUserTenant.setUserId(residentInfo.getUserId());
|
|
sysUserTenant.setUserId(residentInfo.getUserId());
|
|
sysUserTenant.setTenantId(tenantId);
|
|
sysUserTenant.setTenantId(tenantId);
|
|
- sysUserTenantMapper.insert(sysUserTenant);
|
|
|
|
|
|
+ sysUserTenantMapper.insertOrUpdate(sysUserTenant);
|
|
}
|
|
}
|
|
//给该userId赋予角色
|
|
//给该userId赋予角色
|
|
// 新增用户与角色管理
|
|
// 新增用户与角色管理
|
|
@@ -437,8 +494,27 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
Long[] longArray = new Long[1];
|
|
Long[] longArray = new Long[1];
|
|
longArray[0] = sysRoleVo.getRoleId();
|
|
longArray[0] = sysRoleVo.getRoleId();
|
|
sysUser.setRoleIds(longArray);
|
|
sysUser.setRoleIds(longArray);
|
|
|
|
+ //判断该用户是否有住户角色
|
|
|
|
+ SysUserVo sysUserVo = userService.selectUserById(sysUser.getUserId());
|
|
|
|
+ Long roleId = sysUserVo.getRoleId();
|
|
|
|
+ if (roleId != null && !roleId.equals(sysRoleVo.getRoleId())) {
|
|
|
|
+ userService.insertUserRole(sysUser, false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //认证通过后 把用户提交的房本信息同步到房屋主表
|
|
|
|
+ if (ONE.equals(residentType) && Y.equals(isHouseholder)) {
|
|
|
|
+ List<HouseInfoRedident> houseInfoRedidentList = bo.getHouseInfoRedidentList();
|
|
|
|
+ if (houseInfoRedidentList != null && !houseInfoRedidentList.isEmpty()) {
|
|
|
|
+ //新增房屋信息到房屋用户表中
|
|
|
|
+ TenantHelper.ignore(() -> {
|
|
|
|
+ //List<HouseInfo> convert = MapstructUtils.convert(houseInfoRedidentList, HouseInfo.class);
|
|
|
|
+ List<HouseInfo> convert = BeanUtil.copyToList(houseInfoRedidentList, HouseInfo.class);
|
|
|
|
+ return houseInfoMapper.updateBatchById(convert);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- userService.insertUserRole(sysUser, false);
|
|
|
|
}
|
|
}
|
|
return baseMapper.updateById(residentInfo) > 0;
|
|
return baseMapper.updateById(residentInfo) > 0;
|
|
}
|
|
}
|
|
@@ -455,6 +531,7 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
Long userId = bo.getUserId();
|
|
Long userId = bo.getUserId();
|
|
Long residentId = bo.getResidentId();
|
|
Long residentId = bo.getResidentId();
|
|
String tenantId = bo.getTenantId();
|
|
String tenantId = bo.getTenantId();
|
|
|
|
+ Long houseId = bo.getHouseId();
|
|
boolean flag = baseMapper.deleteById(residentId) > 0;
|
|
boolean flag = baseMapper.deleteById(residentId) > 0;
|
|
// userMapper.deleteById(userId);
|
|
// userMapper.deleteById(userId);
|
|
if (TenantHelper.isEnable()) {
|
|
if (TenantHelper.isEnable()) {
|
|
@@ -471,6 +548,10 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
sysUserMapper.updateById(sysUser);
|
|
sysUserMapper.updateById(sysUser);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ //删除用户提交的认证信息,如果有房屋id
|
|
|
|
+ if (houseId != null) {
|
|
|
|
+ houseInfoRedidentMapper.deleteById(houseId);
|
|
|
|
+ }
|
|
// 删除用户与角色关联
|
|
// 删除用户与角色关联
|
|
TenantHelper.ignore(() -> {
|
|
TenantHelper.ignore(() -> {
|
|
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId).eq(SysUserRole::getTenantId, tenantId));
|
|
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId).eq(SysUserRole::getTenantId, tenantId));
|
|
@@ -491,9 +572,7 @@ public class ResidentInfoServiceImpl implements IResidentInfoService {
|
|
if (sysUserTenant != null) {
|
|
if (sysUserTenant != null) {
|
|
sysUser.setTenantId(sysUserTenant.getTenantId());
|
|
sysUser.setTenantId(sysUserTenant.getTenantId());
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
long count = residentInfoList.stream().filter(e -> e.getExamine().equals(TWO)).count();
|
|
long count = residentInfoList.stream().filter(e -> e.getExamine().equals(TWO)).count();
|
|
if (count == 0) {
|
|
if (count == 0) {
|
|
sysUser.setTenantId(TENANT_ID);
|
|
sysUser.setTenantId(TENANT_ID);
|