惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - 漫漫人生路总会错几步

【流量密码】LVS与nginx对比 【架构升华】:数据库是性能的物理终点 【轻量化交付宣言】:DevOps 的本质是工程化,而非工具化 【微服务】是【必须品】吗? 【JWT】真的好吗? PGSQL 1主2从数据库架构与单节点分3库在三块磁盘理论上限畅想(未测试) 相同的硬件,各个数据库专家比赛畅想 maven 原型项目 mysql9.5安装文档 微信图片批量保存的办法 win平台利用winsw将php-cgi作为系统服务,支持服务的正常启动/停止/重启 利用WinSW将Nginx 作为可正常启动/停止的windows服务 JPA使用pg数据库时,bool字段不能跨库迁移的解决方案 【ubuntu】程序运行时的任务栏图标 跨网段通信实战(支持静态路由表的家用路由) Linux系统Mariadb初始化相关(ubuntu) springboot 整合webservice 相关说明 tomcat 服务版本内存设置 navicat连接mysql8报错
一种非常巧妙的设计模式
漫漫人生路总会错几步 · 2026-03-09 · via 博客园 - 漫漫人生路总会错几步
interface ValueSetter<T> {

    public void set(T entity, Object v);

}

interface ValueGetter<T> {

    public Object get(T entity);

}

public class BaseHelper<T extends BaseEntity> implements Converter {

    public static final String ID = "id";
    
    public static final String PARENT_ID = "parentId";

    public static final String UUID = "uuid";

    public static final String DELETED = "deleted";

    public static final String DISABLED = "disabled";

    public static final String CREATE_USER = "createUser";

    public static final String CREATE_TIME = "createTime";

    public static final String UPDATE_TIME = "updateTime";

    public static final String UPDATE_USER = "updateUser";

    public static final String DATA_VERSION = "dataVersion";

    public static final String ORDER_NUM = "orderNum";

    public Map<String, ValueGetter<T>> baseGetterMap() {
        Map<String, ValueGetter<T>> map = new TreeMap<>();
        map.put(ID, T::getId);
        map.put(UUID, T::getUuid);
        map.put(DISABLED, T::getDisabled);
        map.put(CREATE_USER, T::getCreateUser);
        map.put(CREATE_TIME, T::getCreateTime);
        map.put(UPDATE_TIME, T::getUpdateTime);
        map.put(UPDATE_USER, T::getUpdateUser);
        map.put(DATA_VERSION, T::getDataVersion);
        return map;
    }

    public Map<String, ValueSetter<T>> baseSetterMap() {
        Map<String, ValueSetter<T>> map = new TreeMap<>();
        map.put(ID, (T e, Object v) -> e.setId(toLong(v)));
        map.put(UUID, (T e, Object v) -> e.setUuid(toString(v)));
        map.put(DISABLED, (T e, Object v) -> e.setDisabled(toBoolean(v)));
        map.put(CREATE_USER, (T e, Object v) -> e.setCreateUser(toLong(v)));
        map.put(CREATE_TIME, (T e, Object v) -> e.setCreateTime(toDate(v)));
        map.put(UPDATE_TIME, (T e, Object v) -> e.setUpdateTime(toDate(v)));
        map.put(UPDATE_USER, (T e, Object v) -> e.setUpdateUser(toLong(v)));
        map.put(DATA_VERSION, (T e, Object v) -> e.setDataVersion(toLong(v)));
        return map;
    }

    public Map<String, Class<?>> baseFieldTypeInfo() {
        Map<String, Class<?>> map = new TreeMap<>();
        map.put(ID, Long.class);
        map.put(UUID, String.class);
        map.put(DISABLED, Boolean.class);
        map.put(CREATE_USER, Long.class);
        map.put(CREATE_TIME, Date.class);
        map.put(UPDATE_TIME, Date.class);
        map.put(UPDATE_USER, Long.class);
        map.put(DATA_VERSION, Long.class);
        return map;
    }
}
 1 package tech.abcd.core.entity.helper;
 2 
 3 import java.util.*;
 4 
 5 import org.springframework.stereotype.Component;
 6 
 7 import tech.zqxx.common.helper.entity.BaseEntity;
 8 import tech.zqxx.common.helper.entity.BaseHelper;
 9 import tech.zqxx.common.helper.entity.DomainHelper;
10 import tech.zqxx.common.helper.entity.ValueGetter;
11 import tech.zqxx.common.helper.entity.ValueSetter;
12 import tech.zqxx.core.entity.*;
13 
14 /****
15  * 本代码由生成器生成,请勿修改
16  */
17 @Component
18 public class SysDeptHelper extends BaseHelper<SysDept> implements DomainHelper<SysDept>  {
19 
20     // 字段名常量定义
21     public static final String DEPT_NAME = "deptName";
22     public static final String LEADER = "leader";
23     public static final String DATA_VERSION = "dataVersion";
24     public static final String ORDER_NUM = "orderNum";
25     public static final String UPDATE_USER = "updateUser";
26     public static final String REMARK = "remark";
27     public static final String UPDATE_TIME = "updateTime";
28     public static final String UUID = "uuid";
29     public static final String PARENT_ID = "parentId";
30     public static final String CREATE_TIME = "createTime";
31     public static final String DISABLED = "disabled";
32     public static final String CREATE_USER = "createUser";
33     public static final String ID = "id";
34 
35   
36 
37     @Override
38     public Class<SysDept> getDomainClass() {
39         return SysDept.class;
40     }
41 
42     @Override
43     public SysDept create() {
44         return new SysDept();
45     }
46 
47     @Override
48     public Map<String, ValueGetter<SysDept>> getterMap() {
49         Map<String, ValueGetter<SysDept>> map = new HashMap<>();
50         map.put(DEPT_NAME, SysDept::getDeptName);
51         map.put(LEADER, SysDept::getLeader);
52         map.put(ORDER_NUM, SysDept::getOrderNum);
53         map.put(REMARK, SysDept::getRemark);
54         map.put(PARENT_ID, SysDept::getParentId);
55         map.putAll(baseGetterMap());
56         return Collections.unmodifiableMap(map);
57     }
58 
59     @Override
60     public Map<String, ValueSetter<SysDept>> setterMap() {
61         Map<String, ValueSetter<SysDept>> map = new HashMap<>();
62         map.put(DEPT_NAME, (entity, v) -> entity.setDeptName(toString(v)));
63         map.put(LEADER, (entity, v) -> entity.setLeader(toLong(v)));
64         map.put(ORDER_NUM, (entity, v) -> entity.setOrderNum(toLong(v)));
65         map.put(REMARK, (entity, v) -> entity.setRemark(toString(v)));
66         map.put(PARENT_ID, (entity, v) -> entity.setParentId(toLong(v)));
67         map.putAll(baseSetterMap());
68         return Collections.unmodifiableMap(map);
69     }
70 
71     @Override
72     public Map<String, Class<? extends BaseEntity>> fieldComponentTypeInfo() {
73         Map<String, Class<? extends BaseEntity>> map = new HashMap<>();
74         return Collections.unmodifiableMap(map);
75     }
76 
77     @Override
78     public Map<String, Class<?>> fieldTypeInfo() {
79         Map<String, Class<?>> map = new HashMap<>();
80         
81         map.put(DEPT_NAME, String.class);
82         map.put(LEADER, Long.class);
83         map.put(ORDER_NUM, Long.class);
84         map.put(REMARK, String.class);
85         map.put(PARENT_ID, Long.class);
86         map.putAll(baseFieldTypeInfo());
87         return Collections.unmodifiableMap(map);
88     }
89 
90 }

看的懂的,自然知道,这段代码解决了什么问题,看不懂的,一头雾水。