mybatis-plus-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWhen 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:
- Collect Configuration - Collect database information, global configuration, package configuration, strategy configuration
- Determine Architecture - Ask user about architecture type (MVC, DDD, etc.) to determine which objects to generate
- Collect Requirements - Ask user for functional requirements to analyze and determine methods to generate
- Determine Language - Ask user about programming language (Java or Kotlin)
- Create Todo List - Generate a detailed todo list with table names, object types, and method names
- Generate Code - Generate code files with intelligent comments based on table structure and requirements
- Progress Updates - Provide real-time progress updates during code generation
- Statistics - Output statistics after generation completes
此技能遵循系统化的8步工作流程:
- 收集配置信息 - 收集数据库信息、全局配置、包配置、策略配置
- 确定架构类型 - 询问用户架构类型(MVC、DDD等)以确定需要生成的对象
- 收集需求 - 询问用户功能需求,分析并确定需要生成的方法
- 确定开发语言 - 询问用户编程语言(Java或Kotlin)
- 创建任务清单 - 生成包含表名、对象类型和方法名的详细任务清单
- 生成代码 - 根据表结构和需求生成带有智能注释的代码文件
- 进度更新 - 在代码生成过程中提供实时进度更新
- 统计信息 - 生成完成后输出统计数据
Step-by-Step Process
分步流程
Step 1: Collect Configuration
步骤1:收集配置信息
CRITICAL: Before generating any code, you MUST collect the following configuration:
-
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)
-
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.*
- Swagger 2 (使用
- Enable validation annotations (yes/no)
-
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
- Parent package name (e.g.,
-
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.
重要提示:在生成任何代码之前,必须收集以下配置信息:
-
数据库信息:
- 数据库类型(MySQL、PostgreSQL、Oracle等)
- 数据库连接URL(或请用户提供表结构)
- 数据库名称
- 表名(单个或多个表)
- 如果用户无法提供数据库连接,请询问表结构(CREATE TABLE语句或表结构定义)
-
全局配置:
- 作者名称
- 输出目录(默认:)
src/main/java - 文件覆盖策略(覆盖、跳过、询问)
- 是否启用Lombok(是/否)
- 是否启用API文档(是/否)
- API文档类型(如果启用):
- Swagger 2(使用 )
io.swagger.annotations.* - OpenAPI 3(使用 )
io.swagger.v3.oas.annotations.*
- Swagger 2(使用
- 是否启用验证注解(是/否)
-
包配置:
- 父包名(例如:)
com.example.app - Entity包(默认:)
entity - Mapper包(默认:)
mapper - Service包(默认:)
service - ServiceImpl包(默认:)
service.impl - Controller包(默认:)
controller - DTO包(默认:)
dto - VO包(默认:)
vo - BO包(默认:)
bo
- 父包名(例如:
-
策略配置:
- 命名策略(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:
- Ask user for base package path (e.g., )
com.example.order - Use architecture directory mapping to determine correct paths:
- Quick Reference: See for lookup table
reference/architecture-directory-quick-reference.md - Detailed Guide: See for complete mapping rules
reference/architecture-directory-mapping-guide.md
- Quick Reference: See
- Verify directory exists or create it if needed
- Generate files in the correct location
Common Path Examples:
For table with base package :
usercom.example.order- MVC: Entity → , Controller →
com/example/order/entity/User.javacom/example/order/controller/UserController.java - DDD: Entity → , Controller →
com/example/order/domain/model/aggregate/user/User.javacom/example/order/interfaces/web/controller/UserController.java - Hexagonal: Entity → , Controller →
com/example/order/domain/model/entity/User.javacom/example/order/infrastructure/adapter/inbound/web/controller/UserController.java - Clean: Entity → , Controller →
com/example/order/domain/entity/User.javacom/example/order/infrastructure/web/controller/UserController.java - COLA: Entity → , Controller →
com/example/order/domain/model/entity/User.javacom/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
- [ ] 自定义架构
- 请指定需要生成的对象类型等待用户确认后再继续。
重要提示:基于架构的目录映射
确定架构类型后,必须为每个生成的对象确定正确的输出目录。
关键步骤:
- 询问用户基础包路径(例如:)
com.example.order - 使用架构目录映射确定正确路径:
- 快速参考:查看 获取对照表
reference/architecture-directory-quick-reference.md - 详细指南:查看 获取完整映射规则
reference/architecture-directory-mapping-guide.md
- 快速参考:查看
- 验证目录是否存在,如果需要则创建
- 在正确位置生成文件
常见路径示例:
对于基础包为 的 表:
com.example.orderuser- MVC:Entity → , Controller →
com/example/order/entity/User.javacom/example/order/controller/UserController.java - DDD:Entity → , Controller →
com/example/order/domain/model/aggregate/user/User.javacom/example/order/interfaces/web/controller/UserController.java - 六边形架构:Entity → , Controller →
com/example/order/domain/model/entity/User.javacom/example/order/infrastructure/adapter/inbound/web/controller/UserController.java - 整洁架构:Entity → , Controller →
com/example/order/domain/entity/User.javacom/example/order/infrastructure/web/controller/UserController.java - COLA架构:Entity → , Controller →
com/example/order/domain/model/entity/User.javacom/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:
-
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.)
-
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)
重要提示:询问用户功能需求,以了解需要生成哪些方法。
询问用户:
请描述此次生成代码的功能需求:
例如:
- 用户管理:需要根据邮箱查询用户、根据用户名查询用户、用户登录验证
- 订单管理:需要订单统计、订单分页查询、订单状态更新
- 商品管理:需要商品搜索、商品分类查询、库存管理
请详细描述每个表需要哪些功能,我会根据需求自动分析需要生成的方法。用户提供需求后:
-
分析需求以确定:
- 标准CRUD方法(创建、读取、更新、删除)
- 自定义查询方法(findByEmail、findByUsername等)
- 自定义业务方法(统计、聚合等)
- 自定义更新方法(updateStatus、updatePassword等)
-
针对每个表,确定:
- 需要的标准方法
- 根据需求需要的自定义方法
- 方法参数和返回类型
- 业务逻辑提示(用于方法骨架)
输出结果:需求分析报告,包含:
- 每个表的标准方法
- 每个表的自定义方法
- 方法签名(参数和返回类型)
Step 4: Determine Language
步骤4:确定开发语言
CRITICAL: Ask user about programming language.
请选择编程语言:
- [ ] Java
- [ ] KotlinWait for user confirmation before proceeding.
Note: Templates in directory support both Java and Kotlin. Use appropriate templates based on user's choice.
templates/重要提示:询问用户编程语言。
请选择编程语言:
- [ ] Java
- [ ] Kotlin等待用户确认后再继续。
注意: 目录中的模板支持Java和Kotlin。根据用户的选择使用相应的模板。
templates/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
undefinedTodo 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:
- Entity - First (base for all other objects)
- Mapper - Second (data access layer)
- Service - Third (business interface)
- ServiceImpl - Fourth (business implementation)
- Controller - Fifth (API layer)
- DTO/VO/BO - Sixth (if needed by architecture)
For each object:
- Load appropriate template from directory based on object type and language
templates/ - Analyze table structure: Read columns, types, constraints, primary keys, foreign keys, relationships
- 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
- Generate code: Replace template variables, add annotations, generate method skeletons
- For custom methods: Generate signatures, add business logic comments, add TODO hints
- Determine output directory: Use architecture directory mapping (see Step 2)
- 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 for detailed requirements on comments, templates, and code quality.
reference/code-generation-standards.md重要提示:根据表结构和需求生成带有智能注释的代码文件。
生成顺序:
- Entity - 首先生成(所有其他对象的基础)
- Mapper - 其次生成(数据访问层)
- Service - 第三生成(业务接口层)
- ServiceImpl - 第四生成(业务实现层)
- Controller - 第五生成(API层)
- DTO/VO/BO - 第六生成(如果架构需要)
针对每个对象:
- 加载合适的模板 - 根据对象类型和语言从 目录加载
templates/ - 分析表结构 - 读取列、类型、约束、主键、外键、关系
- 生成智能注释 - 基于业务上下文,而非仅技术名称
- 类注释:说明用途,列出主要字段
- 方法注释:说明业务逻辑,包含所有参数和返回类型
- 字段注释:说明业务含义,而非仅列名
- 生成代码 - 替换模板变量,添加注解,生成方法骨架
- 针对自定义方法 - 生成签名,添加业务逻辑注释,添加TODO提示
- 确定输出目录 - 使用架构目录映射(见步骤2)
- 保存文件 - 根据架构和包配置保存到正确位置
生成每个对象后:
- 更新任务清单:用 标记已完成的项
[x] - 向用户显示进度
- 继续生成下一个对象
代码生成标准:查看 获取关于注释、模板和代码质量的详细要求。
reference/code-generation-standards.mdStep 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 for detailed progress update format and examples.
reference/progress-and-statistics-formats.md重要提示:在代码生成过程中提供实时进度更新。
在以下节点更新进度:
- 每个表开始处理时
- 每个对象生成完成时
- 每个方法添加完成时
- 每个表处理完成时
进度格式:查看 获取详细的进度更新格式和示例。
reference/progress-and-statistics-formats.mdStep 8: Statistics
步骤8:统计信息
CRITICAL: After all code generation completes, output comprehensive statistics.
Statistics Format: See for detailed statistics format including:
reference/progress-and-statistics-formats.md- 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:
- Class Comments: Explain purpose based on business context, include table mapping, list main fields
- Method Comments: Explain business logic, include all parameters with types, return value with type, exceptions
- Field Comments: Explain business meaning, include data type and constraints, not just column names
Detailed Standards: See for:
reference/code-generation-standards.md- Complete comment format requirements
- Template usage guidelines
- Template variables reference
- Swagger annotation selection
- Custom method generation standards
- Code quality requirements
重要提示:生成的代码必须包含智能、上下文相关的注释,而非仅模板占位符。
关键要求:
- 类注释:基于业务上下文说明用途,包含表映射信息,列出主要字段
- 方法注释:说明业务逻辑,包含所有参数及其类型、返回值及其类型、异常信息
- 字段注释:说明业务含义,包含数据类型和约束,而非仅列名
详细标准:查看 获取:
reference/code-generation-standards.md- 完整的注释格式要求
- 模板使用指南
- 模板变量参考
- Swagger注解选择规则
- 自定义方法生成标准
- 代码质量要求
Best Practices
最佳实践
- Intelligent Comments: Generate comments based on table structure analysis and business requirements, not just template placeholders
- Context Awareness: Understand table relationships and business context to generate meaningful comments
- Method Analysis: Analyze user requirements to determine what methods are needed
- Progress Tracking: Always update todo list and show progress
- Code Quality: Generate production-ready code with proper annotations and validation
- Template Enhancement: Use templates as base, but enhance with intelligent additions
- Language Support: Support both Java and Kotlin with appropriate templates
- 智能注释:基于表结构分析和业务需求生成注释,而非仅模板占位符
- 上下文感知:理解表关系和业务上下文,生成有意义的注释
- 方法分析:分析用户需求以确定需要哪些方法
- 进度跟踪:始终更新任务清单并显示进度
- 代码质量:生成可用于生产环境的代码,包含适当的注解和验证
- 模板增强:以模板为基础,添加智能扩展内容
- 语言支持:使用相应模板支持Java和Kotlin
Reference Documentation
参考文档
CRITICAL: Use these reference documents for detailed guidance:
重要提示:使用以下参考文档获取详细指导:
Architecture & Directory Mapping
架构与目录映射
- - Complete directory mapping guide for all architectures (CRITICAL)
reference/architecture-directory-mapping-guide.md - - Quick lookup table for directory mappings
reference/architecture-directory-quick-reference.md
- - 所有架构的完整目录映射指南(关键文档)
reference/architecture-directory-mapping-guide.md - - 目录映射快速查询表
reference/architecture-directory-quick-reference.md
Code Generation Standards
代码生成标准
- - Detailed comment standards, template usage, and code quality requirements
reference/code-generation-standards.md - - Complete list of template variables
reference/template-variables.md - - Swagger 2 vs OpenAPI 3 annotation comparison
reference/swagger-annotations-guide.md
- - 详细的注释标准、模板使用和代码质量要求
reference/code-generation-standards.md - - 完整的模板变量列表
reference/template-variables.md - - Swagger 2与OpenAPI 3注解对比
reference/swagger-annotations-guide.md
Progress & Statistics
进度与统计
- - Progress update and statistics output formats
reference/progress-and-statistics-formats.md
- - 进度更新和统计数据输出格式
reference/progress-and-statistics-formats.md
MyBatis-Plus Reference
MyBatis-Plus参考
- - MyBatis-Plus Generator usage guide
reference/mybatis-plus-generator-guide.md
- - MyBatis-Plus Generator使用指南
reference/mybatis-plus-generator-guide.md
Examples
示例
See the directory for complete examples:
examples/- - MVC architecture generation example
examples/mvc-architecture-example.md - - DDD architecture generation example
examples/ddd-architecture-example.md - - Complete workflow example
examples/full-workflow-example.md - - Directory mapping examples for different architectures
examples/architecture-directory-mapping.md - - Swagger 2 vs OpenAPI 3 annotation examples
examples/swagger-annotations-example.md
查看 目录获取完整示例:
examples/- - MVC架构生成示例
examples/mvc-architecture-example.md - - DDD架构生成示例
examples/ddd-architecture-example.md - - 完整工作流程示例
examples/full-workflow-example.md - - 不同架构的目录映射示例
examples/architecture-directory-mapping.md - - Swagger 2与OpenAPI 3注解示例
examples/swagger-annotations-example.md
Templates
模板
Templates are located in directory, using FreeMarker syntax ( files), strictly following MyBatis-Plus official templates.
templates/.ftlStandard Templates (MVC Architecture)
标准模板(MVC架构)
Java Templates:
- - Entity class template
entity.java.ftl - - Mapper interface template
mapper.java.ftl - - Service interface template
service.java.ftl - - Service implementation template
serviceImpl.java.ftl - - Controller template
controller.java.ftl - - DTO template
dto.java.ftl - - VO template
vo.java.ftl - - BO template
bo.java.ftl
Kotlin Templates:
- - Entity data class template
entity.kt.ftl - - Mapper interface template
mapper.kt.ftl - - Service interface template
service.kt.ftl - - Service implementation template
serviceImpl.kt.ftl - - Controller template
controller.kt.ftl - - DTO template
dto.kt.ftl - - VO template
vo.kt.ftl - - BO template
bo.kt.ftl
Java模板:
- - 实体类模板
entity.java.ftl - - Mapper接口模板
mapper.java.ftl - - Service接口模板
service.java.ftl - - Service实现类模板
serviceImpl.java.ftl - - Controller模板
controller.java.ftl - - DTO模板
dto.java.ftl - - VO模板
vo.java.ftl - - BO模板
bo.java.ftl
Kotlin模板:
- - 实体数据类模板
entity.kt.ftl - - Mapper接口模板
mapper.kt.ftl - - Service接口模板
service.kt.ftl - - Service实现类模板
serviceImpl.kt.ftl - - Controller模板
controller.kt.ftl - - DTO模板
dto.kt.ftl - - VO模板
vo.kt.ftl - - BO模板
bo.kt.ftl
DDD Architecture Templates
DDD架构模板
All DDD templates are located in root directory, supporting both Java and Kotlin:
templates/Domain Layer:
- /
aggregate-root.java.ftl- Aggregate root templateaggregate-root.kt.ftl - /
repository.java.ftl- Repository interface template (domain layer)repository.kt.ftl - /
domain-service.java.ftl- Domain service templatedomain-service.kt.ftl - /
value-object.java.ftl- Value object templatevalue-object.kt.ftl - /
domain-event.java.ftl- Domain event templatedomain-event.kt.ftl
Application Layer:
- /
application-service.java.ftl- Application service templateapplication-service.kt.ftl
Interface Layer:
- /
assembler.java.ftl- DTO assembler templateassembler.kt.ftl
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模板位于 根目录,支持Java和Kotlin:
templates/领域层:
- /
aggregate-root.java.ftl- 聚合根模板aggregate-root.kt.ftl - /
repository.java.ftl- Repository接口模板(领域层)repository.kt.ftl - /
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- DTO转换器模板assembler.kt.ftl
模板特性:
- 支持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"的通用术语,如"代码生成器"或"根据表生成代码",不应触发此技能。