mirror of https://gitee.com/stylefeng/roses
【8.0.3】【system】新增用户增加调用更新证书信息
parent
28c18ee45b
commit
6308ea4136
|
@ -17,6 +17,13 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<!-- 多数据源模块,获取数据源上下文 -->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
<artifactId>ds-container-api</artifactId>
|
||||
<version>${roses.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 事件模块 -->
|
||||
<dependency>
|
||||
<groupId>cn.stylefeng.roses</groupId>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.user.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.mp.injector.CustomBaseMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserCertificate;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserCertificateRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.response.SysUserCertificateVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
public interface SysUserCertificateMapper extends BaseMapper<SysUserCertificate> {
|
||||
public interface SysUserCertificateMapper extends CustomBaseMapper<SysUserCertificate> {
|
||||
|
||||
/**
|
||||
* 获取自定义查询列表
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.sys.modular.user.pojo.request;
|
|||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserCertificate;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserOrg;
|
||||
import cn.stylefeng.roses.kernel.validator.api.validators.unique.TableUniqueValue;
|
||||
import lombok.Data;
|
||||
|
@ -159,6 +160,12 @@ public class SysUserRequest extends BaseRequest {
|
|||
@NotEmpty(message = "用户和组织机构关系集合不能为空", groups = {add.class, edit.class})
|
||||
private List<SysUserOrg> userOrgList;
|
||||
|
||||
/**
|
||||
* 用户证书信息集合
|
||||
*/
|
||||
@ChineseDescription("用户证书信息集合")
|
||||
private List<SysUserCertificate> userCertificateList;
|
||||
|
||||
/**
|
||||
* 用户id集合,用在批量删除用户的参数
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.user.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserCertificate;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserCertificateRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -16,68 +14,13 @@ import java.util.List;
|
|||
public interface SysUserCertificateService extends IService<SysUserCertificate> {
|
||||
|
||||
/**
|
||||
* 新增用户证书
|
||||
* 更新用户的证书信息
|
||||
*
|
||||
* @param sysUserCertificateRequest 请求参数
|
||||
* @param userId 用户id集合
|
||||
* @param sysUserCertificateList 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
void add(SysUserCertificateRequest sysUserCertificateRequest);
|
||||
|
||||
/**
|
||||
* 删除用户证书
|
||||
*
|
||||
* @param sysUserCertificateRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
void del(SysUserCertificateRequest sysUserCertificateRequest);
|
||||
|
||||
/**
|
||||
* 批量删除用户证书
|
||||
*
|
||||
* @param sysUserCertificateRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
void batchDelete(SysUserCertificateRequest sysUserCertificateRequest);
|
||||
|
||||
/**
|
||||
* 编辑用户证书
|
||||
*
|
||||
* @param sysUserCertificateRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
void edit(SysUserCertificateRequest sysUserCertificateRequest);
|
||||
|
||||
/**
|
||||
* 查询详情用户证书
|
||||
*
|
||||
* @param sysUserCertificateRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
SysUserCertificate detail(SysUserCertificateRequest sysUserCertificateRequest);
|
||||
|
||||
/**
|
||||
* 获取用户证书列表
|
||||
*
|
||||
* @param sysUserCertificateRequest 请求参数
|
||||
* @return List<SysUserCertificate> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
List<SysUserCertificate> findList(SysUserCertificateRequest sysUserCertificateRequest);
|
||||
|
||||
/**
|
||||
* 获取用户证书分页列表
|
||||
*
|
||||
* @param sysUserCertificateRequest 请求参数
|
||||
* @return PageResult<SysUserCertificate> 返回结果
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
PageResult<SysUserCertificate> findPage(SysUserCertificateRequest sysUserCertificateRequest);
|
||||
void updateUserCertificate(Long userId, List<SysUserCertificate> sysUserCertificateList);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.user.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.dsctn.api.context.DataSourceContext;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUserCertificate;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.enums.SysUserCertificateExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserCertificateMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserCertificateRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserCertificateService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -26,94 +20,27 @@ import java.util.List;
|
|||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
@Service
|
||||
public class SysUserCertificateServiceImpl extends ServiceImpl<SysUserCertificateMapper, SysUserCertificate> implements SysUserCertificateService {
|
||||
|
||||
@Override
|
||||
public void add(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
SysUserCertificate sysUserCertificate = new SysUserCertificate();
|
||||
BeanUtil.copyProperties(sysUserCertificateRequest, sysUserCertificate);
|
||||
this.save(sysUserCertificate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
SysUserCertificate sysUserCertificate = this.querySysUserCertificate(sysUserCertificateRequest);
|
||||
this.removeById(sysUserCertificate.getUserCertificateId());
|
||||
}
|
||||
public class SysUserCertificateServiceImpl extends ServiceImpl<SysUserCertificateMapper, SysUserCertificate> implements
|
||||
SysUserCertificateService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchDelete(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
this.removeByIds(sysUserCertificateRequest.getBatchDeleteIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
SysUserCertificate sysUserCertificate = this.querySysUserCertificate(sysUserCertificateRequest);
|
||||
BeanUtil.copyProperties(sysUserCertificateRequest, sysUserCertificate);
|
||||
this.updateById(sysUserCertificate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUserCertificate detail(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
return this.querySysUserCertificate(sysUserCertificateRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysUserCertificate> findPage(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
LambdaQueryWrapper<SysUserCertificate> wrapper = createWrapper(sysUserCertificateRequest);
|
||||
Page<SysUserCertificate> pageList = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(pageList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserCertificate> findList(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
LambdaQueryWrapper<SysUserCertificate> wrapper = this.createWrapper(sysUserCertificateRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
private SysUserCertificate querySysUserCertificate(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
SysUserCertificate sysUserCertificate = this.getById(sysUserCertificateRequest.getUserCertificateId());
|
||||
if (ObjectUtil.isEmpty(sysUserCertificate)) {
|
||||
throw new ServiceException(SysUserCertificateExceptionEnum.SYS_USER_CERTIFICATE_NOT_EXISTED);
|
||||
public void updateUserCertificate(Long userId, List<SysUserCertificate> sysUserCertificateList) {
|
||||
if (ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(sysUserCertificateList)) {
|
||||
return;
|
||||
}
|
||||
return sysUserCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/11/09 22:44
|
||||
*/
|
||||
private LambdaQueryWrapper<SysUserCertificate> createWrapper(SysUserCertificateRequest sysUserCertificateRequest) {
|
||||
LambdaQueryWrapper<SysUserCertificate> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// 先清空当前绑定的证书信息
|
||||
LambdaQueryWrapper<SysUserCertificate> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
deleteWrapper.eq(SysUserCertificate::getUserId, userId);
|
||||
this.remove(deleteWrapper);
|
||||
|
||||
Long userCertificateId = sysUserCertificateRequest.getUserCertificateId();
|
||||
Long userId = sysUserCertificateRequest.getUserId();
|
||||
Long certificateType = sysUserCertificateRequest.getCertificateType();
|
||||
String certificateNo = sysUserCertificateRequest.getCertificateNo();
|
||||
String issuingAuthority = sysUserCertificateRequest.getIssuingAuthority();
|
||||
String dateIssued = sysUserCertificateRequest.getDateIssued();
|
||||
String dateExpires = sysUserCertificateRequest.getDateExpires();
|
||||
String delFlag = sysUserCertificateRequest.getDelFlag();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(userCertificateId), SysUserCertificate::getUserCertificateId, userCertificateId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(userId), SysUserCertificate::getUserId, userId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(certificateType), SysUserCertificate::getCertificateType, certificateType);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(certificateNo), SysUserCertificate::getCertificateNo, certificateNo);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(issuingAuthority), SysUserCertificate::getIssuingAuthority, issuingAuthority);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(dateIssued), SysUserCertificate::getDateIssued, dateIssued);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(dateExpires), SysUserCertificate::getDateExpires, dateExpires);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(delFlag), SysUserCertificate::getDelFlag, delFlag);
|
||||
|
||||
return queryWrapper;
|
||||
// 重新绑定用户证书信息
|
||||
if (DbTypeEnum.MYSQL.equals(DataSourceContext.me().getCurrentDbType())) {
|
||||
this.getBaseMapper().insertBatchSomeColumn(sysUserCertificateList);
|
||||
} else {
|
||||
this.saveBatch(sysUserCertificateList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import cn.stylefeng.roses.kernel.sys.modular.user.factory.SysUserCreateFactory;
|
|||
import cn.stylefeng.roses.kernel.sys.modular.user.mapper.SysUserMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.pojo.response.PersonalInfo;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserCertificateService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserOrgService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserRoleService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserService;
|
||||
|
@ -79,6 +80,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
@Resource
|
||||
private SecurityConfigService securityConfigService;
|
||||
|
||||
@Resource
|
||||
private SysUserCertificateService sysUserCertificateService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(SysUserRequest sysUserRequest) {
|
||||
|
@ -109,6 +113,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
// 添加用户一个默认角色
|
||||
sysUserRoleService.bindUserDefaultRole(sysUser.getUserId());
|
||||
|
||||
// 增加用户证书的信息
|
||||
sysUserCertificateService.updateUserCertificate(sysUser.getUserId(), sysUserRequest.getUserCertificateList());
|
||||
|
||||
// 记录日志
|
||||
BusinessLogUtil.setLogTitle("新增用户,用户账号:" + sysUser.getAccount());
|
||||
BusinessLogUtil.addContent("新增用户账号信息:", sysUser.getAccount());
|
||||
|
|
Loading…
Reference in New Issue