部分疑问问题修改
This commit is contained in:
+53
@@ -5,6 +5,11 @@ import java.sql.Timestamp;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
@@ -647,4 +652,52 @@ public class DateUtils extends PropertyEditorSupport {
|
|||||||
return calendar.get(Calendar.YEAR);
|
return calendar.get(Calendar.YEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LocalDate转Date
|
||||||
|
* @param localDate
|
||||||
|
* @return Date
|
||||||
|
*/
|
||||||
|
public static Date localDate2Date(LocalDate localDate) {
|
||||||
|
if (null == localDate) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
|
||||||
|
return Date.from(zonedDateTime.toInstant());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date转LocalDate
|
||||||
|
* @param date
|
||||||
|
*/
|
||||||
|
public static LocalDate date2LocalDate(Date date) {
|
||||||
|
if(null == date) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LocalDateTime转Date
|
||||||
|
* @param localDateTime
|
||||||
|
* @return Date
|
||||||
|
*/
|
||||||
|
public static Date localDateTime2Date(LocalDateTime localDateTime){
|
||||||
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
|
ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId);
|
||||||
|
Instant instant = zonedDateTime.toInstant();
|
||||||
|
return Date.from(instant);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Date转LocalDateTime
|
||||||
|
* @param date
|
||||||
|
* @return LocalDateTime
|
||||||
|
*/
|
||||||
|
public static LocalDateTime date2LocalDateTime(Date date){
|
||||||
|
Instant instant = date.toInstant();
|
||||||
|
ZoneId zoneId = ZoneId.systemDefault();
|
||||||
|
ZonedDateTime zonedDateTime = instant.atZone(zoneId);
|
||||||
|
return zonedDateTime.toLocalDateTime();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
-1
@@ -105,7 +105,6 @@ public class PasswordUtil {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static String encrypt(String plaintext) {
|
public static String encrypt(String plaintext) {
|
||||||
|
|
||||||
return encrypt(plaintext, ALGORITHM, Salt);
|
return encrypt(plaintext, ALGORITHM, Salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -208,13 +208,7 @@ public class SysPermissionController {
|
|||||||
return Result.error("请登录系统!");
|
return Result.error("请登录系统!");
|
||||||
}
|
}
|
||||||
List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getUsername());
|
List<SysPermission> metaList = sysPermissionService.queryByUser(loginUser.getUsername());
|
||||||
//添加首页路由
|
|
||||||
//update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
|
||||||
// if(!PermissionDataUtil.hasIndexPage(metaList)){
|
|
||||||
// SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName,"首页")).get(0);
|
|
||||||
// metaList.add(0,indexMenu);
|
|
||||||
// }
|
|
||||||
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
JSONArray menujsonArray = new JSONArray();
|
JSONArray menujsonArray = new JSONArray();
|
||||||
this.getPermissionJsonArray(menujsonArray, metaList, null);
|
this.getPermissionJsonArray(menujsonArray, metaList, null);
|
||||||
|
|||||||
+21
-23
@@ -144,33 +144,31 @@ public class SysUserController {
|
|||||||
String rsaPublicKey = jsonObject.getString("rsaPublicKey");
|
String rsaPublicKey = jsonObject.getString("rsaPublicKey");
|
||||||
String rsaPrivateKey = String.valueOf(redisUtil.get(rsaPublicKey));
|
String rsaPrivateKey = String.valueOf(redisUtil.get(rsaPublicKey));
|
||||||
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
||||||
String email;
|
|
||||||
String phone;
|
|
||||||
try {
|
try {
|
||||||
//1:先用私钥解密数据
|
//1:先用私钥解密数据
|
||||||
email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
String email = CommonUtils.decryptBtRsaPriKey(user.getEmail(), rsaPrivateKey);
|
||||||
phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
String phone = CommonUtils.decryptBtRsaPriKey(user.getPhone(), rsaPrivateKey);
|
||||||
|
|
||||||
|
//3:把数据加密在放回来
|
||||||
|
email = PasswordUtil.encrypt(email);
|
||||||
|
phone = PasswordUtil.encrypt(phone);
|
||||||
|
user.setEmail(email);
|
||||||
|
user.setPhone(phone);
|
||||||
|
|
||||||
|
// 密码加盐
|
||||||
|
String password = CommonUtils.decryptBtRsaPriKey(user.getPassword(), rsaPrivateKey);
|
||||||
|
user.setCreateTime(new Date());//设置创建时间
|
||||||
|
String salt = oConvertUtils.randomGen(8);
|
||||||
|
user.setSalt(salt);
|
||||||
|
String passwordEncode = PasswordUtil.encrypt(user.getUsername(), password, salt);
|
||||||
|
user.setPassword(passwordEncode);
|
||||||
|
user.setStatus(1);
|
||||||
|
user.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new JeroBootException("解密失败!", e);
|
throw new JeroBootException("邮箱和手机号解密失败!", e);
|
||||||
}
|
}
|
||||||
//3:把数据加密在放回来
|
|
||||||
email = PasswordUtil.encrypt(email);
|
|
||||||
phone = PasswordUtil.encrypt(phone);
|
|
||||||
user.setEmail(email);
|
|
||||||
user.setPhone(phone);
|
|
||||||
String password;
|
|
||||||
try {
|
|
||||||
password = CommonUtils.decryptBtRsaPriKey(user.getPassword(), rsaPrivateKey);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new JeroBootException("解密失败!", e);
|
|
||||||
}
|
|
||||||
user.setCreateTime(new Date());//设置创建时间
|
|
||||||
String salt = oConvertUtils.randomGen(8);
|
|
||||||
user.setSalt(salt);
|
|
||||||
String passwordEncode = PasswordUtil.encrypt(user.getUsername(), password, salt);
|
|
||||||
user.setPassword(passwordEncode);
|
|
||||||
user.setStatus(1);
|
|
||||||
user.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
||||||
sysUserService.addUserWithRole(user, selectedRoles);
|
sysUserService.addUserWithRole(user, selectedRoles);
|
||||||
sysUserService.addUserWithDepart(user, selectedDeparts);
|
sysUserService.addUserWithDepart(user, selectedDeparts);
|
||||||
result.success("添加成功!");
|
result.success("添加成功!");
|
||||||
|
|||||||
-57
@@ -1,57 +0,0 @@
|
|||||||
package com.jero.modules.system.util;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
|
|
||||||
import java.time.*;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class DateUtils extends DateUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LocalDate转Date
|
|
||||||
* @param localDate
|
|
||||||
* @return Date
|
|
||||||
*/
|
|
||||||
public static Date localDate2Date(LocalDate localDate) {
|
|
||||||
if (null == localDate) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
|
|
||||||
return Date.from(zonedDateTime.toInstant());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Date转LocalDate
|
|
||||||
* @param date
|
|
||||||
*/
|
|
||||||
public static LocalDate date2LocalDate(Date date) {
|
|
||||||
if(null == date) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LocalDateTime转Date
|
|
||||||
* @param localDateTime
|
|
||||||
* @return Date
|
|
||||||
*/
|
|
||||||
public static Date localDateTime2Date(LocalDateTime localDateTime){
|
|
||||||
ZoneId zoneId = ZoneId.systemDefault();
|
|
||||||
ZonedDateTime zonedDateTime = localDateTime.atZone(zoneId);
|
|
||||||
Instant instant = zonedDateTime.toInstant();
|
|
||||||
return Date.from(instant);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Date转LocalDateTime
|
|
||||||
* @param date
|
|
||||||
* @return LocalDateTime
|
|
||||||
*/
|
|
||||||
public static LocalDateTime date2LocalDateTime(Date date){
|
|
||||||
Instant instant = date.toInstant();
|
|
||||||
ZoneId zoneId = ZoneId.systemDefault();
|
|
||||||
ZonedDateTime zonedDateTime = instant.atZone(zoneId);
|
|
||||||
return zonedDateTime.toLocalDateTime();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user