-
Notifications
You must be signed in to change notification settings - Fork 75
fix: Fix page create and componet library mapper #246
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
Conversation
…ava into feat/develop
WalkthroughThe changes introduce explicit ORM field-to-column mappings in several entity classes using Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant PageController
participant JsonUtils
participant PageService
Client->>PageController: POST /createPage (with JSON body)
PageController->>JsonUtils: decode(request.getInputStream(), Page.class)
JsonUtils-->>PageController: Page object
PageController->>PageService: createPage(Page) or createFolder(Page) (based on isPage)
PageService-->>PageController: Result<Page>
PageController-->>Client: Result<Page>
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (3)
base/src/main/java/com/tinyengine/it/controller/PageController.java (1)
117-117: Update Javadoc parameter documentation.The parameter documentation still references "page" but the parameter is now "request".
- * @param request the request + * @param request the HTTP request containing page data in JSON formatbase/src/main/resources/mappers/ComponentLibraryMapper.xml (2)
17-84: Consider switching=toLIKE(orIN) for free-text columns.For fields such as
name,description,registry,framework, etc., an exact-match requirement is usually too strict from an API-consumer perspective. Unless the service contract mandates exact equality, replacing the equality operator withLIKE CONCAT('%', … ,'%')– or exposing anIN (…)clause for multi-selects – will make the search endpoints markedly more usable.No code is wrong here, but re-evaluating the operator choice could avoid a follow-up PR.
289-293: Minor nit:<where>already strips a leadingAND.The guard
<if test="id != null"> AND CL.id = #{id} </if>is fine, but the inner newline results in:WHERE AND CL.id = ?
<where>removes the firstAND, so the query still runs, but the redundantANDproduces slightly uglier SQL in logs. Dropping it keeps the output clean:- AND CL.id = #{id} + CL.id = #{id}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
app/src/main/resources/sql/mysql/update_all_tables_ddl.sql(0 hunks)base/src/main/java/com/tinyengine/it/controller/PageController.java(2 hunks)base/src/main/java/com/tinyengine/it/model/entity/Component.java(4 hunks)base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java(2 hunks)base/src/main/java/com/tinyengine/it/model/entity/PageHistory.java(2 hunks)base/src/main/java/com/tinyengine/it/model/entity/Tenant.java(1 hunks)base/src/main/resources/mappers/ComponentLibraryMapper.xml(3 hunks)base/src/test/java/com/tinyengine/it/controller/PageControllerTest.java(1 hunks)
💤 Files with no reviewable changes (1)
- app/src/main/resources/sql/mysql/update_all_tables_ddl.sql
🧰 Additional context used
🧬 Code Graph Analysis (1)
base/src/main/java/com/tinyengine/it/controller/PageController.java (1)
base/src/main/java/com/tinyengine/it/common/utils/JsonUtils.java (1)
JsonUtils(45-349)
🔇 Additional comments (13)
base/src/test/java/com/tinyengine/it/controller/PageControllerTest.java (1)
74-80: Test correctly updated to match controller method signature change.The test properly creates a
MockHttpServletRequestwith JSON content and appropriate content type, aligning with the controller's new manual JSON deserialization approach.base/src/main/java/com/tinyengine/it/model/entity/PageHistory.java (3)
55-55: Good explicit column mapping for foreign key reference.The
@TableField(value = "ref_id")annotation clearly maps thepagefield to theref_idcolumn, improving ORM mapping clarity.
62-62: Appropriate foreign key column mapping.The
@TableField(value = "app_id")annotation correctly maps theappfield to theapp_iddatabase column.
79-79: Correct handling of SQL reserved keyword.The
@TableField(value = "group")annotation properly escapes thegroupcolumn name with backticks sincegroupis a reserved SQL keyword.base/src/main/java/com/tinyengine/it/model/entity/Component.java (3)
50-50: Clear field-to-column mapping for component name.The
@TableField(value = "name_en")annotation explicitly maps thecomponentfield to thename_endatabase column, improving code clarity.
79-79: Proper SQL keyword escaping.The
@TableField(value = "group")annotation correctly handles the SQL reserved keywordgroupwith backtick escaping.
103-103: Consistent explicit column mappings.The
@TableFieldannotations forpublicStatus,framework, andisTinyReservedprovide clear mappings to their respective database columns (public,framework,tiny_reserved), improving ORM transparency.Also applies to: 107-107, 117-117
base/src/main/java/com/tinyengine/it/model/entity/ComponentLibrary.java (4)
48-48: Clear foreign key mapping.The
@TableField(value = "app_id")annotation explicitly maps theappIdfield to theapp_iddatabase column.
53-53: Appropriate SQL keyword handling.The
@TableField(value = "package")annotation correctly mapspackageNameto thepackagecolumn, handling the SQL reserved keyword appropriately.
87-87: Consistent boolean field mappings.The
@TableFieldannotations forpublicStatus,isStarted,isOfficial, andisDefaultprovide clear mappings to their database columns with appropriate naming conventions.Also applies to: 91-91, 95-95, 99-99
103-103: Correct non-persistent field annotation.The
@TableField(exist = false)annotation properly marks thecomponentsfield as non-persistent, indicating it's a relationship field not stored directly in this table.base/src/main/resources/mappers/ComponentLibraryMapper.xml (2)
221-281: Potential row explosion due to LEFT JOIN without de-duplication.
queryAllComponentLibraryand the other two queries now return one row per component because of
LEFT JOIN t_component C ON CL.id = C.library_id.With a
<collection>result mapping this is technically correct, but callers expecting a 1-row-per-library result (e.g. for pagination) will receive inflated counts. If the Java side paginates, the join should move to a second query or you should useDISTINCT CL.id …/ windowing to keep the outer rowset unique.Just a heads-up in case API behaviour changes unnoticed.
186-186: Good catch on the stray space in<collection>; mapping looks solid.
* feat: Service extends IService * fix: Modify unit testing * fix: Modify web config * feat: Add JsonUtils and modify related methods * feat: Add JsonUtils and modify related methods * fix: Modify code format * fix: Fix block update bug * fix: Fix page create and componet library mapper
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Refactor
Tests