feat(tenant): 支持租户手机号脱敏开关功能
- Tenant实体新增phoneMasked字段,默认开启手机号脱敏 - getPhone方法根据phoneMasked决定是否返回脱敏手机号 - TenantController分页接口支持mask参数,控制手机号是否脱敏 - TenantMapper调整SQL,始终关联sys_user表获取手机号 - TenantParam新增mask字段,兼容传入脱敏控制参数
This commit is contained in:
@@ -53,7 +53,16 @@ public class TenantController extends BaseController {
|
||||
@Operation(summary = "分页查询租户")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Tenant>> page(TenantParam param) {
|
||||
return success(tenantService.pageRel(param));
|
||||
PageResult<Tenant> result = tenantService.pageRel(param);
|
||||
// 如果传入 mask=false,设置不脱敏
|
||||
if (param.getMask() != null && !param.getMask()) {
|
||||
if (result.getList() != null) {
|
||||
for (Tenant tenant : result.getList()) {
|
||||
tenant.setPhoneMasked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:tenant:list')")
|
||||
|
||||
@@ -112,7 +112,21 @@ public class Tenant implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String freeDomain;
|
||||
|
||||
/**
|
||||
* 是否脱敏手机号,默认true脱敏
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "手机号是否脱敏,默认true")
|
||||
private boolean phoneMasked = true;
|
||||
|
||||
public String getPhone(){
|
||||
return DesensitizedUtil.mobilePhone(this.phone);
|
||||
if (phoneMasked) {
|
||||
return DesensitizedUtil.mobilePhone(this.phone);
|
||||
}
|
||||
return this.phone;
|
||||
}
|
||||
|
||||
public void setPhoneMasked(boolean masked) {
|
||||
this.phoneMasked = masked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,10 @@
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*,b.company_name,b.company_logo as logo,b.admin_url,b.domain,b.free_domain
|
||||
<if test="param.getPhone == true">
|
||||
,c.phone
|
||||
</if>
|
||||
SELECT a.*,b.company_name,b.company_logo as logo,b.admin_url,b.domain,b.free_domain,c.phone
|
||||
FROM sys_tenant a
|
||||
LEFT JOIN sys_company b ON a.tenant_id = b.tenant_id
|
||||
<if test="param.getPhone == true">
|
||||
LEFT JOIN sys_user c ON a.user_id = c.user_id
|
||||
</if>
|
||||
LEFT JOIN sys_user c ON a.user_id = c.user_id
|
||||
<where>
|
||||
<if test="param.tenantId != null">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
|
||||
@@ -52,8 +52,8 @@ public class TenantParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "是否获取手机号码")
|
||||
@Schema(description = "手机号是否脱敏,默认true")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean getPhone;
|
||||
private Boolean mask;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user