refactor: 适配 ContiNew Starter 脱敏模块(安全模块)

This commit is contained in:
Charles7c 2024-02-07 17:50:38 +08:00
parent dc5425dd67
commit 2109789116
3 changed files with 22 additions and 29 deletions

View File

@ -96,6 +96,12 @@
<artifactId>continew-starter-file-excel</artifactId>
</dependency>
<!-- ContiNew Starter 安全模块 - 脱敏 -->
<dependency>
<groupId>top.charles7c.continew</groupId>
<artifactId>continew-starter-security-mask</artifactId>
</dependency>
<!-- ContiNew Starter 安全模块 - 密码编码器 -->
<dependency>
<groupId>top.charles7c.continew</groupId>

View File

@ -16,11 +16,12 @@
package top.charles7c.continew.admin.auth.model.resp;
import cn.hutool.core.util.DesensitizedUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.charles7c.continew.admin.common.enums.GenderEnum;
import top.charles7c.continew.starter.security.mask.annotation.JsonMask;
import top.charles7c.continew.starter.security.mask.enums.MaskType;
import java.io.Serial;
import java.io.Serializable;
@ -68,13 +69,15 @@ public class UserInfoResp implements Serializable {
/**
* 邮箱
*/
@Schema(description = "邮箱", example = "123456789@qq.com")
@Schema(description = "邮箱", example = "c*******@126.com")
@JsonMask(MaskType.EMAIL)
private String email;
/**
* 手机号码
*/
@Schema(description = "手机号码", example = "13811111111")
@Schema(description = "手机号码", example = "188****8888")
@JsonMask(MaskType.MOBILE_PHONE)
private String phone;
/**
@ -131,14 +134,6 @@ public class UserInfoResp implements Serializable {
@Schema(description = "角色编码集合", example = "[\"test\"]")
private Set<String> roles;
public String getEmail() {
return DesensitizedUtil.email(email);
}
public String getPhone() {
return DesensitizedUtil.mobilePhone(phone);
}
public LocalDate getRegistrationDate() {
return createTime.toLocalDate();
}

View File

@ -16,19 +16,17 @@
package top.charles7c.continew.admin.system.model.resp;
import java.io.Serial;
import java.util.Objects;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.hutool.core.util.DesensitizedUtil;
import lombok.Data;
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
import top.charles7c.continew.admin.common.enums.GenderEnum;
import top.charles7c.continew.admin.common.util.helper.LoginHelper;
import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp;
import top.charles7c.continew.starter.security.mask.annotation.JsonMask;
import top.charles7c.continew.starter.security.mask.enums.MaskType;
import java.io.Serial;
import java.util.Objects;
/**
* 用户信息
@ -70,13 +68,15 @@ public class UserResp extends BaseResp {
/**
* 邮箱
*/
@Schema(description = "邮箱", example = "123456789@qq.com")
@Schema(description = "邮箱", example = "c*******@126.com")
@JsonMask(MaskType.EMAIL)
private String email;
/**
* 手机号码
*/
@Schema(description = "手机号码", example = "13811111111")
@Schema(description = "手机号码", example = "188****8888")
@JsonMask(MaskType.MOBILE_PHONE)
private String phone;
/**
@ -97,14 +97,6 @@ public class UserResp extends BaseResp {
@Schema(description = "描述", example = "张三描述信息")
private String description;
public String getEmail() {
return DesensitizedUtil.email(email);
}
public String getPhone() {
return DesensitizedUtil.mobilePhone(phone);
}
@Override
public Boolean getDisabled() {
return this.getIsSystem() || Objects.equals(this.getId(), LoginHelper.getUserId());