diff --git a/gather-app/src/main/java/com/ruoyi/business/util/aspect/responseAspect.java b/gather-app/src/main/java/com/ruoyi/business/util/aspect/responseAspect.java deleted file mode 100644 index 0751035..0000000 --- a/gather-app/src/main/java/com/ruoyi/business/util/aspect/responseAspect.java +++ /dev/null @@ -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 around(ProceedingJoinPoint joinPoint) throws Throwable { - Object proceed = joinPoint.proceed(); - TableDataInfo tableDataInfo = (TableDataInfo) 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; - } -} diff --git a/gather-app/src/main/java/com/ruoyi/database/controller/SmallProgramController.java b/gather-app/src/main/java/com/ruoyi/database/controller/SmallProgramController.java index 336cd93..1930a33 100644 --- a/gather-app/src/main/java/com/ruoyi/database/controller/SmallProgramController.java +++ b/gather-app/src/main/java/com/ruoyi/database/controller/SmallProgramController.java @@ -151,8 +151,7 @@ public class SmallProgramController extends BaseController { customerPlateNoInfo.setPlateNo(plateNo); customerPlateNoInfo.setPlateType(bindTheVehicle.getPlateType()); customerPlateNoInfo.setPhone(loginUserByPhone.getPhone()); - customerPlateNoInfoService.saveOrUpdate(customerPlateNoInfo); - return AjaxResult.success(customerPlateNoInfo); + return toAjax(customerPlateNoInfoService.saveOrUpdate(customerPlateNoInfo)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aspect/responseAspect.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aspect/responseAspect.java deleted file mode 100644 index 3ca6878..0000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/aspect/responseAspect.java +++ /dev/null @@ -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 around(ProceedingJoinPoint joinPoint) throws Throwable { - Object proceed = joinPoint.proceed(); - TableDataInfo tableDataInfo = (TableDataInfo) 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; - } -} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index a116508..a369d0c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.system; +import cn.hutool.core.util.DesensitizedUtil; import com.ruoyi.business.util.StringKit; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.AjaxResult; @@ -186,6 +187,7 @@ public class SysLoginController { .eq(BaseCustomerInfo::getPhone, loginUser.getPhone()) .last("limit 1") .one(); + one.setPhone(DesensitizedUtil.mobilePhone(one.getPhone())); return AjaxResult.success(one); } return AjaxResult.success(loginUser); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java index f2968b1..bfc35b0 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java @@ -183,7 +183,7 @@ public class TokenService { loginUserByPhone.setLoginTime(System.currentTimeMillis()); loginUserByPhone.setExpireTime(loginUserByPhone.getLoginTime() + expireTime * MILLIS_MINUTE); String userKey = getTokenKey(loginUserByPhone.getToken()); - redisCache.setCacheObject(userKey, loginUserByPhone, expireTime, TimeUnit.MINUTES); + redisCache.setCacheObject(userKey, loginUserByPhone, expireTime, TimeUnit.DAYS); } /**