mybatis-plus-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

When to use this skill

何时使用此技能

CRITICAL: This skill should ONLY be triggered when the user explicitly mentions MyBatis-Plus or mybatis-plus-generator.
ALWAYS use this skill when the user mentions:
  • MyBatis-Plus code generation (explicitly mentions "MyBatis-Plus" or "mybatis-plus")
  • Generating MyBatis-Plus code from database tables
  • MyBatis-Plus generator or mybatis-plus-generator
  • Creating MyBatis-Plus Entity, Mapper, Service, Controller code
  • 生成 MyBatis-Plus 代码 (explicitly mentions "MyBatis-Plus")
  • MyBatis-Plus 代码生成器 (MyBatis-Plus code generator)
  • 使用 MyBatis-Plus 生成代码 (generate code using MyBatis-Plus)
Trigger phrases include:
  • "生成 MyBatis-Plus 代码" (generate MyBatis-Plus code) - must include "MyBatis-Plus"
  • "MyBatis-Plus 代码生成" (MyBatis-Plus code generation) - must include "MyBatis-Plus"
  • "mybatis-plus-generator" (explicitly mentions the generator)
  • "使用 MyBatis-Plus 根据表结构生成代码" (use MyBatis-Plus to generate code from table structure)
  • "MyBatis-Plus 生成 Entity、Service、Controller" (MyBatis-Plus generate Entity, Service, Controller)
  • "MyBatis-Plus 代码生成器" (MyBatis-Plus code generator)
DO NOT trigger this skill for:
  • Generic code generation without mentioning MyBatis-Plus
  • JPA/Hibernate code generation
  • Other ORM frameworks (TypeORM, Sequelize, etc.)
  • Generic CRUD operations without MyBatis-Plus context
  • "根据表结构生成代码" without "MyBatis-Plus" (too generic)
  • "生成 CRUD 代码" without "MyBatis-Plus" (too generic)
  • "代码生成器" without "MyBatis-Plus" (too generic)
Supported architectures:
  • Traditional MVC (Model-View-Controller)
  • DDD (Domain-Driven Design)
  • Layered Architecture
  • Clean Architecture
Supported languages:
  • Java
  • Kotlin
Supported component types:
  • Entity (实体类)
  • Mapper (数据访问接口)
  • Service (服务接口)
  • ServiceImpl (服务实现类)
  • Controller (控制器)
  • DTO (Data Transfer Object)
  • VO (Value Object / View Object)
  • BO (Business Object)
  • Model (数据模型)
重要提示:此技能仅在用户明确提到MyBatis-Plus或mybatis-plus-generator时触发。
当用户提及以下内容时,务必使用此技能:
  • MyBatis-Plus代码生成(明确提到"MyBatis-Plus"或"mybatis-plus")
  • 从数据库表生成MyBatis-Plus代码
  • MyBatis-Plus生成器或mybatis-plus-generator
  • 创建MyBatis-Plus的Entity、Mapper、Service、Controller代码
  • 生成 MyBatis-Plus 代码(明确提到"MyBatis-Plus")
  • MyBatis-Plus 代码生成器(MyBatis-Plus code generator)
  • 使用 MyBatis-Plus 生成代码(generate code using MyBatis-Plus)
触发关键词包括:
  • "生成 MyBatis-Plus 代码"(generate MyBatis-Plus code)- 必须包含"MyBatis-Plus"
  • "MyBatis-Plus 代码生成"(MyBatis-Plus code generation)- 必须包含"MyBatis-Plus"
  • "mybatis-plus-generator"(明确提到生成器)
  • "使用 MyBatis-Plus 根据表结构生成代码"(use MyBatis-Plus to generate code from table structure)
  • "MyBatis-Plus 生成 Entity、Service、Controller"(MyBatis-Plus generate Entity, Service, Controller)
  • "MyBatis-Plus 代码生成器"(MyBatis-Plus code generator)
请勿在以下场景触发此技能:
  • 未提及MyBatis-Plus的通用代码生成请求
  • JPA/Hibernate代码生成
  • 其他ORM框架(TypeORM、Sequelize等)
  • 无MyBatis-Plus上下文的通用CRUD操作
  • 未包含"MyBatis-Plus"的"根据表结构生成代码"(过于通用)
  • 未包含"MyBatis-Plus"的"生成 CRUD 代码"(过于通用)
  • 未包含"MyBatis-Plus"的"代码生成器"(过于通用)
支持的架构:
  • 传统MVC(Model-View-Controller)
  • DDD(领域驱动设计)
  • 分层架构
  • 整洁架构
支持的语言:
  • Java
  • Kotlin
支持的组件类型:
  • Entity(实体类)
  • Mapper(数据访问接口)
  • Service(服务接口)
  • ServiceImpl(服务实现类)
  • Controller(控制器)
  • DTO(Data Transfer Object)
  • VO(Value Object / View Object)
  • BO(Business Object)
  • Model(数据模型)

How to use this skill

如何使用此技能

CRITICAL: This skill should ONLY be triggered when the user explicitly mentions MyBatis-Plus or mybatis-plus-generator. Do NOT trigger for generic code generation requests without MyBatis-Plus context.
重要提示:此技能仅在用户明确提到MyBatis-Plus或mybatis-plus-generator时触发。请勿在无MyBatis-Plus上下文的通用代码生成请求中触发。

Workflow Overview

工作流程概述

This skill follows a systematic 8-step workflow:
  1. Collect Configuration - Collect database information, global configuration, package configuration, strategy configuration
  2. Determine Architecture - Ask user about architecture type (MVC, DDD, etc.) to determine which objects to generate
  3. Collect Requirements - Ask user for functional requirements to analyze and determine methods to generate
  4. Determine Language - Ask user about programming language (Java or Kotlin)
  5. Create Todo List - Generate a detailed todo list with table names, object types, and method names
  6. Generate Code - Generate code files with intelligent comments based on table structure and requirements
  7. Progress Updates - Provide real-time progress updates during code generation
  8. Statistics - Output statistics after generation completes
此技能遵循系统化的8步工作流程:
  1. 收集配置信息 - 收集数据库信息、全局配置、包配置、策略配置
  2. 确定架构类型 - 询问用户架构类型(MVC、DDD等)以确定需要生成的对象
  3. 收集需求 - 询问用户功能需求,分析并确定需要生成的方法
  4. 确定开发语言 - 询问用户编程语言(Java或Kotlin)
  5. 创建任务清单 - 生成包含表名、对象类型和方法名的详细任务清单
  6. 生成代码 - 根据表结构和需求生成带有智能注释的代码文件
  7. 进度更新 - 在代码生成过程中提供实时进度更新
  8. 统计信息 - 生成完成后输出统计数据

Step-by-Step Process

分步流程

Step 1: Collect Configuration

步骤1:收集配置信息

CRITICAL: Before generating any code, you MUST collect the following configuration:
  1. Database Information:
    • Database type (MySQL, PostgreSQL, Oracle, etc.)
    • Database connection URL (or ask user to provide table structure)
    • Database name
    • Table names (one or multiple tables)
    • If user cannot provide database connection, ask for table structure (CREATE TABLE statement or table schema)
  2. Global Configuration:
    • Author name
    • Output directory (default:
      src/main/java
      )
    • File override strategy (overwrite, skip, ask)
    • Enable Lombok (yes/no)
    • Enable API documentation (yes/no)
    • API Documentation Type (if enabled):
      • Swagger 2 (使用
        io.swagger.annotations.*
        )
      • OpenAPI 3 (使用
        io.swagger.v3.oas.annotations.*
        )
    • Enable validation annotations (yes/no)
  3. Package Configuration:
    • Parent package name (e.g.,
      com.example.app
      )
    • Entity package (default:
      entity
      )
    • Mapper package (default:
      mapper
      )
    • Service package (default:
      service
      )
    • ServiceImpl package (default:
      service.impl
      )
    • Controller package (default:
      controller
      )
    • DTO package (default:
      dto
      )
    • VO package (default:
      vo
      )
    • BO package (default:
      bo
      )
  4. Strategy Configuration:
    • Naming strategy (camelCase, PascalCase, etc.)
    • Table prefix removal (yes/no, prefix name)
    • Field naming strategy
    • Primary key strategy (AUTO, UUID, etc.)
IMPORTANT: API Documentation Type Selection:
When user enables API documentation, you MUST ask:
请选择 API 文档类型:
- [ ] Swagger 2
  - 使用注解:@ApiModel, @ApiModelProperty, @Api, @ApiOperation
  - 依赖:springfox-swagger2, springfox-swagger-ui
  - 适用于:Spring Boot 2.x 项目
- [ ] OpenAPI 3
  - 使用注解:@Schema, @Tag, @Operation, @Parameter
  - 依赖:springdoc-openapi-ui
  - 适用于:Spring Boot 2.2+ 和 Spring Boot 3.x 项目
Wait for user confirmation before proceeding.
Output: A configuration summary showing all collected information, including API documentation type.
重要提示:在生成任何代码之前,必须收集以下配置信息:
  1. 数据库信息:
    • 数据库类型(MySQL、PostgreSQL、Oracle等)
    • 数据库连接URL(或请用户提供表结构)
    • 数据库名称
    • 表名(单个或多个表)
    • 如果用户无法提供数据库连接,请询问表结构(CREATE TABLE语句或表结构定义)
  2. 全局配置:
    • 作者名称
    • 输出目录(默认:
      src/main/java
    • 文件覆盖策略(覆盖、跳过、询问)
    • 是否启用Lombok(是/否)
    • 是否启用API文档(是/否)
    • API文档类型(如果启用):
      • Swagger 2(使用
        io.swagger.annotations.*
      • OpenAPI 3(使用
        io.swagger.v3.oas.annotations.*
    • 是否启用验证注解(是/否)
  3. 包配置:
    • 父包名(例如:
      com.example.app
    • Entity包(默认:
      entity
    • Mapper包(默认:
      mapper
    • Service包(默认:
      service
    • ServiceImpl包(默认:
      service.impl
    • Controller包(默认:
      controller
    • DTO包(默认:
      dto
    • VO包(默认:
      vo
    • BO包(默认:
      bo
  4. 策略配置:
    • 命名策略(camelCase、PascalCase等)
    • 是否移除表前缀(是/否,前缀名称)
    • 字段命名策略
    • 主键策略(AUTO、UUID等)
重要提示:API文档类型选择:
当用户启用API文档时,必须询问:
请选择 API 文档类型:
- [ ] Swagger 2
  - 使用注解:@ApiModel, @ApiModelProperty, @Api, @ApiOperation
  - 依赖:springfox-swagger2, springfox-swagger-ui
  - 适用于:Spring Boot 2.x 项目
- [ ] OpenAPI 3
  - 使用注解:@Schema, @Tag, @Operation, @Parameter
  - 依赖:springdoc-openapi-ui
  - 适用于:Spring Boot 2.2+ 和 Spring Boot 3.x 项目
等待用户确认后再继续。
输出结果:显示所有收集到的信息的配置摘要,包括API文档类型。

Step 2: Determine Architecture

步骤2:确定架构类型

CRITICAL: You MUST ask the user about the architecture type to determine which objects to generate.
Present architecture options:
请选择项目架构类型:
- [ ] 传统 MVC (Model-View-Controller)
  - 生成:Entity, Mapper, Service, ServiceImpl, Controller
- [ ] DDD (领域驱动设计)
  - 生成:Entity, Mapper, Service, ServiceImpl, Controller, DTO, VO, BO
- [ ] 分层架构 (Layered Architecture)
  - 生成:Entity, Mapper, Service, ServiceImpl, Controller
- [ ] 整洁架构 (Clean Architecture)
  - 生成:Entity, Repository, UseCase, Controller, DTO
- [ ] 自定义架构
  - 请指定需要生成的对象类型
Wait for user confirmation before proceeding.
IMPORTANT: Directory Mapping Based on Architecture
After determining the architecture type, you MUST identify the correct output directories for each generated object.
CRITICAL Steps:
  1. Ask user for base package path (e.g.,
    com.example.order
    )
  2. Use architecture directory mapping to determine correct paths:
    • Quick Reference: See
      reference/architecture-directory-quick-reference.md
      for lookup table
    • Detailed Guide: See
      reference/architecture-directory-mapping-guide.md
      for complete mapping rules
  3. Verify directory exists or create it if needed
  4. Generate files in the correct location
Common Path Examples:
For
user
table with base package
com.example.order
:
  • MVC: Entity →
    com/example/order/entity/User.java
    , Controller →
    com/example/order/controller/UserController.java
  • DDD: Entity →
    com/example/order/domain/model/aggregate/user/User.java
    , Controller →
    com/example/order/interfaces/web/controller/UserController.java
  • Hexagonal: Entity →
    com/example/order/domain/model/entity/User.java
    , Controller →
    com/example/order/infrastructure/adapter/inbound/web/controller/UserController.java
  • Clean: Entity →
    com/example/order/domain/entity/User.java
    , Controller →
    com/example/order/infrastructure/web/controller/UserController.java
  • COLA: Entity →
    com/example/order/domain/model/entity/User.java
    , Controller →
    com/example/order/adapter/web/controller/UserController.java
CRITICAL: Always confirm the exact directory structure with the user if the project structure is unclear. Ask: "请确认项目的目录结构,以便我将生成的代码放在正确的位置。"
重要提示:必须询问用户架构类型,以确定需要生成的对象。
提供架构选项:
请选择项目架构类型:
- [ ] 传统 MVC (Model-View-Controller)
  - 生成:Entity, Mapper, Service, ServiceImpl, Controller
- [ ] DDD (领域驱动设计)
  - 生成:Entity, Mapper, Service, ServiceImpl, Controller, DTO, VO, BO
- [ ] 分层架构 (Layered Architecture)
  - 生成:Entity, Mapper, Service, ServiceImpl, Controller
- [ ] 整洁架构 (Clean Architecture)
  - 生成:Entity, Repository, UseCase, Controller, DTO
- [ ] 自定义架构
  - 请指定需要生成的对象类型
等待用户确认后再继续。
重要提示:基于架构的目录映射
确定架构类型后,必须为每个生成的对象确定正确的输出目录。
关键步骤:
  1. 询问用户基础包路径(例如:
    com.example.order
  2. 使用架构目录映射确定正确路径:
    • 快速参考:查看
      reference/architecture-directory-quick-reference.md
      获取对照表
    • 详细指南:查看
      reference/architecture-directory-mapping-guide.md
      获取完整映射规则
  3. 验证目录是否存在,如果需要则创建
  4. 在正确位置生成文件
常见路径示例:
对于基础包为
com.example.order
user
表:
  • MVC:Entity →
    com/example/order/entity/User.java
    , Controller →
    com/example/order/controller/UserController.java
  • DDD:Entity →
    com/example/order/domain/model/aggregate/user/User.java
    , Controller →
    com/example/order/interfaces/web/controller/UserController.java
  • 六边形架构:Entity →
    com/example/order/domain/model/entity/User.java
    , Controller →
    com/example/order/infrastructure/adapter/inbound/web/controller/UserController.java
  • 整洁架构:Entity →
    com/example/order/domain/entity/User.java
    , Controller →
    com/example/order/infrastructure/web/controller/UserController.java
  • COLA架构:Entity →
    com/example/order/domain/model/entity/User.java
    , Controller →
    com/example/order/adapter/web/controller/UserController.java
重要提示:如果项目结构不明确,请始终与用户确认确切的目录结构。询问:"请确认项目的目录结构,以便我将生成的代码放在正确的位置。"

Step 3: Collect Requirements

步骤3:收集需求

CRITICAL: Ask user for functional requirements to understand what methods need to be generated.
Ask the user:
请描述此次生成代码的功能需求:

例如:
- 用户管理:需要根据邮箱查询用户、根据用户名查询用户、用户登录验证
- 订单管理:需要订单统计、订单分页查询、订单状态更新
- 商品管理:需要商品搜索、商品分类查询、库存管理

请详细描述每个表需要哪些功能,我会根据需求自动分析需要生成的方法。
After user provides requirements:
  1. Analyze requirements to identify:
    • Standard CRUD methods (create, read, update, delete)
    • Custom query methods (findByEmail, findByUsername, etc.)
    • Custom business methods (statistics, aggregation, etc.)
    • Custom update methods (updateStatus, updatePassword, etc.)
  2. For each table, identify:
    • Standard methods needed
    • Custom methods needed based on requirements
    • Method parameters and return types
    • Business logic hints (for method skeletons)
Output: A requirements analysis showing:
  • Standard methods for each table
  • Custom methods for each table
  • Method signatures (parameters and return types)
重要提示:询问用户功能需求,以了解需要生成哪些方法。
询问用户:
请描述此次生成代码的功能需求:

例如:
- 用户管理:需要根据邮箱查询用户、根据用户名查询用户、用户登录验证
- 订单管理:需要订单统计、订单分页查询、订单状态更新
- 商品管理:需要商品搜索、商品分类查询、库存管理

请详细描述每个表需要哪些功能,我会根据需求自动分析需要生成的方法。
用户提供需求后:
  1. 分析需求以确定:
    • 标准CRUD方法(创建、读取、更新、删除)
    • 自定义查询方法(findByEmail、findByUsername等)
    • 自定义业务方法(统计、聚合等)
    • 自定义更新方法(updateStatus、updatePassword等)
  2. 针对每个表,确定:
    • 需要的标准方法
    • 根据需求需要的自定义方法
    • 方法参数和返回类型
    • 业务逻辑提示(用于方法骨架)
输出结果:需求分析报告,包含:
  • 每个表的标准方法
  • 每个表的自定义方法
  • 方法签名(参数和返回类型)

Step 4: Determine Language

步骤4:确定开发语言

CRITICAL: Ask user about programming language.
请选择编程语言:
- [ ] Java
- [ ] Kotlin
Wait for user confirmation before proceeding.
Note: Templates in
templates/
directory support both Java and Kotlin. Use appropriate templates based on user's choice.
重要提示:询问用户编程语言。
请选择编程语言:
- [ ] Java
- [ ] Kotlin
等待用户确认后再继续。
注意
templates/
目录中的模板支持Java和Kotlin。根据用户的选择使用相应的模板。

Step 5: Create Todo List

步骤5:创建任务清单

CRITICAL: After collecting all information, create a detailed todo list.
For each table, generate a structured todo list:
markdown
undefined
重要提示:收集所有信息后,创建详细的任务清单。
为每个表生成结构化的任务清单:
markdown
undefined

Todo List: MyBatis-Plus Code Generation

任务清单:MyBatis-Plus代码生成

Table: user

表:user

Entity 层

Entity 层

  • User.java - 实体类
    • 类注释
    • 字段定义(id, username, email, password, status, createTime, updateTime)
    • 字段注释
  • User.java - 实体类
    • 类注释
    • 字段定义(id, username, email, password, status, createTime, updateTime)
    • 字段注释

Mapper 层

Mapper 层

  • UserMapper.java - 数据访问接口
    • 类注释
    • 基础 CRUD 方法(继承 BaseMapper)
  • UserMapper.java - 数据访问接口
    • 类注释
    • 基础 CRUD 方法(继承 BaseMapper)

Service 层

Service 层

  • UserService.java - 服务接口
    • 类注释
    • saveUser() - 保存用户
    • findById() - 根据ID查询
    • updateUser() - 更新用户
    • deleteById() - 删除用户
    • findByEmail() - 根据邮箱查询(自定义方法)
    • findByUsername() - 根据用户名查询(自定义方法)
  • UserService.java - 服务接口
    • 类注释
    • saveUser() - 保存用户
    • findById() - 根据ID查询
    • updateUser() - 更新用户
    • deleteById() - 删除用户
    • findByEmail() - 根据邮箱查询(自定义方法)
    • findByUsername() - 根据用户名查询(自定义方法)

ServiceImpl 层

ServiceImpl 层

  • UserServiceImpl.java - 服务实现类
    • 类注释
    • 实现所有 Service 接口方法
    • 方法注释和实现骨架
  • UserServiceImpl.java - 服务实现类
    • 类注释
    • 实现所有 Service 接口方法
    • 方法注释和实现骨架

Controller 层

Controller 层

  • UserController.java - 控制器
    • 类注释
    • createUser() - 创建用户
    • getUserById() - 查询用户
    • updateUser() - 更新用户
    • deleteUser() - 删除用户
    • getUserByEmail() - 根据邮箱查询(自定义接口)
  • UserController.java - 控制器
    • 类注释
    • createUser() - 创建用户
    • getUserById() - 查询用户
    • updateUser() - 更新用户
    • deleteUser() - 删除用户
    • getUserByEmail() - 根据邮箱查询(自定义接口)

DTO 层(如果架构需要)

DTO 层(如果架构需要)

  • UserCreateDTO.java - 创建用户DTO
  • UserUpdateDTO.java - 更新用户DTO
  • UserQueryDTO.java - 查询用户DTO
  • UserCreateDTO.java - 创建用户DTO
  • UserUpdateDTO.java - 更新用户DTO
  • UserQueryDTO.java - 查询用户DTO

VO 层(如果架构需要)

VO 层(如果架构需要)

  • UserVO.java - 用户视图对象
  • UserVO.java - 用户视图对象

Table: order

表:order

...

**Important**: 
- Organize by table
- List all objects that need to be generated
- Include all methods (standard + custom)
- Use checkboxes for tracking progress
...

**注意**:
- 按表组织
- 列出所有需要生成的对象
- 包含所有方法(标准+自定义)
- 使用复选框跟踪进度

Step 6: Generate Code

步骤6:生成代码

CRITICAL: Generate code files with intelligent comments based on table structure and requirements.
Order of generation:
  1. Entity - First (base for all other objects)
  2. Mapper - Second (data access layer)
  3. Service - Third (business interface)
  4. ServiceImpl - Fourth (business implementation)
  5. Controller - Fifth (API layer)
  6. DTO/VO/BO - Sixth (if needed by architecture)
For each object:
  1. Load appropriate template from
    templates/
    directory based on object type and language
  2. Analyze table structure: Read columns, types, constraints, primary keys, foreign keys, relationships
  3. Generate intelligent comments: Based on business context, not just technical names
    • Class comments: Explain purpose, list main fields
    • Method comments: Explain business logic, include all parameters and return types
    • Field comments: Explain business meaning, not just column names
  4. Generate code: Replace template variables, add annotations, generate method skeletons
  5. For custom methods: Generate signatures, add business logic comments, add TODO hints
  6. Determine output directory: Use architecture directory mapping (see Step 2)
  7. Save files to correct location based on architecture and package configuration
After generating each object:
  • Update the todo list: mark completed items with
    [x]
  • Show progress to the user
  • Continue to the next object
Code Generation Standards: See
reference/code-generation-standards.md
for detailed requirements on comments, templates, and code quality.
重要提示:根据表结构和需求生成带有智能注释的代码文件。
生成顺序:
  1. Entity - 首先生成(所有其他对象的基础)
  2. Mapper - 其次生成(数据访问层)
  3. Service - 第三生成(业务接口层)
  4. ServiceImpl - 第四生成(业务实现层)
  5. Controller - 第五生成(API层)
  6. DTO/VO/BO - 第六生成(如果架构需要)
针对每个对象:
  1. 加载合适的模板 - 根据对象类型和语言从
    templates/
    目录加载
  2. 分析表结构 - 读取列、类型、约束、主键、外键、关系
  3. 生成智能注释 - 基于业务上下文,而非仅技术名称
    • 类注释:说明用途,列出主要字段
    • 方法注释:说明业务逻辑,包含所有参数和返回类型
    • 字段注释:说明业务含义,而非仅列名
  4. 生成代码 - 替换模板变量,添加注解,生成方法骨架
  5. 针对自定义方法 - 生成签名,添加业务逻辑注释,添加TODO提示
  6. 确定输出目录 - 使用架构目录映射(见步骤2)
  7. 保存文件 - 根据架构和包配置保存到正确位置
生成每个对象后:
  • 更新任务清单:用
    [x]
    标记已完成的项
  • 向用户显示进度
  • 继续生成下一个对象
代码生成标准:查看
reference/code-generation-standards.md
获取关于注释、模板和代码质量的详细要求。

Step 7: Progress Updates

步骤7:进度更新

CRITICAL: Provide real-time progress updates during code generation.
Update progress after:
  • Each table starts processing
  • Each object is generated
  • Each method is added
  • Each table completes
Progress Format: See
reference/progress-and-statistics-formats.md
for detailed progress update format and examples.
重要提示:在代码生成过程中提供实时进度更新。
在以下节点更新进度:
  • 每个表开始处理时
  • 每个对象生成完成时
  • 每个方法添加完成时
  • 每个表处理完成时
进度格式:查看
reference/progress-and-statistics-formats.md
获取详细的进度更新格式和示例。

Step 8: Statistics

步骤8:统计信息

CRITICAL: After all code generation completes, output comprehensive statistics.
Statistics Format: See
reference/progress-and-statistics-formats.md
for detailed statistics format including:
  • Overall statistics (tables, objects, methods, files, lines)
  • Per-table statistics
  • Per-type statistics
  • File locations
  • Code quality checklist
重要提示:所有代码生成完成后,输出全面的统计数据。
统计格式:查看
reference/progress-and-statistics-formats.md
获取详细的统计格式,包括:
  • 总体统计数据(表数、对象数、方法数、文件数、代码行数)
  • 按表统计数据
  • 按类型统计数据
  • 文件位置
  • 代码质量检查清单

Code Generation Standards

代码生成标准

IMPORTANT: Generated code must include intelligent, context-aware comments, not just template placeholders.
Key Requirements:
  1. Class Comments: Explain purpose based on business context, include table mapping, list main fields
  2. Method Comments: Explain business logic, include all parameters with types, return value with type, exceptions
  3. Field Comments: Explain business meaning, include data type and constraints, not just column names
Detailed Standards: See
reference/code-generation-standards.md
for:
  • Complete comment format requirements
  • Template usage guidelines
  • Template variables reference
  • Swagger annotation selection
  • Custom method generation standards
  • Code quality requirements
重要提示:生成的代码必须包含智能、上下文相关的注释,而非仅模板占位符。
关键要求:
  1. 类注释:基于业务上下文说明用途,包含表映射信息,列出主要字段
  2. 方法注释:说明业务逻辑,包含所有参数及其类型、返回值及其类型、异常信息
  3. 字段注释:说明业务含义,包含数据类型和约束,而非仅列名
详细标准:查看
reference/code-generation-standards.md
获取:
  • 完整的注释格式要求
  • 模板使用指南
  • 模板变量参考
  • Swagger注解选择规则
  • 自定义方法生成标准
  • 代码质量要求

Best Practices

最佳实践

  1. Intelligent Comments: Generate comments based on table structure analysis and business requirements, not just template placeholders
  2. Context Awareness: Understand table relationships and business context to generate meaningful comments
  3. Method Analysis: Analyze user requirements to determine what methods are needed
  4. Progress Tracking: Always update todo list and show progress
  5. Code Quality: Generate production-ready code with proper annotations and validation
  6. Template Enhancement: Use templates as base, but enhance with intelligent additions
  7. Language Support: Support both Java and Kotlin with appropriate templates
  1. 智能注释:基于表结构分析和业务需求生成注释,而非仅模板占位符
  2. 上下文感知:理解表关系和业务上下文,生成有意义的注释
  3. 方法分析:分析用户需求以确定需要哪些方法
  4. 进度跟踪:始终更新任务清单并显示进度
  5. 代码质量:生成可用于生产环境的代码,包含适当的注解和验证
  6. 模板增强:以模板为基础,添加智能扩展内容
  7. 语言支持:使用相应模板支持Java和Kotlin

Reference Documentation

参考文档

CRITICAL: Use these reference documents for detailed guidance:
重要提示:使用以下参考文档获取详细指导:

Architecture & Directory Mapping

架构与目录映射

  • reference/architecture-directory-mapping-guide.md
    - Complete directory mapping guide for all architectures (CRITICAL)
  • reference/architecture-directory-quick-reference.md
    - Quick lookup table for directory mappings
  • reference/architecture-directory-mapping-guide.md
    - 所有架构的完整目录映射指南(关键文档)
  • reference/architecture-directory-quick-reference.md
    - 目录映射快速查询表

Code Generation Standards

代码生成标准

  • reference/code-generation-standards.md
    - Detailed comment standards, template usage, and code quality requirements
  • reference/template-variables.md
    - Complete list of template variables
  • reference/swagger-annotations-guide.md
    - Swagger 2 vs OpenAPI 3 annotation comparison
  • reference/code-generation-standards.md
    - 详细的注释标准、模板使用和代码质量要求
  • reference/template-variables.md
    - 完整的模板变量列表
  • reference/swagger-annotations-guide.md
    - Swagger 2与OpenAPI 3注解对比

Progress & Statistics

进度与统计

  • reference/progress-and-statistics-formats.md
    - Progress update and statistics output formats
  • reference/progress-and-statistics-formats.md
    - 进度更新和统计数据输出格式

MyBatis-Plus Reference

MyBatis-Plus参考

  • reference/mybatis-plus-generator-guide.md
    - MyBatis-Plus Generator usage guide
  • reference/mybatis-plus-generator-guide.md
    - MyBatis-Plus Generator使用指南

Examples

示例

See the
examples/
directory for complete examples:
  • examples/mvc-architecture-example.md
    - MVC architecture generation example
  • examples/ddd-architecture-example.md
    - DDD architecture generation example
  • examples/full-workflow-example.md
    - Complete workflow example
  • examples/architecture-directory-mapping.md
    - Directory mapping examples for different architectures
  • examples/swagger-annotations-example.md
    - Swagger 2 vs OpenAPI 3 annotation examples
查看
examples/
目录获取完整示例:
  • examples/mvc-architecture-example.md
    - MVC架构生成示例
  • examples/ddd-architecture-example.md
    - DDD架构生成示例
  • examples/full-workflow-example.md
    - 完整工作流程示例
  • examples/architecture-directory-mapping.md
    - 不同架构的目录映射示例
  • examples/swagger-annotations-example.md
    - Swagger 2与OpenAPI 3注解示例

Templates

模板

Templates are located in
templates/
directory, using FreeMarker syntax (
.ftl
files), strictly following MyBatis-Plus official templates.
模板位于
templates/
目录,使用 FreeMarker 语法(
.ftl
文件),严格遵循 MyBatis-Plus官方模板

Standard Templates (MVC Architecture)

标准模板(MVC架构)

Java Templates:
  • entity.java.ftl
    - Entity class template
  • mapper.java.ftl
    - Mapper interface template
  • service.java.ftl
    - Service interface template
  • serviceImpl.java.ftl
    - Service implementation template
  • controller.java.ftl
    - Controller template
  • dto.java.ftl
    - DTO template
  • vo.java.ftl
    - VO template
  • bo.java.ftl
    - BO template
Kotlin Templates:
  • entity.kt.ftl
    - Entity data class template
  • mapper.kt.ftl
    - Mapper interface template
  • service.kt.ftl
    - Service interface template
  • serviceImpl.kt.ftl
    - Service implementation template
  • controller.kt.ftl
    - Controller template
  • dto.kt.ftl
    - DTO template
  • vo.kt.ftl
    - VO template
  • bo.kt.ftl
    - BO template
Java模板:
  • entity.java.ftl
    - 实体类模板
  • mapper.java.ftl
    - Mapper接口模板
  • service.java.ftl
    - Service接口模板
  • serviceImpl.java.ftl
    - Service实现类模板
  • controller.java.ftl
    - Controller模板
  • dto.java.ftl
    - DTO模板
  • vo.java.ftl
    - VO模板
  • bo.java.ftl
    - BO模板
Kotlin模板:
  • entity.kt.ftl
    - 实体数据类模板
  • mapper.kt.ftl
    - Mapper接口模板
  • service.kt.ftl
    - Service接口模板
  • serviceImpl.kt.ftl
    - Service实现类模板
  • controller.kt.ftl
    - Controller模板
  • dto.kt.ftl
    - DTO模板
  • vo.kt.ftl
    - VO模板
  • bo.kt.ftl
    - BO模板

DDD Architecture Templates

DDD架构模板

All DDD templates are located in
templates/
root directory, supporting both Java and Kotlin:
Domain Layer:
  • aggregate-root.java.ftl
    /
    aggregate-root.kt.ftl
    - Aggregate root template
  • repository.java.ftl
    /
    repository.kt.ftl
    - Repository interface template (domain layer)
  • domain-service.java.ftl
    /
    domain-service.kt.ftl
    - Domain service template
  • value-object.java.ftl
    /
    value-object.kt.ftl
    - Value object template
  • domain-event.java.ftl
    /
    domain-event.kt.ftl
    - Domain event template
Application Layer:
  • application-service.java.ftl
    /
    application-service.kt.ftl
    - Application service template
Interface Layer:
  • assembler.java.ftl
    /
    assembler.kt.ftl
    - DTO assembler template
Template Features:
  • Support for Swagger 2 and OpenAPI 3 annotations
  • Intelligent comments based on table structure
  • Custom method generation support
  • Kotlin-specific features (data classes, null safety, etc.)
  • DDD-specific patterns (aggregate root, value objects, domain events)
  • FreeMarker syntax for template engine
Reference: See MyBatis-Plus official templates at:
所有DDD模板位于
templates/
根目录,支持Java和Kotlin:
领域层:
  • aggregate-root.java.ftl
    /
    aggregate-root.kt.ftl
    - 聚合根模板
  • repository.java.ftl
    /
    repository.kt.ftl
    - Repository接口模板(领域层)
  • domain-service.java.ftl
    /
    domain-service.kt.ftl
    - 领域服务模板
  • value-object.java.ftl
    /
    value-object.kt.ftl
    - 值对象模板
  • domain-event.java.ftl
    /
    domain-event.kt.ftl
    - 领域事件模板
应用层:
  • application-service.java.ftl
    /
    application-service.kt.ftl
    - 应用服务模板
接口层:
  • assembler.java.ftl
    /
    assembler.kt.ftl
    - DTO转换器模板
模板特性:
  • 支持Swagger 2和OpenAPI 3注解
  • 基于表结构的智能注释
  • 支持自定义方法生成
  • Kotlin特定特性(数据类、空安全等)
  • DDD特定模式(聚合根、值对象、领域事件)
  • FreeMarker模板引擎语法
参考:查看MyBatis-Plus官方模板:

Keywords

关键词

English keywords: mybatis-plus, mybatis-plus-generator, mybatis-plus code generator, mybatis-plus code generation, generate mybatis-plus code, mybatis-plus entity generator, mybatis-plus mapper generator, mybatis-plus service generator, mybatis-plus controller generator, mybatis-plus crud generation, mybatis-plus from table, mybatis-plus code from database
Chinese keywords (中文关键词): MyBatis-Plus, mybatis-plus-generator, MyBatis-Plus 代码生成器, MyBatis-Plus 代码生成, 生成 MyBatis-Plus 代码, MyBatis-Plus 实体类生成, MyBatis-Plus Mapper 生成, MyBatis-Plus Service 生成, MyBatis-Plus Controller 生成, MyBatis-Plus CRUD 生成, MyBatis-Plus 根据表生成代码, MyBatis-Plus 数据库转代码, MyBatis-Plus 表转 Java, 使用 MyBatis-Plus 生成代码
IMPORTANT: All keywords must include "MyBatis-Plus" or "mybatis-plus" to avoid false triggers. Generic terms like "代码生成器" (code generator) or "根据表生成代码" (generate code from table) without "MyBatis-Plus" should NOT trigger this skill.
英文关键词: mybatis-plus, mybatis-plus-generator, mybatis-plus code generator, mybatis-plus code generation, generate mybatis-plus code, mybatis-plus entity generator, mybatis-plus mapper generator, mybatis-plus service generator, mybatis-plus controller generator, mybatis-plus crud generation, mybatis-plus from table, mybatis-plus code from database
中文关键词: MyBatis-Plus, mybatis-plus-generator, MyBatis-Plus 代码生成器, MyBatis-Plus 代码生成, 生成 MyBatis-Plus 代码, MyBatis-Plus 实体类生成, MyBatis-Plus Mapper 生成, MyBatis-Plus Service 生成, MyBatis-Plus Controller 生成, MyBatis-Plus CRUD 生成, MyBatis-Plus 根据表生成代码, MyBatis-Plus 数据库转代码, MyBatis-Plus 表转 Java, 使用 MyBatis-Plus 生成代码
重要提示:所有关键词必须包含"MyBatis-Plus"或"mybatis-plus",以避免误触发。不包含"MyBatis-Plus"的通用术语,如"代码生成器"或"根据表生成代码",不应触发此技能。