feat(auth): 人员授权相关功能修改

This commit is contained in:
2025-07-26 02:37:02 +08:00
parent d43b600e51
commit 3b7635bf1d
23 changed files with 368 additions and 94 deletions

View File

@@ -83,6 +83,16 @@ public class ResidentUnit extends TenantEntity {
*/
private Long authGroupId;
/**
* 开始时间
*/
private Date authBegDate;
/**
* 结束时间
*/
private Date authEndDate;
/**
* 创建人id
*/

View File

@@ -45,27 +45,26 @@ public class ResidentPersonBo extends BaseEntity {
@NotNull(message = "性别不能为空", groups = { AddGroup.class, EditGroup.class })
private Long gender;
/**
* 权限组
*/
@NotNull(message = "权限组不能为空", groups = { AddGroup.class, EditGroup.class })
private Long authGroupId;
/**
* 证件号
*/
@NotBlank(message = "证件号不能为空", groups = { AddGroup.class, EditGroup.class })
private String idCard;
/**
* 权限组
*/
private Long authGroupId;
/**
* 开始时间
*/
private Date begDate;
private Date authBegDate;
/**
* 结束时间
*/
private Date endDate;
private Date authEndDate;
/**
* e8平台id

View File

@@ -69,6 +69,21 @@ public class ResidentUnitBo extends BaseEntity {
@NotNull(message = "入驻时间不能为空", groups = { AddGroup.class, EditGroup.class })
private Date time;
/**
* 权限组
*/
private Long authGroupId;
/**
* 开始时间
*/
private Date authBegDate;
/**
* 结束时间
*/
private Date authEndDate;
/**
* 状态
*/
@@ -81,12 +96,6 @@ public class ResidentUnitBo extends BaseEntity {
// @NotNull(message = "员工人数不能为空", groups = { AddGroup.class, EditGroup.class })
private Long number=0L;
/**
* 权限组
*/
@NotNull(message = "权限组不能为空", groups = { AddGroup.class, EditGroup.class })
private Long authGroupId;
/**
* 备注
*/

View File

@@ -113,5 +113,10 @@ public class ResidentPersonVo implements Serializable {
@ExcelProperty(value = "权限组id")
private Long authGroupId;
/**
* e8平台id
*/
private Long eEightId;
}

View File

@@ -109,4 +109,16 @@ public class ResidentUnitVo implements Serializable {
@ExcelProperty(value = "权限组id")
private Long authGroupId;
/**
* 开始时间
*/
@ExcelProperty(value = "开始时间")
private Date authBegDate;
/**
* 结束时间
*/
@ExcelProperty(value = "结束时间")
private Date authEndDate;
}

View File

@@ -0,0 +1,41 @@
package org.dromara.property.dubbo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.property.api.RemoteResidentPersonService;
import org.dromara.property.api.domain.vo.RemoteResidentPersonVo;
import org.dromara.property.domain.vo.ResidentPersonVo;
import org.dromara.property.service.IResidentPersonService;
import java.util.List;
/**
* @author lsm
* @apiNote RemoteResidentPersonServiceImpl
* @since 2025/7/26
*/
@Slf4j
@DubboService
@RequiredArgsConstructor
public class RemoteResidentPersonServiceImpl implements RemoteResidentPersonService {
private final IResidentPersonService residentPersonService;
// 查询已上传图片,未授权人员
@Override
// 查询已上传图片,未授权人员
public List<RemoteResidentPersonVo> queryUnAuthPerson(){
List<ResidentPersonVo> listVo = residentPersonService.queryUnAuthPerson();
return listVo.stream().map(vo -> {
RemoteResidentPersonVo remoteResidentPersonVo = new RemoteResidentPersonVo();
remoteResidentPersonVo.setId(vo.getId());
remoteResidentPersonVo.setOssId(vo.getImg());
remoteResidentPersonVo.setEEightId(vo.getEEightId());
remoteResidentPersonVo.setAuthGroupId(vo.getAuthGroupId());
return remoteResidentPersonVo;
}).toList();
}
}

View File

@@ -1,6 +1,5 @@
package org.dromara.property.service;
import org.dromara.property.domain.ResidentPerson;
import org.dromara.property.domain.vo.ResidentPersonVo;
import org.dromara.property.domain.bo.ResidentPersonBo;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -13,7 +12,7 @@ import java.util.List;
* 入驻员工Service接口
*
* @author mocheng
* @date 2025-06-19
* @since 2025-06-19
*/
public interface IResidentPersonService {
@@ -69,8 +68,15 @@ public interface IResidentPersonService {
/**
* 获取单位人员数量
* @param unitId
* @return
* @param unitId 单元id
* @return Long
*/
Long queryPersonCount(Long unitId);
/**
* 查询已上传图片,未授权人员
*
* @return List<ResidentPersonVo>
*/
List<ResidentPersonVo> queryUnAuthPerson();
}

View File

@@ -1,7 +1,6 @@
package org.dromara.property.service.impl;
import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
@@ -10,10 +9,13 @@ import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.property.domain.vo.ResidentUnitVo;
import org.dromara.property.service.IResidentUnitService;
import org.dromara.sis.api.RemoteSisAuth;
import org.dromara.sis.api.domain.RemotePersonAuth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.dromara.property.domain.bo.ResidentPersonBo;
import org.dromara.property.domain.vo.ResidentPersonVo;
@@ -22,6 +24,7 @@ import org.dromara.property.mapper.ResidentPersonMapper;
import org.dromara.property.service.IResidentPersonService;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@@ -30,14 +33,18 @@ import java.util.Collection;
* 入驻员工Service业务层处理
*
* @author mocheng
* @date 2025-06-19
* @since 2025-06-19
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class ResidentPersonServiceImpl implements IResidentPersonService {
private final ResidentPersonMapper baseMapper;
@Resource
private ResidentPersonMapper baseMapper;
@Lazy
@Autowired
private IResidentUnitService residentUnitService;
@DubboReference
private RemoteSisAuth remoteSisAuth;
@@ -108,7 +115,13 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
ResidentPerson add = MapstructUtils.convert(bo, ResidentPerson.class);
Assert.notNull(add, "数据处理失败");
// 唯一性校验
assert add != null;
validEntityBeforeSave(add);
// 首次入驻新用户权限组默认使用公司权限
ResidentUnitVo ruVo = residentUnitService.queryById(bo.getUnitId());
add.setAuthGroupId(ruVo.getAuthGroupId());
boolean flag = baseMapper.insert(add) > 0;
Assert.isTrue(flag, "员工入驻失败!");
if (flag) {
@@ -116,21 +129,20 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
RemotePersonAuth personAuth = new RemotePersonAuth();
personAuth.setId(add.getId());
personAuth.setName(bo.getUserName());
personAuth.setSex(bo.getGender() != 1L ? 0 : 1);
personAuth.setSex(bo.getGender().intValue());
personAuth.setPhone(bo.getPhone());
personAuth.setEmail(bo.getEmail());
personAuth.setIdCardNumber(bo.getIdCard());
personAuth.setOssId(bo.getImg());
personAuth.setCarNumber(bo.getCarNumber());
personAuth.setBegDate(bo.getBegDate());
personAuth.setEndDate(bo.getEndDate());
personAuth.setAuthGroupId(bo.getAuthGroupId());
Long personId = remoteSisAuth.personAuth(personAuth);
Assert.notNull(personId, "新增授权记录失败");
bo.setId(add.getId());
bo.setEEightId(personId);
this.updateByBo(bo);
// 使用公司权限组
personAuth.setAuthBegDate(ruVo.getAuthBegDate());
personAuth.setAuthEndDate(ruVo.getAuthEndDate());
personAuth.setAuthGroupId(ruVo.getAuthGroupId());
Boolean auth = remoteSisAuth.personAuth(personAuth);
Assert.isTrue(auth, "新增授权记录失败");
}
return flag;
}
@@ -177,7 +189,17 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
LambdaQueryWrapper<ResidentPerson> lqw = new LambdaQueryWrapper<>();
lqw.eq(ResidentPerson::getId, ids);
List<ResidentPersonVo> list = baseMapper.selectVoList(lqw);
boolean hasEnabled = list.stream()
.anyMatch(vo -> vo.getState() == 1); // 遇到第一个启用人员立即返回
Assert.isTrue(!hasEnabled, "当前存在人员状态为启用,请核对后再试!");
boolean hasE8 = list.stream()
.anyMatch(vo -> vo.getEEightId() != null); // 遇到第一个e8人员立即返回
Assert.isTrue(!hasE8, "当前存在人员已下发权限,请删除通行权限后再试!");
}
return baseMapper.deleteByIds(ids) > 0;
}
@@ -185,8 +207,8 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
/**
* 获取单位人员数量
*
* @param unitId
* @return
* @param unitId 单位id
* @return Long
*/
@Override
public Long queryPersonCount(Long unitId) {
@@ -194,4 +216,17 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
lqw.eq(unitId != null, ResidentPerson::getUnitId, unitId);
return baseMapper.selectCount(lqw);
}
/**
* 查询已上传图片,未授权人员
*
* @return List<ResidentPersonVo>
*/
public List<ResidentPersonVo> queryUnAuthPerson(){
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
lqw.isNotNull(ResidentPerson::getImg)
.ne(ResidentPerson::getImg, "")
.isNull(ResidentPerson::getEEightId);
return baseMapper.selectVoList(lqw);
}
}