用户新增传输过程加密
This commit is contained in:
@@ -2037,8 +2037,8 @@ CREATE TABLE `sys_user` (
|
||||
`avatar` varchar(255) DEFAULT NULL COMMENT '头像',
|
||||
`birthday` datetime DEFAULT NULL COMMENT '生日',
|
||||
`sex` tinyint(1) DEFAULT NULL COMMENT '性别(0-默认未知,1-男,2-女)',
|
||||
`email` varchar(45) DEFAULT NULL COMMENT '电子邮件',
|
||||
`phone` varchar(45) DEFAULT NULL COMMENT '电话',
|
||||
`email` varchar(200) DEFAULT NULL COMMENT '电子邮件',
|
||||
`phone` varchar(200) DEFAULT NULL COMMENT '电话',
|
||||
`org_code` varchar(64) DEFAULT NULL COMMENT '机构编码',
|
||||
`status` tinyint(1) DEFAULT NULL COMMENT '性别(1-正常,2-冻结)',
|
||||
`del_flag` tinyint(1) DEFAULT NULL COMMENT '删除状态(0-正常,1-已删除)',
|
||||
|
||||
+23
-15
@@ -2,6 +2,7 @@ package com.jero.modules.system.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -144,15 +145,17 @@ public class SysUserController {
|
||||
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
||||
|
||||
try {
|
||||
//1:先用私钥解密数据
|
||||
String email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
||||
String phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
||||
if (StrUtil.isNotEmpty(user.getEmail())){
|
||||
String email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
||||
// email = PasswordUtil.encrypt(email);
|
||||
user.setEmail(email);
|
||||
}
|
||||
|
||||
//3:把数据加密在放回来
|
||||
email = PasswordUtil.encrypt(email);
|
||||
phone = PasswordUtil.encrypt(phone);
|
||||
user.setEmail(email);
|
||||
user.setPhone(phone);
|
||||
if (StrUtil.isNotEmpty(user.getPhone())){
|
||||
String phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
||||
// phone = PasswordUtil.encrypt(phone);
|
||||
user.setPhone(phone);
|
||||
}
|
||||
|
||||
// 密码加盐
|
||||
String password = CommonUtils.decryptBtRsaPriKey(user.getPassword(), rsaPrivateKey);
|
||||
@@ -192,18 +195,23 @@ public class SysUserController {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
||||
String email;
|
||||
String phone;
|
||||
String email = null;
|
||||
String phone = null;
|
||||
try {
|
||||
//1:先用私钥解密数据
|
||||
email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
||||
phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
||||
if (StrUtil.isNotEmpty(user.getEmail())){
|
||||
email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(user.getPhone())){
|
||||
phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new JeroBootException("解密失败!", e);
|
||||
}
|
||||
//3:把数据加密在放回来
|
||||
email = PasswordUtil.encrypt(email);
|
||||
phone = PasswordUtil.encrypt(phone);
|
||||
// 3:把数据加密在放回来
|
||||
// email = PasswordUtil.encrypt(email);
|
||||
// phone = PasswordUtil.encrypt(phone);
|
||||
user.setEmail(email);
|
||||
user.setPhone(phone);
|
||||
user.setUpdateTime(new Date());
|
||||
|
||||
+1
@@ -175,4 +175,5 @@ public class SysUser implements Serializable {
|
||||
|
||||
/**设备id uniapp推送用*/
|
||||
private String clientId;
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@
|
||||
</select>
|
||||
|
||||
<!--根据parent_id查询下级部门-->
|
||||
<select id="queryTreeListByPid" parameterType="Object" resultType="org.jeecg.modules.system.entity.SysDepart">
|
||||
<select id="queryTreeListByPid" parameterType="Object" resultType="com.jero.modules.system.entity.SysDepart">
|
||||
SELECT * FROM sys_depart where del_flag = '0'
|
||||
<choose>
|
||||
<when test="parentId != null and parentId != ''">
|
||||
@@ -49,7 +49,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 根据OrgCod查询公司信息 -->
|
||||
<select id="queryCompByOrgCode" resultType="org.jeecg.modules.system.entity.SysDepart">
|
||||
<select id="queryCompByOrgCode" resultType="com.jero.modules.system.entity.SysDepart">
|
||||
select * from sys_depart where del_flag = '0' and org_category='1' and org_code= #{orgCode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -131,7 +131,7 @@ spring:
|
||||
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://10.0.3.44:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://10.10.10.44:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: 123456
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
|
||||
Reference in New Issue
Block a user