MCPInstall

ddd4j-mybatis

DDD4J MyBatis-Plus 持久层约定技能。覆盖 ActiveRecord 模式(Entity必须extends BaseEntity→Model )、@TableLogic逻辑删除、审计字段自动填充(createBy/createTime/updateBy/updateTime)、@Param("model")XML参数约定、PaginationEntity分页封装(15条/页/Oracle风格offset)、类型处理器体系(BooleanEnum/JSON双套/ListSetArray拆分)、BaseMapper内置getPagedList/setStatus/getCountBy等方法。 当用户在 DDD4J 项目中定义 Entity/Repository、编写 Mapper XML、使用分页查询、配置类型处理器时需要此技能。 配合 ddd4j-core 技能使用。

Installs
53
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/full-stack-skills/ddd-skills --skill ddd4j-mybatis
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads ddd4j-mybatis automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

DDD4J MyBatis-Plus 持久层约定

编码 DDD4J 项目中 MyBatis-Plus 的使用规则。LLM 会用标准 MyBatis-Plus 写法,但不符项目约定。

为什么需要这个技能

LLM 会用 implements Serializable 定义实体——DDD4J 要求 extends BaseEntity<T extends Model<?>>(ActiveRecord模式)。LLM 会在 XML 中写 #{entity.beginTime}——DDD4J 要求 #{model.beginTime}(@Param("model"))。这些约定 LLM 不知道。

Capability Boundaries

✅ Strong Suits

  1. 实体继承链 — BaseEntity→Model<T>(ActiveRecord),PaginationEntity→BaseEntity
  2. 审计字段 — createBy/createTime(INSERT填充)、updateBy/updateTime(INSERT_UPDATE填充)
  3. 逻辑删除 — @TableLogic 标记 isDeleted 字段
  4. @Param("model") 约定 — getPagedList 的参数名是 model,不是 entity
  5. 分页封装 — PaginationEntity(默认15条/页,Oracle风格offset=(pageNo-1)*limit+1)
  6. 类型处理器 — BooleanEnum(0/1)、JSON(双套)、List/Set/Array
  7. BaseMapper 内置方法 — getPagedList/setStatus/getCountBy*

❌ Out of Scope

  1. 实体/Controller/Service 继承层级 → ddd4j-core
  2. Jackson JSON 配置 → ddd4j-jackson

LLM 最常犯的错误

#错误正确做法
1implements Serializableextends BaseEntity<T>(继承 Model<T>,ActiveRecord)
2重复声明 createBy/createTimeBaseEntity 已声明,子类不要再加
3XML 写 #{entity.beginTime}写 #{model.beginTime}
4new Page<T>(1, 10)用 PaginationEntity<T> 封装
5逻辑删除写 UPDATE SET is_delete=1用 @TableLogic,MyBatis-Plus 自动处理
6自定义 Boolean 字段映射用 BooleanEnum + CustomBooleanEnumTypeHandler
7手动 offset 计算 (pageNo-1)*limitPaginationEntity.getOffset() 已封装

核心规则速查

// ✅ 正确:实体定义
@Data
@TableName("sys_user")
public class SysUser extends BaseEntity<SysUser> {   // Model<T> → ActiveRecord
    // ↓ 已继承,不再声明
    // Long createBy, createTime, updateBy, updateTime
    // Integer isDeleted (@TableLogic)
    // LocalDateTime beginTime, endTime (@TableField(exist=false), @JsonIgnore)
    // String keywords, params (@TableField(exist=false), @JsonIgnore)

    private String username;
    private String status;    // BooleanEnum 映射: 0=否, 1=是
}

// ✅ 分页查询
PaginationEntity<SysUser> entity = new PaginationEntity<>();
entity.setPageNo(1);          // 第1页
entity.setLimit(15);          // 默认15条
entity.setBeginTime(LocalDateTime.now().minusDays(7));
List<SysUser> list = baseService.getPagedList(
    new Page<>(entity.getPageNo(), entity.getLimit()), entity
);

// ✅ Mapper XML(注意参数名 model)
<select id="getPagedList" resultType="SysUser">
    SELECT * FROM sys_user
    WHERE is_deleted = 0
    <if test="model.beginTime != null">
        AND create_time >= #{model.beginTime}
    </if>
</select>

// ✅ 内置方法(BaseServiceImpl 已提供)
baseService.setStatus(id, "1");          // @Transactional
baseService.getCountByName("admin");
baseService.getCountByCode("ADMIN");
baseService.getCountByParent(parentId);
baseService.getValue("some_key");        // 从缓存读取

Gotchas

  1. 实体必须 extends BaseEntity,不能 implements Serializable — 失去 ActiveRecord 能力
  2. @Param("model") 是固定约定 — XML 引用必须是 #{model.xxx}
  3. PaginationEntity.getOffset() 是 Oracle 风格 — ((pageNo−1)*limit+1),不是0开头
  4. beginTime/endTime 在 Entity 上,不在独立 QueryDTO — 加 @TableField(exist=false) 即可
  5. BooleanEnum 映射 Integer 0/1 — 数据库不用原生 Boolean 类型
  6. JSON 类型处理器有两套 — 核心用 fastjson2(jdbc包),cmet用 hutool
  7. 逻辑删除条件自动拼接 — SQL 不用写 is_deleted = 0(但复杂查询建议加上)
  8. setStatus 是 @Transactional — 子类重写也必须加上事务注解

Data Privacy

本技能不收集、存储或传输任何用户数据。

FAQ

What does the ddd4j-mybatis skill do?

DDD4J MyBatis-Plus 持久层约定技能。覆盖 ActiveRecord 模式(Entity必须extends BaseEntity→Model )、@TableLogic逻辑删除、审计字段自动填充(createBy/createTime/updateBy/updateTime)、@Param("model")XML参数约定、PaginationEntity分页封装(15条/页/Oracle风格offset)、类型处理器体系(BooleanEnum/JSON双套/ListSetArray拆分)、BaseMapper内置getPagedList/setStatus/getCountBy等方法。 当用户在 DDD4J 项目中定义 Entity/Repository、编写 Mapper XML、使用分页查询、配置类型处理器时需要此技能。 配合 ddd4j-core 技能使用。

How do I install ddd4j-mybatis?

Run npx skills add https://github.com/full-stack-skills/ddd-skills --skill ddd4j-mybatis in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/ddd4j-mybatis/ (personal) or .claude/skills/ddd4j-mybatis/ (project).

Which AI agents can use ddd4j-mybatis?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is ddd4j-mybatis safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains ddd4j-mybatis?

It is published by full-stack-skills in full-stack-skills/ddd-skills. It has 53 recorded installs.

More from full-stack-skills/ddd-skills

View all →

ddd-domain-designer

full-stack-skills/ddd-skills

Domain-driven design complete workflow — event-storming-driven 6-step domain modeling process, aggregate design 5-principles + 6-rules, bounded context identification, entity/value object design patterns, domain event catalog, and code mapping. Use when user asks about domain modeling, 领域建模, aggregate design, 聚合设计, bounded context, 限界上下文, or needs to design DDD domain model.

Frontend & Design151 installs

ddd-code-reviewer

full-stack-skills/ddd-skills

DDD code review and anti-pattern detection — anemia model detection, layered compliance checking, aggregate design review, rich model verification, scoring system (5 dimensions), and ArchUnit automated validation. Use when user asks about code review, 代码审查, DDD review, 架构审查, anti-pattern detection, 反模式检测, or needs to check if code follows DDD.

ddd-event-storming

full-stack-skills/ddd-skills

Event Storming workshop facilitation guide — collaborative domain exploration methodology with 6-step process (chaos exploration/timeline/pivotal events/commands & actors/aggregate discovery/bounded context), standardized sticky note color conventions (orange/blue/yellow/green/pink/purple), workshop preparation and facilitation tips, and digital tool recommendations. Use when user asks about event storming, 事件风暴, workshop, 工作坊, domain exploration, collaborative modeling, or needs to organize a DDD discovery workshop.

143 installs

ddd-api-designer

full-stack-skills/ddd-skills

API design from domain model — CQRS command/query separation, REST API endpoint design, data object conversion chain (PO→DO→DTO→VO), unified response format, OpenAPI/Swagger generation, BFF pattern, API versioning, and security design. Use when user asks about API design, REST API, OpenAPI, BFF, DTO design, 接口设计, or data object conversion.

Backend & APIs139 installs

ddd-architecture-clean

full-stack-skills/ddd-skills

Comprehensive guidance for Clean Architecture (整洁架构) — Robert C. Martin's Clean Architecture with Enterprise Business Rules, Use Cases, Interface Adapters, and Frameworks layers. Covers core entities, use case interactors, dependency rules, and full implementation steps with Java/Spring Boot examples. Use when user asks about Clean Architecture, 整洁架构, Robert Martin, Uncle Bob, use case driven architecture, or needs to implement DDD with clean architecture.

ddd-architecture-layered

full-stack-skills/ddd-skills

Comprehensive guidance for DDD Layered Architecture (DDD 四层架构) — Traditional 3-layer to DDD 4-layer transformation with Interface/Application/Domain/Infrastructure layers. Covers complete directory structure, dependency inversion, ArchUnit validation, Spring Boot integration, and step-by-step migration guide. Use when user asks about layered architecture, DDD four-layer, 分层架构, traditional layering with DDD, or needs a simple DDD entry point for small to medium teams.

Popular other skills

View category →

hyperframes-cli

heygen-com/hyperframes

The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.

1.3M installs

triage

mattpocock/skills

Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.

1M installs

ask-matt

mattpocock/skills

Ask which skill or flow fits your situation. A router over the skills in this repo.

778.4K installs

to-questionnaire

mattpocock/skills

Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

508.9K installs

wait-what

mattpocock/skills

Stop. That last message did not land: re-pitch it.

459.7K installs

loop-me

mattpocock/skills

Grill me about specs for the workflows I want to build, within this workspace.

447.9K installs