1.添加手机号和身份证的安全性和保密性
2.添加对应的定时任务
This commit is contained in:
@@ -6,6 +6,9 @@ import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.AppUser;
|
||||
import com.ruoyi.common.utils.EncryptDecryptUtil;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.quickssl.api.CryptoClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -67,6 +70,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
@Autowired
|
||||
private EncryptDecryptUtil encryptDecryptUtil;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
@@ -262,6 +268,12 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
@Transactional
|
||||
public int insertUser(SysUser user)
|
||||
{
|
||||
//添加保密性和完整性
|
||||
savePhoneSm4(user);
|
||||
//判断是否是求职者
|
||||
if(!ArrayUtils.contains(user.getRoleIds(), 1102L)){
|
||||
saveIdCardSm4(user);
|
||||
}
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// 新增用户岗位关联
|
||||
@@ -271,6 +283,40 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
* @param sysUser
|
||||
*/
|
||||
public void savePhoneSm4(SysUser sysUser) {
|
||||
String phone = sysUser.getPhonenumber();
|
||||
try {
|
||||
if(!StringUtils.isBlank(phone)){
|
||||
String phoneSm4=encryptDecryptUtil.sm4Encrypt(phone);
|
||||
String phoneSm3=encryptDecryptUtil.sm3Hash(phone);
|
||||
sysUser.setPhonenumberEncrypt(phoneSm4);
|
||||
sysUser.setPhonenumberCipher(phoneSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("手机号/身份证加密失败", e);
|
||||
throw new RuntimeException("加密失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveIdCardSm4(SysUser sysUser) {
|
||||
String idCard = sysUser.getIdCard();
|
||||
try {
|
||||
if(!StringUtils.isBlank(idCard)){
|
||||
String idCardSm4=encryptDecryptUtil.sm4Encrypt(idCard);
|
||||
String idCardSm3=encryptDecryptUtil.sm3Hash(idCard);
|
||||
sysUser.setIdCardEncrypt(idCardSm4);
|
||||
sysUser.setIdCardCipher(idCardSm3);
|
||||
}
|
||||
} catch (CryptoClient.CryptoException e) {
|
||||
log.error("手机号/身份证加密失败", e);
|
||||
throw new RuntimeException("加密失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
@@ -302,6 +348,13 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
insertUserPost(user);
|
||||
|
||||
//添加保密性和完整性
|
||||
savePhoneSm4(user);
|
||||
//判断是否时求职者
|
||||
if(!ArrayUtils.contains(user.getRoleIds(), 1102L)){
|
||||
saveIdCardSm4(user);
|
||||
}
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="idCard != null and idCard != ''">id_card,</if>
|
||||
<if test="appUserId != null">app_user_id,</if>
|
||||
<if test="phonenumberCipher != null">phonenumber_cipher,</if>
|
||||
<if test="idCardCipher != null">id_card_cipher,</if>
|
||||
<if test="phonenumberEncrypt != null">phonenumber_encrypt,</if>
|
||||
<if test="idCardEncrypt != null">id_card_encrypt,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
@@ -198,6 +202,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="idCard != null and idCard != ''">#{idCard},</if>
|
||||
<if test="appUserId != null">#{appUserId},</if>
|
||||
<if test="phonenumberCipher != null">#{phonenumberCipher},</if>
|
||||
<if test="idCardCipher != null">#{idCardCipher},</if>
|
||||
<if test="phonenumberEncrypt != null">#{phonenumberEncrypt},</if>
|
||||
<if test="idCardEncrypt != null">#{idCardEncrypt},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
@@ -219,6 +227,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="idCard != null">id_card = #{idCard},</if>
|
||||
<if test="phonenumberCipher != null">phonenumber_cipher=#{phonenumberCipher},</if>
|
||||
<if test="idCardCipher != null">id_card_cipher=#{idCardCipher},</if>
|
||||
<if test="phonenumberEncrypt != null">phonenumber_encrypt=#{phonenumberEncrypt},</if>
|
||||
<if test="idCardEncrypt != null">id_card_encrypt=#{idCardEncrypt},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
@@ -250,5 +262,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectUserByIdCard" resultType="com.ruoyi.common.core.domain.entity.SysUser">
|
||||
<include refid="selectSysUserVo" /> where del_flag='0' and id_card = #{idCard} LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -9,7 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="roleId" column="role_id" />
|
||||
</resultMap>
|
||||
|
||||
<delete id="deleteUserRoleByUserId" parameterType="Long">
|
||||
<delete id="deleteUserRoleByUserId" parameterType="java.lang.Long">
|
||||
delete from sys_user_role where user_id=#{userId}
|
||||
</delete>
|
||||
|
||||
@@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select count(1) from sys_user_role where role_id=#{roleId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteUserRole" parameterType="Long">
|
||||
<delete id="deleteUserRole" parameterType="java.lang.Long">
|
||||
delete from sys_user_role where user_id in
|
||||
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
|
||||
Reference in New Issue
Block a user