Skip to content

Commit

Permalink
refactor: 适配 ContiNew Starter 脱敏模块(安全模块)
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Feb 7, 2024
1 parent dc5425d commit 2109789
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
6 changes: 6 additions & 0 deletions continew-admin-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -68,13 +69,15 @@ public class UserInfoResp implements Serializable {
/**
* 邮箱
*/
@Schema(description = "邮箱", example = "[email protected]")
@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;

/**
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* 用户信息
Expand Down Expand Up @@ -70,13 +68,15 @@ public class UserResp extends BaseResp {
/**
* 邮箱
*/
@Schema(description = "邮箱", example = "[email protected]")
@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;

/**
Expand All @@ -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());
Expand Down

0 comments on commit 2109789

Please sign in to comment.