1.添加手机号和身份证的安全性和保密性
2.添加对应的定时任务
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ruoyi.cms.controller.cms;
|
||||
|
||||
import com.ruoyi.cms.domain.CommunityUser;
|
||||
import com.ruoyi.cms.service.ICommunityUserService;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
@@ -35,6 +36,8 @@ public class CommunityUserController extends BaseController {
|
||||
@PreAuthorize("@ss.hasPermi('application:mgmt:add')")
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CommunityUser communityUser) {
|
||||
//联系方式添加保密性和完整性
|
||||
QuickValidUtils.savePhoneSm4(communityUser);
|
||||
return toAjax(communityUserService.save(communityUser));
|
||||
}
|
||||
|
||||
@@ -42,6 +45,8 @@ public class CommunityUserController extends BaseController {
|
||||
@PreAuthorize("@ss.hasPermi('application:mgmt:edit')")
|
||||
@PutMapping
|
||||
public AjaxResult update(@RequestBody CommunityUser communityUser) {
|
||||
//联系方式添加保密性和完整性
|
||||
QuickValidUtils.savePhoneSm4(communityUser);
|
||||
return toAjax(communityUserService.updateById(communityUser));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.ruoyi.cms.cron;
|
||||
|
||||
import com.ruoyi.cms.mapper.JobMapper;
|
||||
import com.ruoyi.cms.service.IBussinessOperLogService;
|
||||
import com.ruoyi.cms.service.ICompanyService;
|
||||
import com.ruoyi.cms.service.IESJobSearchService;
|
||||
import com.ruoyi.cms.service.IJobService;
|
||||
import com.ruoyi.cms.service.*;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -28,4 +25,18 @@ public class JobCron {
|
||||
}
|
||||
//下架过期岗位
|
||||
public void updateJobDown(){SpringUtils.getBean(IJobService.class).updateJobDown();}
|
||||
//批量修改app_user
|
||||
public void updateAppUserEncrypt(){SpringUtils.getBean(IAppUserService.class).updateAppUserEncrypt(); }
|
||||
//批量更新工作人员配置
|
||||
public void updateCommunityUserEncrypt(){SpringUtils.getBean(ICommunityUserService.class).updateCommunityUserEncrypt();}
|
||||
//批量更新企业表中法人联系方式和身份证
|
||||
public void updateCompanyEncrypt(){SpringUtils.getBean(ICompanyService.class).updateCompanyEncrypt();}
|
||||
//批量更新录入人中身份证和手机号
|
||||
public void updateEmployeeConfirmEncrypt(){SpringUtils.getBean(EmployeeConfirmService.class).updatePhoneEncrypt();}
|
||||
//批量更新企业联系人
|
||||
public void updateCompanyContactEncrypt(){SpringUtils.getBean(CompanyContactService.class).updateCompanyContactEncrypt();}
|
||||
//批量更新岗位联系人
|
||||
public void updateJobContactEncrypt(){SpringUtils.getBean(JobContactService.class).updateJobContactEncrypt();}
|
||||
//批量更新sys系统用户身份证和手机号
|
||||
public void updateSysUserEncrypt(){SpringUtils.getBean(IAppUserService.class).updateSysUserEncrypt();}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,14 @@ public class CommunityUser extends BaseEntity {
|
||||
*/
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 手机号完整性
|
||||
*/
|
||||
private String phoneNumberCipher;
|
||||
|
||||
/**
|
||||
* 手机号机密性
|
||||
*/
|
||||
private String phoneNumberEncrypt;
|
||||
|
||||
}
|
||||
|
||||
@@ -71,4 +71,16 @@ public class EmployeeConfirm extends BaseEntity {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long applyId;
|
||||
|
||||
@ApiModelProperty("联系方式完整性")
|
||||
private String contactPersonPhoneCipher;
|
||||
|
||||
@ApiModelProperty("身份证完整性")
|
||||
private String idCardCipher;
|
||||
|
||||
@ApiModelProperty("联系方式机密性")
|
||||
private String contactPersonPhoneEncrypt;
|
||||
|
||||
@ApiModelProperty("身份证机密性")
|
||||
private String idCardEncrypt;
|
||||
}
|
||||
|
||||
@@ -50,4 +50,10 @@ public class JobContact extends BaseEntity {
|
||||
*/
|
||||
@ApiModelProperty("职务")
|
||||
private String position;
|
||||
|
||||
@ApiModelProperty("联系人电话完整性")
|
||||
private String contactPersonPhoneCipher;
|
||||
|
||||
@ApiModelProperty("联系人电话机密性")
|
||||
private String contactPersonPhoneEncrypt;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,6 @@ public class WechatGroupVo {
|
||||
private String phoneNumber;
|
||||
private String wechatName;
|
||||
private Long communityId;
|
||||
private String phoneNumberCipher;
|
||||
private String phoneNumberEncrypt;
|
||||
}
|
||||
|
||||
@@ -38,4 +38,10 @@ public interface AppUserMapper extends BaseMapper<AppUser>
|
||||
SysUser selectSysUserIdcard(@Param("idCard") String idCard);
|
||||
|
||||
List<AppUserShow> selectUserApplyList(AppUser appUser);
|
||||
|
||||
void batchUpdateIdCardAndPhone(List<AppUser> list);
|
||||
|
||||
List<SysUser> getSysUserListEncrypt();
|
||||
|
||||
void batchUpdateSysUserEncrypt(List<SysUser> list);
|
||||
}
|
||||
|
||||
@@ -35,4 +35,8 @@ public interface CompanyMapper extends BaseMapper<Company>
|
||||
public Company selectByCode(@Param("code") String code);
|
||||
|
||||
List<Company> selectBycodes(List<String> list);
|
||||
|
||||
List<Company> selectCompanyEncryptList(Company company);
|
||||
|
||||
void batchUpdateEncrypt(List<Company> list);
|
||||
}
|
||||
|
||||
@@ -16,4 +16,6 @@ import java.util.List;
|
||||
public interface EmployeeConfirmMapper extends BaseMapper<EmployeeConfirm> {
|
||||
|
||||
List<EmployeeConfirm> getEmployeeConfirmList(EmployeeConfirm employeeConfirm);
|
||||
|
||||
void updatePhoneEncrypt(List<EmployeeConfirm> list);
|
||||
}
|
||||
|
||||
@@ -20,4 +20,6 @@ public interface JobContactMapper extends BaseMapper<JobContact> {
|
||||
int batchInsert(List<JobContact> list);
|
||||
|
||||
List<JobContact> selectByJobIds(@Param("jobIds") List<Long> longs);
|
||||
|
||||
void batchUpdateEncrypt(List<JobContact> list);
|
||||
}
|
||||
|
||||
@@ -18,5 +18,7 @@ public interface CompanyContactService {
|
||||
int insertUpadteCompanyContact(List<CompanyContact> list);
|
||||
|
||||
int insertContact(CompanyContact contact);
|
||||
|
||||
void updateCompanyContactEncrypt();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,5 +20,7 @@ public interface EmployeeConfirmService {
|
||||
int updateEmployeeConfirm(EmployeeConfirm employeeConfirm);
|
||||
|
||||
int deleteEmployeeConfirmIds(Long[] ids);
|
||||
|
||||
void updatePhoneEncrypt();
|
||||
}
|
||||
|
||||
|
||||
@@ -88,4 +88,11 @@ public interface IAppUserService
|
||||
public AppUser getYtjValidIdcard(String phone);
|
||||
|
||||
AjaxResult recognition(byte[] bytes, String fileName, Long userId);
|
||||
|
||||
//更新app用户
|
||||
public void updateAppUserEncrypt();
|
||||
//更新sys用户
|
||||
public void updateSysUserEncrypt();
|
||||
|
||||
public AppUser selectAppuserByIdcard(String idCard,String userType);
|
||||
}
|
||||
|
||||
@@ -9,4 +9,6 @@ public interface ICommunityUserService extends IService<CommunityUser> {
|
||||
List<CommunityUser> selectCommunityUserList(CommunityUser communityUser);
|
||||
|
||||
int delCommunityUser(Long[] ids);
|
||||
|
||||
void updateCommunityUserEncrypt();
|
||||
}
|
||||
|
||||
@@ -79,4 +79,9 @@ public interface ICompanyService
|
||||
Company queryCodeCompany(String code);
|
||||
|
||||
List<Company> selectLikeCompanyList(Company company);
|
||||
|
||||
/**
|
||||
* 批量更新身份证和手机号加密
|
||||
*/
|
||||
void updateCompanyEncrypt();
|
||||
}
|
||||
|
||||
@@ -16,5 +16,7 @@ public interface JobContactService{
|
||||
List<JobContact> getSelectList(JobContact jobContact);
|
||||
|
||||
int batchInsert(List<JobContact> list);
|
||||
|
||||
void updateJobContactEncrypt();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cms.domain.UserInfoDetail;
|
||||
import com.ruoyi.cms.util.AppUserFieldCustomCopy;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.MyChart;
|
||||
import com.ruoyi.common.core.domain.entity.File;
|
||||
@@ -85,6 +86,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
public AppUser selectAppUserByUserId(Long userId)
|
||||
{
|
||||
AppUser appUser = appUserMapper.selectById(userId);
|
||||
//验证手机号完整性
|
||||
QuickValidUtils.phoneValid(appUser);
|
||||
|
||||
if(StringUtils.isNotEmpty(appUser.getJobTitleId())){
|
||||
List<String> list = Arrays.asList(appUser.getJobTitleId().split(","));
|
||||
List<Long> collect = list.stream().map(Long::valueOf).collect(Collectors.toList());
|
||||
@@ -94,17 +98,25 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
//查询企业信息
|
||||
if("0".equals(appUser.getIsCompanyUser())){
|
||||
Company company=companyMapper.selectOne(Wrappers.<Company>lambdaQuery()
|
||||
//.eq(Company::getCode, appUser.getIdCard())
|
||||
.apply("UPPER(code) = {0}", StringUtil.toUpperCaseIgnoreBlank(appUser.getIdCard()))
|
||||
.orderByDesc(Company::getUpdateTime).last("LIMIT 1"));
|
||||
//解密手机号
|
||||
if(company!=null){
|
||||
QuickValidUtils.legalPhoneOrIdCardValid(company);
|
||||
}
|
||||
appUser.setCompany(company);
|
||||
if(company!=null){
|
||||
CompanyContact contact=new CompanyContact();
|
||||
contact.setCompanyId(company.getCompanyId());
|
||||
List<CompanyContact> companyContactList=companyContactMapper.getSelectList(contact);
|
||||
companyContactList.stream().forEach(it->{
|
||||
QuickValidUtils.companyContactPhoneValid(it);
|
||||
});
|
||||
company.setCompanyContactList(companyContactList);
|
||||
}
|
||||
}else if("1".equals(appUser.getIsCompanyUser())){
|
||||
//验证身份证完整性
|
||||
QuickValidUtils.idCardValid(appUser);
|
||||
//工作经历
|
||||
UserWorkExperiences workExperiences=new UserWorkExperiences();
|
||||
workExperiences.setUserId(appUser.getUserId());
|
||||
@@ -146,15 +158,19 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertAppUser(AppUser appUser)
|
||||
{
|
||||
//一体机加密
|
||||
if(StringUtils.isNotEmpty(appUser.getYtjPassword())){
|
||||
try {
|
||||
appUser.setYtjPassword(SiteSecurityUtils.encryptPassword(appUser.getYtjPassword()));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("密码加密出错", e);
|
||||
}
|
||||
appUser.setYtjPassword(SiteSecurityUtils.encryptPassword(appUser.getYtjPassword()));
|
||||
}else{
|
||||
appUser.setYtjPassword(null);
|
||||
}
|
||||
|
||||
//密码机完整性/保密性
|
||||
QuickValidUtils.savePhoneSm4(appUser);
|
||||
//判断如果是企业则不加密
|
||||
if(!StringUtil.IS_COMPANY_USER.equals(appUser.getIsCompanyUser())){
|
||||
QuickValidUtils.saveIdCardSm4(appUser);
|
||||
}
|
||||
return appUserMapper.insert(appUser);
|
||||
}
|
||||
|
||||
@@ -212,6 +228,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
if(!StringUtils.isBlank(appUser.getArea())){
|
||||
appUser.setRegionCode(StringUtil.getAreaToRegionCode(appUser.getArea()));
|
||||
}
|
||||
//手机号/身份证完整性
|
||||
QuickValidUtils.savePhoneIdCardSm4(appUser);
|
||||
return appUserMapper.updateById(appUser);
|
||||
}
|
||||
|
||||
@@ -229,20 +247,35 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
|
||||
@Override
|
||||
public AppUser getPhone(String phone) {
|
||||
return appUserMapper.selectOne(new LambdaQueryWrapper<AppUser>()
|
||||
AppUser appUser=appUserMapper.selectOne(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getPhone, phone).eq(AppUser::getDelFlag,"0").orderByDesc(AppUser::getUpdateTime).last("LIMIT 1"));
|
||||
if(appUser!=null){
|
||||
//phone解密/验证完整性
|
||||
QuickValidUtils.phoneValid(appUser);
|
||||
}
|
||||
return appUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser getPhoneAndNoRole(String phone) {
|
||||
return appUserMapper.selectOne(new LambdaQueryWrapper<AppUser>()
|
||||
AppUser appUser=appUserMapper.selectOne(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getPhone, phone).eq(AppUser::getDelFlag,"0").isNull(AppUser::getIsCompanyUser).orderByDesc(AppUser::getUpdateTime).last("LIMIT 1"));
|
||||
if(appUser!=null){
|
||||
//phone解密/验证完整性
|
||||
QuickValidUtils.phoneValid(appUser);
|
||||
}
|
||||
return appUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser getPhoneAndUserType(String phone,String userType) {
|
||||
return appUserMapper.selectOne(new LambdaQueryWrapper<AppUser>()
|
||||
AppUser appUser=appUserMapper.selectOne(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getPhone, phone).eq(AppUser::getIsCompanyUser,userType).eq(AppUser::getDelFlag,"0").orderByDesc(AppUser::getUpdateTime).last("LIMIT 1"));
|
||||
if(appUser!=null){
|
||||
//phone解密/验证完整性
|
||||
QuickValidUtils.phoneValid(appUser);
|
||||
}
|
||||
return appUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -299,6 +332,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
appSkillMapper.batchInsert(registerBody.getAppSkillsList());
|
||||
}
|
||||
mapUserRole.put("roleId",StringUtil.SYS_QZZ);
|
||||
//身份证加密/完整性
|
||||
QuickValidUtils.saveIdCardSm4(appUser);
|
||||
}
|
||||
//保存sys_user
|
||||
SysUser parmUser=appUserMapper.selectSysUserIdcard(appUser.getIdCard());
|
||||
@@ -405,6 +440,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
*/
|
||||
private void handleCompanyUserLogic(AppUser appUser, Company company) {
|
||||
if (company != null) {
|
||||
//企业法人和联系方式加密和完整性
|
||||
QuickValidUtils.legalSm4(company);
|
||||
Company resultCom=companyMapper.selectByCode(company.getCode());
|
||||
if(resultCom==null){
|
||||
// 保存企业信息(新增场景)
|
||||
@@ -447,6 +484,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
.filter(contact -> contact.getContactPerson() != null
|
||||
&& contact.getContactPersonPhone() != null
|
||||
&& contact.getCompanyId() != null)
|
||||
.peek(QuickValidUtils::saveCompanyContactPhoneSm4)
|
||||
.filter(contact -> {
|
||||
String currentUniqueKey = contact.getContactPerson() + "_" + contact.getContactPersonPhone() + "_" + contact.getCompanyId();
|
||||
return !existingContactKeySet.contains(currentUniqueKey);
|
||||
@@ -464,6 +502,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
* @param registerBody 注册请求体
|
||||
*/
|
||||
private void handleJobSeekerUserLogic(AppUser appUser, RegisterBody registerBody) {
|
||||
//身份证加密/完整性
|
||||
QuickValidUtils.saveIdCardSm4(appUser);
|
||||
|
||||
Long userId = appUser.getUserId();
|
||||
// 保存工作经历
|
||||
saveUserWorkExperiences(userId, registerBody.getExperiencesList());
|
||||
@@ -579,6 +620,16 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
.orderByDesc(AppUser::getUpdateTime).last("LIMIT 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUser selectAppuserByIdcard(String idCard,String userType) {
|
||||
return appUserMapper.selectOne(Wrappers.<AppUser>lambdaQuery()
|
||||
//.eq(AppUser::getIdCard, idCard)
|
||||
.apply("UPPER(id_card) = {0}", StringUtil.toUpperCaseIgnoreBlank(idCard))
|
||||
.eq(AppUser::getDelFlag,"0")
|
||||
.eq(AppUser::getIsCompanyUser,userType)
|
||||
.orderByDesc(AppUser::getUpdateTime).last("LIMIT 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserLky selectAppUserInfo(AppUser appUser) {
|
||||
AppUserLky lky=new AppUserLky();
|
||||
@@ -957,4 +1008,30 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper,AppUser> imple
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateAppUserEncrypt(){
|
||||
List<AppUser> userList=appUserMapper.selectAppUserList(new AppUser());
|
||||
List<AppUser> encryptedList=userList.stream().peek(user->{
|
||||
QuickValidUtils.savePhoneSm4(user);
|
||||
if(!StringUtil.IS_COMPANY_USER.equals(user.getIsCompanyUser())){
|
||||
QuickValidUtils.saveIdCardSm4(user);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
List<List<AppUser>> batches = StringUtil.splitList(encryptedList, StringUtil.BATCH_SIZE);
|
||||
for (List<AppUser> batch : batches) {
|
||||
appUserMapper.batchUpdateIdCardAndPhone(batch);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateSysUserEncrypt(){
|
||||
List<SysUser> sysUserList=appUserMapper.getSysUserListEncrypt();
|
||||
List<SysUser> encryptList=sysUserList.stream().peek(QuickValidUtils::saveSysUserSm4).collect(Collectors.toList());
|
||||
if(!encryptList.isEmpty()){
|
||||
List<List<SysUser>> batches = StringUtil.splitList(encryptList, StringUtil.BATCH_SIZE);
|
||||
for (List<SysUser> batch : batches) {
|
||||
appUserMapper.batchUpdateSysUserEncrypt(batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.cms.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cms.domain.CommunityUser;
|
||||
@@ -9,12 +10,15 @@ import com.ruoyi.cms.domain.WechatGroup;
|
||||
import com.ruoyi.cms.mapper.CommunityUserMapper;
|
||||
import com.ruoyi.cms.mapper.WechatGroupMapper;
|
||||
import com.ruoyi.cms.service.ICommunityUserService;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class CommunityUserServiceImpl extends ServiceImpl<CommunityUserMapper, CommunityUser>
|
||||
@@ -25,11 +29,11 @@ public class CommunityUserServiceImpl extends ServiceImpl<CommunityUserMapper, C
|
||||
|
||||
@Override
|
||||
public List<CommunityUser> selectCommunityUserList(CommunityUser communityUser) {
|
||||
|
||||
return baseMapper.selectList(Wrappers.lambdaQuery(CommunityUser.class)
|
||||
List<CommunityUser> list=baseMapper.selectList(Wrappers.lambdaQuery(CommunityUser.class)
|
||||
.like(StrUtil.isNotBlank(communityUser.getWechatName()), CommunityUser::getWechatName, communityUser.getWechatName())
|
||||
.like(StrUtil.isNotBlank(communityUser.getPhoneNumber()), CommunityUser::getPhoneNumber, communityUser.getPhoneNumber())
|
||||
);
|
||||
return list.stream().peek(QuickValidUtils::phoneValid).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,4 +47,38 @@ public class CommunityUserServiceImpl extends ServiceImpl<CommunityUserMapper, C
|
||||
}
|
||||
return baseMapper.deleteBatchIds(userIds);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCommunityUserEncrypt(){
|
||||
try {
|
||||
List<CommunityUser> userList = baseMapper.selectList(Wrappers.lambdaQuery(CommunityUser.class));
|
||||
List<CommunityUser> encryptList = userList.stream().peek(QuickValidUtils::savePhoneSm4).collect(Collectors.toList());
|
||||
if(!encryptList.isEmpty()){
|
||||
batchUpdatePhoneAndCipher(encryptList);
|
||||
}
|
||||
System.out.println("用户手机号加密更新完成,共处理 {} 条数据"+userList.size());
|
||||
}catch (Exception e) {
|
||||
log.error("用户手机号加密更新失败", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新
|
||||
* @param userList
|
||||
*/
|
||||
public void batchUpdatePhoneAndCipher(List<CommunityUser> userList) {
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < userList.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, userList.size());
|
||||
List<CommunityUser> subList = userList.subList(i, end);
|
||||
subList.forEach(user -> {
|
||||
LambdaUpdateWrapper<CommunityUser> wrapper = Wrappers.lambdaUpdate();
|
||||
wrapper.eq(CommunityUser::getId, user.getId())
|
||||
.set(CommunityUser::getPhoneNumberEncrypt, user.getPhoneNumberEncrypt())
|
||||
.set(CommunityUser::getPhoneNumberCipher, user.getPhoneNumberCipher());
|
||||
baseMapper.update(null, wrapper);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import com.ruoyi.common.core.domain.entity.CompanyContact;
|
||||
import com.ruoyi.cms.mapper.CompanyContactMapper;
|
||||
import com.ruoyi.cms.service.CompanyContactService;
|
||||
@@ -28,6 +30,7 @@ public class CompanyContactServiceImpl extends ServiceImpl<CompanyContactMapper,
|
||||
@Transactional
|
||||
public int insertUpadteCompanyContact(List<CompanyContact> list) {
|
||||
Map<Boolean, List<CompanyContact>> partitioned = list.stream()
|
||||
.peek(QuickValidUtils::saveCompanyContactPhoneSm4)
|
||||
.collect(Collectors.partitioningBy(it -> it.getId() != null));
|
||||
List<CompanyContact> add=partitioned.get(false);
|
||||
List<CompanyContact> udp=partitioned.get(true);
|
||||
@@ -42,6 +45,19 @@ public class CompanyContactServiceImpl extends ServiceImpl<CompanyContactMapper,
|
||||
|
||||
@Override
|
||||
public int insertContact(CompanyContact contact) {
|
||||
QuickValidUtils.saveCompanyContactPhoneSm4(contact);
|
||||
return companyContactMapper.insert(contact);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCompanyContactEncrypt(){
|
||||
List<CompanyContact> list=companyContactMapper.getSelectList(new CompanyContact());
|
||||
List<CompanyContact> encryptList=list.stream().peek(QuickValidUtils::saveCompanyContactPhoneSm4).collect(Collectors.toList());
|
||||
if(!encryptList.isEmpty()){
|
||||
List<List<CompanyContact>> batches = StringUtil.splitList(encryptList, StringUtil.BATCH_SIZE);
|
||||
for (List<CompanyContact> batch : batches) {
|
||||
companyContactMapper.batchUpdate(batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cms.domain.*;
|
||||
import com.ruoyi.cms.domain.query.LabelQuery;
|
||||
import com.ruoyi.cms.mapper.*;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.Company;
|
||||
import com.ruoyi.common.core.domain.entity.CompanyContact;
|
||||
@@ -119,16 +121,19 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
||||
if(count>0){
|
||||
throw new ServiceException(company.getName()+",该公司已存在");
|
||||
}
|
||||
List<CompanyContact> contacts=company.getCompanyContactList();
|
||||
//加密法人身份证和联系方式
|
||||
QuickValidUtils.legalPhoneOrIdCardValid(company);
|
||||
int insert =companyMapper.insert(company);
|
||||
if(insert>0){
|
||||
if(company.getCompanyContactList()!=null){
|
||||
company.getCompanyContactList().forEach(x->{
|
||||
CompanyContact companyContact=new CompanyContact();
|
||||
BeanUtils.copyProperties(x,companyContact);
|
||||
companyContact.setCompanyId(company.getCompanyId());
|
||||
companyContactMapper.insert(companyContact);
|
||||
});
|
||||
}
|
||||
if(insert>0&&contacts!=null){
|
||||
contacts.forEach(x->{
|
||||
CompanyContact companyContact=new CompanyContact();
|
||||
BeanUtils.copyProperties(x,companyContact);
|
||||
companyContact.setCompanyId(company.getCompanyId());
|
||||
//手机号加密
|
||||
QuickValidUtils.saveCompanyContactPhoneSm4(companyContact);
|
||||
companyContactMapper.insert(companyContact);
|
||||
});
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
@@ -146,6 +151,8 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
||||
if(count>1){
|
||||
throw new ServiceException(company.getName()+",该公司已存在");
|
||||
}
|
||||
//加密法人身份证和联系方式
|
||||
QuickValidUtils.legalPhoneOrIdCardValid(company);
|
||||
int i=companyMapper.updateById(company);
|
||||
if(i>0){
|
||||
companyContactMapper.update(null,Wrappers.<CompanyContact>lambdaUpdate()
|
||||
@@ -157,6 +164,8 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
||||
companyContact.setCompanyId(company.getCompanyId());
|
||||
companyContact.setContactPerson(x.getContactPerson());
|
||||
companyContact.setContactPersonPhone(x.getContactPersonPhone());
|
||||
//手机号加密
|
||||
QuickValidUtils.saveCompanyContactPhoneSm4(companyContact);
|
||||
companyContactMapper.insert(companyContact);
|
||||
});
|
||||
}
|
||||
@@ -330,4 +339,17 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
||||
public List<Company> selectLikeCompanyList(Company company) {
|
||||
return companyMapper.selectLikeCompanyList(company);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCompanyEncrypt() {
|
||||
List<Company> companyList=companyMapper.selectCompanyEncryptList(new Company());
|
||||
List<Company> encryptList=companyList.stream().peek(QuickValidUtils::legalSm4).collect(Collectors.toList());
|
||||
if(!encryptList.isEmpty()){
|
||||
List<List<Company>> batches = StringUtil.splitList(encryptList, StringUtil.BATCH_SIZE);
|
||||
for (List<Company> batch : batches) {
|
||||
companyMapper.batchUpdateEncrypt(batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,15 @@ import com.ruoyi.cms.mapper.JobMapper;
|
||||
import com.ruoyi.cms.mapper.NoticeMapper;
|
||||
import com.ruoyi.cms.service.EmployeeConfirmService;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import com.ruoyi.cms.util.notice.NoticeUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -36,7 +39,9 @@ public class EmployeeConfirmServiceImpl implements EmployeeConfirmService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertEmployeeConfirm(EmployeeConfirm employeeConfirm) {
|
||||
QuickValidUtils.savePhoneIdCardSm4(employeeConfirm);
|
||||
int t=employeeConfirmMapper.insert(employeeConfirm);
|
||||
if(t>0){
|
||||
JobApply apply=new JobApply();
|
||||
@@ -53,7 +58,9 @@ public class EmployeeConfirmServiceImpl implements EmployeeConfirmService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateEmployeeConfirm(EmployeeConfirm employeeConfirm) {
|
||||
QuickValidUtils.savePhoneIdCardSm4(employeeConfirm);
|
||||
return employeeConfirmMapper.updateById(employeeConfirm);
|
||||
}
|
||||
|
||||
@@ -61,4 +68,16 @@ public class EmployeeConfirmServiceImpl implements EmployeeConfirmService {
|
||||
public int deleteEmployeeConfirmIds(Long[] ids) {
|
||||
return employeeConfirmMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePhoneEncrypt(){
|
||||
List<EmployeeConfirm> list=employeeConfirmMapper.getEmployeeConfirmList(new EmployeeConfirm());
|
||||
List<EmployeeConfirm> encryptList=list.stream().peek(QuickValidUtils::savePhoneIdCardSm4).collect(Collectors.toList());
|
||||
if(!encryptList.isEmpty()){
|
||||
List<List<EmployeeConfirm>> batches = StringUtil.splitList(encryptList, StringUtil.BATCH_SIZE);
|
||||
for (List<EmployeeConfirm> batch : batches) {
|
||||
employeeConfirmMapper.updatePhoneEncrypt(batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,15 @@ package com.ruoyi.cms.service.impl;
|
||||
import com.ruoyi.cms.domain.JobContact;
|
||||
import com.ruoyi.cms.mapper.JobContactMapper;
|
||||
import com.ruoyi.cms.service.JobContactService;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -23,4 +28,16 @@ public class JobContactServiceImpl extends ServiceImpl<JobContactMapper, JobCont
|
||||
public int batchInsert(List<JobContact> list) {
|
||||
return jobContactMapper.batchInsert(list);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateJobContactEncrypt(){
|
||||
List<JobContact> list=jobContactMapper.getSelectList(new JobContact());
|
||||
List<JobContact> encryptList=list.stream().peek(QuickValidUtils::savePhoneSm4).collect(Collectors.toList());
|
||||
if(!encryptList.isEmpty()){
|
||||
List<List<JobContact>> batches = StringUtil.splitList(encryptList, StringUtil.BATCH_SIZE);
|
||||
for (List<JobContact> batch : batches) {
|
||||
jobContactMapper.batchUpdateEncrypt(batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.cms.domain.*;
|
||||
import com.ruoyi.cms.domain.vo.JobExcelVo;
|
||||
import com.ruoyi.cms.util.DictUtils;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import com.ruoyi.cms.util.notice.NoticeUtils;
|
||||
import com.ruoyi.common.core.domain.entity.File;
|
||||
import com.ruoyi.cms.domain.query.ESJobSearch;
|
||||
@@ -24,10 +26,7 @@ import com.ruoyi.common.core.domain.entity.Company;
|
||||
import com.ruoyi.common.core.domain.entity.JobTitle;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.SiteSecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.*;
|
||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -375,6 +374,8 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
JobContact jobContact=new JobContact();
|
||||
BeanUtils.copyProperties(x,jobContact);
|
||||
jobContact.setJobId(job.getJobId());
|
||||
//加密
|
||||
QuickValidUtils.savePhoneSm4(jobContact);
|
||||
jobContactMapper.insert(jobContact);
|
||||
});
|
||||
//添加附件
|
||||
@@ -458,6 +459,8 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
targetContact.setContactPerson(originContact.getContactPerson());
|
||||
targetContact.setContactPersonPhone(originContact.getContactPersonPhone());
|
||||
targetContact.setPosition(originContact.getPosition());
|
||||
//加密手机号
|
||||
QuickValidUtils.savePhoneSm4(targetContact);
|
||||
|
||||
if (originContact.getId() == null) {
|
||||
insertList.add(targetContact);
|
||||
@@ -637,7 +640,9 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
JobContact contact = new JobContact();
|
||||
contact.setJobId(jobId);
|
||||
List<JobContact> contacts = jobContactMapper.getSelectList(contact);
|
||||
job.setJobContactList(contacts == null ? Collections.emptyList() : contacts);
|
||||
List<JobContact> contactList = contacts == null ? Collections.emptyList() : contacts;
|
||||
contactList.forEach(QuickValidUtils::phoneValid);
|
||||
job.setJobContactList(contactList);
|
||||
//查询附件
|
||||
String baseFilePath = StringUtil.getFilePath(request);
|
||||
File queryFile = new File();
|
||||
@@ -663,7 +668,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
public List<CandidateVO> candidates(Long jobId) {
|
||||
List<CandidateVO> jobList = jobApplyMapper.candidates(jobId);
|
||||
List<JobTitle> jobTitles = jobTitleMapper.selectList(new QueryWrapper<>());
|
||||
jobList.forEach(x->x.setJobTitle(wrapperJobTitleList(jobTitles,x.getJobTitleId())));
|
||||
jobList.stream().filter(Objects::nonNull).peek(QuickValidUtils::candidatePhoneOrIdCardValid).forEach(x->x.setJobTitle(wrapperJobTitleList(jobTitles,x.getJobTitleId())));
|
||||
return jobList;
|
||||
}
|
||||
|
||||
@@ -1061,7 +1066,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper,Job> implements IJobSe
|
||||
|
||||
//修改联系人
|
||||
List<JobContact> jobContactList = job.getJobContactList() != null ? job.getJobContactList() : Collections.emptyList();
|
||||
jobContactList.stream().filter(Objects::nonNull).forEach(it -> it.setJobId(job.getJobId()));
|
||||
jobContactList.stream().filter(Objects::nonNull).peek(QuickValidUtils::savePhoneSm4).forEach(it -> it.setJobId(job.getJobId()));
|
||||
if(!jobContactList.isEmpty()){
|
||||
jobContactMapper.batchInsert(jobContactList);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import com.ruoyi.cms.domain.WechatGroup;
|
||||
import com.ruoyi.cms.domain.vo.WechatGroupVo;
|
||||
import com.ruoyi.cms.mapper.WechatGroupMapper;
|
||||
import com.ruoyi.cms.service.IWechatGroupService;
|
||||
import com.ruoyi.cms.util.encrypt.QuickValidUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class WechatGroupServiceImpl extends ServiceImpl<WechatGroupMapper, WechatGroup>
|
||||
@@ -15,6 +17,7 @@ public class WechatGroupServiceImpl extends ServiceImpl<WechatGroupMapper, Wecha
|
||||
|
||||
@Override
|
||||
public List<WechatGroupVo> selectWechatGroupList(WechatGroup wechatGroup) {
|
||||
return baseMapper.selectWechatGroupList(wechatGroup);
|
||||
List<WechatGroupVo> list=baseMapper.selectWechatGroupList(wechatGroup);
|
||||
return list.stream().peek(QuickValidUtils::phoneValid).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,9 @@ public class StringUtil {
|
||||
*/
|
||||
public static final Map<String, String> REGION_CODE_CODE_MAP;
|
||||
|
||||
//批量条数
|
||||
public static final int BATCH_SIZE = 1000;
|
||||
|
||||
static {
|
||||
Map<String, String> tempMap = new HashMap<>();
|
||||
tempMap.put("中专及以上", "1");
|
||||
@@ -365,4 +368,13 @@ public class StringUtil {
|
||||
default: return code;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<List<T>> splitList(List<T> list, int batchSize) {
|
||||
List<List<T>> batches = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, list.size());
|
||||
batches.add(list.subList(i, end));
|
||||
}
|
||||
return batches;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,587 @@
|
||||
package com.ruoyi.cms.util.encrypt;
|
||||
|
||||
import com.ruoyi.cms.domain.CommunityUser;
|
||||
import com.ruoyi.cms.domain.EmployeeConfirm;
|
||||
import com.ruoyi.cms.domain.JobContact;
|
||||
import com.ruoyi.cms.domain.vo.CandidateVO;
|
||||
import com.ruoyi.cms.domain.vo.WechatGroupVo;
|
||||
import com.ruoyi.cms.util.StringUtil;
|
||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
||||
import com.ruoyi.common.core.domain.entity.Company;
|
||||
import com.ruoyi.common.core.domain.entity.CompanyContact;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.EncryptDecryptUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quickssl.api.CryptoClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 加密验签工具类
|
||||
*/
|
||||
@Component
|
||||
public class QuickValidUtils {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(QuickValidUtils.class);
|
||||
|
||||
private static volatile QuickValidUtils INSTANCE;
|
||||
|
||||
@Autowired
|
||||
private EncryptDecryptUtil encryptDecryptUtil;
|
||||
|
||||
private static final String TAMPER_PHONE_IDCARD_MSG = "手机号或者身份证信息完整性已被篡改,请联系管理员确认!";
|
||||
private static final String TAMPER_PHONE_MSG = "手机号信息完整性已被篡改,请联系管理员确定!";
|
||||
private static final String TAMPER_IDCARD_MSG = "身份证信息完整性已被篡改,请联系管理员确定!";
|
||||
|
||||
/**
|
||||
* Spring初始化完成后赋值静态实例
|
||||
*/
|
||||
@PostConstruct
|
||||
public synchronized void init() {
|
||||
if (INSTANCE != null) {
|
||||
log.warn("QuickValidUtils已初始化,重复初始化被忽略");
|
||||
return;
|
||||
}
|
||||
if (encryptDecryptUtil == null) {
|
||||
throw new IllegalStateException("EncryptDecryptUtil注入失败,请检查Spring配置");
|
||||
}
|
||||
INSTANCE = this;
|
||||
log.info("QuickValidUtils初始化成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工具类实例
|
||||
*/
|
||||
private static QuickValidUtils getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (QuickValidUtils.class) {
|
||||
if (INSTANCE == null) {
|
||||
throw new IllegalStateException("QuickValidUtils未初始化,请确保Spring容器已启动并完成注入");
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
// ======================== 提取的通用私有方法 ========================
|
||||
/**
|
||||
* 通用SM4解密方法
|
||||
* @param cipherText 加密串
|
||||
* @return 解密后的明文
|
||||
* @throws CryptoClient.CryptoException 解密异常
|
||||
*/
|
||||
private static String sm4Decrypt(String cipherText) throws CryptoClient.CryptoException {
|
||||
return getInstance().encryptDecryptUtil.sm4Decrypt(cipherText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用SM4加密方法
|
||||
* @param plainText 明文
|
||||
* @return 加密后的密文
|
||||
* @throws CryptoClient.CryptoException 加密异常
|
||||
*/
|
||||
private static String sm4Encrypt(String plainText) throws CryptoClient.CryptoException {
|
||||
return getInstance().encryptDecryptUtil.sm4Encrypt(plainText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用SM3验签方法
|
||||
* @param plainText 明文
|
||||
* @param sign 待验证的签名字符串
|
||||
* @return true-验签通过,false-验签失败
|
||||
* @throws Exception 验签异常
|
||||
*/
|
||||
private static boolean sm3Verify(String plainText, String sign) throws CryptoClient.CryptoException {
|
||||
return getInstance().encryptDecryptUtil.sm3Verify(plainText, sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用SM3哈希方法(生成签名字符串)
|
||||
* @param plainText 明文
|
||||
* @return 哈希后的签名字符串
|
||||
* @throws CryptoClient.CryptoException 哈希异常
|
||||
*/
|
||||
private static String sm3Hash(String plainText) throws CryptoClient.CryptoException {
|
||||
return getInstance().encryptDecryptUtil.sm3Hash(plainText);
|
||||
}
|
||||
|
||||
// ======================== 原有业务方法 ========================
|
||||
/**
|
||||
* 企业-解密手机号/身份证并验签
|
||||
* @param company 企业实体
|
||||
*/
|
||||
public static void legalPhoneOrIdCardValid(Company company) {
|
||||
String phone = "";
|
||||
boolean phoneTrue = true;
|
||||
String idCard = "";
|
||||
boolean idCardTrue = true;
|
||||
try {
|
||||
if (!StringUtils.isBlank(company.getLegalPhone())) {
|
||||
phone = sm4Decrypt(company.getLegalPhoneEncrypt());
|
||||
phoneTrue = sm3Verify(phone, company.getLegalPhoneCipher());
|
||||
//company.setLegalPhone(phone);
|
||||
}
|
||||
if (!StringUtils.isBlank(company.getLegalIdCard())) {
|
||||
idCard = sm4Decrypt(company.getLegalIdCardEncrypt());
|
||||
idCardTrue = sm3Verify(idCard, company.getLegalIdCardCipher());
|
||||
//company.setLegalIdCard(idCard);
|
||||
}
|
||||
if (!phoneTrue || !idCardTrue) {
|
||||
throw new RuntimeException(TAMPER_PHONE_IDCARD_MSG);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("企业法人手机号/身份证解密失败", e);
|
||||
throw new RuntimeException("解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("企业法人手机号/身份证验签失败", e1);
|
||||
throw new RuntimeException("验签失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业或个人
|
||||
* @param vo
|
||||
*/
|
||||
public static void candidatePhoneOrIdCardValid(CandidateVO vo) {
|
||||
String phone = "";
|
||||
boolean phoneTrue = true;
|
||||
String idCard = "";
|
||||
boolean idCardTrue = true;
|
||||
try {
|
||||
if(!StringUtils.isBlank(vo.getPhone())){
|
||||
phone=sm4Decrypt(vo.getPhoneEncrypt());
|
||||
phoneTrue=sm3Verify(phone,vo.getPhoneCipher());
|
||||
//vo.setPhone(phone);
|
||||
}
|
||||
if(!StringUtils.isBlank(vo.getIdCard())){
|
||||
idCard=sm4Decrypt(vo.getIdCardEncrypt());
|
||||
idCardTrue=sm3Verify(idCard,vo.getIdCardCipher());
|
||||
//vo.setIdCard(idCard);
|
||||
}
|
||||
if (!phoneTrue || !idCardTrue) {
|
||||
throw new RuntimeException(TAMPER_PHONE_IDCARD_MSG);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("企业和个人手机号/身份证解密失败", e);
|
||||
throw new RuntimeException("解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("企业和个人手机号/身份证验签失败", e1);
|
||||
throw new RuntimeException("验签失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业联系人手机号解密/完整性验签
|
||||
* @param contact 企业联系人实体
|
||||
*/
|
||||
public static void companyContactPhoneValid(CompanyContact contact) {
|
||||
String phone = "";
|
||||
boolean phoneTrue = true;
|
||||
try {
|
||||
if (!StringUtils.isBlank(contact.getContactPersonPhone())) {
|
||||
phone = sm4Decrypt(contact.getContactPersonPhoneEncrypt());
|
||||
phoneTrue = sm3Verify(phone, contact.getContactPersonPhoneCipher());
|
||||
//contact.setContactPersonPhone(phone);
|
||||
if (!phoneTrue) {
|
||||
throw new RuntimeException(TAMPER_PHONE_MSG);
|
||||
}
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("企业联系人手机号解密失败", e);
|
||||
throw new RuntimeException("用户信息解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("企业联系人手机号验签失败", e1);
|
||||
throw new RuntimeException("用户信息验证失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户验证-手机号解密/验证完整性
|
||||
* @param appUser 用户实体
|
||||
*/
|
||||
public static void phoneValid(AppUser appUser) {
|
||||
String phone = "";
|
||||
boolean phoneTrue = false;
|
||||
try {
|
||||
if(StringUtils.isNotBlank(appUser.getPhoneEncrypt())) {
|
||||
phone = sm4Decrypt(appUser.getPhoneEncrypt());
|
||||
phoneTrue = sm3Verify(phone, appUser.getPhoneCipher());
|
||||
//appUser.setPhone(phone);
|
||||
if (!phoneTrue) {
|
||||
throw new RuntimeException(TAMPER_PHONE_MSG);
|
||||
}
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("App用户手机号解密失败", e);
|
||||
throw new RuntimeException("用户信息解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("App用户手机号验签失败", e1);
|
||||
throw new RuntimeException("用户信息验证失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位联系人解密/验证完整性
|
||||
* @param jobContact
|
||||
*/
|
||||
public static void phoneValid(JobContact jobContact) {
|
||||
String phone = "";
|
||||
boolean phoneTrue = false;
|
||||
try {
|
||||
if(StringUtils.isNotBlank(jobContact.getContactPersonPhoneEncrypt())){
|
||||
phone=sm4Decrypt(jobContact.getContactPersonPhoneEncrypt());
|
||||
phoneTrue=sm3Verify(phone,jobContact.getContactPersonPhoneCipher());
|
||||
//jobContact.setContactPersonPhone(phone);
|
||||
if (!phoneTrue) {
|
||||
throw new RuntimeException(TAMPER_PHONE_MSG);
|
||||
}
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("岗位联系人手机号解密失败", e);
|
||||
throw new RuntimeException("用户信息解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("岗位联系人手机号验签失败", e1);
|
||||
throw new RuntimeException("用户信息验证失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 工作人员手机号解密/验证完整性
|
||||
* @param communityUser
|
||||
*/
|
||||
public static void phoneValid(CommunityUser communityUser) {
|
||||
String phone = "";
|
||||
boolean phoneTrue = false;
|
||||
try {
|
||||
if(StringUtils.isNotBlank(communityUser.getPhoneNumber())){
|
||||
phone=sm4Decrypt(communityUser.getPhoneNumberEncrypt());
|
||||
phoneTrue=sm3Verify(phone,communityUser.getPhoneNumberCipher());
|
||||
//communityUser.setPhoneNumber(phone);
|
||||
if (!phoneTrue) {
|
||||
throw new RuntimeException(TAMPER_PHONE_MSG);
|
||||
}
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("手机号解密失败", e);
|
||||
throw new RuntimeException("手机号解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("手机号验签失败", e1);
|
||||
throw new RuntimeException("手机号验证失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*转发对象手机号
|
||||
* @param vo
|
||||
*/
|
||||
public static void phoneValid(WechatGroupVo vo) {
|
||||
String phone = "";
|
||||
boolean phoneTrue = false;
|
||||
try {
|
||||
if(StringUtils.isNotBlank(vo.getPhoneNumber())){
|
||||
phone=sm4Decrypt(vo.getPhoneNumberEncrypt());
|
||||
phoneTrue=sm3Verify(phone,vo.getPhoneNumberCipher());
|
||||
//vo.setPhoneNumber(phone);
|
||||
if (!phoneTrue) {
|
||||
throw new RuntimeException(TAMPER_PHONE_MSG);
|
||||
}
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("手机号解密失败", e);
|
||||
throw new RuntimeException("手机号解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("手机号验签失败", e1);
|
||||
throw new RuntimeException("手机号验证失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证解密/验证完整性
|
||||
* @param appUser 用户实体
|
||||
*/
|
||||
public static void idCardValid(AppUser appUser) {
|
||||
String idCard = "";
|
||||
boolean idCardTrue = true;
|
||||
try {
|
||||
if (StringUtils.isNotBlank(appUser.getIdCardCipher())) {
|
||||
idCard = sm4Decrypt(appUser.getIdCardEncrypt());
|
||||
idCardTrue = sm3Verify(idCard, appUser.getIdCardCipher());
|
||||
//appUser.setIdCard(idCard);
|
||||
}
|
||||
if (!idCardTrue) {
|
||||
throw new RuntimeException(TAMPER_IDCARD_MSG);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("App用户身份证解密失败", e);
|
||||
throw new RuntimeException("用户信息解密失败:" + e.getMessage(), e);
|
||||
} catch (Exception e1) {
|
||||
log.error("App用户身份证验签失败", e1);
|
||||
throw new RuntimeException("用户信息验证失败:" + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号加密/生成完整性校验串
|
||||
* @param appUser 用户实体
|
||||
*/
|
||||
public static void savePhoneSm4(AppUser appUser) {
|
||||
try {
|
||||
String phoneSm4 = sm4Encrypt(appUser.getPhone());
|
||||
String phoneSm3 = sm3Hash(appUser.getPhone());
|
||||
appUser.setPhoneEncrypt(phoneSm4);
|
||||
appUser.setPhoneCipher(phoneSm3);
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("App用户手机号加密失败", e);
|
||||
throw new RuntimeException("手机号加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 岗位联系人加密
|
||||
* @param jobContact
|
||||
*/
|
||||
public static void savePhoneSm4(JobContact jobContact) {
|
||||
try {
|
||||
if(!StringUtils.isBlank(jobContact.getContactPersonPhone())){
|
||||
String phoneSm4=sm4Encrypt(jobContact.getContactPersonPhone());
|
||||
String phoneSm3=sm3Hash(jobContact.getContactPersonPhone());
|
||||
jobContact.setContactPersonPhoneEncrypt(phoneSm4);
|
||||
jobContact.setContactPersonPhoneCipher(phoneSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("岗位联系人用户手机号加密失败", e);
|
||||
throw new RuntimeException("手机号加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信抓取负责人
|
||||
* @param communityUser
|
||||
*/
|
||||
public static void savePhoneSm4(CommunityUser communityUser) {
|
||||
try {
|
||||
if(!StringUtils.isBlank(communityUser.getPhoneNumber())){
|
||||
String phoneSm4=sm4Encrypt(communityUser.getPhoneNumber());
|
||||
String phoneSm3=sm3Hash(communityUser.getPhoneNumber());
|
||||
communityUser.setPhoneNumberEncrypt(phoneSm4);
|
||||
communityUser.setPhoneNumberCipher(phoneSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("岗位联系人用户手机号加密失败", e);
|
||||
throw new RuntimeException("手机号加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证加密/生成完整性校验串
|
||||
* @param appUser 用户实体
|
||||
*/
|
||||
public static void saveIdCardSm4(AppUser appUser) {
|
||||
try {
|
||||
if (!StringUtils.isBlank(appUser.getIdCard())) {
|
||||
String idCardUper = StringUtil.toUpperCaseIgnoreBlank(appUser.getIdCard());
|
||||
String idCardSm4 = sm4Encrypt(idCardUper);
|
||||
String idCardSm3 = sm3Hash(idCardUper);
|
||||
appUser.setIdCardEncrypt(idCardSm4);
|
||||
appUser.setIdCardCipher(idCardSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("App用户身份证加密失败", e);
|
||||
throw new RuntimeException("身份证加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号、身份证加密/生成完整性校验串
|
||||
* @param appUser 用户实体
|
||||
*/
|
||||
public static void savePhoneIdCardSm4(AppUser appUser) {
|
||||
try {
|
||||
//密码机完整性/保密性
|
||||
if (!StringUtils.isBlank(appUser.getPhone())) {
|
||||
String phoneSm4 = sm4Encrypt(appUser.getPhone());
|
||||
String phoneSm3 = sm3Hash(appUser.getPhone());
|
||||
appUser.setPhoneEncrypt(phoneSm4);
|
||||
appUser.setPhoneCipher(phoneSm3);
|
||||
}
|
||||
if (!StringUtils.isBlank(appUser.getIdCard())) {
|
||||
String idCardUper = StringUtil.toUpperCaseIgnoreBlank(appUser.getIdCard());
|
||||
String idCardSm4 = sm4Encrypt(idCardUper);
|
||||
String idCardSm3 = sm3Hash(idCardUper);
|
||||
appUser.setIdCardEncrypt(idCardSm4);
|
||||
appUser.setIdCardCipher(idCardSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("App用户手机号+身份证加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证手机号加密/完整性
|
||||
* @param employeeConfirm
|
||||
*/
|
||||
public static void savePhoneIdCardSm4(EmployeeConfirm employeeConfirm){
|
||||
try {
|
||||
if(!StringUtils.isBlank(employeeConfirm.getContactPersonPhone())){
|
||||
String phoneSm4=sm4Encrypt(employeeConfirm.getContactPersonPhone());
|
||||
String phoneSm3=sm3Hash(employeeConfirm.getContactPersonPhone());
|
||||
employeeConfirm.setContactPersonPhoneEncrypt(phoneSm4);
|
||||
employeeConfirm.setContactPersonPhoneCipher(phoneSm3);
|
||||
}
|
||||
if(!StringUtils.isBlank(employeeConfirm.getIdCard())){
|
||||
String idCardSm4=sm4Encrypt(employeeConfirm.getIdCard());
|
||||
String idCardSm3=sm3Hash(employeeConfirm.getIdCard());
|
||||
employeeConfirm.setIdCardEncrypt(idCardSm4);
|
||||
employeeConfirm.setIdCardCipher(idCardSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("企业法人手机号/身份证加密失败", e);
|
||||
throw new RuntimeException("手机号加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业法人身份证和手机号加密/生成完整性校验串
|
||||
* @param company 企业实体
|
||||
*/
|
||||
public static void legalSm4(Company company) {
|
||||
String legalIdCard = company.getLegalIdCard();
|
||||
String legalPhone = company.getLegalPhone();
|
||||
try {
|
||||
if (!StringUtils.isBlank(legalPhone)) {
|
||||
String phoneSm4 = sm4Encrypt(legalPhone);
|
||||
String phoneSm3 = sm3Hash(legalPhone);
|
||||
company.setLegalPhoneEncrypt(phoneSm4);
|
||||
company.setLegalPhoneCipher(phoneSm3);
|
||||
}
|
||||
if (!StringUtils.isBlank(legalIdCard)) {
|
||||
String idCardSm4 = sm4Encrypt(legalIdCard);
|
||||
String idCardSm3 = sm3Hash(legalIdCard);
|
||||
company.setLegalIdCardEncrypt(idCardSm4);
|
||||
company.setLegalIdCardCipher(idCardSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("企业法人手机号/身份证加密失败", e);
|
||||
throw new RuntimeException("法人手机号/身份证,加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业联系人手机号加密/生成完整性校验串
|
||||
* @param contact 企业联系人实体
|
||||
*/
|
||||
public static void saveCompanyContactPhoneSm4(CompanyContact contact) {
|
||||
try {
|
||||
String phoneSm4 = sm4Encrypt(contact.getContactPersonPhone());
|
||||
String phoneSm3 = sm3Hash(contact.getContactPersonPhone());
|
||||
contact.setContactPersonPhoneEncrypt(phoneSm4);
|
||||
contact.setContactPersonPhoneCipher(phoneSm3);
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("企业联系人手机号加密失败", e);
|
||||
throw new RuntimeException("手机号加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密系统管理用户
|
||||
* @param sysUser
|
||||
*/
|
||||
public static void saveSysUserSm4(SysUser sysUser) {
|
||||
String phone = sysUser.getPhonenumber();
|
||||
String idCard = sysUser.getIdCard();
|
||||
try {
|
||||
if (!StringUtils.isBlank(phone)) {
|
||||
String phoneSm4 = sm4Encrypt(phone);
|
||||
String phoneSm3 = sm3Hash(phone);
|
||||
sysUser.setPhonenumberEncrypt(phoneSm4);
|
||||
sysUser.setPhonenumberCipher(phoneSm3);
|
||||
}
|
||||
Long[] roleIds=sysUser.getRoleIds();
|
||||
if (!StringUtils.isBlank(idCard)&& roleIds != null && roleIds.length > 0) {
|
||||
boolean contains1102 = !Arrays.asList(roleIds).contains(StringUtil.COMPANY_ADMIN_ROLE_KEY);
|
||||
if (contains1102) {
|
||||
String idCardSm4 = sm4Encrypt(idCard);
|
||||
String idCardSm3 = sm3Hash(idCard);
|
||||
sysUser.setIdCardEncrypt(idCardSm4);
|
||||
sysUser.setIdCardCipher(idCardSm3);
|
||||
}
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("企业法人手机号/身份证加密失败", e);
|
||||
throw new RuntimeException("法人手机号/身份证,加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用SM4解密方法(对外提供)
|
||||
* @param sm4 加密串
|
||||
* @return 解密后的明文
|
||||
*/
|
||||
public static String getSm4Decrypt(String sm4) {
|
||||
String deSm4 = "";
|
||||
try {
|
||||
deSm4 = sm4Decrypt(sm4);
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
deSm4=sm4;
|
||||
log.error("通用SM4解密失败,密文:{}", sm4, e);
|
||||
}
|
||||
return deSm4;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
* @param sm4
|
||||
* @return
|
||||
*/
|
||||
public static String getSm4Encrypt(String sm4) {
|
||||
String deSm4 = "";
|
||||
try {
|
||||
deSm4 = sm4Encrypt(sm4);
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
deSm4=sm4;
|
||||
log.error("通用SM4加密失败,密文:{}", sm4, e);
|
||||
}
|
||||
return deSm4;
|
||||
}
|
||||
|
||||
/**
|
||||
* pc互联网端-加密返回数组
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
public static String[] savePhoneSm4(String phone){
|
||||
String phoneSm4;
|
||||
String phoneSm3;
|
||||
try {
|
||||
phoneSm4 = sm4Encrypt(phone);
|
||||
phoneSm3= sm3Hash(phone);
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("用户手机号加密失败:{}",phone, e);
|
||||
throw new RuntimeException("手机号加密失败",e);
|
||||
}
|
||||
return new String[]{phoneSm4,phoneSm3};
|
||||
}
|
||||
|
||||
/**
|
||||
* pc互联网端-用户身份证加密
|
||||
* @param idCard
|
||||
* @return
|
||||
*/
|
||||
public static String[] saveIdCardSm4(String idCard){
|
||||
String idCardSm4;
|
||||
String idCardSm3;
|
||||
try {
|
||||
idCardSm4 = sm4Encrypt(idCard);
|
||||
idCardSm3= sm3Hash(idCard);
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("用户身份证加密失败:{}",idCard, e);
|
||||
throw new RuntimeException("身份证加密失败",e);
|
||||
}
|
||||
return new String[]{idCardSm4,idCardSm3};
|
||||
}
|
||||
}
|
||||
@@ -152,4 +152,88 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by b.create_time desc
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateIdCardAndPhone">
|
||||
UPDATE app_user
|
||||
SET id_card = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.idCard}
|
||||
</foreach>
|
||||
END,
|
||||
id_card_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.idCardCipher}
|
||||
</foreach>
|
||||
END,
|
||||
id_card_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.idCardEncrypt}
|
||||
</foreach>
|
||||
END,
|
||||
phone = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.phone}
|
||||
</foreach>
|
||||
END,
|
||||
phone_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.phoneCipher}
|
||||
</foreach>
|
||||
END,
|
||||
phone_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.phoneEncrypt}
|
||||
</foreach>
|
||||
END
|
||||
WHERE user_id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item.userId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="batchUpdateSysUserEncrypt">
|
||||
UPDATE sys_user
|
||||
SET id_card = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.idCard}
|
||||
</foreach>
|
||||
END,
|
||||
id_card_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.idCardCipher}
|
||||
</foreach>
|
||||
END,
|
||||
id_card_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.idCardEncrypt}
|
||||
</foreach>
|
||||
END,
|
||||
phonenumber = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.phonenumber}
|
||||
</foreach>
|
||||
END,
|
||||
phonenumber_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.phonenumberCipher}
|
||||
</foreach>
|
||||
END,
|
||||
phonenumber_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN user_id = #{item.userId} THEN #{item.phonenumberEncrypt}
|
||||
</foreach>
|
||||
END
|
||||
WHERE user_id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item.userId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getSysUserListEncrypt" resultType="com.ruoyi.common.core.domain.entity.SysUser">
|
||||
select a.user_id,a.phonenumber,a.id_card, b.roleIdsStr
|
||||
from sys_user a
|
||||
inner join (SELECT user_id, STRING_AGG(CAST(role_id AS TEXT), ',') AS roleIdsStr
|
||||
FROM sys_user_role GROUP BY user_id) b
|
||||
on a.user_id = b.user_id and (phonenumber is not null or id_card is not null)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -18,7 +18,7 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCompanyContactVo">
|
||||
select id, company_id, contact_person, contact_person_phone, del_flag, create_by, create_time, update_by, update_time, remark from company_contact
|
||||
select id, company_id, contact_person, contact_person_phone, del_flag, create_by, create_time, update_by, update_time, remark,contact_person_phone_cipher,contact_person_phone_encrypt from company_contact
|
||||
</sql>
|
||||
|
||||
<select id="getSelectList" resultMap="CompanyContactResult" parameterType="CompanyContact">
|
||||
@@ -39,12 +39,14 @@
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO company_contact (
|
||||
company_id, contact_person, contact_person_phone,
|
||||
create_by, create_time, del_flag,remark
|
||||
create_by, create_time, del_flag,remark,contact_person_phone_cipher,
|
||||
contact_person_phone_encrypt
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.companyId}, #{item.contactPerson}, #{item.contactPersonPhone},
|
||||
#{item.createBy}, #{item.createTime}, #{item.delFlag},#{item.remark}
|
||||
#{item.createBy}, #{item.createTime}, #{item.delFlag},#{item.remark},
|
||||
#{item.contactPersonPhoneCipher},#{item.contactPersonPhoneEncrypt}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
@@ -76,6 +78,18 @@
|
||||
</foreach>
|
||||
ELSE update_time
|
||||
END,
|
||||
contact_person_phone_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhoneCipher}
|
||||
</foreach>
|
||||
ELSE contact_person_phone_cipher
|
||||
END,
|
||||
contact_person_phone_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhoneEncrypt}
|
||||
</foreach>
|
||||
ELSE contact_person_phone_encrypt
|
||||
END,
|
||||
remark = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.remark}
|
||||
|
||||
@@ -137,4 +137,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateEncrypt">
|
||||
UPDATE company
|
||||
SET legal_id_card = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN company_id = #{item.companyId} THEN #{item.legalIdCard}
|
||||
</foreach>
|
||||
END,
|
||||
legal_id_card_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN company_id = #{item.companyId} THEN #{item.legalIdCardCipher}
|
||||
</foreach>
|
||||
END,
|
||||
legal_id_card_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN company_id = #{item.companyId} THEN #{item.legalIdCardEncrypt}
|
||||
</foreach>
|
||||
END,
|
||||
legal_phone = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN company_id = #{item.companyId} THEN #{item.legalPhone}
|
||||
</foreach>
|
||||
END,
|
||||
legal_phone_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN company_id = #{item.companyId} THEN #{item.legalPhoneCipher}
|
||||
</foreach>
|
||||
END,
|
||||
legal_phone_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN company_id = #{item.companyId} THEN #{item.legalPhoneEncrypt}
|
||||
</foreach>
|
||||
END
|
||||
WHERE company_id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item.companyId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectCompanyEncryptList" parameterType="Company" resultMap="CompanyResult">
|
||||
<include refid="selectCompanyVo"/>
|
||||
<where> del_flag = '0' and (legal_id_card is not null or legal_phone is not null)
|
||||
<if test="name != null and name != ''"> and name like concat('%', cast(#{name, jdbcType=VARCHAR} as varchar), '%')</if>
|
||||
<if test="location != null and location != ''"> and location like concat('%', cast(#{location, jdbcType=VARCHAR} as varchar), '%')</if>
|
||||
<if test="industry != null and industry != ''"> and industry = #{industry}</if>
|
||||
<if test="scale != null and scale != ''"> and scale = #{scale}</if>
|
||||
<if test="nature != null and nature != ''"> and nature = #{nature}</if>
|
||||
<if test="code != null and code != ''"> and code = #{code}</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="companyId != null and companyId != ''"> and company_id = #{companyId}</if>
|
||||
<if test="regionCode != null and regionCode != ''"> and region_code = #{regionCode}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -35,4 +35,42 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="updatePhoneEncrypt">
|
||||
UPDATE employee_confirm
|
||||
SET id_card = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.idCard}
|
||||
</foreach>
|
||||
END,
|
||||
id_card_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.idCardCipher}
|
||||
</foreach>
|
||||
END,
|
||||
id_card_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.idCardEncrypt}
|
||||
</foreach>
|
||||
END,
|
||||
contact_person_phone = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhone}
|
||||
</foreach>
|
||||
END,
|
||||
contact_person_phone_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhoneCipher}
|
||||
</foreach>
|
||||
END,
|
||||
contact_person_phone_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhoneEncrypt}
|
||||
</foreach>
|
||||
END
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="contactPersonPhoneCipher" column="contact_person_phone_cipher"/>
|
||||
<result property="contactPersonPhoneEncrypt" column="contact_person_phone_encrypt"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<sql id="JobContactVo">
|
||||
select id, job_id, contact_person, contact_person_phone, position, del_flag, create_by, create_time, update_by, update_time, remark from job_contact
|
||||
select id, job_id, contact_person, contact_person_phone, position, del_flag, create_by, create_time, update_by, update_time, remark,contact_person_phone_cipher,contact_person_phone_encrypt from job_contact
|
||||
</sql>
|
||||
|
||||
|
||||
@@ -45,12 +47,14 @@
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO job_contact (
|
||||
job_id, contact_person, contact_person_phone,position,
|
||||
create_by, create_time, del_flag,remark
|
||||
create_by, create_time, del_flag,remark,contact_person_phone_cipher,
|
||||
contact_person_phone_encrypt
|
||||
) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.jobId}, #{item.contactPerson}, #{item.contactPersonPhone},#{item.position},
|
||||
#{item.createBy}, #{item.createTime}, #{item.delFlag},#{item.remark}
|
||||
#{item.createBy}, #{item.createTime}, #{item.delFlag},#{item.remark},#{item.contactPersonPhoneCipher},
|
||||
#{item.contactPersonPhoneEncrypt}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
@@ -73,4 +77,27 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="batchUpdateEncrypt">
|
||||
UPDATE job_contact
|
||||
SET contact_person_phone = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhone}
|
||||
</foreach>
|
||||
END,
|
||||
contact_person_phone_cipher = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhoneCipher}
|
||||
</foreach>
|
||||
END,
|
||||
contact_person_phone_encrypt = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.contactPersonPhoneEncrypt}
|
||||
</foreach>
|
||||
END
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<mapper namespace="com.ruoyi.cms.mapper.WechatGroupMapper">
|
||||
|
||||
<select id="selectWechatGroupList" resultType="com.ruoyi.cms.domain.vo.WechatGroupVo">
|
||||
select g.create_time, g.id, g.name, g.is_push, u.wechat_name, u.phone_number, u.id communityId
|
||||
select g.create_time, g.id, g.name, g.is_push, u.wechat_name, u.phone_number, u.id communityId,u.phone_number_cipher,u.phone_number_encrypt
|
||||
from wechat_group g join community_user u on g.community_id = u.id
|
||||
where g.del_flag = 0 and u.del_flag = 0
|
||||
<if test="p.name != null and p.name != ''">
|
||||
|
||||
Reference in New Issue
Block a user