Develop#18
Merged
Merged
Conversation
…t related query handlers
…vice and implement related query handlers
…and local development instructions
There was a problem hiding this comment.
Pull request overview
This PR significantly expands the bundle module with read APIs (search/count for bundles and bundle items) plus a new BookmarkController aggregating bookmark-typed bundles, adds the supporting query/handler/model/DTO classes, tightens Hibernate config (globally_quoted_identifiers: true) across identity, message, and bundle, normalizes index/table naming on identity entities (and adds indexes to Token/OnetimePassword/Authlog), and adds a multi-section README.
Changes:
- New
bundleread-side:BookmarkController,BundleControllersearch/count endpoints,Bundle{,Item}{List,Count}Query/Handler,BundleListModel,BundleItemListDto, plusBundleApplicationServiceextensions. - Persistence/config tweaks:
globally_quoted_identifiersenabled in three modules; identity entity table/index renames (users→user,idx_*prefix, new indexes onToken/OnetimePassword/Authlog);BundleExtend.itemCount→itemsCount;Long.getLongbug fixed toLong.parseLonginBundleCreateCommandHandler. - Misc: security rules updated for new GET endpoints;
BundleControllerroute base changed/api/bundles→/api/bundleand methods renamed to*Async; newMapUtilityand Lombok@DataonBundleUpdateCommand; comprehensive README.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | New project README; uses hard-coded absolute paths in commands. |
| message/src/main/resources/application.yaml | Adds globally_quoted_identifiers/multiTenancy/format_sql under hibernate. |
| identity/src/main/resources/application.yaml | Adds globally_quoted_identifiers: true. |
| identity/src/main/java/.../entity/UserRole.java | Renames index to idx_user_role_unique. |
| identity/src/main/java/.../entity/UserAuthority.java | Renames index to idx_user_authority_unique. |
| identity/src/main/java/.../entity/User.java | Renames table users→user and index names. |
| identity/src/main/java/.../entity/Token.java | Adds idx_token_jti (unique) and idx_token_subject indexes; wildcard import. |
| identity/src/main/java/.../entity/OnetimePassword.java | Adds idx_onetime_password_request_id index; wildcard import. |
| identity/src/main/java/.../entity/Authlog.java | Adds user_id/username indexes; wildcard import. |
| framework/src/main/java/.../utility/MapUtility.java | New tryGet(map, key, consumer) helper. |
| bundle/src/main/resources/application.yaml | Adds globally_quoted_identifiers: true. |
| bundle/src/main/java/.../persistence/query/BundleListQuery.java | New record query with tryGet helper. |
| bundle/src/main/java/.../persistence/query/BundleItemListQuery.java | New record query. |
| bundle/src/main/java/.../persistence/query/BundleItemCountQuery.java | New record query. |
| bundle/src/main/java/.../persistence/query/BundleCountQuery.java | New record query. |
| bundle/src/main/java/.../persistence/profile/BundleMapProfile.java | Adds Bundle→BundleListModel mapping with extend fields. |
| bundle/src/main/java/.../persistence/model/BundleListModel.java | New read model for bundle list responses. |
| bundle/src/main/java/.../persistence/model/BundleItemModel.java | Adds fields incl. reserved-word order. |
| bundle/src/main/java/.../persistence/handler/BundleListQueryHandler.java | New handler; default branch maps unknown criteria keys directly to JPA equality. |
| bundle/src/main/java/.../persistence/handler/BundleItemListQueryHandler.java | New handler; double query.where and unscoped join. |
| bundle/src/main/java/.../persistence/handler/BundleItemCountQueryHandler.java | New handler; same double where issue. |
| bundle/src/main/java/.../persistence/handler/BundleCountQueryHandler.java | New count handler; same default over-permissive branch. |
| bundle/src/main/java/.../persistence/entity/BundleExtend.java | Renames item_count→items_count. |
| bundle/src/main/java/.../persistence/entity/Bundle.java | Lowercases text columnDefinition. |
| bundle/src/main/java/.../interfaces/package-info.java | Aligns package with file location. |
| bundle/src/main/java/.../interfaces/controller/BundleController.java | Renames base URL, methods to *Async, new /list & /count. |
| bundle/src/main/java/.../interfaces/controller/BookmarkController.java | New controller for /api/bookmark/**. |
| bundle/src/main/java/.../configure/SecurityConfiguration.java | Adds permitAll/authenticated GET rules; ordering makes /my unreachable. |
| bundle/src/main/java/.../application/implement/BundleApplicationServiceImpl.java | Implements new search/count methods; mutates and forwards owned key. |
| bundle/src/main/java/.../application/handler/BundleCreateCommandHandler.java | Fixes Long.getLong→Long.parseLong. |
| bundle/src/main/java/.../application/dto/BundleItemListDto.java | New DTO; reserved-word field order. |
| bundle/src/main/java/.../application/contract/BundleApplicationService.java | Adds search/count contract methods + class javadoc. |
| bundle/src/main/java/.../application/command/BundleUpdateCommand.java | Replaces explicit getters/setters with Lombok @Data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+60
to
+63
| query.where(builder.and(predicates.toArray(new Predicate[0]))); | ||
| if (!predicates.isEmpty()) { | ||
| query.where(builder.or(predicates.toArray(new Predicate[0]))); | ||
| } |
Comment on lines
+53
to
+56
| query.where(builder.and(predicates.toArray(new Predicate[0]))); | ||
| if (!predicates.isEmpty()) { | ||
| query.where(builder.or(predicates.toArray(new Predicate[0]))); | ||
| } |
Comment on lines
+35
to
+37
| auth.requestMatchers(HttpMethod.GET, "/api/bundle/**").permitAll() | ||
| .requestMatchers(HttpMethod.GET, "/api/bookmark/**").permitAll() | ||
| .requestMatchers(HttpMethod.GET, "/api/bookmark/my").authenticated() |
Comment on lines
+42
to
+57
| message.criteria().forEach((k, v) -> { | ||
| switch (k) { | ||
| case "ownerId" -> predicates.add(builder.equal(select.get("ownerId"), v)); | ||
| case "type" -> predicates.add(builder.equal(select.get("type"), v)); | ||
| case "keyword" -> { | ||
| if (v instanceof String keyword) { | ||
| Predicate orGroup = builder.or( | ||
| builder.like(select.get("name"), "%" + keyword + "%"), | ||
| builder.like(select.get("description"), "%" + keyword + "%") | ||
| ); | ||
| predicates.add(orGroup); | ||
| } | ||
| } | ||
| default -> predicates.add(builder.equal(select.get(k), v)); | ||
| } | ||
| }); |
Comment on lines
+35
to
+50
| message.criteria().forEach((key, value) -> { | ||
| switch (key) { | ||
| case "ownerId" -> predicates.add(builder.equal(select.get("ownerId"), value)); | ||
| case "type" -> predicates.add(builder.equal(select.get("type"), value)); | ||
| case "keyword" -> { | ||
| if (value instanceof String keyword) { | ||
| Predicate orGroup = builder.or( | ||
| builder.like(select.get("name"), "%" + keyword + "%"), | ||
| builder.like(select.get("description"), "%" + keyword + "%") | ||
| ); | ||
| predicates.add(orGroup); | ||
| } | ||
| } | ||
| default -> predicates.add(builder.equal(select.get(key), value)); | ||
| } | ||
| }); |
Comment on lines
+12
to
+15
| @Table(name = "user", indexes = { | ||
| @Index(name = "idx_user_idx_username", columnList = "username", unique = true), | ||
| @Index(name = "idx_user_idx_email", columnList = "email", unique = true), | ||
| @Index(name = "idx_user_idx_phone", columnList = "phone", unique = true) |
| private String title; | ||
| private String description; | ||
| private String image; | ||
| private int order; |
| var query = builder.createQuery(BundleItem.class); | ||
| var entity = query.from(BundleItem.class); | ||
|
|
||
| Join<BundleItem, Bundle> join = entity.join(Bundle.class); |
Comment on lines
+52
to
+85
| ```bash | ||
| cd /Users/rong/Code/Github/Linkyou/server | ||
| mvn clean install | ||
| ``` | ||
|
|
||
| ### 2) 仅运行测试 | ||
|
|
||
| ```bash | ||
| cd /Users/rong/Code/Github/Linkyou/server | ||
| mvn test | ||
| ``` | ||
|
|
||
| ### 3) 启动本地依赖(Docker Compose) | ||
|
|
||
| ```bash | ||
| cd /Users/rong/Code/Github/Linkyou/server | ||
| docker compose -f docker-compose.yaml up -d | ||
| ``` | ||
|
|
||
| ### 4) 停止本地依赖 | ||
|
|
||
| ```bash | ||
| cd /Users/rong/Code/Github/Linkyou/server | ||
| docker compose -f docker-compose.yaml down | ||
| ``` | ||
|
|
||
| ## 常用模块命令 | ||
|
|
||
| 在根目录执行(示例以 `identity` 模块为例): | ||
|
|
||
| ```bash | ||
| cd /Users/rong/Code/Github/Linkyou/server | ||
| mvn -pl identity -am clean package | ||
| ``` |
Comment on lines
+6
to
+12
| public class MapUtility { | ||
| public static <K, V> void tryGet(Map<K, V> criteria, K key, Consumer<? super V> function) { | ||
| if (criteria.containsKey(key)) { | ||
| function.accept(criteria.get(key)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.