Skip to content

feat: Add model API #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open

feat: Add model API #249

wants to merge 20 commits into from

Conversation

lu-yg
Copy link
Collaborator

@lu-yg lu-yg commented Jul 23, 2025

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Full CRUD for "Model" entities: create, update, delete, detail, and paginated/filtered listing with API docs and standardized responses.
  • Database

    • Added new "Model" table to store model metadata (names, version, URL, parameters, methods, description, audit/tenant/site fields) with a unique index; removed a deprecated component-library column; fixed tenant insert syntax.
  • Other

    • Added supporting DTOs, enums, mappers, service and controller layers for model management and API modeling.

Copy link

coderabbitai bot commented Jul 23, 2025

Walkthrough

Adds a new Model domain: SQL DDL scripts (MySQL/H2/Docker) to create t_model, Java entity and DTOs, enums, MyBatis mapper (interface + XML), service interface and implementation, REST controller, and a minor SQL mapper syntax fix.

Changes

Cohort / File(s) Change Summary
SQL — create model tables
app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql, app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql, docker-deploy-data/mysql/init/create_model_ddl_2025_0717.sql
Added DDL to drop-if-exists and create t_model with columns (id, name_cn/name or name, name_en, version, model_url, parameters, method, description, audit fields, tenant/renter/site fields), per-column comments, PK on id, unique index on (name/name_cn, version), engine/table comments.
SQL — updates
app/src/main/resources/sql/h2/update_all_tables_ddl.sql
Removed previously added app_id ALTER TABLE statement for t_component_library.
Java — enums
base/src/main/java/com/tinyengine/it/common/enums/Enums.java
Added enums methodName, paramType, and methodParam with string values and getters.
Controller
base/src/main/java/com/tinyengine/it/controller/ModelController.java
New REST controller exposing endpoints for list (paginated), find, create, update, delete, and detail for Model; includes validation, logging annotations, and API docs.
Mapper interface
base/src/main/java/com/tinyengine/it/mapper/ModelMapper.java
New ModelMapper extending BaseMapper<Model> with createModel(Model) and updateModelById(Model) declared.
MyBatis XML mapper
base/src/main/resources/mappers/ModelMapper.xml
New mapper XML: ResultMap, Base_Column_List, dynamic condition/update fragments, and SQL for select/insert/update/delete against t_model.
DTOs
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java, .../ParametersDto.java, .../RequestParameter.java, .../ResponseParameter.java
Added DTO classes modeling method metadata and nested parameter structures (Lombok @Data).
Entity
base/src/main/java/com/tinyengine/it/model/entity/Model.java
New Model entity mapped to t_model with fields nameCn/nameEn/version/modelUrl/parameters/method/description; list fields use ListTypeHandler.
Service interface
base/src/main/java/com/tinyengine/it/service/material/ModelService.java
Added ModelService interface declaring CRUD and paginated query methods.
Service implementation
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java
New ModelServiceImpl implementing CRUD and paginated queries; constructs method metadata DTOs, validates inputs, throws ServiceException on DB anomalies, delegates to mapper.
Mapper fix
base/src/main/resources/mappers/TenantMapper.xml
Fixed missing closing parenthesis in createTenant insert VALUES clause.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Controller as ModelController
    participant Service as ModelServiceImpl
    participant Mapper as ModelMapper
    participant DB

    Client->>Controller: HTTP (Create/Update/Delete/Get/List/Find)
    Controller->>Service: validate & forward request
    Service->>Mapper: execute SQL (insert/update/delete/select)
    Mapper->>DB: run query against t_model
    DB-->>Mapper: results
    Mapper-->>Service: mapped Model(s)
    Service-->>Controller: result / Page / list / status
    Controller-->>Client: Result wrapper response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I dug a little table neat and bright,
Columns, DTOs, mappers stitched just right.
Controllers call, services weave the lore,
SQL hums beneath the door.
A carrot for the new model's flight.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b1230c and b78d2f2.

📒 Files selected for processing (1)
  • app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🧹 Nitpick comments (12)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)

22-26: LGTM! Simple and well-structured DTO.

The implementation follows established patterns and integrates well with the related DTOs (RequestParameter, ParametersDto, MethodDto). Consider adding validation annotations (e.g., @NotNull, @NotBlank) if these fields have business constraints.

base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)

22-29: LGTM! Comprehensive parameter DTO with good field selection.

The class effectively models parameter metadata with appropriate field types. The use of primitive boolean for required is acceptable since it defaults to false, but consider Boolean wrapper if you need to distinguish between unset and false values.

base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)

20-20: Fix the documentation comment.

The comment incorrectly refers to "responseParameter dto" when this is actually the RequestParameter class.

- * The type responseParameter dto.
+ * The type RequestParameter dto.
base/src/main/java/com/tinyengine/it/service/material/ModelService.java (3)

46-48: Fix Javadoc parameter syntax.

The Javadoc parameter documentation uses incorrect syntax with spaces.

-     * @ param the model
+     * @param model the model

54-56: Fix Javadoc parameter syntax.

The Javadoc parameter documentation uses incorrect syntax with spaces.

-     * @ param the id
+     * @param id the id

62-64: Fix Javadoc parameter syntax.

The Javadoc parameter documentation uses incorrect syntax with spaces.

-     * @ param the model
+     * @param model the model
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (3)

1007-1043: Consider Java naming conventions for enum names.

The enum methodName should follow Java naming conventions and be named MethodName. However, I notice this is consistent with some existing enums in the file like paramType and methodParam.

For better adherence to Java conventions, consider:

-    public enum methodName {
+    public enum MethodName {

1045-1081: Consider Java naming conventions for enum names.

Same naming convention issue as with methodName.

-    public enum paramType {
+    public enum ParamType {

1083-1149: Consider Java naming conventions for enum names.

Same naming convention issue as with the other new enums.

-    public enum methodParam {
+    public enum MethodParam {
base/src/main/resources/mappers/ModelMapper.xml (1)

24-32: Use parameterized LIKE queries for text search fields

The current conditions use exact equality checks for text fields like parameters, method, and description. These should typically use LIKE queries for better search functionality.

-        <if test="parameters!=null and parameters!=''">
-            AND parameters = #{parameters}
-        </if>
-        <if test="method!=null and method!=''">
-            AND `method` = #{method}
-        </if>
-        <if test="description!=null and description!=''">
-            AND description = #{description}
-        </if>
+        <if test="parameters!=null and parameters!=''">
+            AND parameters LIKE CONCAT('%', #{parameters}, '%')
+        </if>
+        <if test="method!=null and method!=''">
+            AND `method` LIKE CONCAT('%', #{method}, '%')
+        </if>
+        <if test="description!=null and description!=''">
+            AND description LIKE CONCAT('%', #{description}, '%')
+        </if>
base/src/main/java/com/tinyengine/it/controller/ModelController.java (1)

129-129: Fix incorrect parameter descriptions

The parameter descriptions incorrectly refer to "appId" instead of "id" or "modelId".

-        @Parameter(name = "id", description = "appId"),
+        @Parameter(name = "id", description = "Model ID"),

And in line 171:

-        @Parameter(name = "id", description = "appId")
+        @Parameter(name = "id", description = "Model ID")

Also applies to: 171-171

base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)

70-90: Simplify query logic for name filters

The current implementation has complex conditional logic for OR queries that could be simplified.

 public Page<Model> pageQuery(int currentPage, int pageSize, String nameCn, String nameEn) {
     Page<Model> page = new Page<>(currentPage, pageSize);
     QueryWrapper<Model> queryWrapper = new QueryWrapper<>();
 
-    // 判断 nameCn 是否存在
-    if (nameCn != null && !nameCn.isEmpty()) {
-        queryWrapper.like("name_cn", nameCn);
-    }
-
-    // 判断 nameEn 是否存在
-    if (nameEn != null && !nameEn.isEmpty()) {
-        if (nameCn != null && !nameCn.isEmpty()) {
-            queryWrapper.or().like("name_en", nameEn);
-        } else {
-            queryWrapper.like("name_en", nameEn);
-        }
-    }
+    if (nameCn != null && !nameCn.isEmpty() && nameEn != null && !nameEn.isEmpty()) {
+        queryWrapper.and(wrapper -> wrapper
+            .like("name_cn", nameCn)
+            .or()
+            .like("name_en", nameEn));
+    } else if (nameCn != null && !nameCn.isEmpty()) {
+        queryWrapper.like("name_cn", nameCn);
+    } else if (nameEn != null && !nameEn.isEmpty()) {
+        queryWrapper.like("name_en", nameEn);
+    }
 
     page(page, queryWrapper);
     return page;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24cfb66 and 216177b.

📒 Files selected for processing (16)
  • app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql (1 hunks)
  • app/src/main/resources/sql/h2/update_all_tables_ddl.sql (0 hunks)
  • app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql (1 hunks)
  • base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/controller/ModelController.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/mapper/ModelMapper.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/model/entity/Model.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/material/ModelService.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1 hunks)
  • base/src/main/resources/mappers/ModelMapper.xml (1 hunks)
  • base/src/main/resources/mappers/TenantMapper.xml (1 hunks)
  • docker-deploy-data/mysql/init/create_model_ddl_2025_0717.sql (1 hunks)
🧬 Code Graph Analysis (5)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (3)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)
  • Data (22-29)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)
  • Data (22-26)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (3)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)
  • Data (22-29)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)
  • Data (22-26)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (3)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)
  • Data (22-29)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (3)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)
  • Data (22-26)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-1150)
💤 Files with no reviewable changes (1)
  • app/src/main/resources/sql/h2/update_all_tables_ddl.sql
🧰 Additional context used
🧬 Code Graph Analysis (5)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (3)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)
  • Data (22-29)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)
  • Data (22-26)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (3)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)
  • Data (22-29)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)
  • Data (22-26)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (3)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)
  • Data (22-29)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (3)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)
  • Data (22-26)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-1150)
🔇 Additional comments (9)
base/src/main/resources/mappers/TenantMapper.xml (1)

145-145: LGTM! Critical SQL syntax fix.

The missing closing parenthesis would have caused SQL execution failures. This fix properly matches the opening parenthesis in the INSERT statement.

base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)

24-29: LGTM! Well-designed hierarchical parameter structure.

The class effectively models request parameters with support for nested children through List<ParametersDto>. This design enables complex API parameter modeling while maintaining clean separation of concerns.

base/src/main/java/com/tinyengine/it/mapper/ModelMapper.java (1)

23-40: LGTM! Well-designed mapper interface following MyBatis-Plus patterns.

The interface properly extends BaseMapper<Model> and adds domain-specific methods with appropriate signatures. The Chinese documentation is comprehensive and follows the project's documentation standards. The int return type correctly indicates affected row counts for the persistence operations.

base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)

24-29: LGTM! Clean DTO implementation.

The DTO follows standard patterns with appropriate field types and Lombok integration. The structure aligns well with the referenced RequestParameter and ResponseParameter DTOs from the relevant code snippets.

base/src/main/java/com/tinyengine/it/service/material/ModelService.java (1)

21-66: Well-designed service interface.

The interface follows standard patterns with appropriate CRUD methods and extends MyBatis-Plus IService correctly. Method signatures and return types are consistent and appropriate for model management operations.

base/src/main/java/com/tinyengine/it/model/entity/Model.java (1)

33-58: Well-designed entity class.

The entity follows best practices:

  • Proper MyBatis-Plus annotations with custom type handlers for complex fields
  • Comprehensive Swagger documentation for API generation
  • Appropriate use of Lombok for boilerplate reduction
  • Clean field naming and types that align with the database schema
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)

1007-1149: Well-structured enums for model API support.

The three new enums provide good constants for the model API feature:

  • methodName: Defines CRUD operations with Chinese descriptions
  • paramType: Covers essential data types for API parameters
  • methodParam: Provides common parameter names for consistency

The implementation follows the established pattern in the file with proper encapsulation and accessor methods.

app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql (1)

1-21: Well-designed database schema.

The table structure is thoughtfully designed with:

  • Appropriate data types and sizes for each field
  • Proper primary key and unique constraints
  • Comprehensive audit trail fields
  • Multi-tenancy support fields
  • Alignment with the Model entity class structure

The unique index on name_cn and version ensures data integrity by preventing duplicate models.

base/src/main/resources/mappers/ModelMapper.xml (1)

151-158: Potential trailing comma issue in dynamic SET clause

The ModelSetColumns SQL fragment could generate a trailing comma if all conditions are met, which would cause a SQL syntax error.

MyBatis <set> tag automatically handles trailing commas, so the update statement is correctly structured. The SQL fragment itself has commas but when used within <set> tags, MyBatis manages them properly.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (6)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (6)

55-61: Incomplete fix from previous review - search both name fields

The method only searches the Chinese name field, but based on the schema having both name_cn and name_en columns, it should search both fields as suggested in the previous review.

 public List<Model> getModelByName(String nameCn) {
     QueryWrapper<Model> queryWrapper = new QueryWrapper<>();
-    queryWrapper.like("name_cn", nameCn);
+    queryWrapper.like("name_cn", nameCn)
+               .or()
+               .like("name_en", nameCn);
     return this.baseMapper.selectList(queryWrapper);
 }

102-107: Extract duplicate method generation logic

The same method generation code is duplicated in both createModel and updateModelById methods.

Extract this logic into a private method:

+private List<MethodDto> generateStandardMethods(Model model) {
+    List<MethodDto> methodDtos = new ArrayList<>();
+    methodDtos.add(getMethodDto(Enums.methodName.CREATED.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.UPDATE.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.QUERY.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.DELETE.getValue(), model));
+    return methodDtos;
+}

 public Model createModel(Model model) {
-    List<MethodDto> methodDtos = new ArrayList<>();
-    methodDtos.add(getMethodDto(Enums.methodName.CREATED.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.UPDATE.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.QUERY.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.DELETE.getValue(), model));
-    model.setMethod(methodDtos);
+    model.setMethod(generateStandardMethods(model));
     int result = this.baseMapper.createModel(model);
     // ... rest of the method

110-110: Fix error message parameter

The error handling uses the same error code for both parameters, which doesn't provide meaningful error information.

-            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
+            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg());

128-128: Fix error message parameter

Same issue as in createModel - using error code for message parameter.

-            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
+            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg());

150-150: Fix error message parameters in both exceptions

Both ServiceException calls use error code for the message parameter.

-        throw new ServiceException(ExceptionEnum.CM002.getResultCode(), ExceptionEnum.CM002.getResultCode());
+        throw new ServiceException(ExceptionEnum.CM002.getResultCode(), ExceptionEnum.CM002.getResultMsg());
         
-        throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
+        throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg());

Also applies to: 154-154


187-187: Use proper string comparison with equals()

String comparison should use .equals() method instead of != operator.

-        if (name != Enums.methodName.DELETE.getValue()) {
+        if (!name.equals(Enums.methodName.DELETE.getValue())) {
🧹 Nitpick comments (1)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)

70-90: Consider simplifying the query builder logic

The implementation is correct, but the nested conditionals could be simplified for better readability.

 public Page<Model> pageQuery(int currentPage, int pageSize, String nameCn, String nameEn) {
     Page<Model> page = new Page<>(currentPage, pageSize);
     QueryWrapper<Model> queryWrapper = new QueryWrapper<>();

-    // 判断 nameCn 是否存在
-    if (nameCn != null && !nameCn.isEmpty()) {
-        queryWrapper.like("name_cn", nameCn);
-    }
-
-    // 判断 nameEn 是否存在
-    if (nameEn != null && !nameEn.isEmpty()) {
-        if (nameCn != null && !nameCn.isEmpty()) {
-            queryWrapper.or().like("name_en", nameEn);
-        } else {
-            queryWrapper.like("name_en", nameEn);
-        }
-    }
+    boolean hasNameCn = nameCn != null && !nameCn.isEmpty();
+    boolean hasNameEn = nameEn != null && !nameEn.isEmpty();
+    
+    if (hasNameCn) {
+        queryWrapper.like("name_cn", nameCn);
+    }
+    
+    if (hasNameEn) {
+        if (hasNameCn) {
+            queryWrapper.or();
+        }
+        queryWrapper.like("name_en", nameEn);
+    }

     page(page, queryWrapper);
     return page;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 216177b and b6ae13e.

📒 Files selected for processing (3)
  • base/src/main/java/com/tinyengine/it/controller/ModelController.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/material/ModelService.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1 hunks)
🧬 Code Graph Analysis (1)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-1150)
🚧 Files skipped from review as they are similar to previous changes (2)
  • base/src/main/java/com/tinyengine/it/service/material/ModelService.java
  • base/src/main/java/com/tinyengine/it/controller/ModelController.java
🧰 Additional context used
🧬 Code Graph Analysis (1)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-1150)
🔇 Additional comments (3)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (3)

43-47: LGTM!

The queryModelById method implementation is clean and follows MyBatis Plus conventions correctly.


204-227: Well-structured response parameter builder

The static method correctly builds standard API response structures with appropriate fields for different operation types.


108-108: No changes needed for custom mapper methods

The createModel and updateModelById XML mappings use dynamic SQL fragments (ModelSetColumns, conditional <if> blocks) and explicitly enable generated keys. The standard insert/updateById provided by MyBatis-Plus would generate static SQL (updating all columns, possibly overwriting fields with null) and relies on annotations for key generation. Your custom mapper methods are justified to support:

  • Partial updates (only non-null fields)
  • Explicit control over generated keys

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (3)

102-107: Extract duplicate method generation logic.

The same method generation code is duplicated in both createModel and updateModelById methods.

Extract this logic into a private method:

+private List<MethodDto> generateStandardMethods(Model model) {
+    List<MethodDto> methodDtos = new ArrayList<>();
+    methodDtos.add(getMethodDto(Enums.methodName.CREATED.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.UPDATE.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.QUERY.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.DELETE.getValue(), model));
+    return methodDtos;
+}

 public Model createModel(Model model) {
-    List<MethodDto> methodDtos = new ArrayList<>();
-    methodDtos.add(getMethodDto(Enums.methodName.CREATED.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.UPDATE.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.QUERY.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.DELETE.getValue(), model));
-    model.setMethod(methodDtos);
+    model.setMethod(generateStandardMethods(model));
     int result = this.baseMapper.createModel(model);

And apply the same change in updateModelById.

Also applies to: 143-148


110-110: Improve error messages for better debugging.

The error handling uses the same error code for the message parameter, which doesn't provide meaningful information.

-            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
+            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg());

Apply this fix to all three occurrences at lines 110, 128, and 154.

Also applies to: 128-128, 154-154


187-187: Use proper string comparison with equals().

String comparison should use .equals() method instead of != operator.

-        if (!name.equals(Enums.methodName.DELETE.getValue())) {
+        if (!name.equals(Enums.methodName.DELETE.getValue())) {

Wait, I see the code already uses !name.equals() which is correct. There might have been a misunderstanding in the past review. The current code is correct.

🧹 Nitpick comments (2)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (2)

50-61: Fix javadoc parameter name inconsistency.

The javadoc mentions @param name but the actual parameter is nameCn. Update the javadoc to match the parameter name.

     /**
      * 根据name查询表t_model信息
      *
-     * @param name
+     * @param nameCn
      * @return the model list
      */

101-113: Consider adding transaction management for data consistency.

The createModel and updateModelById methods perform database operations that might benefit from explicit transaction management to ensure data consistency.

Add @Transactional annotation to ensure atomicity:

+import org.springframework.transaction.annotation.Transactional;

 @Override
 @SystemServiceLog(description = "创建model实现方法")
+@Transactional
 public Model createModel(Model model) {

Apply the same to updateModelById and deleteModelById methods.

Also applies to: 142-158

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6ae13e and ee3ae16.

📒 Files selected for processing (1)
  • base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1 hunks)
🧬 Code Graph Analysis (1)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-1150)
🧰 Additional context used
🧬 Code Graph Analysis (1)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-1150)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (6)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (6)

102-107: Extract duplicate method generation logic.

The same method generation code is duplicated in both createModel and updateModelById methods.

Extract this logic into a private method:

+private List<MethodDto> generateStandardMethods(Model model) {
+    List<MethodDto> methodDtos = new ArrayList<>();
+    methodDtos.add(getMethodDto(Enums.methodName.CREATED.getValue(), Enums.methodName.INSERTAPI.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.UPDATE.getValue(), Enums.methodName.UPDATEAPI.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.QUERY.getValue(), Enums.methodName.QUERYAPI.getValue(), model));
+    methodDtos.add(getMethodDto(Enums.methodName.DELETE.getValue(), Enums.methodName.DELETEAPI.getValue(), model));
+    return methodDtos;
+}

 public Model createModel(Model model) {
-    List<MethodDto> methodDtos = new ArrayList<>();
-    methodDtos.add(getMethodDto(Enums.methodName.CREATED.getValue(), Enums.methodName.INSERTAPI.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.UPDATE.getValue(), Enums.methodName.UPDATEAPI.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.QUERY.getValue(), Enums.methodName.QUERYAPI.getValue(), model));
-    methodDtos.add(getMethodDto(Enums.methodName.DELETE.getValue(), Enums.methodName.DELETEAPI.getValue(), model));
-    model.setMethod(methodDtos);
+    model.setMethod(generateStandardMethods(model));
     int result = this.baseMapper.createModel(model);
     // ... rest of the method

110-110: Improve error messages for better debugging.

The error handling uses the same error code for the message parameter, which doesn't provide meaningful information.

-            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
+            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg());

128-128: Improve error messages for better debugging.

The error handling uses the same error code for the message parameter, which doesn't provide meaningful information.

-            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
+            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg());

143-148: Extract duplicate method generation logic.

The same method generation code is duplicated in both createModel and updateModelById methods.


150-150: Use appropriate error message for null ID validation.

The null ID validation throws an error with the same code used for both parameters.

-            throw new ServiceException(ExceptionEnum.CM002.getResultCode(), ExceptionEnum.CM002.getResultCode());
+            throw new ServiceException(ExceptionEnum.CM002.getResultCode(), ExceptionEnum.CM002.getResultMsg());

154-154: Improve error messages for better debugging.

The error handling uses the same error code for the message parameter, which doesn't provide meaningful information.

-            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultCode());
+            throw new ServiceException(ExceptionEnum.CM001.getResultCode(), ExceptionEnum.CM001.getResultMsg());
🧹 Nitpick comments (1)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)

57-61: Consider searching both Chinese and English name fields.

While the method now correctly queries the name_cn field, consider enhancing the search to include both Chinese and English names for better flexibility.

 public List<Model> getModelByName(String nameCn) {
     QueryWrapper<Model> queryWrapper = new QueryWrapper<>();
-    queryWrapper.like("name_cn", nameCn);
+    queryWrapper.like("name_cn", nameCn)
+               .or()
+               .like("name_en", nameCn);
     return this.baseMapper.selectList(queryWrapper);
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee3ae16 and da990da.

📒 Files selected for processing (3)
  • base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1 hunks)
  • base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • base/src/main/java/com/tinyengine/it/common/enums/Enums.java
🧰 Additional context used
🧬 Code Graph Analysis (2)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (3)
base/src/main/java/com/tinyengine/it/model/dto/ParametersDto.java (1)
  • Data (22-29)
base/src/main/java/com/tinyengine/it/model/dto/RequestParameter.java (1)
  • Data (24-29)
base/src/main/java/com/tinyengine/it/model/dto/ResponseParameter.java (1)
  • Data (22-26)
base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (1)
base/src/main/java/com/tinyengine/it/common/enums/Enums.java (1)
  • Enums (20-1170)
🔇 Additional comments (5)
base/src/main/java/com/tinyengine/it/model/dto/MethodDto.java (1)

24-30: Well-designed DTO class for method metadata.

The MethodDto class is cleanly implemented with appropriate field types and naming conventions. The use of Lombok's @Data annotation reduces boilerplate code while maintaining readability.

base/src/main/java/com/tinyengine/it/service/material/impl/ModelServiceImpl.java (4)

43-47: Simple and correct query implementation.

The method properly uses the inherited baseMapper to query by ID with appropriate logging annotation.


70-90: Well-implemented pagination with conditional filtering.

The method correctly handles optional filtering parameters and properly constructs the QueryWrapper with conditional OR logic.


160-203: Well-implemented method DTO generation with proper string comparison.

The method correctly uses .equals() for string comparison and handles different method types appropriately. The logic for generating request/response parameters based on method type is sound.


205-228: Clean implementation of response parameter generation.

The static method provides a consistent way to generate standard response parameters with appropriate conditional logic for query methods.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (2)
app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql (2)

22-22: Remove MySQL-specific ENGINE clause for H2

H2 doesn't support "engine = innodb". Drop it to avoid syntax errors.

-) engine = innodb comment = '模型表';
+) comment = '模型表';

14-16: Add auto-update for last_updated_time (H2 lacks ON UPDATE)

last_updated_time won't auto-update on UPDATE with only DEFAULT CURRENT_TIMESTAMP. Implement app-level update or an H2-compatible trigger solution.

Options:

  • App-level: always set last_updated_time = CURRENT_TIMESTAMP in UPDATE statements.
  • H2 trigger: if you use Java triggers, register a BEFORE UPDATE trigger to set NEW.last_updated_time.

Please confirm which approach you prefer and I can provide the exact implementation for your stack.

🧹 Nitpick comments (4)
base/src/main/java/com/tinyengine/it/model/entity/Model.java (4)

51-56: Optional: specify JDBC type for JSON columns to avoid driver ambiguity

If your ListTypeHandler stores JSON as text, hinting JDBC type improves portability (MySQL TEXT/LONGTEXT, H2 CLOB).

-    @TableField(typeHandler = ListTypeHandler.class)
+    @TableField(typeHandler = ListTypeHandler.class/*, jdbcType = org.apache.ibatis.type.JdbcType.CLOB*/)
     private List<ParametersDto> parameters;

-    @TableField(typeHandler = ListTypeHandler.class)
+    @TableField(typeHandler = ListTypeHandler.class/*, jdbcType = org.apache.ibatis.type.JdbcType.CLOB*/)
     private  List<MethodDto> method;

If you choose to enable jdbcType, add the import:
import org.apache.ibatis.type.JdbcType;


41-42: Fix Swagger schema name casing to match column naming

Use name_en (lowercase) for consistency with DDL and camelCase-to-underscore mapping.

-    @Schema(name = "name_En", description = "英文名称")
+    @Schema(name = "name_en", description = "英文名称")

56-56: Nit: remove extra whitespace

Double space before List.

-    private  List<MethodDto> method;
+    private List<MethodDto> method;

50-56: Validate column sizes vs JSON payload size

parameters is VARCHAR(2000) in H2 DDL; complex JSON arrays may exceed 2000 chars. Consider TEXT/LONGTEXT (MySQL) / CLOB (H2) for both parameters and method columns.

If you want, I can produce aligned DDL changes for MySQL and H2 to switch parameters to TEXT/CLOB and keep method as LONGTEXT/CLOB.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbd88d6 and 7b1230c.

📒 Files selected for processing (3)
  • app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql (1 hunks)
  • base/src/main/java/com/tinyengine/it/model/entity/Model.java (1 hunks)
  • base/src/main/resources/mappers/ModelMapper.xml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • base/src/main/resources/mappers/ModelMapper.xml
🔇 Additional comments (3)
app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql (3)

1-22: No changes needed—H2 is already in MySQL compatibility mode

The DDL’s MySQL-specific syntax (backticks, inline comments, LONGTEXT, USING BTREE, ENGINE) is supported because in application-local.yml (line 6) H2 is started with MODE=MySQL.


11-11: No changes needed for LONGTEXT
Your H2 configuration (application-local.yml) runs in MySQL compatibility mode (MODE=MySQL), which supports the LONGTEXT type. You can safely keep the existing column definition as-is.


5-5: No changes needed: H2 is running in MySQL compatibility mode
Your application-local.yml sets MODE=MySQL on the H2 JDBC URL, so AUTO_INCREMENT is valid in this context.

`name_cn` varchar(255) comment '中文名称',
`name_en` varchar(255) comment '英文名称',
`version` varchar(255) comment '版本',
`model_url` varchar(255) comment '模型url',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Cross-DB consistency: ensure MySQL DDL also includes model_url

Entity and mapper use model_url. Verify MySQL DDL defines it to avoid runtime SQL errors in MySQL environments.

Expected: MySQL DDL should contain a column named model_url with a compatible type (e.g., VARCHAR(255)).


🏁 Script executed:

#!/bin/bash
# Check MySQL DDLs include model_url
fd -a create_model_ddl_*.sql app/src/main/resources/sql/mysql | xargs -I {} sh -c 'echo "---- {}"; cat "{}"'
rg -n --glob 'app/src/main/resources/sql/mysql/**' 'model_url'

Length of output: 177


🏁 Script executed:

#!/bin/bash
# List all SQL files under the MySQL DDL directory
echo "=== SQL files under app/src/main/resources/sql/mysql ==="
fd -t f -e sql app/src/main/resources/sql/mysql

# List any create_model_ddl SQL files specifically
echo "=== create_model_ddl SQL files under MySQL DDL ==="
fd -t f -e sql 'create_model_ddl' app/src/main/resources/sql/mysql

# Search for model_url occurrences in all MySQL SQL files
echo "=== Searching for model_url in MySQL DDL SQL files ==="
rg -n 'model_url' -R app/src/main/resources/sql/mysql

Length of output: 1426


🏁 Script executed:

#!/bin/bash
# Display the MySQL create_model_ddl file and check for model_url
echo "---- app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql ----"
cat app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql

echo
echo "---- Searching for model_url in that file ----"
grep -n 'model_url' app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql || echo "model_url not found in MySQL DDL"

Length of output: 1582


Add model_url to MySQL DDL for cross-DB consistency

The MySQL DDL file for t_model is missing the model_url column present in H2. Please update:

• File:
app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql

• Location:
In the column list, immediately after the site_id definition and before the primary-key clause.

• Diff to apply:

     `site_id`            varchar(60) comment '站点id,设计预留字段',
+    `model_url`          varchar(255) comment '模型url',
     primary key (`id`) using btree,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
`model_url` varchar(255) comment '模型url',
`site_id` varchar(60) comment '站点id,设计预留字段',
`model_url` varchar(255) comment '模型url',
primary key (`id`) using btree,
🤖 Prompt for AI Agents
In app/src/main/resources/sql/mysql/create_model_ddl_2025_0717.sql, in the
t_model table column list immediately after the site_id definition and before
the primary-key clause, add a model_url column matching H2: a varchar(255) with
the same comment '模型url' and correct comma placement; ensure the column syntax
follows the surrounding MySQL style (backticks or no backticks consistent with
the file) and that the trailing commas around the primary-key clause remain
valid.

Comment on lines +20 to +21
primary key (`id`) using btree,
unique index `u_idx_model` (`name_cn`,`version`) using btree
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Drop "USING BTREE" and prefer a standard unique constraint

"USING BTREE" is MySQL-specific and unnecessary. Use a portable unique constraint inline.

-    primary key (`id`) using btree,
-    unique index `u_idx_model` (`name_cn`,`version`) using btree
+    primary key (`id`),
+    constraint `u_idx_model` unique (`name_cn`, `version`)

Remove MySQL-specific “USING BTREE” and use standard constraint in H2 DDL

H2 does not support the MySQL-only USING BTREE clause—defining the key and a unique constraint is sufficient.

File: app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql
Lines: 20–21

-    primary key (`id`) using btree,
-    unique index `u_idx_model` (`name_cn`,`version`) using btree
+    primary key (`id`),
+    constraint `u_idx_model` unique (`name_cn`, `version`)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
primary key (`id`) using btree,
unique index `u_idx_model` (`name_cn`,`version`) using btree
primary key (`id`),
constraint `u_idx_model` unique (`name_cn`, `version`)
🤖 Prompt for AI Agents
In app/src/main/resources/sql/h2/create_model_ddl_2025_0717.sql around lines 20
to 21, the DDL uses MySQL-specific "USING BTREE" on the primary key and unique
index; remove the "USING BTREE" clauses and declare the constraints using
standard H2 syntax (keep primary key on `id` and define the unique
constraint/index on (`name_cn`,`version`) without engine-specific clauses).

Comment on lines +35 to +36
@TableName("t_model")
@Schema(name = "Model", description = "模型表")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Enable autoResultMap so ListTypeHandler works on read/write

Without autoResultMap=true, MyBatis-Plus may not apply custom type handlers for result mapping, causing serialization/deserialization issues for parameters/method fields.

-@TableName("t_model")
+@TableName(value = "t_model", autoResultMap = true)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@TableName("t_model")
@Schema(name = "Model", description = "模型表")
@TableName(value = "t_model", autoResultMap = true)
@Schema(name = "Model", description = "模型表")
🤖 Prompt for AI Agents
In base/src/main/java/com/tinyengine/it/model/entity/Model.java around lines 35
to 36, the @TableName annotation lacks autoResultMap=true so custom
ListTypeHandler won't be applied on result mapping; update the annotation to
enable autoResultMap (e.g. set autoResultMap = true on @TableName) so
MyBatis-Plus uses custom type handlers for read/write, or alternatively enable
autoResultMap in global MyBatis-Plus configuration if preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant