mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fix: 无法生成内置数据脱敏处理器键(Masks)的问题。
This commit is contained in:
parent
5e1b5cd587
commit
b0a3b358d7
@ -20,6 +20,8 @@ import com.mybatisflex.annotation.Id;
|
|||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
import com.mybatisflex.codegen.config.ColumnConfig;
|
import com.mybatisflex.codegen.config.ColumnConfig;
|
||||||
import com.mybatisflex.codegen.config.EntityConfig;
|
import com.mybatisflex.codegen.config.EntityConfig;
|
||||||
|
import com.mybatisflex.core.mask.MaskManager;
|
||||||
|
import com.mybatisflex.core.mask.Masks;
|
||||||
import com.mybatisflex.core.util.StringUtil;
|
import com.mybatisflex.core.util.StringUtil;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@ -364,9 +366,21 @@ public class Column {
|
|||||||
annotations.append(columnAnnotation);
|
annotations.append(columnAnnotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@ColumnMask 注解
|
// @ColumnMask 注解
|
||||||
if (columnConfig.getMaskType() != null) {
|
String maskType = columnConfig.getMaskType();
|
||||||
annotations.append("@ColumnMask(\"").append(columnConfig.getMaskType()).append("\")");
|
if (maskType != null) {
|
||||||
|
if (annotations.length() != 0) {
|
||||||
|
annotations.append("\n\t");
|
||||||
|
}
|
||||||
|
annotations.append("@ColumnMask(");
|
||||||
|
if (MaskManager.getProcessorMap().containsKey(maskType)) {
|
||||||
|
// @ColumnMask(Masks.MOBILE)
|
||||||
|
annotations.append("Masks.").append(maskType.toUpperCase());
|
||||||
|
} else {
|
||||||
|
// @ColumnMask("custom")
|
||||||
|
annotations.append("\"").append(maskType).append("\"");
|
||||||
|
}
|
||||||
|
annotations.append(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
return annotations.toString();
|
return annotations.toString();
|
||||||
@ -390,6 +404,9 @@ public class Column {
|
|||||||
}
|
}
|
||||||
if (columnConfig.getMaskType() != null) {
|
if (columnConfig.getMaskType() != null) {
|
||||||
addImportClass(importClasses, ColumnMask.class.getName());
|
addImportClass(importClasses, ColumnMask.class.getName());
|
||||||
|
if (MaskManager.getProcessorMap().containsKey(columnConfig.getMaskType())) {
|
||||||
|
addImportClass(importClasses, Masks.class.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnConfig.getJdbcType() != null) {
|
if (columnConfig.getJdbcType() != null) {
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.mybatisflex.core.mask;
|
package com.mybatisflex.core.mask;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -58,6 +59,9 @@ public class MaskManager {
|
|||||||
processorMap.put(type, processor);
|
processorMap.put(type, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, MaskProcessor> getProcessorMap() {
|
||||||
|
return Collections.unmodifiableMap(processorMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳过脱敏处理
|
* 跳过脱敏处理
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user