From 6308ea4136ab03d02b7726c4f9338fb531e9b28c Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Thu, 9 Nov 2023 23:50:20 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=908.0.3=E3=80=91=E3=80=90system=E3=80=91?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E5=A2=9E=E5=8A=A0=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=9B=B4=E6=96=B0=E8=AF=81=E4=B9=A6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel-s-system/system-business-hr/pom.xml | 7 ++ .../user/mapper/SysUserCertificateMapper.java | 4 +- .../user/pojo/request/SysUserRequest.java | 7 ++ .../service/SysUserCertificateService.java | 65 +---------- .../impl/SysUserCertificateServiceImpl.java | 107 +++--------------- .../user/service/impl/SysUserServiceImpl.java | 7 ++ 6 files changed, 44 insertions(+), 153 deletions(-) diff --git a/kernel-s-system/system-business-hr/pom.xml b/kernel-s-system/system-business-hr/pom.xml index 0b7998cc3..2f3062901 100644 --- a/kernel-s-system/system-business-hr/pom.xml +++ b/kernel-s-system/system-business-hr/pom.xml @@ -17,6 +17,13 @@ + + + cn.stylefeng.roses + ds-container-api + ${roses.version} + + cn.stylefeng.roses diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/mapper/SysUserCertificateMapper.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/mapper/SysUserCertificateMapper.java index 62c91e23e..eb9de6043 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/mapper/SysUserCertificateMapper.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/mapper/SysUserCertificateMapper.java @@ -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 { +public interface SysUserCertificateMapper extends CustomBaseMapper { /** * 获取自定义查询列表 diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/pojo/request/SysUserRequest.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/pojo/request/SysUserRequest.java index c71b7e8ed..d4b545134 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/pojo/request/SysUserRequest.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/pojo/request/SysUserRequest.java @@ -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 userOrgList; + /** + * 用户证书信息集合 + */ + @ChineseDescription("用户证书信息集合") + private List userCertificateList; + /** * 用户id集合,用在批量删除用户的参数 */ diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserCertificateService.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserCertificateService.java index 4ae7425cb..d00ee5f0d 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserCertificateService.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserCertificateService.java @@ -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 { /** - * 新增用户证书 + * 更新用户的证书信息 * - * @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 返回结果 - * @author fengshuonan - * @since 2023/11/09 22:44 - */ - List findList(SysUserCertificateRequest sysUserCertificateRequest); - - /** - * 获取用户证书分页列表 - * - * @param sysUserCertificateRequest 请求参数 - * @return PageResult 返回结果 - * @author fengshuonan - * @since 2023/11/09 22:44 - */ - PageResult findPage(SysUserCertificateRequest sysUserCertificateRequest); + void updateUserCertificate(Long userId, List sysUserCertificateList); } diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserCertificateServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserCertificateServiceImpl.java index e187d1393..ff01a1be6 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserCertificateServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserCertificateServiceImpl.java @@ -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 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 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 findPage(SysUserCertificateRequest sysUserCertificateRequest) { - LambdaQueryWrapper wrapper = createWrapper(sysUserCertificateRequest); - Page pageList = this.page(PageFactory.defaultPage(), wrapper); - return PageResultFactory.createPageResult(pageList); - } - - @Override - public List findList(SysUserCertificateRequest sysUserCertificateRequest) { - LambdaQueryWrapper 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 sysUserCertificateList) { + if (ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(sysUserCertificateList)) { + return; } - return sysUserCertificate; - } - /** - * 创建查询wrapper - * - * @author fengshuonan - * @since 2023/11/09 22:44 - */ - private LambdaQueryWrapper createWrapper(SysUserCertificateRequest sysUserCertificateRequest) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + // 先清空当前绑定的证书信息 + LambdaQueryWrapper 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); + } } } diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java index c86a30b28..863599734 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java @@ -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 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 impl // 添加用户一个默认角色 sysUserRoleService.bindUserDefaultRole(sysUser.getUserId()); + // 增加用户证书的信息 + sysUserCertificateService.updateUserCertificate(sysUser.getUserId(), sysUserRequest.getUserCertificateList()); + // 记录日志 BusinessLogUtil.setLogTitle("新增用户,用户账号:" + sysUser.getAccount()); BusinessLogUtil.addContent("新增用户账号信息:", sysUser.getAccount());