修改token有效期
This commit is contained in:
parent
901b4a16eb
commit
9332621f5a
|
|
@ -1,57 +0,0 @@
|
||||||
package com.ruoyi.business.util.aspect;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.DesensitizedUtil;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.annotation.Around;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Aspect
|
|
||||||
@Component
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class responseAspect {
|
|
||||||
|
|
||||||
@Around("execution(* com.ruoyi.database.controller.SmallProgramController.*(..))")
|
|
||||||
public TableDataInfo<Object> around(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
||||||
Object proceed = joinPoint.proceed();
|
|
||||||
TableDataInfo<Object> tableDataInfo = (TableDataInfo<Object>) proceed;
|
|
||||||
List list = (List) tableDataInfo.getRows();
|
|
||||||
|
|
||||||
for (Object o : list) {
|
|
||||||
// 获取list表中类的类型
|
|
||||||
Class<?> aClass = o.getClass();
|
|
||||||
|
|
||||||
// 遍历实体类的字段
|
|
||||||
for (Field field : aClass.getDeclaredFields()) {
|
|
||||||
String fieldName = field.getName();
|
|
||||||
// 判断字段是否为电话号码或身份证号码,并对其进行脱敏
|
|
||||||
if (StrUtil.containsIgnoreCase(fieldName, "idcard")) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
String value = String.valueOf(field.get(o));
|
|
||||||
try {
|
|
||||||
ReflectUtil.setFieldValue(o, fieldName, DesensitizedUtil.idCardNum(value, 4, 4));
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.containsIgnoreCase(fieldName, "phone")) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
String value = String.valueOf(field.get(o));
|
|
||||||
try {
|
|
||||||
ReflectUtil.setFieldValue(o, fieldName, DesensitizedUtil.mobilePhone(value));
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tableDataInfo.setRows(list);
|
|
||||||
return tableDataInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -151,8 +151,7 @@ public class SmallProgramController extends BaseController {
|
||||||
customerPlateNoInfo.setPlateNo(plateNo);
|
customerPlateNoInfo.setPlateNo(plateNo);
|
||||||
customerPlateNoInfo.setPlateType(bindTheVehicle.getPlateType());
|
customerPlateNoInfo.setPlateType(bindTheVehicle.getPlateType());
|
||||||
customerPlateNoInfo.setPhone(loginUserByPhone.getPhone());
|
customerPlateNoInfo.setPhone(loginUserByPhone.getPhone());
|
||||||
customerPlateNoInfoService.saveOrUpdate(customerPlateNoInfo);
|
return toAjax(customerPlateNoInfoService.saveOrUpdate(customerPlateNoInfo));
|
||||||
return AjaxResult.success(customerPlateNoInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
package com.ruoyi.web.controller.aspect;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.DesensitizedUtil;
|
|
||||||
import cn.hutool.core.util.ReflectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.annotation.Around;
|
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Aspect
|
|
||||||
@Component
|
|
||||||
public class responseAspect {
|
|
||||||
|
|
||||||
@Around("execution(* com.ruoyi.web.controller.system.SysLoginController.getCustomerInfo())")
|
|
||||||
public TableDataInfo<Object> around(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
||||||
Object proceed = joinPoint.proceed();
|
|
||||||
TableDataInfo<Object> tableDataInfo = (TableDataInfo<Object>) proceed;
|
|
||||||
List list = (List) tableDataInfo.getRows();
|
|
||||||
|
|
||||||
for (Object o : list) {
|
|
||||||
// 获取list表中类的类型
|
|
||||||
Class<?> aClass = o.getClass();
|
|
||||||
|
|
||||||
// 遍历实体类的字段
|
|
||||||
for (Field field : aClass.getDeclaredFields()) {
|
|
||||||
String fieldName = field.getName();
|
|
||||||
// 判断字段是否为电话号码或身份证号码,并对其进行脱敏
|
|
||||||
if (StrUtil.containsIgnoreCase(fieldName, "idcard")) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
String value = String.valueOf(field.get(o));
|
|
||||||
try {
|
|
||||||
ReflectUtil.setFieldValue(o, fieldName, DesensitizedUtil.idCardNum(value, 4, 4));
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.containsIgnoreCase(fieldName, "phone")) {
|
|
||||||
field.setAccessible(true);
|
|
||||||
String value = String.valueOf(field.get(o));
|
|
||||||
try {
|
|
||||||
ReflectUtil.setFieldValue(o, fieldName, DesensitizedUtil.mobilePhone(value));
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tableDataInfo.setRows(list);
|
|
||||||
return tableDataInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.DesensitizedUtil;
|
||||||
import com.ruoyi.business.util.StringKit;
|
import com.ruoyi.business.util.StringKit;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
|
@ -186,6 +187,7 @@ public class SysLoginController {
|
||||||
.eq(BaseCustomerInfo::getPhone, loginUser.getPhone())
|
.eq(BaseCustomerInfo::getPhone, loginUser.getPhone())
|
||||||
.last("limit 1")
|
.last("limit 1")
|
||||||
.one();
|
.one();
|
||||||
|
one.setPhone(DesensitizedUtil.mobilePhone(one.getPhone()));
|
||||||
return AjaxResult.success(one);
|
return AjaxResult.success(one);
|
||||||
}
|
}
|
||||||
return AjaxResult.success(loginUser);
|
return AjaxResult.success(loginUser);
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ public class TokenService {
|
||||||
loginUserByPhone.setLoginTime(System.currentTimeMillis());
|
loginUserByPhone.setLoginTime(System.currentTimeMillis());
|
||||||
loginUserByPhone.setExpireTime(loginUserByPhone.getLoginTime() + expireTime * MILLIS_MINUTE);
|
loginUserByPhone.setExpireTime(loginUserByPhone.getLoginTime() + expireTime * MILLIS_MINUTE);
|
||||||
String userKey = getTokenKey(loginUserByPhone.getToken());
|
String userKey = getTokenKey(loginUserByPhone.getToken());
|
||||||
redisCache.setCacheObject(userKey, loginUserByPhone, expireTime, TimeUnit.MINUTES);
|
redisCache.setCacheObject(userKey, loginUserByPhone, expireTime, TimeUnit.DAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue