feat(sis): 新增个人门禁授权功能
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
@@ -115,6 +115,12 @@
|
||||
<artifactId>property-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>sis-api</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -4,6 +4,7 @@ import org.dromara.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.io.Serial;
|
||||
@@ -27,17 +28,14 @@ public class ResidentPerson extends TenantEntity {
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@@ -50,67 +48,58 @@ public class ResidentPerson extends TenantEntity {
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Long gender;
|
||||
|
||||
/**
|
||||
* 人脸图片
|
||||
*/
|
||||
private String img;
|
||||
|
||||
/**
|
||||
* 所属单位id
|
||||
*/
|
||||
private Long unitId;
|
||||
|
||||
/**
|
||||
* 所属单位名称
|
||||
*/
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 入驻位置
|
||||
*/
|
||||
private String locathon;
|
||||
|
||||
/**
|
||||
* 入驻时间
|
||||
*/
|
||||
private Date time;
|
||||
|
||||
/**
|
||||
* 车牌号码
|
||||
*/
|
||||
private String carNumber;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Long state;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 权限组
|
||||
*/
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* e8平台id
|
||||
*/
|
||||
private Long eEightId;
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long createById;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
private Long updateById;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
|
@@ -27,12 +27,6 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@@ -44,16 +38,40 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
*/
|
||||
@NotBlank(message = "联系电话不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String phone;
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@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 Date begDate;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endDate;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 人脸图片
|
||||
*/
|
||||
@@ -87,15 +105,8 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
// @NotNull(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long state=1L;
|
||||
|
||||
/**
|
||||
* 权限组
|
||||
*/
|
||||
@NotNull(message = "权限组不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long authGroupId;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@@ -2,6 +2,7 @@ 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;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -11,12 +12,15 @@ 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.sis.api.RemoteSisAuth;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.ResidentPersonBo;
|
||||
import org.dromara.property.domain.vo.ResidentPersonVo;
|
||||
import org.dromara.property.domain.ResidentPerson;
|
||||
import org.dromara.property.mapper.ResidentPersonMapper;
|
||||
import org.dromara.property.service.IResidentPersonService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -35,6 +39,9 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
|
||||
private final ResidentPersonMapper baseMapper;
|
||||
|
||||
@DubboReference
|
||||
private final RemoteSisAuth remoteSisAuth;
|
||||
|
||||
/**
|
||||
* 查询入驻员工
|
||||
*
|
||||
@@ -42,7 +49,7 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
* @return 入驻员工
|
||||
*/
|
||||
@Override
|
||||
public ResidentPersonVo queryById(Long id){
|
||||
public ResidentPersonVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
@@ -76,7 +83,6 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(ResidentPerson::getId);
|
||||
lqw.eq(bo.getUserId() != null, ResidentPerson::getUserId, bo.getUserId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getUserName()), ResidentPerson::getUserName, bo.getUserName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getPhone()), ResidentPerson::getPhone, bo.getPhone());
|
||||
lqw.eq(bo.getGender() != null, ResidentPerson::getGender, bo.getGender());
|
||||
@@ -97,12 +103,34 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(ResidentPersonBo bo) {
|
||||
ResidentPerson add = MapstructUtils.convert(bo, ResidentPerson.class);
|
||||
Assert.notNull(add, "数据处理失败");
|
||||
// 唯一性校验
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "员工入驻失败!");
|
||||
if (flag) {
|
||||
log.info("开始写入授权记录, {}", bo.getUserName());
|
||||
RemotePersonAuth personAuth = new RemotePersonAuth();
|
||||
personAuth.setId(add.getId());
|
||||
personAuth.setName(bo.getUserName());
|
||||
personAuth.setSex(bo.getGender() != 1L ? 0 : 1);
|
||||
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, "新增授权记录失败");
|
||||
add.setEEightId(personId);
|
||||
bo.setId(add.getId());
|
||||
this.updateByBo(bo);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@@ -123,16 +151,20 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeUpdate(ResidentPerson entity){
|
||||
private void validEntityBeforeUpdate(ResidentPerson entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ResidentPerson entity){
|
||||
private void validEntityBeforeSave(ResidentPerson entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
boolean exists = baseMapper.exists(new LambdaQueryWrapper<ResidentPerson>().eq(ResidentPerson::getUserId, entity.getUserId()));
|
||||
Assert.isTrue(!exists,"该用户已入住!");
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(ResidentPerson::getIdCard, entity.getIdCard())
|
||||
.eq(ResidentPerson::getUnitId, entity.getUnitId());
|
||||
boolean exists = baseMapper.exists(lqw);
|
||||
Assert.isTrue(!exists, "当前单位,{}已入驻!", entity.getUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +176,7 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
@@ -152,6 +184,7 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
|
||||
/**
|
||||
* 获取单位人员数量
|
||||
*
|
||||
* @param unitId
|
||||
* @return
|
||||
*/
|
||||
|
Reference in New Issue
Block a user