Compare commits

..
286 Commits
Author SHA1 Message Date
Timi 684d7e19dc v1.0.82
CI / build-deploy (pull_request) Successful in 15m24s
CI / notify-on-failure (pull_request) Skipped
2026-11-27 00:59:44 +08:00
Timi 19544b1fd2 fix(file): remove rate limit from streaming content endpoints 2026-11-27 00:51:25 +08:00
Timi 34d9b189d2 fix(gao-ai): qualify redis beans in required args constructors 2026-11-26 17:06:03 +08:00
Timi 247535000b fix(multilingual): bind fields through generic response wrappers
Run multilingual backfill before the global return handler and traverse Object-typed fields by runtime type, so @MultilingualField still works when the body is wrapped in TimiResponse.
2026-11-26 15:07:28 +08:00
Timi 57422a64f2 fix: remove stale permission records
- remove ROLE_RELATION permissions superseded by ROLE_PERMISSION_INHERIT
- remove legacy export permissions superseded by DATA_EXPORT
- remove unused SETTING create and delete permissions
2026-11-26 14:48:52 +08:00
Timi 164dc4aef1 feat: remove permission create and delete
- remove permission create, batch create and delete endpoints and permission codes
- soft delete PERMISSION:CREATE and PERMISSION:DELETE via V95
- fail startup on builtin permission drift outside production
2026-11-26 11:39:14 +08:00
Timi 765561aad2 feat: remove setting create and delete 2026-11-26 10:57:17 +08:00
Timi 23204f3a48 v1.0.81
CI / build-deploy (pull_request) Successful in 1m2s
CI / notify-on-failure (pull_request) Skipped
2026-11-25 20:06:56 +08:00
Timi 02193b2ad1 feat(file): restrict preview to images and videos
- generate size-aware thumbnails (32-512px) with single-flight and atomic writes
- add optional v parameter for immutable browser caching
- serve PNG for PNG/GIF sources and JPEG otherwise
- drop PDF, text and WebP from preview support
2026-11-25 20:05:28 +08:00
Timi 62a2bbfe44 feat(api): add batch detail endpoints 2026-11-25 16:00:08 +08:00
Timi dd82259221 docs(openapi): add AI index and annotate setting endpoints
- add openapi-index.py to generate a compact Markdown index from OpenAPI JSON/YAML
- generate docs/openapi.index.md from the export scripts by default
- annotate SettingController with tags, operations, parameters and public security
- document the AI index workflow in api-integration.md
2026-11-25 13:18:08 +08:00
Timi 3f4a85a3d3 feat: remove preview file request rate limit 2026-11-25 12:50:09 +08:00
Timi d4fc4274fd v1.0.80
CI / build-deploy (pull_request) Successful in 10m21s
CI / notify-on-failure (pull_request) Skipped
2026-11-25 01:25:46 +08:00
Timi aefc0ad205 feat(openapi): integrate springdoc and API integration guide
- add springdoc-openapi and expose /v3/api-docs, /v3/api-docs.yaml and Swagger UI
- keep API docs responses unwrapped by replacing the global return handler
- add Chinese @Tag/@Operation/@Parameter docs for file and async task controllers
- add docs/api-integration.md and local export scripts for AI agent consumption
- ignore local OpenAPI snapshots and force LF for shell scripts
2026-11-25 01:23:30 +08:00
Timi dc5f62fd93 chore: remove serena project config 2026-11-25 01:23:26 +08:00
Timi 3b62f795de feat(file): refactor file management module
- add virtual path storage, granular permissions, trash and share features

- secure upload, archive and transfer tasks; add folder size calculation

- split controllers and add async task SSE progress events

- add Flyway migrations and file module tests
2026-11-24 15:36:17 +08:00
Timi 7e7a9cf60c feat(gao-ai): add confirmed write operations
- add prepare/commit/cancel MCP tools and pending operation state
- enforce execution identity, permissions, exact confirmation and audit
- support attachments and operation confirmation cards
- rewrite Dify DSL for write routing and destructive confirmations
2026-11-24 11:41:59 +08:00
Timi 58310b1e33 feat(gao): add customer profile and event month PDF exports 2026-11-23 15:27:25 +08:00
Timi badda20f32 v1.0.79
CI / build-deploy (pull_request) Successful in 35s
CI / notify-on-failure (pull_request) Skipped
2026-11-20 13:11:39 +08:00
Timi 386e26e77e feat(gao): add customer point ledger detail api 2026-11-19 17:56:07 +08:00
Timi 597101723c feat(gao): update customer recycle api 2026-11-19 16:11:18 +08:00
Timi 30e5888240 style(gao): perf GaoRecycle* code 2026-11-19 11:21:11 +08:00
Timi 743f491efc style(gao): long sql to XML 2026-11-19 01:38:42 +08:00
Timi c40ba5383e feat(gao): add GaoRecycleLedger entity 2026-11-19 01:33:36 +08:00
Timi ca87a273bc feat(gao): point redemption in product stock list and detail 2026-11-18 16:41:03 +08:00
Timi 0166a5585b chore(app): change max app update note to 8 2026-11-18 16:28:44 +08:00
Timi 78cfe0708c feat(gao): sync point redemption photo to product stock out 2026-11-18 16:27:58 +08:00
Timi bdcf32ba26 v1.0.78
CI / build-deploy (pull_request) Successful in 33s
CI / notify-on-failure (pull_request) Skipped
2026-11-18 00:10:14 +08:00
Timi 6feaad4b33 fix(app): db transactional 2026-11-18 00:10:01 +08:00
Timi 8954902994 v1.0.77
CI / build-deploy (pull_request) Successful in 34s
CI / notify-on-failure (pull_request) Skipped
2026-11-17 23:37:38 +08:00
Timi 09a8547ded feat(app): dual pointer for app channel 2026-11-17 23:37:31 +08:00
Timi 82110e36b7 v1.0.76
CI / build-deploy (pull_request) Successful in 33s
CI / notify-on-failure (pull_request) Skipped
2026-11-17 16:37:51 +08:00
Timi 5604edc00b fix(app): lost update log for point to native package 2026-11-17 16:37:33 +08:00
Timi 7294e9050d v1.0.75
CI / build-deploy (pull_request) Successful in 33s
CI / notify-on-failure (pull_request) Skipped
2026-11-17 15:55:08 +08:00
Timi 7d87ca7a86 fix(app): host update 2026-11-17 15:55:08 +08:00
Timi 6b2841274d v1.0.74
CI / build-deploy (pull_request) Successful in 33s
CI / notify-on-failure (pull_request) Skipped
2026-11-17 14:55:12 +08:00
Timi d5ccfbb231 fix(system): delete app release fail 2026-11-17 14:54:58 +08:00
Timi 96750730d3 v1.0.73
CI / build-deploy (pull_request) Successful in 34s
CI / notify-on-failure (pull_request) Skipped
2026-11-17 14:26:22 +08:00
Timi 725503152e fix(attach): lost file name for download 2026-11-17 14:26:09 +08:00
Timi 5233ac7eef v1.0.72
CI / build-deploy (pull_request) Successful in 35s
CI / notify-on-failure (pull_request) Skipped
2026-11-17 11:51:44 +08:00
Timi 343406efc7 feat(app): response apk package 2026-11-17 11:51:44 +08:00
Timi ee33284a2c feat(gao): support customer birthdate followup reminder 2026-11-16 16:23:00 +08:00
Timi 32bfdaa116 fix(gao): allow CI update log 2026-11-15 17:15:34 +08:00
Timi 7bbd217bdd feat(gao): no modification product base unit 2026-11-14 16:31:43 +08:00
Timi 1349b3c069 fix(gao): order remind url 2026-11-14 15:49:55 +08:00
Timi 8c0845d610 fix(system): fix apk recent update log 2026-11-14 15:05:56 +08:00
Timi 4ae8b1dda8 v1.0.71
CI / build-deploy (pull_request) Successful in 34s
CI / notify-on-failure (pull_request) Skipped
2026-11-14 01:05:20 +08:00
Timi f0c586ace8 feat(gao recycle): customer recycle list 2026-11-14 01:05:02 +08:00
Timi 43e7a509c2 feat(gao recycle): support quick fulfillment for recycle order 2026-11-13 19:05:52 +08:00
Timi a14a9a5581 feat(system): app update log api 2026-11-13 15:04:29 +08:00
Timi 8f4a839b2f v1.0.70
CI / build-deploy (pull_request) Successful in 32s
CI / notify-on-failure (pull_request) Skipped
2026-11-12 17:44:23 +08:00
Timi bd3f10fe60 fix: db timezone 2026-11-12 17:44:03 +08:00
Timi 169fd257a9 feat: recycle system 2026-11-12 17:37:05 +08:00
Timi bc901e2f0b v1.0.69
CI / build-deploy (pull_request) Successful in 33s
CI / notify-on-failure (pull_request) Skipped
2026-11-08 20:04:59 +08:00
Timi 74dd150469 add recycle 2026-11-08 18:50:53 +08:00
Timi 03a4d4a8ff v1.0.68
CI / build-deploy (pull_request) Successful in 34s
CI / notify-on-failure (pull_request) Skipped
2026-11-08 02:02:47 +08:00
Timi 7d8172e063 feat: can fulfillment sku order filter 2026-11-08 01:39:42 +08:00
Timi e5a065fbaf fix: gray permille for appVersion 2026-11-08 00:46:46 +08:00
Timi a8c04cf342 v1.0.67
CI / build-deploy (pull_request) Successful in 32s
CI / notify-on-failure (pull_request) Skipped
2026-11-07 00:05:23 +08:00
Timi 669118c0f8 fix attach create response fail 2026-11-07 00:05:11 +08:00
Timi b2cbe15d8b v1.0.66
CI / build-deploy (pull_request) Successful in 32s
CI / notify-on-failure (pull_request) Skipped
2026-11-06 23:58:41 +08:00
Timi a5426ce894 add APP_RELEASE attach 2026-11-06 23:58:29 +08:00
Timi aef3864a31 v1.0.65
CI / build-deploy (pull_request) Successful in 34s
CI / notify-on-failure (pull_request) Skipped
2026-11-06 23:36:48 +08:00
Timi 9a6bdfc3f0 add: app version and user api key 2026-11-06 23:36:32 +08:00
Timi d029ba58c3 v1.0.64
CI / build-deploy (pull_request) Successful in 32s
CI / notify-on-failure (pull_request) Skipped
2026-10-30 01:23:04 +08:00
Timi b0b623fa10 support customer list 2026-10-30 01:22:45 +08:00
Timi 4f1a5cbd9d v1.0.63
CI / build-deploy (pull_request) Successful in 33s
CI / notify-on-failure (pull_request) Skipped
2026-10-29 20:01:44 +08:00
Timi 9aac55a180 add skuFulfillmentList 2026-10-29 14:23:29 +08:00
Timi 6fd765661d fix cancel fulfillment permission 2026-10-28 11:56:11 +08:00
Timi 7222d19d02 v1.0.62
CI / build-deploy (pull_request) Successful in 33s
CI / notify-on-failure (pull_request) Skipped
2026-10-28 00:57:47 +08:00
Timi 5d55aee586 cancel sale order with fulfillment and fund record 2026-10-28 00:35:12 +08:00
Timi 14a81d1080 download from attachment api for data export 2026-10-26 11:46:02 +08:00
Timi 3d53a6a34b v1.0.61
CI / build-deploy (pull_request) Successful in 32s
CI / notify-on-failure (pull_request) Skipped
2026-10-26 00:33:58 +08:00
Timi fe8e9b7a8c fix data export 2026-10-26 00:33:40 +08:00
Timi 389bee2e45 v1.0.60
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-10-25 01:17:43 +08:00
Timi f3eddc69af add data export 2026-10-25 01:17:24 +08:00
Timi c20f0b6f45 fix AOP log 2026-10-23 14:33:37 +08:00
Timi 282832b950 split AuditOperation 2026-10-22 11:56:31 +08:00
Timi 72111f0a1b v1.0.59
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Skipped
2026-10-21 01:35:59 +08:00
Timi 4ba6e3a76f fix multilingual serialize 2026-10-21 01:35:43 +08:00
Timi 98b48cc9ae unlimit GaoOrderFulfillmentPage endAt 2026-10-21 01:01:46 +08:00
Timi b3db103494 add Tag useCount 2026-10-21 01:01:34 +08:00
Timi 618d91c6aa add quick fulfillment 2026-10-20 21:46:04 +08:00
Timi 7d272d3cd3 v1.0.58
CI / build-deploy (pull_request) Successful in 30s
CI / notify-on-failure (pull_request) Skipped
2026-10-16 01:33:32 +08:00
Timi adaadcbe51 fix GaoProductStockRecordPageResult 2026-10-16 01:33:17 +08:00
Timi a4abdc0632 add GaoPointRedeemSkuPageResult 2026-10-16 00:22:37 +08:00
Timi dbf7cb8b0f product stock total for page 2026-10-15 10:43:34 +08:00
Timi ce2a0d2995 revoke fulfillment and payment for cancel sale order 2026-10-14 15:53:46 +08:00
Timi f0b001dba9 add /manual-in/batch for gao product 2026-10-14 14:44:31 +08:00
Timi 0dab1ad039 v1.0.57
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Skipped
2026-10-05 16:10:07 +08:00
Timi 12fb82de34 update gao product edit 2026-10-05 16:09:35 +08:00
Timi 8fe00fbb7c update sms max customer 2026-09-26 09:58:49 +08:00
Timi b6f20c976d v1.0.56
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-25 23:43:25 +08:00
Timi 369da9f997 add main agent DSL 2026-09-25 22:07:42 +08:00
Timi cd8e552d21 support sku filter 2026-09-25 22:07:31 +08:00
Timi b30434777d v1.0.55
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Skipped
2026-09-23 23:15:19 +08:00
Timi 4aafb17214 add point chart 2026-09-23 21:54:39 +08:00
Timi 134218b56a v1.0.54
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-23 01:07:17 +08:00
Timi 5a07bfb7e3 add sku filter 2026-09-23 00:14:18 +08:00
Timi 1203ccfa4a with skuId for only once sku 2026-09-22 17:53:45 +08:00
Timi 7adea85e1f update order remind content 2026-09-22 16:52:18 +08:00
Timi 48eaf2356f v1.0.53
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-22 01:31:15 +08:00
Timi 970952d9fa clone fulfillment attach to stock out 2026-09-21 23:59:13 +08:00
Timi e5bfb59a1c v1.0.52
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Skipped
2026-09-21 01:18:35 +08:00
Timi 51c1d20d3c more filter for sales order 2026-09-20 15:40:03 +08:00
Timi 9256e08cfc v1.0.51
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-19 01:26:29 +08:00
Timi d0dcd0283e add customer order summary 2026-09-19 01:26:03 +08:00
Timi 76c5495c32 add package filter for SalesOrderPage 2026-09-18 18:28:15 +08:00
Timi cee7dd2442 v1.0.50
CI / build-deploy (pull_request) Successful in 28s
CI / notify-on-failure (pull_request) Skipped
2026-09-18 01:51:00 +08:00
Timi 8f2545f271 add customer followup 2026-09-18 01:47:54 +08:00
Timi b5a7c0d46c v1.0.49
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-17 01:31:21 +08:00
Timi 088afbe5c1 update customer in list 2026-09-17 01:31:02 +08:00
Timi 0d155ec5b2 update AIAgent 2026-09-16 15:15:36 +08:00
Timi 7d53d31c3f add GaoProductStockBatchRequest 2026-09-16 15:15:19 +08:00
Timi cd8bcae5be auto verify for order fulfillment and payment 2026-09-16 13:06:39 +08:00
Timi a2b6253d1d add customerCount for list event record 2026-09-16 12:54:39 +08:00
Timi 6ac84c11b2 v1.0.48
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-16 01:34:19 +08:00
Timi 1192bee431 add AIAgent 2026-09-16 01:09:55 +08:00
Timi c77813af0d remove ./http 2026-09-15 11:00:14 +08:00
Timi aa7b83ed1e v1.0.47
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-15 01:25:48 +08:00
Timi ac310414fe add point redemption 2026-09-15 01:25:32 +08:00
Timi 8618a00e5d v1.0.46
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-14 14:12:57 +08:00
Timi 5f97a1933e add GAO_HELP type 2026-09-14 14:12:42 +08:00
Timi 398e1b8095 v1.0.45
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-14 02:13:15 +08:00
Timi 086d2b42e2 add SalesOrderStraightThroughRequest paymentAmount 2026-09-14 00:47:59 +08:00
Timi b24d6b3a01 v1.0.44
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-13 01:37:51 +08:00
Timi c35132d06b total_earned DESC order for point account 2026-09-13 01:37:41 +08:00
Timi 91072d6d50 auto complete order 2026-09-13 01:25:48 +08:00
Timi f0b72b70e7 v1.0.43
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-12 01:24:03 +08:00
Timi daa5a6aa5e fix off product sku for keep fulfillment 2026-09-12 01:23:47 +08:00
Timi 4a157e9578 v1.0.42
CI / build-deploy (pull_request) Successful in 24s
CI / notify-on-failure (pull_request) Skipped
2026-09-12 00:11:21 +08:00
Timi eabb4c6aa6 fix event record CONTINUOUS_DAYS rank 2026-09-12 00:11:07 +08:00
Timi cb6051cc41 v1.0.41
CI / build-deploy (pull_request) Successful in 59s
CI / notify-on-failure (pull_request) Skipped
2026-09-11 23:53:06 +08:00
Timi 1d1009b121 add customer list for GaoCustomerDailyStateView 2026-09-11 23:52:43 +08:00
Timi 94f3fbb867 add customer age and disease chart 2026-09-11 20:24:09 +08:00
Timi fc4d55517b v1.0.40
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-11 00:26:14 +08:00
Timi ec72a99d74 response customer pinyin 2026-09-11 00:24:58 +08:00
Timi a431db6e6e fix article detail request method 2026-09-10 20:27:53 +08:00
Timi 9cfb31b015 support pinyin for product 2026-09-10 20:27:32 +08:00
Timi b000390a75 v1.0.39
CI / build-deploy (pull_request) Successful in 24s
CI / notify-on-failure (pull_request) Skipped
2026-09-10 14:09:49 +08:00
Timi 1b9f92caf5 add setting map 2026-09-10 14:09:38 +08:00
Timi 7b08641acc add customer order map 2026-09-10 14:09:30 +08:00
Timi 66c13062b2 fix notify fail 2026-09-10 12:47:29 +08:00
Timi cdf8a426e9 v1.0.38
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-10 01:31:20 +08:00
Timi a2d69fe721 support gift 2026-09-10 01:31:06 +08:00
Timi 19db357b44 update article CRUD 2026-09-10 01:30:50 +08:00
Timi 07ffef3e2a add cancel operator 2026-09-09 17:14:29 +08:00
Timi f93ec3cd4d v1.0.37
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-09 14:21:18 +08:00
Timi 3cdac98832 add allowDecimalQuantity 2026-09-09 14:21:04 +08:00
Timi c122c35376 refactor LoggerService.excute 2026-09-09 13:04:16 +08:00
Timi 2ea06fb5c0 v1.0.36
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-09 01:49:52 +08:00
Timi 00bb300755 support split fulfillment by base unit 2026-09-09 01:49:40 +08:00
Timi ea44dd5c0e update point rule groovy script 2026-09-09 01:08:45 +08:00
Timi 818207d6c9 fix FileController 2026-09-08 18:09:31 +08:00
Timi af76eb43b8 update SystemSetting 2026-09-08 16:52:32 +08:00
Timi d920b8630d v1.0.35
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-08 01:05:45 +08:00
Timi 1e62576d36 v1.0.34
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 23:10:27 +08:00
Timi bb5abcb48e v1.0.33
CI / build-deploy (pull_request) Successful in 24s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 17:40:06 +08:00
Timi 4a549e77cb v1.0.32
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 16:41:53 +08:00
Timi 461af4d581 v1.0.31
CI / build-deploy (pull_request) Successful in 39s
CI / notify-on-failure (pull_request) Skipped
2026-09-07 15:33:29 +08:00
Timi 37dc1c9904 add gao product SKU 2026-09-07 12:07:18 +08:00
Timi 3a4386261c add gao user remind 2026-09-07 12:06:38 +08:00
Timi 01d33a1122 add product/order chart 2026-09-06 17:56:47 +08:00
Timi db2fca5715 update customer package 2026-09-06 15:49:57 +08:00
Timi f3166f0413 add sales order 2026-09-06 12:09:58 +08:00
Timi 41f692aad9 add groovy script 2026-09-04 20:38:17 +08:00
Timi df16ac3c8e rename GaoStockRecord to GaoProductStockRecord 2026-09-04 10:37:43 +08:00
Timi 913dc3d278 update product unit 2026-09-03 15:16:16 +08:00
Timi 731c777b8b add gao product 2026-09-03 10:47:58 +08:00
Timi a81c8476e7 v1.0.30
CI / build-deploy (pull_request) Successful in 25s
CI / notify-on-failure (pull_request) Skipped
2026-09-02 01:44:32 +08:00
Timi e7cf1a72e3 v1.0.30
CI / build-deploy (pull_request) Failing after 6s
CI / notify-on-failure (pull_request) Successful in 0s
2026-09-02 01:42:24 +08:00
Timi eec665109e v1.0.30
CI / build-deploy (pull_request) Failing after 3s
CI / notify-on-failure (pull_request) Successful in 0s
2026-09-02 01:37:47 +08:00
Timi f6a2f5a6f5 support half paid 2026-09-01 14:07:04 +08:00
Timi 9ba610de86 update store diary attachment 2026-09-01 14:06:13 +08:00
Timi e59dc363f4 v1.0.29
CI / build-deploy (pull_request) Skipped
CI / notify-on-failure (pull_request) Skipped
2026-09-01 01:17:10 +08:00
Timi eeb7b5b32e add GaoPackage 2026-09-01 01:16:52 +08:00
Timi b4b6a13f8d add GaoPackage 2026-08-31 20:31:28 +08:00
Timi 4a7de1909c fix store diary page 2026-08-31 17:26:33 +08:00
Timi b7fcecfa7b add store diary 2026-08-31 15:10:25 +08:00
Timi 3b68e6dd85 update event status 2026-08-31 12:20:51 +08:00
Timi 5cfcd24657 v1.0.28
CI / build-deploy (pull_request) Successful in 23s
CI / notify-on-failure (pull_request) Skipped
2026-08-30 23:51:06 +08:00
Timi 712118556b add event option 2026-08-30 23:50:47 +08:00
Timi 4496619eeb v1.0.27
CI / build-deploy (pull_request) Successful in 23s
CI / notify-on-failure (pull_request) Skipped
2026-08-30 01:46:02 +08:00
Timi c85b400a94 fix require photo event 2026-08-30 01:25:22 +08:00
Timi 94c99e3444 fix update customer code 2026-08-29 16:05:24 +08:00
Timi 44c2095d77 add event verify 2026-08-29 15:35:11 +08:00
Timi 35ec38ed9c v1.0.26
CI / build-deploy (pull_request) Successful in 23s
CI / notify-on-failure (pull_request) Skipped
2026-08-29 00:50:26 +08:00
Timi 2b5be16ad7 fix notify delete 2026-08-29 00:49:50 +08:00
Timi d747a0fdae add gao user notify 2026-08-25 22:55:18 +08:00
Timi 9f884e2b74 keep alive attachment variant 2026-08-25 22:54:55 +08:00
Timi 0239697a2b fix customer invited count 2026-08-25 17:57:54 +08:00
Timi 2b11bdf65e tiptap content for notify detail 2026-08-24 16:50:23 +08:00
Timi 81933d4e61 v1.0.25
CI / build-deploy (pull_request) Successful in 22s
CI / notify-on-failure (pull_request) Skipped
2026-08-24 01:49:58 +08:00
Timi 43d76040d8 fix store permission 2026-08-24 01:49:44 +08:00
Timi 8de739cbb7 v1.0.24
CI / build-deploy (pull_request) Successful in 24s
CI / notify-on-failure (pull_request) Skipped
2026-08-22 17:55:54 +08:00
Timi e2e0023d13 v1.0.23
CI / build-deploy (pull_request) Successful in 23s
CI / notify-on-failure (pull_request) Skipped
2026-08-22 17:50:56 +08:00
Timi 8c6eed2379 update store delete 2026-08-22 17:21:30 +08:00
Timi c32ecd1f8c add point account list api 2026-08-22 16:42:09 +08:00
Timi 3c56e21efa add point totalConsumed 2026-08-22 11:45:00 +08:00
Timi 376f0ecd05 fix multi role invite error 2026-08-22 11:20:09 +08:00
Timi a208947a1b v1.0.22
CI / build-deploy (pull_request) Successful in 24s
CI / notify-on-failure (pull_request) Skipped
2026-08-22 01:31:14 +08:00
Timi fc62663f2c v1.0.22
CI / build-deploy (pull_request) Failing after 3s
CI / notify-on-failure (pull_request) Successful in 0s
2026-08-22 01:27:28 +08:00
Timi fcae2eac09 fix gao user invite validate 2026-08-21 23:51:38 +08:00
Timi 2e9225852d add AttachmentVariant 2026-08-21 23:43:40 +08:00
Timi 3a3809b661 fix gao user invite 2026-08-21 21:54:09 +08:00
Timi 1b8936f197 support sms login 2026-08-21 18:13:58 +08:00
Timi aff056712e v1.0.21
CI / build-deploy (pull_request) Successful in 22s
CI / notify-on-failure (pull_request) Skipped
2026-08-21 15:29:15 +08:00
Timi af18b0999d v1.0.20 2026-08-21 15:28:49 +08:00
Timi 4963988ec2 v1.0.20
CI / build-deploy (pull_request) Successful in 30s
CI / notify-on-failure (pull_request) Skipped
2026-08-21 15:25:04 +08:00
Timi 022185079c v1.0.19
CI / build-deploy (pull_request) Successful in 28s
CI / notify-on-failure (pull_request) Skipped
2026-08-21 13:52:05 +08:00
Timi acc3f05f12 support pinyin search 2026-08-21 13:51:26 +08:00
Timi a523df6a07 v1.0.18
CI / build-deploy (pull_request) Successful in 39s
CI / notify-on-failure (pull_request) Skipped
2026-08-21 01:39:14 +08:00
Timi 31c583eeb5 add internal notify 2026-08-21 01:38:51 +08:00
Timi e3ef3e5275 implement notify 2026-08-20 23:14:54 +08:00
Timi 84190b9773 point tier rule allow greater than 0 for min 2026-08-20 16:09:46 +08:00
Timi 7808d22775 support tag for customer create 2026-08-20 14:57:29 +08:00
Timi fba559cd22 fix customer delete 2026-08-20 11:19:24 +08:00
Timi dcc75efa87 v1.0.17
CI / build-deploy (pull_request) Successful in 22s
CI / notify-on-failure (pull_request) Skipped
2026-08-20 01:29:48 +08:00
Timi a9465299a9 add feedback 2026-08-20 00:22:19 +08:00
Timi 42152c7b79 fix event record DAILY_HALF_DAY 2026-08-19 17:56:05 +08:00
Timi 1a896ef457 add point rule sort 2026-08-19 16:12:23 +08:00
Timi 9d8990a028 add permission list and role list for user detail 2026-08-19 10:38:36 +08:00
Timi 17d88fc338 add event value chart 2026-08-18 17:26:56 +08:00
Timi bb40f347a3 support consume point 2026-08-18 16:46:30 +08:00
Timi 3d4e32e5da v1.0.16
CI / build-deploy (pull_request) Successful in 23s
CI / notify-on-failure (pull_request) Skipped
2026-08-16 11:36:02 +08:00
Timi bdc4cbb240 v1.0.15
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Skipped
2026-08-16 01:49:18 +08:00
Timi 7f6cebd4e2 v1.0.15
CI / build-deploy (pull_request) Failing after 6s
CI / notify-on-failure (pull_request) Successful in 0s
2026-08-16 01:44:45 +08:00
Timi 75fd4bed18 fix event save fail for limit == 1 2026-08-15 15:01:08 +08:00
Timi 8db6f962c9 v1.0.14
CI / build-deploy (pull_request) Successful in 22s
CI / notify-on-failure (pull_request) Skipped
2026-08-15 01:30:51 +08:00
Timi e35cf3aa59 1.0.14
CI / build-deploy (pull_request) Failing after 10s
CI / notify-on-failure (pull_request) Successful in 0s
2026-08-15 01:25:08 +08:00
Timi 457e716b38 add totalNumberValue for rank 2026-08-14 18:58:04 +08:00
Timi ab4a164680 return NumberValueTotal for list 2026-08-14 18:44:53 +08:00
Timi 9dfca25f8c update point tier rule 2026-08-14 18:26:38 +08:00
Timi e369a38e2e add Gao user invite 2026-08-14 11:57:10 +08:00
Timi f1e10df6a7 rename Gao GlobalManager role name 2026-08-14 11:31:25 +08:00
Timi 36e2a37af2 v1.0.13
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Skipped
2026-08-13 17:52:03 +08:00
Timi 348f7396a1 add point log 2026-08-13 14:04:07 +08:00
Timi c0b04fc554 v1.0.12
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-13 01:02:22 +08:00
Timi 5e5748b521 add customer in gao point ledger list api 2026-08-13 00:46:32 +08:00
Timi 67d79f7527 fix gao event rank 2026-08-13 00:24:39 +08:00
Timi ee530d2a8c refactor mapper xml 2026-08-12 16:11:08 +08:00
Timi 5f36844279 update GaoStore update 2026-08-12 12:10:21 +08:00
Timi 5b9391a50a add GaoStore.autoClosedDay 2026-08-12 12:03:30 +08:00
Timi 6bc73414d9 remove @RequireGaoRole 2026-08-12 11:06:48 +08:00
Timi d555aad9ac v1.0.11
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-12 00:48:54 +08:00
Timi 2f42204794 v1.0.10
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-12 00:42:35 +08:00
Timi 72bdb8d49b v1.0.9
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-11 23:58:00 +08:00
Timi 5ec6bc472f add chart api 2026-08-11 23:58:00 +08:00
Timi 81b7356d67 nullable point account detail api 2026-08-11 23:58:00 +08:00
Timi 44af16f451 fix new permission D authorize fail 2026-08-11 23:57:59 +08:00
Timi c6157db0de add gao point 2026-08-11 23:57:59 +08:00
Timi 39ac73dc66 refactor permission system 2026-08-11 23:57:59 +08:00
Timi 6e43ff349d fix gao store id 2026-08-07 19:10:25 +08:00
Timi ab79391cdc fix user login ip and time 2026-08-07 15:28:16 +08:00
Timi 67bc9382c5 add store sort api 2026-08-07 11:49:17 +08:00
Timi 7e40e0202e add store 2026-08-07 11:37:54 +08:00
Timi 7ffdd715ee refactor gao module 2026-08-06 13:16:52 +08:00
Timi 1709316ce1 refactor gao module 2026-08-06 10:52:50 +08:00
Timi 568563475e v1.0.8
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-04 00:35:57 +08:00
Timi 8a92e46eb1 unlimit attach read rate 2026-08-03 23:46:12 +08:00
Timi 1875cec8a5 add registration event rank 2026-08-03 23:45:56 +08:00
Timi 4c162dad34 v0.0.18
CI / build-deploy (pull_request) Successful in 20s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-03 19:59:08 +08:00
Timi c49686c411 v0.0.18
CI / build-deploy (pull_request) Failing after 8s
CI / notify-on-failure (pull_request) Successful in 0s
2026-08-03 19:57:44 +08:00
Timi 65161a7fad fix customer update 2026-08-03 19:21:12 +08:00
Timi 187f270866 add customer lunar birthdate 2026-08-03 18:54:17 +08:00
Timi 50d4bba045 batch customer event 2026-08-03 17:30:33 +08:00
Timi 6eedc06a07 update GAO logger 2026-08-03 15:34:01 +08:00
Timi b55b43eba4 add customer/event record export permission 2026-08-03 13:00:40 +08:00
Timi 20289a3168 add GAO logger 2026-08-03 12:22:48 +08:00
Timi d45bf11477 add GaoRegistrationEvent status and valid date range 2026-08-03 11:41:33 +08:00
Timi 7370b2fc98 rename registration event limit type 2026-08-03 10:48:43 +08:00
Timi 2f366fe219 v1.0.7
CI / build-deploy (pull_request) Successful in 20s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-01 17:34:06 +08:00
Timi f1715a3e32 v1.0.6
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-01 17:03:28 +08:00
Timi 833a303bb6 v1.0.5
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-01 16:51:53 +08:00
Timi 1658be7d8d v1.0.4
CI / build-deploy (pull_request) Successful in 21s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-01 11:11:53 +08:00
Timi 6c537852a0 v1.0.3
CI / build-deploy (pull_request) Successful in 1m8s
CI / notify-on-failure (pull_request) Has been skipped
2026-08-01 01:19:21 +08:00
Timi 15bf9bd688 v1.0.3
CI / build-deploy (pull_request) Failing after 2m52s
CI / notify-on-failure (pull_request) Successful in 0s
2026-08-01 01:13:08 +08:00
Timi ce22661a9b v1.0.3 2026-07-31 18:36:37 +08:00
Timi 22e415dd7b Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	pom.xml
#	src/main/java/com/imyeyu/api/annotation/EnableSetting.java
#	src/main/java/com/imyeyu/api/annotation/EnableSettingInterceptor.java
#	src/main/java/com/imyeyu/api/modules/blog/util/UserToken.java
#	src/main/java/com/imyeyu/api/modules/common/bean/SettingModule.java
#	src/main/java/com/imyeyu/api/modules/common/controller/CommentController.java
#	src/main/java/com/imyeyu/api/modules/common/controller/CommonController.java
#	src/main/java/com/imyeyu/api/modules/common/controller/UserController.java
#	src/main/java/com/imyeyu/api/modules/common/entity/Setting.java
#	src/main/java/com/imyeyu/api/modules/common/mapper/SettingMapper.java
#	src/main/java/com/imyeyu/api/modules/common/service/SettingService.java
#	src/main/java/com/imyeyu/api/modules/common/service/implement/MultilingualServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/common/service/implement/SettingServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/common/service/implement/TempFileServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/common/task/MultilingualTranslateTask.java
#	src/main/java/com/imyeyu/api/modules/git/bean/gitea/GiteaAPI.java
#	src/main/java/com/imyeyu/api/modules/git/controller/DeveloperController.java
#	src/main/java/com/imyeyu/api/modules/git/service/implement/RepositoryServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/journal/controller/JournalController.java
#	src/main/java/com/imyeyu/api/modules/journal/controller/ToolController.java
#	src/main/java/com/imyeyu/api/modules/journal/util/JournalAPIInterceptor.java
#	src/main/java/com/imyeyu/api/modules/minecraft/annotation/RequiredFMCServerTokenInterceptor.java
#	src/main/java/com/imyeyu/api/modules/minecraft/controller/MinecraftController.java
#	src/main/java/com/imyeyu/api/modules/minecraft/controller/PlayerController.java
#	src/main/java/com/imyeyu/api/modules/minecraft/service/implement/PlayerServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/music/runner/ControllerBootstrapRunner.java
#	src/main/java/com/imyeyu/api/modules/music/runner/PlayerBootstrapRunner.java
#	src/main/java/com/imyeyu/api/modules/system/bean/ServerFile.java
#	src/main/java/com/imyeyu/api/modules/system/controller/FileController.java
#	src/main/java/com/imyeyu/api/modules/system/controller/SystemController.java
#	src/main/java/com/imyeyu/api/modules/system/service/implement/FileServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/system/service/implement/StatusServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/system/service/implement/TerminalServiceImplement.java
#	src/main/java/com/imyeyu/api/modules/system/task/ServerStatusTask.java
#	src/main/java/com/imyeyu/api/modules/system/task/TerminalTask.java
#	src/main/java/com/imyeyu/api/modules/system/task/status/AbstractDequeStatusCollector.java
#	src/main/java/com/imyeyu/api/modules/system/task/status/collector/NetworkStatusCollector.java
#	src/main/java/com/imyeyu/api/modules/system/util/SystemAPIInterceptor.java
#	src/main/java/com/imyeyu/api/util/InitApplication.java
2026-07-31 15:18:12 +08:00
Timi 844c5381c4 v1.0.3 2026-07-31 15:16:55 +08:00
Timi e45809a0db refactor all 2026-07-31 01:03:53 +08:00
Timi 0625c17716 refactor Setting 2026-04-28 10:22:19 +08:00
Timi 4e7f340cc6 clear jackson method 2026-04-14 15:38:12 +08:00
Timi 3cc371c53e v1.0.2
CI / build-deploy (pull_request) Successful in 27s
CI / notify-on-failure (pull_request) Has been skipped
2026-04-13 18:27:29 +08:00
Timi b46e9079d5 v1.0.1
CI / build-deploy (pull_request) Successful in 26s
CI / notify-on-failure (pull_request) Has been skipped
2026-04-13 00:09:55 +08:00
Timi dc20070bf8 update status api 2026-04-13 00:09:48 +08:00
1254 changed files with 80753 additions and 15132 deletions
+2
View File
@@ -0,0 +1,2 @@
# Shell 脚本使用 LF,避免 Windows 下 CRLF 导致执行失败
*.sh text eol=lf
+6 -1
View File
@@ -14,7 +14,7 @@ jobs:
outputs:
deployment_status: ${{ steps.set_status.outputs.status }}
env:
JAVA_HOME: /usr/lib/jvm/java-21-openjdk
JAVA_HOME: /usr/lib/jvm/java-25-openjdk
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -46,6 +46,11 @@ jobs:
<username>${{ vars.TIMI_NEXUS_USERNAME }}</username>
<password>${{ vars.TIMI_NEXUS_PASSWORD }}</password>
</server>
<server>
<id>e2ins_nexus</id>
<username>${{ vars.E2INS_NEXUS_USERNAME }}</username>
<password>${{ vars.E2INS_NEXUS_PASSWORD }}</password>
</server>
</servers>
</settings>
EOF
+9 -3
View File
@@ -1,12 +1,14 @@
/config
/data
/docs
/logs
/target
/temp
/.claude
/CLAUDE.md
/AGENTS.md
/.workbuddy
# OpenAPI 本地导出(scripts/export-openapi.*)
/docs/openapi.local.yaml
/docs/openapi.local.json
multilingualField/
!.mvn/wrapper/maven-wrapper.jar
@@ -44,5 +46,9 @@ build/
### VS Code ###
.vscode/
### Python ###
__pycache__/
*.py[cod]
### Mac OS ###
.DS_Store
+3
View File
@@ -1,5 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
/httpRequests
/dataSources
/dataSources.local.xml
CopilotChatHistory.xml
developer-tools.xml
+5
View File
@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="vm.imyeyu.develop" uuid="05742bdc-a11a-4147-9168-ef976a70258a">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://vm.imyeyu.develop:3306/timi_server</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
+12
View File
@@ -0,0 +1,12 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="IncorrectHttpHeaderInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="customHeaders">
<set>
<option value="Token" />
</set>
</option>
</inspection_tool>
</profile>
</component>
+35 -29
View File
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
@@ -10,49 +11,54 @@
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
<option name="myDefaultNotNull" value="jakarta.validation.constraints.NotNull" />
<option name="myOrdered" value="true" />
<option name="myNullables">
<value>
<list size="14">
<list size="16">
<item index="0" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="org.jspecify.nullness.Nullable" />
<item index="2" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="3" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="4" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
<item index="7" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="8" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="9" class="java.lang.String" itemvalue="jakarta.annotation.Nullable" />
<item index="10" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="11" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="12" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="13" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="org.jspecify.annotations.Nullable" />
<item index="6" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
<item index="10" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
<item index="11" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="12" class="java.lang.String" itemvalue="jakarta.annotation.Nullable" />
<item index="13" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="14" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="15" class="java.lang.String" itemvalue="org.springframework.lang.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="15">
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="1" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="2" class="java.lang.String" itemvalue="jakarta.annotation.Nonnull" />
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
<item index="5" class="java.lang.String" itemvalue="lombok.NonNull" />
<item index="6" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="7" class="java.lang.String" itemvalue="jakarta.validation.constraints.NotNull" />
<item index="8" class="java.lang.String" itemvalue="org.jspecify.nullness.NonNull" />
<item index="9" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
<item index="10" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="11" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="12" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="13" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="14" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
<list size="17">
<item index="0" class="java.lang.String" itemvalue="jakarta.validation.constraints.NotNull" />
<item index="1" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="2" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="org.jspecify.nullness.NonNull" />
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
<item index="6" class="java.lang.String" itemvalue="org.jspecify.annotations.NonNull" />
<item index="7" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
<item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
<item index="12" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="13" class="java.lang.String" itemvalue="jakarta.annotation.Nonnull" />
<item index="14" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="15" class="java.lang.String" itemvalue="lombok.NonNull" />
<item index="16" class="java.lang.String" itemvalue="org.springframework.lang.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" project-jdk-name="temurin-25" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+9 -1
View File
@@ -4,4 +4,12 @@
技术栈:SpringBoot MariaDB MyBatis Redis
[timijava](https://github.com/imyeyu/timijava)
[timijava](https://github.com/imyeyu/timijava)
### GAO 客户画像 PDF
`POST /gao/customer/profile/pdf?id={客户ID}` 返回 `application/pdf`,响应按浏览器内预览处理。调用者需要独立的 `CUSTOMER_PROFILE:READ` 权限,且客户必须在其门店数据范围内;画像读取不再要求分别持有订单、积分或回收物权限。默认不将该权限授予店长或门店管理角色,需要在角色管理中显式授权。
统计限定客户所属门店。事件包含已核销及无需核销的记录,排除待核销记录,并沿用既有事件查询对历史消费事件的排除规则;上月和本月按服务端时区的自然月计算。订单排除取消单,金额由分换算为元,净收款为已付款减退款。积分月份按流水发生时间统计获得和消费;回收物按品种和单位分别展示,账户流水中的获得、使用及人工调整与回收支付的当前核销状态分别统计。数量、积分和金额均按每四位分组。
PDF 使用 `templates/GaoCustomerProfile.ftl`,单页展示最多 6 种事件、6 项产品、4 种回收物和 3 条跟进提醒;多出的数据不影响总体汇总。长文本会截断,页面空间不足时会缩小字号;若仍无法排入一页,接口返回错误,不生成多页文件。使用首张 `PHOTO` 附件并按比例转为灰度;无图片或图片格式无法解码时使用占位。字体使用服务器上合法安装的宋体 SimSun,默认路径为 `C:/Windows/Fonts/simsun.ttc`。非 Windows 环境或使用其他路径时,设置 `gao.customer-profile.font-path` 指向包含 SimSun 的 TTC 文件;服务不会自动替换字体,字体缺失时接口返回错误。项目不分发该字体文件。
View File
+283
View File
@@ -0,0 +1,283 @@
# TimiServerAPI 接口对接说明
> 接口的路径、方法、参数、请求体、响应体以 `docs/openapi.local.yaml` 为准。本文只补充 OpenAPI 无法完整表达的横切约定:统一响应包装、鉴权、错误码、分页、二进制响应与 SSE。
>
> 本文不重复 OpenAPI 中的接口清单和字段说明。
- 服务版本:`1.0.79`
- OpenAPI 版本:`3.1.0`
- 默认本地地址:`http://localhost:18092`(无 context-path)
- OpenAPI JSON:`/v3/api-docs`
- OpenAPI YAML:`/v3/api-docs.yaml`
- Swagger UI:`/swagger-ui.html`
---
## 1. 文档快照与覆盖范围
### 1.1 导出本地快照
仓库提供两个导出脚本,默认输出 `docs/openapi.local.yaml`:
```powershell
# PowerShell
.\scripts\export-openapi.ps1
# 指定地址与文件名(.json 后缀会导出 JSON)
.\scripts\export-openapi.ps1 -BaseUrl http://192.168.1.10:18092 -OutFile docs\openapi.local.json
```
```bash
# Bash
bash scripts/export-openapi.sh
bash scripts/export-openapi.sh http://192.168.1.10:18092 docs/openapi.local.json
```
`docs/openapi.local.*` 是本地快照,已在 `.gitignore` 中忽略,不应提交。需要给远程 AI Agent 使用时,优先发送该文件,而不是 `localhost` 地址。
导出脚本会同时生成面向 AI Agent 的接口索引 `docs/openapi.index.md`:按业务模块列出接口的方法、路径、摘要、参数、请求体与响应 schema。索引体积远小于完整 OpenAPI,适合先用于定位,再读取 OpenAPI 中的对应片段。PowerShell 使用 `-NoIndex`、Bash 使用 `SKIP_INDEX=1` 可跳过索引生成。
### 1.2 覆盖范围说明
SpringDoc 会扫描项目中的全部 Controller,因此 OpenAPI 文件里会包含用户、标签、系统设置等模块的接口。目前已对文件、异步任务与系统设置模块的 8 个 Controller 补充了完整的中文 `@Tag` / `@Operation` / `@Parameter` 描述;这些接口的路径、参数、请求体和响应结构均已包含在 OpenAPI 中。其他模块的接口属于 SpringDoc 自动生成的基础描述,业务语义可能不完整,复杂接口请结合源码或联调确认。
OpenAPI 中还声明了全局 `Token` 安全要求,但登录、注册等公开接口实际可能不需要登录。**是否需要鉴权以接口实际行为为准**;公开接口已在 OpenAPI 中按操作单独标记 `security`。
---
## 2. 基础约定
### 2.1 请求格式
- 普通接口:`Content-Type: application/json`
- 上传类接口:`multipart/form-data`
- 字符编码:UTF-8
- 时间字段:除特别说明外,均为 **epoch 毫秒**(`long`)
- 大小字段:字节(`long`)
### 2.2 鉴权
请求头优先使用:
```http
Token: <登录令牌或 API Key>
```
服务端也兼容以下写法:
```http
token: <登录令牌或 API Key>
```
以及 URL 参数:
```text
?token=<登录令牌或 API Key>
```
> 生产环境建议只使用 `Token` 请求头。URL 参数容易进入访问日志、浏览器历史和 Referer。
>
> 浏览器原生 `EventSource` 不能设置自定义请求头,SSE 场景才使用 `?token=`。
支持两种凭证:
1. **登录令牌**:通过登录接口获取,具体接口见 OpenAPI。
2. **API Key**:以 `tk_` 开头,格式为 `tk_<8位十六进制>_<32位十六进制>`。API Key 创建后只返回一次明文,不能用于管理 API Key 本身。
### 2.3 统一响应包装(TimiResponse)
除二进制、SSE 等特殊接口外,所有 JSON 接口都会被统一包装为:
```json
{
"code": 20000,
"message": "可选,面向用户的提示",
"messageCode": "可选,国际化消息键",
"data": {}
}
```
字段说明:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `code` | number | 业务代码,**不是 HTTP 状态码** |
| `message` | string | 提示信息,可能根据语言返回不同文案 |
| `messageCode` | string | 国际化消息键,可能不存在 |
| `data` | any | 业务数据;为 `null` 时通常被省略 |
判断成功请使用:
```ts
const success = response.code <= 30000; // 20000 成功,20001 表示成功但忽略请求
```
不要只根据 HTTP 状态码判断业务结果。普通 JSON 接口即使业务失败,HTTP 状态通常仍是 `200`。
### 2.4 错误码
| code | 含义 |
| --- | --- |
| `20000` | 成功 |
| `20001` | 成功,忽略请求 |
| `40000` | 缺少参数 / 未登录 |
| `40001` | 参数不合法 |
| `40002` | 参数已过期 |
| `40100` | 无权限 |
| `40101` | 权限错误 |
| `40102` | 非法请求 / 请求过于频繁 |
| `40301` | 数据已存在 |
| `40400` | 数据不存在 |
| `40401` | 返回数据异常 |
| `40402` | 数据被禁用 |
| `40403` | 上游服务超时 |
| `50000` | 服务异常 |
| `50001` | 不支持的操作 |
| `50002` | 服务内部变量缺失 |
| `50003` | 服务已关闭 |
| `50300` | 服务繁忙 |
### 2.5 多语言
可通过以下任一方式指定语言:
```http
Accept-Language: zh-CN
```
```text
?lang=zh_CN
```
默认 `zh_CN`。
### 2.6 分页
分页接口的请求体通常是 `Page<T>`:
```json
{
"index": 0,
"size": 16,
"equalsExample": {},
"likesExample": {},
"equalsLogic": "AND",
"likesLogic": "OR",
"orderMap": {
"created_at": "DESC"
}
}
```
- `index`:页码,**从 0 开始**,默认 `0`
- `size`:每页数量,默认 `16`;部分接口会限制最大值(例如 100)
- `equalsExample`:精确匹配示例
- `likesExample`:模糊匹配示例
- `equalsLogic`:精确条件连接方式,`AND` / `OR`
- `likesLogic`:模糊条件连接方式,`AND` / `OR`
- `orderMap`:排序字段与方向,字段通常使用数据库下划线命名
分页响应通常是 `PageResult<T>`:
```json
{
"total": 128,
"pages": 8,
"list": [],
"empty": false,
"notEmpty": true
}
```
---
## 3. 特殊响应类型
### 3.1 二进制响应
部分接口直接返回二进制数据或字节流,不经过 `TimiResponse`:
- 成功时直接返回字节流
- 失败时使用标准 HTTP 状态码,例如 `400`、`403`、`404`、`500`
- 响应头可能包含 `Content-Type`、`Content-Length`、`Content-Disposition`、`ETag`、`Last-Modified`、`Accept-Ranges`、`Content-Range`
- 前端应使用 `blob` / `arrayBuffer`,不能按 JSON 解析
具体哪些接口属于二进制响应,以 OpenAPI 中定义的响应 `Content-Type` 为准。
#### 缩略图预览
`GET /system/file/preview/{path}` 仅支持图片和视频,其他类型返回 `400`。图片和视频统一返回缩略图:
- `size`:缩略图最大边长(像素),范围 `32-512`,默认 `256`
- `v`:缓存版本号,建议传文件列表返回的 `etag`;传入后响应使用一年强缓存,不传时缓存一天
- 响应 `Content-Type` 为 `image/jpeg` 或 `image/png`;PNG/GIF 源图使用 PNG,其余使用 JPEG
- 支持 `If-None-Match` 条件请求,`ETag` 已包含缩略图尺寸和算法版本
### 3.2 SSE
部分长任务接口使用 `text/event-stream`,不经过 `TimiResponse`。事件类型如下:
| event | 说明 |
| --- | --- |
| `snapshot` | 连接建立后的当前任务快照 |
| `progress` | 状态或进度发生变化 |
| `heartbeat` | 心跳,约 15 秒一次 |
| `done` | 任务成功,随后服务端关闭连接 |
| `error` | 任务失败、被中断、死亡,或订阅异常,随后关闭连接 |
说明:
- 事件 `data` 是 JSON,字段和状态枚举以 OpenAPI 中对应的任务模型为准。
- 任务结束后服务端主动关闭连接;断线后可回退到 OpenAPI 中的任务详情接口轮询。
- 浏览器原生 `EventSource` 不能设置 `Token` 请求头,使用查询参数传递令牌。
```ts
const source = new EventSource(`${sseUrl}?token=${encodeURIComponent(token)}`);
source.addEventListener("progress", (event) => {
const task = JSON.parse(event.data);
console.log(task.progress, task.status);
});
source.addEventListener("done", (event) => {
const task = JSON.parse(event.data);
source.close();
});
```
其中 `sseUrl` 从 OpenAPI 中对应的 SSE 接口获取。
---
## 4. AI Agent 对接建议
1. **优先使用导出的 OpenAPI 文件**,不要只给 `localhost` URL。远程 Agent 无法访问本机地址。可先读 `docs/openapi.index.md` 定位模块和接口,再读取 OpenAPI 中的对应片段,避免整份文档占用上下文。
2. 用 OpenAPI 生成 TypeScript 类型和请求客户端,再在客户端层统一补充 `TimiResponse` 包装。
3. 不要假设 OpenAPI 的返回类型就是最终响应体;普通 JSON 接口需要取 `data`。
4. 二进制接口单独处理:使用 `blob` / `arrayBuffer`,按 HTTP 状态判断成败。
5. SSE 单独处理:使用 `EventSource` 或 fetch 流式读取,`Token` 放查询参数。
6. 分页接口使用 `Page<T>` / `PageResult<T>`,`index` 从 0 开始。
7. 业务错误优先看 `code`,不要只看 HTTP 状态。
8. 接口路径、参数和字段结构以 OpenAPI 为准,不要根据本文猜测。
推荐给 AI Agent 的简要约束:
```text
这是一个 Spring Boot 接口项目。接口路径、参数和响应结构以 OpenAPI 为准。
普通 JSON 接口返回 TimiResponse 包装:{ code, message?, messageCode?, data? },
code <= 30000 表示成功。鉴权使用 Token 请求头。
二进制接口不包装,按 HTTP 状态判断;SSE 接口不包装,Token 放查询参数。
分页请求使用 Page<T>,index 从 0 开始。
```
---
## 5. 已知限制
- OpenAPI 的响应 Schema 不包含 `TimiResponse` 包装。
- 只有文件、异步任务与系统设置模块的 8 个 Controller 有较完整的中文接口描述,其他模块为基础自动生成信息。
- 二进制接口的响应体无法在 OpenAPI 中完整表达,需结合本文和实际响应头处理。
- OpenAPI 全局声明了 `Token`,公开接口的实际鉴权行为以接口为准。
- 当前没有提交固定的 `docs/openapi.yaml` 版本化文件;需要时使用导出脚本生成本地快照,或后续接入 CI 导出。
- `docs/openapi.index.md` 从本地 OpenAPI 快照生成,接口变更后需重新执行导出脚本更新;索引只提供定位信息,字段定义以 OpenAPI 原文为准。
+811
View File
@@ -0,0 +1,811 @@
# TimiServerAPI 接口索引
> 本文件由 `scripts/openapi-index.py` 从 OpenAPI 快照生成,请勿手工编辑。
> 数据来源:`docs/openapi.local.yaml`。完整字段定义以 OpenAPI 原文为准。
- 服务版本:`1.0.79`
- OpenAPI 版本:`3.1.0`
- 路径数:464
- 接口数:466(同一路径的同一处理器会合并多个 HTTP 方法)
- 模块数:36
## 使用说明
- 先按模块定位接口,再读取 `docs/openapi.local.yaml` 中对应的 `path` 或 `components/schemas`,不要整文件加载。
- 参数列中 `*` 表示必填;`header:`、`cookie:` 为参数位置前缀,其余为 path/query 参数。
- 摘要前的 `[公开]` 表示 OpenAPI 中显式标记为无需登录;未标记的接口默认使用 `Token` 鉴权。
- 方法列出现多个 HTTP 方法,表示 Controller 使用了未限定 method 的 `@RequestMapping`。
- 请求体和响应列展示顶层 schema 名称;`binary` 表示二进制响应,`SSE` 表示 `text/event-stream`。
- 普通 JSON 接口的响应仍由 `TimiResponse` 包装,鉴权、错误码、分页等约定见 `docs/api-integration.md`。
## 模块导航
| 模块 | 接口数 | 路径前缀 |
| --- | ---: | --- |
| [`gao-ai`](#module-gao-ai) | 8 | `/gao/ai/` |
| [`gao-customer`](#module-gao-customer) | 41 | `/gao/customer/` |
| [`gao-data-export`](#module-gao-data-export) | 3 | `/gao/data-export/` |
| [`gao-event`](#module-gao-event) | 20 | `/gao/event/` |
| [`gao-fund`](#module-gao-fund) | 5 | `/gao/fund/` |
| [`gao-notify`](#module-gao-notify) | 2 | `/gao/notify/` |
| [`gao-order`](#module-gao-order) | 13 | `/gao/order/` |
| [`gao-package`](#module-gao-package) | 6 | `/gao/package/` |
| [`gao-point`](#module-gao-point) | 11 | `/gao/point/` |
| [`gao-product`](#module-gao-product) | 51 | `/gao/product/` |
| [`gao-recycle`](#module-gao-recycle) | 32 | `/gao/recycle/` |
| [`gao-report`](#module-gao-report) | 1 | `/gao/report/` |
| [`gao-role`](#module-gao-role) | 2 | `/gao/role/` |
| [`gao-sales`](#module-gao-sales) | 27 | `/gao/sales/` |
| [`gao-store`](#module-gao-store) | 28 | `/gao/store/` |
| [`gao-tag`](#module-gao-tag) | 7 | `/gao/tag/` |
| [`gao-user`](#module-gao-user) | 10 | `/gao/user/` |
| [`system`](#module-system) | 48 | `/system/` |
| [`user`](#module-user) | 44 | `/user/` |
| [`app`](#module-app) | 13 | `/app/` |
| [`.well-known`](#module-.well-known) | 6 | `/.well-known/` |
| [`article`](#module-article) | 5 | `/article/` |
| [`attach`](#module-attach) | 14 | `/attach/` |
| [`captcha`](#module-captcha) | 2 | `/captcha/` |
| [`comment`](#module-comment) | 13 | `/comment/` |
| [`feedback`](#module-feedback) | 5 | `/feedback/` |
| [`fmc`](#module-fmc) | 1 | `/fmc/` |
| [`icon`](#module-icon) | 4 | `/icon/` |
| [`journal`](#module-journal) | 7 | `/journal/` |
| [`log`](#module-log) | 1 | `/log/` |
| [`mcp`](#module-mcp) | 5 | `/mcp/` |
| [`mirror`](#module-mirror) | 2 | `/mirror/` |
| [`notify`](#module-notify) | 15 | `/notify/` |
| [`root`](#module-root) | 1 | `/` |
| [`setting`](#module-setting) | 6 | `/setting/` |
| [`tag`](#module-tag) | 7 | `/tag/` |
<a id="module-gao-ai"></a>
## gao-ai
共 8 个接口,路径前缀 `/gao/ai/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/ai/attachment/upload` | upload | storeId | object{file} (multipart/form-data) | Array<GaoAiAttachmentView> | gao-ai-operation-controller |
| POST | `/gao/ai/chat` | chat | - | GaoAiChatRequest | SSE | gao-ai-chat-controller |
| POST | `/gao/ai/conversation/delete` | deleteConversation | conversationId* | - | - | gao-ai-chat-controller |
| POST | `/gao/ai/conversation/list` | listConversation | - | GaoAiConversationListRequest | JsonNode | gao-ai-chat-controller |
| POST | `/gao/ai/conversation/read` | readConversation | - | GaoAiConversationReadRequest | JsonNode | gao-ai-chat-controller |
| POST | `/gao/ai/operation/cancel` | cancel | - | GaoAiOperationCommitRequest | GaoAiToolResult | gao-ai-operation-controller |
| POST | `/gao/ai/operation/commit` | commit | - | GaoAiOperationCommitRequest | GaoAiToolResult | gao-ai-operation-controller |
| GET | `/gao/ai/operation/pending` | pending | conversationId, storeId | - | GaoAiToolResult | gao-ai-operation-controller |
<a id="module-gao-customer"></a>
## gao-customer
共 41 个接口,路径前缀 `/gao/customer/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/customer/chart/customer/disease/word` | customerDiseaseWord | - | GaoCustomerDiseaseWordReq | Array<GaoCustomerDiseaseWordView> | gao-customer-chart-controller |
| POST | `/gao/customer/chart/event/record/calendar` | eventRecordCalendar | - | GaoCustomerChartReq | Array<GaoEventRecordCalendarView> | gao-customer-chart-controller |
| POST | `/gao/customer/chart/event/record/daily` | eventRecordDaily | - | GaoCustomerChartReq | Array<GaoEventRecordDailyStatView> | gao-customer-chart-controller |
| POST | `/gao/customer/consumption-record/list` | list | - | GaoCustomerConsumptionRecordPage | GaoCustomerConsumptionRecordPageResult | gao-customer-consumption-record-controller |
| POST | `/gao/customer/create` | create | - | GaoCustomer_Public | string | gao-customer-controller |
| POST | `/gao/customer/delete` | delete | id* | - | - | gao-customer-controller |
| POST | `/gao/customer/detail` | detail | id* | - | GaoCustomer_Public | gao-customer-controller |
| POST | `/gao/customer/find/code` | findByCode | storeId*, code* | - | GaoCustomer_Public | gao-customer-controller |
| POST | `/gao/customer/find/id` | findById | id* | - | GaoCustomer_Public | gao-customer-controller |
| POST | `/gao/customer/find/name` | findByName | storeId*, name* | - | GaoCustomer_Public | gao-customer-controller |
| POST | `/gao/customer/follow-up-reminder/complete` | complete | id* | - | - | gao-customer-follow-up-reminder-controller |
| POST | `/gao/customer/follow-up-reminder/create` | create | - | GaoCustomerFollowUpReminder | string | gao-customer-follow-up-reminder-controller |
| POST | `/gao/customer/follow-up-reminder/delete` | delete | id* | - | - | gao-customer-follow-up-reminder-controller |
| POST | `/gao/customer/follow-up-reminder/detail` | detail | id* | - | GaoCustomerFollowUpReminder_Public | gao-customer-follow-up-reminder-controller |
| POST | `/gao/customer/follow-up-reminder/list` | list | - | GaoCustomerFollowUpReminderPage_Public | GaoCustomerFollowUpReminderPageResult_Public | gao-customer-follow-up-reminder-controller |
| POST | `/gao/customer/follow-up-reminder/update` | update | - | GaoCustomerFollowUpReminder | - | gao-customer-follow-up-reminder-controller |
| POST | `/gao/customer/invite/delete` | deleteInvite | customerId* | - | - | gao-customer-controller |
| POST | `/gao/customer/invite/save` | saveInvite | introducerCustomerId*, customerId* | - | - | gao-customer-controller |
| POST | `/gao/customer/invited/list` | listInvited | introducerCustomerId* | - | Array<GaoCustomer_Public> | gao-customer-controller |
| POST | `/gao/customer/list` | list | - | GaoCustomerPage_Public | PageResultGaoCustomer_Public | gao-customer-controller |
| POST | `/gao/customer/package/cancel` | cancel | - | GaoCustomerPackageCancelRequest | GaoCustomerPackage | gao-customer-package-controller |
| POST | `/gao/customer/package/detail` | detail | id* | - | GaoCustomerPackage | gao-customer-package-controller |
| POST | `/gao/customer/package/list` | list | - | GaoCustomerPackagePage | PageResultGaoCustomerPackage | gao-customer-package-controller |
| POST | `/gao/customer/package/purchase` | purchase | - | GaoCustomerPackagePurchaseRequest | GaoCustomerPackage | gao-customer-package-controller |
| POST | `/gao/customer/point/account/detail` | detailById | id*, storeId | - | GaoPointAccount | gao-point-account-controller |
| POST | `/gao/customer/point/account/detail/customer` | detail | customerId*, storeId | - | GaoPointAccount | gao-point-account-controller |
| POST | `/gao/customer/point/account/list` | list | - | GaoPointAccountPage | PageResultGaoPointAccount | gao-point-account-controller |
| POST | `/gao/customer/point/adjust` | adjust | - | GaoPointAdjustRequest | - | gao-point-ledger-controller |
| POST | `/gao/customer/point/ledger/detail` | detail | id*, storeId | - | GaoPointLedger | gao-point-ledger-controller |
| POST | `/gao/customer/point/ledger/list` | list | - | GaoPointLedgerPage | PageResultGaoPointLedger | gao-point-ledger-controller |
| POST | `/gao/customer/point/rule/create` | create | - | GaoPointRule | string | gao-point-rule-controller |
| POST | `/gao/customer/point/rule/delete` | delete | id* | - | - | gao-point-rule-controller |
| POST | `/gao/customer/point/rule/detail` | detail | id* | - | GaoPointRule | gao-point-rule-controller |
| POST | `/gao/customer/point/rule/list` | list | - | PageGaoPointRule | PageResultGaoPointRule | gao-point-rule-controller |
| POST | `/gao/customer/point/rule/script/list` | scriptList | - | - | Array<GroovyScript> | gao-point-rule-controller |
| POST | `/gao/customer/point/rule/sort` | sort | - | Array<string> | - | gao-point-rule-controller |
| POST | `/gao/customer/point/rule/update` | update | - | GaoPointRule | - | gao-point-rule-controller |
| POST | `/gao/customer/profile/pdf` | pdf | id* | - | - | gao-customer-profile-controller |
| POST | `/gao/customer/state/daily` | dailyStat | - | GaoCustomerTrendStateReq | Array<GaoCustomerDailyStateView> | gao-customer-controller |
| POST | `/gao/customer/state/gender` | genderStat | storeId* | - | Array<GaoCustomerGenderStatView> | gao-customer-controller |
| POST | `/gao/customer/update` | update | - | GaoCustomer | - | gao-customer-controller |
<a id="module-gao-data-export"></a>
## gao-data-export
共 3 个接口,路径前缀 `/gao/data-export/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/data-export/stat` | stat | - | GaoDataExportStatRequest | GaoDataExportStatView | gao-data-export-controller |
| POST | `/gao/data-export/task` | create | - | GaoDataExportCreateRequest | GaoDataExportTaskView | gao-data-export-controller |
| GET | `/gao/data-export/task/{taskId}` | detail | taskId* | - | GaoDataExportTaskView | gao-data-export-controller |
<a id="module-gao-event"></a>
## gao-event
共 20 个接口,路径前缀 `/gao/event/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/event/create` | create | - | GaoEvent | - | gao-event-controller |
| POST | `/gao/event/delete` | delete | id* | - | - | gao-event-controller |
| POST | `/gao/event/detail` | detail | id* | - | GaoEvent | gao-event-controller |
| POST | `/gao/event/list` | list | - | PageGaoEvent | PageResultGaoEvent | gao-event-controller |
| POST | `/gao/event/list/history` | listHistory | - | PageGaoEvent | PageResultGaoEvent | gao-event-controller |
| POST | `/gao/event/list/valid` | listValid | storeId* | - | Array<GaoEvent> | gao-event-controller |
| POST | `/gao/event/options/update` | updateOptions | id* | Array<GaoEventOptionGroup> | - | gao-event-controller |
| POST | `/gao/event/record/create` | create | - | GaoEventRecord | - | gao-event-record-controller |
| POST | `/gao/event/record/create/batch` | createBatch | - | Array<GaoEventRecord> | - | gao-event-record-controller |
| POST | `/gao/event/record/create/customer` | createWithCustomer | - | GaoCustomer | - | gao-event-record-controller |
| POST | `/gao/event/record/delete` | delete | id* | - | - | gao-event-record-controller |
| POST | `/gao/event/record/detail` | detail | id* | - | GaoEventRecord_Public | gao-event-record-controller |
| POST | `/gao/event/record/list` | list | - | GaoEventRecordPage_Public | GaoEventRecordPageResult_Public | gao-event-record-controller |
| POST | `/gao/event/record/month/pdf` | export | eventId*, month* | - | - | gao-event-month-export-controller |
| POST | `/gao/event/record/option/stat` | optionStat | - | GaoEventRecordPage | Array<GaoEventOptionStatView> | gao-event-record-controller |
| POST | `/gao/event/record/rank` | eventRank | - | GaoEventRecordRankPage | PageResultGaoCustomerEventRankView | gao-event-record-controller |
| POST | `/gao/event/record/update` | update | - | GaoEventRecord | - | gao-event-record-controller |
| POST | `/gao/event/record/verify` | verify | id* | - | - | gao-event-record-controller |
| POST | `/gao/event/sort` | sort | - | Array<string> | - | gao-event-controller |
| POST | `/gao/event/update` | update | - | GaoEvent | - | gao-event-controller |
<a id="module-gao-fund"></a>
## gao-fund
共 5 个接口,路径前缀 `/gao/fund/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/fund/record/detail` | detail | id* | - | GaoFundRecord | gao-fund-record-controller |
| POST | `/gao/fund/record/list` | list | - | GaoFundRecordPage | PageResultGaoFundRecord | gao-fund-record-controller |
| POST | `/gao/fund/record/my-receive/detail` | detailMyReceive | id* | - | GaoFundRecord | gao-fund-record-controller |
| POST | `/gao/fund/record/my-receive/list` | listMyReceive | - | GaoFundRecordPage | PageResultGaoFundRecord | gao-fund-record-controller |
| POST | `/gao/fund/record/revoke` | revoke | - | GaoFundRevokeRequest | GaoFundRecord | gao-fund-record-controller |
<a id="module-gao-notify"></a>
## gao-notify
共 2 个接口,路径前缀 `/gao/notify/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/notify/create` | create | - | Notify | Notify | gao-notify-controller |
| POST | `/gao/notify/recipient/list` | recipientList | - | PageGaoUser_Public | PageResultGaoUser_Public | gao-notify-controller |
<a id="module-gao-order"></a>
## gao-order
共 13 个接口,路径前缀 `/gao/order/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/order/fulfillment/cancel` | cancel | - | GaoOrderFulfillmentActionRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/create` | create | - | GaoOrderFulfillmentCreateRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/create-and-verify` | createAndVerify | - | GaoOrderFulfillmentCreateRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/detail` | detail | id* | - | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/list` | list | - | GaoOrderFulfillmentPage | PageResultGaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/prepare-stock` | prepareStock | - | GaoOrderFulfillmentPrepareStockRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/quick/create` | createQuickFulfillment | - | GaoQuickFulfillmentCreateRequest | Array<GaoOrderFulfillment> | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/quick/sku-list` | listQuickFulfillmentSku | - | GaoQuickFulfillmentCustomerRequest | Array<GaoQuickFulfillmentSkuView> | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/quick/source-order-list` | listQuickFulfillmentSourceOrder | - | GaoQuickFulfillmentSourceOrderListRequest | Array<GaoQuickFulfillmentSourceOrderView> | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/reject` | reject | - | GaoOrderFulfillmentActionRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/return` | returnGoods | - | GaoOrderFulfillmentReturnRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/revoke` | revoke | - | GaoOrderFulfillmentRevokeRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
| POST | `/gao/order/fulfillment/verify` | verify | - | GaoOrderFulfillmentActionRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
<a id="module-gao-package"></a>
## gao-package
共 6 个接口,路径前缀 `/gao/package/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/package/config/create` | create | - | GaoPackageConfig | string | gao-package-config-controller |
| POST | `/gao/package/config/delete` | delete | id* | - | - | gao-package-config-controller |
| POST | `/gao/package/config/detail` | detail | id* | - | GaoPackageConfig | gao-package-config-controller |
| POST | `/gao/package/config/list` | list | - | GaoPackageConfigPage | PageResultGaoPackageConfig | gao-package-config-controller |
| POST | `/gao/package/config/list/valid` | listValid | storeId* | - | Array<GaoPackageConfig> | gao-package-config-controller |
| POST | `/gao/package/config/update` | update | - | GaoPackageConfig | - | gao-package-config-controller |
<a id="module-gao-point"></a>
## gao-point
共 11 个接口,路径前缀 `/gao/point/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/point/redeem-sku/create` | create | - | GaoPointRedeemSkuRequest | GaoPointRedeemSku | gao-point-redeem-sku-controller |
| POST | `/gao/point/redeem-sku/delete` | delete | id*, storeId | - | - | gao-point-redeem-sku-controller |
| POST | `/gao/point/redeem-sku/detail` | detail | id*, storeId | - | GaoPointRedeemSku | gao-point-redeem-sku-controller |
| POST | `/gao/point/redeem-sku/disable` | disable | id*, storeId | - | - | gao-point-redeem-sku-controller |
| POST | `/gao/point/redeem-sku/list` | list | - | GaoPointRedeemSkuPage | GaoPointRedeemSkuPageResult | gao-point-redeem-sku-controller |
| POST | `/gao/point/redeem-sku/update` | update | - | GaoPointRedeemSkuRequest | GaoPointRedeemSku | gao-point-redeem-sku-controller |
| POST | `/gao/point/redemption/create` | create | - | GaoPointRedemptionCreateRequest | GaoPointRedemption | gao-point-redemption-controller |
| POST | `/gao/point/redemption/detail` | detail | id*, storeId | - | GaoPointRedemption | gao-point-redemption-controller |
| POST | `/gao/point/redemption/list` | list | - | GaoPointRedemptionPage | PageResultGaoPointRedemption | gao-point-redemption-controller |
| POST | `/gao/point/redemption/return` | returnRedemption | - | GaoPointRedemptionReturnRequest | GaoPointRedemption | gao-point-redemption-controller |
| POST | `/gao/point/redemption/return/list` | returnList | redemptionId*, storeId | - | Array<GaoPointRedemptionReturn> | gao-point-redemption-controller |
<a id="module-gao-product"></a>
## gao-product
共 51 个接口,路径前缀 `/gao/product/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/product/category/create` | categoryCreate | - | GaoProductCategory | string | gao-product-controller |
| POST | `/gao/product/category/disable` | categoryDisable | id* | - | - | gao-product-controller |
| POST | `/gao/product/category/list` | categoryList | - | GaoProductCategoryPage | PageResultGaoProductCategory | gao-product-controller |
| POST | `/gao/product/category/sort` | categorySort | - | Array<string> | - | gao-product-controller |
| POST | `/gao/product/category/update` | categoryUpdate | - | GaoProductCategory | - | gao-product-controller |
| POST | `/gao/product/chart/fulfillment/daily` | fulfillmentDaily | - | GaoProductChartReq | Array<GaoProductFulfillmentDailyStatView> | gao-product-chart-controller |
| POST | `/gao/product/chart/fulfillment/rank` | fulfillmentRank | - | GaoProductChartReq | Array<GaoProductFulfillmentRankView> | gao-product-chart-controller |
| POST | `/gao/product/chart/sales/daily` | salesDaily | - | GaoProductChartReq | Array<GaoProductSalesDailyStatView> | gao-product-chart-controller |
| POST | `/gao/product/chart/sales/rank` | salesRank | - | GaoProductChartReq | Array<GaoProductSalesRankView> | gao-product-chart-controller |
| POST | `/gao/product/chart/sales/unit/rank` | unitSalesRank | - | GaoProductChartReq | Array<GaoProductUnitSalesRankView> | gao-product-chart-controller |
| POST | `/gao/product/chart/stock/health` | stockHealth | - | GaoProductChartReq | Array<GaoProductStockHealthView> | gao-product-chart-controller |
| POST | `/gao/product/chart/stock/movement/daily` | stockMovementDaily | - | GaoProductChartReq | Array<GaoProductStockMovementDailyStatView> | gao-product-chart-controller |
| POST | `/gao/product/chart/structure/category` | category | - | GaoProductChartReq | Array<GaoProductCategoryStatView> | gao-product-chart-controller |
| POST | `/gao/product/chart/structure/type` | type | - | GaoProductChartReq | Array<GaoProductTypeStatView> | gao-product-chart-controller |
| POST | `/gao/product/create` | create | - | GaoProduct | string | gao-product-controller |
| POST | `/gao/product/delete` | delete | id* | - | - | gao-product-controller |
| POST | `/gao/product/detail` | detail | id* | - | GaoProduct | gao-product-controller |
| POST | `/gao/product/disable` | disable | id* | - | - | gao-product-controller |
| POST | `/gao/product/list` | list | - | GaoProductPage | PageResultGaoProduct | gao-product-controller |
| POST | `/gao/product/sellable/list` | sellableList | - | GaoProductPage | Array<GaoProduct> | gao-product-controller |
| POST | `/gao/product/sku/chart/fulfillment/daily` | fulfillmentDaily | - | GaoProductChartReq | Array<GaoProductSkuFulfillmentDailyStatView> | gao-product-sku-chart-controller |
| POST | `/gao/product/sku/chart/fulfillment/rank` | fulfillmentRank | - | GaoProductChartReq | Array<GaoProductSkuFulfillmentRankView> | gao-product-sku-chart-controller |
| POST | `/gao/product/sku/chart/sales/daily` | salesDaily | - | GaoProductChartReq | Array<GaoProductSkuSalesDailyStatView> | gao-product-sku-chart-controller |
| POST | `/gao/product/sku/chart/sales/rank` | salesRank | - | GaoProductChartReq | Array<GaoProductSkuSalesRankView> | gao-product-sku-chart-controller |
| POST | `/gao/product/sku/chart/sales/unit/rank` | unitSalesRank | - | GaoProductChartReq | Array<GaoProductSkuUnitSalesRankView> | gao-product-sku-chart-controller |
| POST | `/gao/product/sku/chart/stock/health` | stockHealth | - | GaoProductChartReq | Array<GaoProductSkuStockHealthView> | gao-product-sku-chart-controller |
| POST | `/gao/product/sku/chart/stock/movement/daily` | stockMovementDaily | - | GaoProductChartReq | Array<GaoProductSkuStockMovementDailyStatView> | gao-product-sku-chart-controller |
| POST | `/gao/product/sku/create` | skuCreate | - | GaoProductSku | string | gao-product-controller |
| POST | `/gao/product/sku/detail` | skuDetail | id* | - | GaoProductSku | gao-product-controller |
| POST | `/gao/product/sku/disable` | skuDisable | id* | - | - | gao-product-controller |
| POST | `/gao/product/sku/fulfillment-list` | skuFulfillmentList | - | Array<string> | Array<GaoProductSkuFulfillmentView> | gao-product-controller |
| POST | `/gao/product/sku/update` | skuUpdate | - | GaoProductSku | - | gao-product-controller |
| POST | `/gao/product/spec/create` | specCreate | - | GaoProductSpec | string | gao-product-controller |
| POST | `/gao/product/spec/list` | specList | productId* | - | Array<GaoProductSpec> | gao-product-controller |
| POST | `/gao/product/spec/update` | specUpdate | - | GaoProductSpec | - | gao-product-controller |
| POST | `/gao/product/spec/value/create` | specValueCreate | - | GaoProductSpecValue | string | gao-product-controller |
| POST | `/gao/product/spec/value/update` | specValueUpdate | - | GaoProductSpecValue | - | gao-product-controller |
| POST | `/gao/product/stock/batch-detail` | batchDetail | - | GaoProductStockBatchRequest | Array<GaoProductStock> | gao-product-stock-controller |
| POST | `/gao/product/stock/detail` | detail | storeId, skuId* | - | GaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/stock/initial-in` | initialIn | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/stock/list` | list | - | GaoProductStockPage | PageResultGaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/stock/manual-in` | manualIn | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/stock/manual-in/batch` | manualInBatch | - | GaoProductStockManualInBatchRequest | Array<GaoProductStock> | gao-product-stock-controller |
| POST | `/gao/product/stock/manual-out` | manualOut | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/stock/manual-revoke` | manualRevoke | - | GaoProductStockManualRevokeRequest | GaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/stock/product-list` | productList | - | GaoProductStockPage | PageResultGaoProductStockProductView | gao-product-stock-controller |
| POST | `/gao/product/stock/record/detail` | recordDetail | id* | - | GaoProductStockRecord | gao-product-stock-controller |
| POST | `/gao/product/stock/record/list` | recordList | - | GaoProductStockRecordPage | GaoProductStockRecordPageResult | gao-product-stock-controller |
| POST | `/gao/product/stock/stocktake-gain` | stocktakeGain | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/stock/stocktake-loss` | stocktakeLoss | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
| POST | `/gao/product/update` | update | - | GaoProduct | - | gao-product-controller |
<a id="module-gao-recycle"></a>
## gao-recycle
共 32 个接口,路径前缀 `/gao/recycle/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/recycle/account/customers` | customers | - | GaoRecycleAccountCustomerPage | GaoRecycleAccountCustomerPageResult | gao-recycle-account-controller |
| POST | `/gao/recycle/account/items` | accountItems | storeId* | - | Array<GaoRecycleItem> | gao-recycle-account-controller |
| POST | `/gao/recycle/account/list` | list | storeId*, customerId* | - | Array<GaoRecycleAccount> | gao-recycle-account-controller |
| POST | `/gao/recycle/account/yield/delete` | deleteYield | storeId*, skuId*, recycleItemId* | - | - | gao-recycle-account-controller |
| POST | `/gao/recycle/account/yield/list` | yields | storeId*, skuId* | - | Array<GaoRecycleProductYield> | gao-recycle-account-controller |
| POST | `/gao/recycle/account/yield/product/list` | yieldsByProduct | storeId*, productId* | - | Array<GaoRecycleProductYield> | gao-recycle-account-controller |
| POST | `/gao/recycle/account/yield/save` | saveYield | storeId*, skuId*, recycleItemId*, quantityPerBase* | - | - | gao-recycle-account-controller |
| POST | `/gao/recycle/config/item/detail` | itemDetail | storeId, id* | - | GaoRecycleItem | gao-recycle-config-controller |
| POST | `/gao/recycle/config/item/save` | saveItem | - | GaoRecycleItemRequest | GaoRecycleItem | gao-recycle-config-controller |
| POST | `/gao/recycle/config/items` | items | storeId, status, keyword, offset, limit | - | PageResultGaoRecycleItem | gao-recycle-config-controller |
| POST | `/gao/recycle/config/rule/delete` | deleteRule | storeId, id* | - | - | gao-recycle-config-controller |
| POST | `/gao/recycle/config/rule/detail` | ruleDetail | storeId, id* | - | GaoRecycleExchangeRule | gao-recycle-config-controller |
| POST | `/gao/recycle/config/rule/save` | saveRule | - | GaoRecycleExchangeRuleRequest | GaoRecycleExchangeRule | gao-recycle-config-controller |
| POST | `/gao/recycle/config/rules` | rules | storeId, status, recycleItemId, skuId, keyword, offset, limit | - | PageResultGaoRecycleExchangeRule | gao-recycle-config-controller |
| POST | `/gao/recycle/config/rules/active` | activeRules | storeId, recycleItemId, skuId, keyword, offset, limit | - | PageResultGaoRecycleExchangeRule | gao-recycle-config-controller |
| POST | `/gao/recycle/exchange/create` | create | - | GaoRecycleExchangeCreateRequest | GaoRecycleExchange | gao-recycle-exchange-write-controller |
| POST | `/gao/recycle/exchange/detail` | detail | id* | - | GaoRecycleExchangeDetail | gao-recycle-exchange-query-controller |
| POST | `/gao/recycle/ledger/adjust` | adjust | - | GaoRecycleAccountAdjustRequest | - | gao-recycle-ledger-controller |
| POST | `/gao/recycle/ledger/detail` | detail | id* | - | GaoRecycleLedger | gao-recycle-ledger-controller |
| POST | `/gao/recycle/ledger/list` | list | - | GaoRecycleLedgerPage | PageResultGaoRecycleLedger | gao-recycle-ledger-controller |
| POST | `/gao/recycle/payment/cancel` | cancel | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/create` | create | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/create-and-verify` | createAndVerify | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/detail` | detail | id* | - | GaoRecyclePayment | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/list` | list | orderId* | - | Array<GaoRecyclePayment> | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/reject` | reject | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/revoke` | revoke | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/search` | search | storeId, customerId, orderId, status, beginAt, endAt, offset, limit | - | Array<GaoRecyclePayment> | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/transactions` | transactions | orderId* | - | Array<GaoOrderTransactionView> | gao-recycle-payment-controller |
| POST | `/gao/recycle/payment/verify` | verify | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
| POST | `/gao/recycle/stat/exchange` | exchange | storeId, startAt*, endAt* | - | Array<GaoRecycleExchangeStatView> | gao-recycle-stat-controller |
| POST | `/gao/recycle/stat/recycle` | recycle | storeId, startAt*, endAt* | - | Array<GaoRecycleStatView> | gao-recycle-stat-controller |
<a id="module-gao-report"></a>
## gao-report
共 1 个接口,路径前缀 `/gao/report/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/report/options/customers` | customers | storeId, keyword, offset | - | Array<GaoReportOption> | gao-report-option-controller |
<a id="module-gao-role"></a>
## gao-role
共 2 个接口,路径前缀 `/gao/role/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/role/available/list` | availableList | - | - | Array<Role> | gao-role-controller |
| POST | `/gao/role/management/list` | managementList | - | - | Array<Role> | gao-role-controller |
<a id="module-gao-sales"></a>
## gao-sales
共 27 个接口,路径前缀 `/gao/sales/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/sales/order/cancel` | cancel | - | GaoSalesOrderCancelRequest | GaoSalesOrder | gao-sales-order-controller |
| POST | `/gao/sales/order/chart/customer/calendar` | calendar | - | GaoSalesOrderChartReq | Array<GaoSalesOrderCalendarStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/customer/consumption/daily` | consumptionDaily | - | GaoSalesOrderChartReq | Array<GaoSalesOrderConsumptionDailyStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/customer/product/rank` | customerProductRank | - | GaoSalesOrderChartReq | Array<GaoCustomerOrderProductRankView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/customer/rank` | customerRank | - | GaoSalesOrderChartReq | Array<GaoCustomerOrderRankView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/customer/repeat/daily` | repeatDaily | - | GaoSalesOrderChartReq | Array<GaoCustomerRepeatDailyStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/customer/repeat/interval` | repeatInterval | - | GaoSalesOrderChartReq | Array<GaoCustomerRepeatIntervalStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/customer/sku/rank` | customerSkuRank | - | GaoSalesOrderChartReq | Array<GaoCustomerOrderSkuRankView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/daily` | daily | - | GaoSalesOrderChartReq | Array<GaoSalesOrderDailyStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/payment` | payment | - | GaoSalesOrderChartReq | Array<GaoSalesOrderPaymentStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/receivable` | receivable | - | GaoSalesOrderChartReq | GaoSalesOrderReceivableStatView | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/status` | status | - | GaoSalesOrderChartReq | Array<GaoSalesOrderStatusStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/chart/type` | type | - | GaoSalesOrderChartReq | Array<GaoSalesOrderTypeStatView> | gao-sales-order-chart-controller |
| POST | `/gao/sales/order/customer-product/list` | customerProductList | - | GaoCustomerProductPage | PageResultGaoCustomerProductCustomerView | gao-sales-order-controller |
| POST | `/gao/sales/order/detail` | detail | id* | - | GaoSalesOrder | gao-sales-order-controller |
| POST | `/gao/sales/order/direct-product/create` | createDirectProduct | - | GaoDirectProductOrderCreateRequest | GaoSalesOrder | gao-sales-order-controller |
| POST | `/gao/sales/order/fund/revoke` | revoke | - | GaoOrderPaymentRevokeRequest | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/list` | list | - | GaoSalesOrderPage | PageResultGaoSalesOrder | gao-sales-order-controller |
| POST | `/gao/sales/order/payment/cancel` | cancelPayment | - | GaoOrderPaymentActionRequest | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/payment/receive` | receive | - | GaoOrderPaymentReceiveRequest | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/payment/receive-and-verify` | receiveAndVerify | - | GaoOrderPaymentReceiveRequest | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/payment/reject` | reject | - | GaoOrderPaymentActionRequest | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/payment/verify` | verify | id* | - | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/refund` | refund | - | GaoOrderPaymentRefundRequest | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/refund/confirm-none` | confirmNoRefund | - | GaoOrderPaymentNoRefundRequest | GaoFundRecord | gao-sales-order-controller |
| POST | `/gao/sales/order/summary` | summary | - | GaoSalesOrderPage | GaoSalesOrderReceivableStatView | gao-sales-order-controller |
| POST | `/gao/sales/order/update` | update | - | GaoSalesOrderUpdateRequest | GaoSalesOrder | gao-sales-order-controller |
<a id="module-gao-store"></a>
## gao-store
共 28 个接口,路径前缀 `/gao/store/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/store/business/day/calendar` | calendar | storeId*, beginDateValue*, endDateValue* | - | Array<GaoStoreBusinessDay> | gao-store-business-day-controller |
| POST | `/gao/store/business/day/create` | create | - | GaoStoreBusinessDay | string | gao-store-business-day-controller |
| POST | `/gao/store/business/day/delete` | delete | id* | - | - | gao-store-business-day-controller |
| POST | `/gao/store/business/day/detail` | detail | id* | - | GaoStoreBusinessDay | gao-store-business-day-controller |
| POST | `/gao/store/business/day/list` | list | - | PageGaoStoreBusinessDay | PageResultGaoStoreBusinessDay | gao-store-business-day-controller |
| POST | `/gao/store/business/day/update` | update | - | GaoStoreBusinessDay | - | gao-store-business-day-controller |
| POST | `/gao/store/chart/customer/age` | customerAge | storeId* | - | Array<GaoCustomerAgeStatView> | gao-store-chart-controller |
| POST | `/gao/store/chart/customer/daily` | customerDaily | - | GaoStoreChartReq | Array<GaoCustomerDailyStateView> | gao-store-chart-controller |
| POST | `/gao/store/chart/customer/gender` | customerGender | storeId* | - | Array<GaoCustomerGenderStatView> | gao-store-chart-controller |
| POST | `/gao/store/chart/event/record/calendar` | eventRecordCalendar | - | GaoStoreChartReq | Array<GaoEventRecordCalendarView> | gao-store-chart-controller |
| POST | `/gao/store/chart/event/record/daily` | eventRecordDaily | - | GaoStoreChartReq | Array<GaoEventRecordDailyStatView> | gao-store-chart-controller |
| POST | `/gao/store/chart/event/record/number-value/daily` | eventRecordNumberValueDaily | - | GaoStoreChartReq | Array<GaoEventRecordNumberValueDailyStatView> | gao-store-chart-controller |
| POST | `/gao/store/chart/point/ledger/daily` | pointDaily | - | GaoStoreChartReq | Array<GaoPointDailyStatView> | gao-store-chart-controller |
| POST | `/gao/store/chart/point/redemption/product/rank` | pointRedemptionProductRank | - | GaoStoreChartReq | Array<GaoPointRedemptionProductRankView> | gao-store-chart-controller |
| POST | `/gao/store/create` | create | - | GaoStore | string | gao-store-controller |
| POST | `/gao/store/delete` | delete | id* | - | - | gao-store-controller |
| POST | `/gao/store/detail` | detail | id* | - | GaoStore | gao-store-controller |
| POST | `/gao/store/diary/create` | create | - | Article | string | gao-store-diary-controller |
| POST | `/gao/store/diary/delete` | delete | id* | - | - | gao-store-diary-controller |
| POST | `/gao/store/diary/detail` | detail | id* | - | Article_Public | gao-store-diary-controller |
| POST | `/gao/store/diary/list` | list | - | GaoStoreDiaryPage_Public | PageResultArticle_Public | gao-store-diary-controller |
| POST | `/gao/store/diary/update` | update | - | Article | - | gao-store-diary-controller |
| POST | `/gao/store/list` | list | - | PageGaoStore | PageResultGaoStore | gao-store-controller |
| POST | `/gao/store/setting/map` | map | - | Array<string> | Map<String, Setting> | gao-store-setting-controller |
| POST | `/gao/store/setting/update` | update | - | Array<Setting> | - | gao-store-setting-controller |
| POST | `/gao/store/sort` | sort | - | Array<string> | - | gao-store-controller |
| POST | `/gao/store/update` | update | - | GaoStore | - | gao-store-controller |
| POST | `/gao/store/user` | getLoginStore | - | - | GaoStore | gao-store-controller |
<a id="module-gao-tag"></a>
## gao-tag
共 7 个接口,路径前缀 `/gao/tag/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/tag/apply` | apply | - | TagApply | - | gao-tag-controller |
| POST | `/gao/tag/create` | create | - | Tag_Public | Tag_Public | gao-tag-controller |
| POST | `/gao/tag/delete` | delete | id* | - | - | gao-tag-controller |
| POST | `/gao/tag/detail` | detail | id* | - | Tag_Public | gao-tag-controller |
| POST | `/gao/tag/list` | list | - | PageTag_Public | PageResultTag_Public | gao-tag-controller |
| GET | `/gao/tag/list/biz/id` | listByBizType | bizType*, bizId* | - | Array<Tag_Public> | gao-tag-controller |
| POST | `/gao/tag/update` | update | - | Tag | - | gao-tag-controller |
<a id="module-gao-user"></a>
## gao-user
共 10 个接口,路径前缀 `/gao/user/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/gao/user/create` | create | - | GaoUser_Public | GaoUser_Public | gao-user-controller |
| POST | `/gao/user/delete` | delete | id* | - | - | gao-user-controller |
| POST | `/gao/user/detail` | detail | id* | - | GaoUser_Public | gao-user-controller |
| POST | `/gao/user/invite` | invite | - | GaoUserInviteCreateRequest | GaoUserInviteCreateResponse | gao-user-controller |
| POST | `/gao/user/invite/register` | registerByInvite | - | GaoUserInviteRegisterRequest_Public | LoginResponse_Public | gao-user-controller |
| POST | `/gao/user/invite/validate` | validateInvite | - | GaoUserInviteValidateRequest | GaoUserInviteValidateResponse | gao-user-controller |
| POST | `/gao/user/list` | list | - | PageGaoUser_Public | PageResultGaoUser_Public | gao-user-controller |
| POST | `/gao/user/role/list` | roleList | - | - | Array<Role> | gao-user-controller |
| POST | `/gao/user/transfer/store` | transferStore | - | GaoUser_Public | GaoUser_Public | gao-user-controller |
| POST | `/gao/user/update` | update | - | GaoUser_Public | GaoUser_Public | gao-user-controller |
<a id="module-system"></a>
## system
共 48 个接口,路径前缀 `/system/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET | `/system/docker/container` | listContainers | - | - | Array<DockerContainerSummaryView> | docker-controller |
| GET | `/system/docker/container/{containerId}/history` | getContainerHistory | containerId*, window | - | DockerContainerHistoryView | docker-controller |
| GET | `/system/docker/container/{containerId}/status` | getContainerStatus | containerId* | - | DockerContainerStatusView | docker-controller |
| POST | `/system/file/copy` | 创建复制任务 | - | ArchiveRequest | string | 系统-文件归档 |
| POST | `/system/file/cut` | 创建移动任务 | - | ArchiveRequest | string | 系统-文件归档 |
| POST | `/system/file/delete` | 删除到回收站 | - | FileListRequest | Array<FileTrash> | 系统-文件回收站 |
| GET/HEAD | `/system/file/download/{path}` | 下载文件 | path* | - | - | 系统-文件内容 |
| GET | `/system/file/exist` | 判断路径是否存在 | path* | - | boolean | 系统-文件 |
| GET | `/system/file/hash` | 计算文件 SHA-256 | path* | - | FileHash | 系统-文件 |
| GET | `/system/file/list` | 获取目录列表 | path | - | Array<ServerFile> | 系统-文件 |
| POST | `/system/file/mkdir` | 创建目录 | - | MkdirRequest | ServerFile | 系统-文件 |
| GET | `/system/file/object/{path}` | 获取文件属性 | path* | - | ServerFile | 系统-文件 |
| GET | `/system/file/preview/{path}` | 预览文件 | path* | - | - | 系统-文件内容 |
| GET | `/system/file/read/{path}` | 读取文件 | path* | - | - | 系统-文件内容 |
| POST | `/system/file/rename` | 重命名或移动 | - | RenameRequest | ServerFile | 系统-文件 |
| POST | `/system/file/search` | 搜索文件 | - | SearchRequest | SearchResult | 系统-文件 |
| GET | `/system/file/share` | 获取分享列表 | - | - | Array<FileShare> | 系统-文件分享 |
| POST | `/system/file/share` | 创建文件分享 | - | ShareCreateRequest | FileShare | 系统-文件分享 |
| DELETE | `/system/file/share/{id}` | 取消文件分享 | id* | - | FileShare | 系统-文件分享 |
| GET/HEAD | `/system/file/share/{token}/download` | [公开] 下载分享文件 | token*, password | - | - | 系统-文件分享 |
| POST | `/system/file/size` | 统计目录大小 | - | PathRequest | string | 系统-文件 |
| POST | `/system/file/tar` | 创建 TAR 压缩任务 | - | ArchiveRequest | string | 系统-文件归档 |
| GET | `/system/file/trash` | 获取回收站列表 | - | - | Array<FileTrash> | 系统-文件回收站 |
| DELETE | `/system/file/trash` | 清空回收站 | - | - | integer | 系统-文件回收站 |
| POST | `/system/file/trash/restore` | 恢复回收站文件 | - | IdRequest | ServerFile | 系统-文件回收站 |
| DELETE | `/system/file/trash/{id}` | 彻底删除回收站记录 | id* | - | - | 系统-文件回收站 |
| POST | `/system/file/untar` | 创建 TAR 解压任务 | - | UnarchiveRequest | string | 系统-文件归档 |
| POST | `/system/file/unzip` | 创建 ZIP 解压任务 | - | UnarchiveRequest | string | 系统-文件归档 |
| POST | `/system/file/upload` | 上传文件 | path*, name*, overwrite | object{file} | ServerFile | 系统-文件上传 |
| POST | `/system/file/upload/chunk` | 上传分片 | uploadId*, index* | object{file} | - | 系统-文件上传 |
| POST | `/system/file/upload/complete` | 完成分片上传 | - | UploadCompleteRequest | ServerFile | 系统-文件上传 |
| POST | `/system/file/upload/init` | 初始化分片上传 | - | UploadInitRequest | UploadInit | 系统-文件上传 |
| POST | `/system/file/zip` | 创建 ZIP 压缩任务 | - | ArchiveRequest | string | 系统-文件归档 |
| POST | `/system/multilingual/create` | create | - | Multilingual_Admin | Multilingual_Admin | multilingual-controller |
| POST | `/system/multilingual/delete` | delete | id* | - | - | multilingual-controller |
| POST | `/system/multilingual/detail` | detail | id* | - | Multilingual_Admin | multilingual-controller |
| POST | `/system/multilingual/update` | update | - | Multilingual | - | multilingual-controller |
| GET | `/system/server/status` | getStatus | metrics | - | SystemStatusSnapshotView | system-controller |
| GET | `/system/server/status/history` | getStatusHistory | window, metrics | - | SystemStatusHistoryView | system-controller |
| POST | `/system/task/debug` | 创建调试任务 | second | - | string | 系统-异步任务 |
| GET | `/system/task/detail` | 获取任务详情 | uuid* | - | AbstractAsyncTask | 系统-异步任务 |
| GET | `/system/task/events` | 订阅任务事件 | uuid* | - | SSE | 系统-异步任务 |
| POST | `/system/task/interrupt` | 中断任务 | uuid* | - | - | 系统-异步任务 |
| POST | `/system/task/list` | 获取任务列表 | - | - | Array<AsyncTaskView> | 系统-异步任务 |
| POST | `/system/task/pause` | 暂停任务 | uuid* | - | - | 系统-异步任务 |
| POST | `/system/task/start` | 启动任务 | uuid* | - | - | 系统-异步任务 |
| GET | `/system/ups/history` | getHistory | window | - | UpsHistoryView | ups-controller |
| GET | `/system/ups/status` | getStatus | - | - | UpsStatusView | ups-controller |
<a id="module-user"></a>
## user
共 44 个接口,路径前缀 `/user/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/user/api-key/create` | create | - | CreateRequest | CreateResult | user-api-key-controller |
| POST | `/user/api-key/delete` | delete | id* | - | - | user-api-key-controller |
| POST | `/user/api-key/list` | list | - | - | Array<KeyInfo> | user-api-key-controller |
| POST | `/user/api-key/revoke` | revoke | id* | - | - | user-api-key-controller |
| POST | `/user/cancel` | cancel | - | CancelRequest | - | user-controller |
| POST | `/user/create` | create | - | User | - | user-controller |
| POST | `/user/current/update` | updateCurrent | - | User | LoginResponse | user-controller |
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/user/delete` | delete | id* | - | - | user-controller |
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/user/detail` | detail | id* | - | User | user-controller |
| POST | `/user/list` | list | - | PageUser | PageResultUser | user-controller |
| POST | `/user/login` | login | - | CaptchaDataLoginRequest_Public | LoginResponse_Public | user-controller |
| POST | `/user/login/sms` | loginBySms | - | SmsCaptchaVerifyRequest_Public | LoginResponse_Public | user-controller |
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/user/login/token` | token | - | - | LoginResponse_Public | user-controller |
| POST | `/user/logout` | logout | - | - | - | user-controller |
| POST | `/user/permission/grantable/list` | listGrantable | moduleCode* | - | Array<Permission> | permission-controller |
| POST | `/user/permission/list` | list | - | PagePermission | PageResultPermission | permission-controller |
| POST | `/user/permission/update` | update | - | Permission | - | permission-controller |
| POST | `/user/phone/verify` | verifyPhone | - | PhoneVerifyRequest | - | user-controller |
| POST | `/user/phone/verify/send` | sendPhoneCode | - | PhoneVerifyCodeSendRequest | - | user-controller |
| POST | `/user/register` | register | - | CaptchaDataUser_Public | LoginResponse_Public | user-controller |
| POST | `/user/role/authorized/create` | authorizeUserRole | - | UserRoleAuthorizeRequest | - | role-controller |
| POST | `/user/role/authorized/list` | listUserRole | moduleCode, userId* | - | Array<Role> | role-controller |
| POST | `/user/role/authorized/permission` | listAuthorizedPermission | userId* | - | Array<Permission> | role-controller |
| POST | `/user/role/create` | create | - | Role | - | role-controller |
| POST | `/user/role/current/detail/list` | listCurrentRoleDetail | moduleCode | - | Array<Role> | role-controller |
| POST | `/user/role/delegation/grantable/list` | listGrantableDelegationPermission | roleId* | - | Array<Permission> | role-controller |
| POST | `/user/role/delegation/list` | listDelegationPermission | roleId* | - | Array<Permission> | role-controller |
| POST | `/user/role/delegation/update` | updateRoleDelegation | - | Role | - | role-controller |
| POST | `/user/role/delete` | delete | id* | - | - | role-controller |
| POST | `/user/role/detail` | detail | id* | - | Role | role-controller |
| POST | `/user/role/grantable/list` | listGrantableRole | moduleCode* | - | Array<Role> | role-controller |
| POST | `/user/role/list` | list | - | PageRole | PageResultRole | role-controller |
| POST | `/user/role/manageable/list` | listManageableRole | moduleCode* | - | Array<Role> | role-controller |
| POST | `/user/role/parent/create/grantable/list` | listCreateGrantableParentRole | moduleCode* | - | Array<Role> | role-controller |
| POST | `/user/role/parent/grantable/list` | listGrantableParentRole | roleId* | - | Array<Role> | role-controller |
| POST | `/user/role/parent/update` | updateRoleParent | - | Role | - | role-controller |
| POST | `/user/role/permission/grantable/list` | listGrantableRolePermission | roleId* | - | Array<Permission> | role-controller |
| POST | `/user/role/update` | update | - | Role | - | role-controller |
| POST | `/user/update` | update | - | User | - | user-controller |
| POST | `/user/update/email` | updateEmail | - | - | - | user-controller |
| POST | `/user/update/password` | updatePassword | - | UpdatePasswordRequest | - | user-controller |
<a id="module-app"></a>
## app
共 13 个接口,路径前缀 `/app/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/app/channel/delete` | channelDelete | channelId* | - | - | app-release-controller |
| GET | `/app/channel/list` | channelList | productId* | - | Array<AppChannel> | app-release-controller |
| POST | `/app/product/delete` | productDelete | productId* | - | - | app-release-controller |
| POST | `/app/product/list` | productList | - | - | Array<AppProduct> | app-release-controller |
| POST | `/app/product/save` | productSave | - | AppProduct | AppProduct | app-release-controller |
| POST | `/app/release/create` | releaseCreate | - | AppRelease | AppRelease | app-release-controller |
| POST | `/app/release/delete` | releaseDelete | releaseId* | - | - | app-release-controller |
| GET | `/app/release/list` | releaseList | productId* | - | Array<AppRelease> | app-release-controller |
| POST | `/app/release/publish` | publish | releaseId*, channelCode, grayPermille, note | - | - | app-release-controller |
| POST | `/app/release/revoke` | revoke | releaseId* | - | - | app-release-controller |
| POST | `/app/release/rollback` | rollback | productId*, channelCode, targetReleaseId* | - | - | app-release-controller |
| POST | `/app/update/check` | check | - | AppUpdateCheckRequest | AppUpdateCheckResponse | app-update-controller |
| POST | `/app/update/notes` | notes | - | AppUpdateCheckRequest | AppUpdateNotesResponse | app-update-controller |
<a id="module-.well-known"></a>
## .well-known
共 6 个接口,路径前缀 `/.well-known/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET | `/.well-known/oauth-authorization-server` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
| GET | `/.well-known/oauth-authorization-server/mcp/gao-ai` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
| GET | `/.well-known/oauth-protected-resource` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
| GET | `/.well-known/oauth-protected-resource/mcp/gao-ai` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
| GET | `/.well-known/openid-configuration` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
| GET | `/.well-known/openid-configuration/mcp/gao-ai` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
<a id="module-article"></a>
## article
共 5 个接口,路径前缀 `/article/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/article/create` | create | - | Article_Public | Article_Public | article-controller |
| POST | `/article/delete` | delete | id* | - | - | article-controller |
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/article/detail` | detail | id* | - | Article_Public | article-controller |
| POST | `/article/list` | list | - | PageArticle_Public | PageResultArticle_Public | article-controller |
| POST | `/article/update` | update | - | Article | - | article-controller |
<a id="module-attach"></a>
## attach
共 14 个接口,路径前缀 `/attach/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET | `/attach/count/biz` | countByBiz | bizType*, bizId*, attachTypeList | - | integer | attachment-controller |
| POST | `/attach/create` | create | - | Attachment (multipart/form-data) | Attachment | attachment-controller |
| POST | `/attach/delete` | delete | id* | - | - | attachment-controller |
| POST | `/attach/detail` | detail | id* | - | Attachment | attachment-controller |
| GET | `/attach/detail/byAttachType` | detailByAttachType | bizType*, bizId*, attachType* | - | Attachment | attachment-controller |
| GET | `/attach/detail/byBiz` | detailByBiz | bizType*, bizId* | - | Attachment | attachment-controller |
| GET | `/attach/download/{id}` | readById | id*, thumbWidth, thumbHeight, fitMode | - | - | attachment-controller |
| GET | `/attach/list/biz` | listByBiz | bizType*, bizId*, attachTypeList | - | Array<Attachment> | attachment-controller |
| POST | `/attach/page/biz` | pageByBiz | bizType*, bizId*, attachTypeList | PageAttachment | PageResultAttachment | attachment-controller |
| GET | `/attach/read/{id}` | readById | id*, thumbWidth, thumbHeight, fitMode | - | - | attachment-controller |
| GET | `/attach/temp/download` | read | id* | - | - | attachment-controller |
| GET | `/attach/temp/read` | read | id* | - | - | attachment-controller |
| POST | `/attach/temp/upload` | upload | file*, ttl | - | Array<TempFileResp> | attachment-controller |
| POST | `/attach/update` | update | - | Attachment (multipart/form-data) | - | attachment-controller |
<a id="module-captcha"></a>
## captcha
共 2 个接口,路径前缀 `/captcha/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET | `/captcha` | captcha | width*, height* | - | Result | common-controller |
| GET | `/captcha/img` | captchaImg | width*, height* | - | - | common-controller |
<a id="module-comment"></a>
## comment
共 13 个接口,路径前缀 `/comment/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/comment/create` | create | - | CommentCreateReq_Public | Comment_Public | comment-controller |
| POST | `/comment/delete` | delete | id*, userId* | - | - | comment-controller |
| GET | `/comment/detail/tree` | detailTree | id*, currentUserId | - | Comment_Public | comment-controller |
| GET | `/comment/flat/list` | listFlatRoot | bizType*, bizId*, offset, currentUserId | - | FlatCommentListResp_Public | comment-controller |
| GET | `/comment/flat/thread` | getFlatThread | commentId*, offset, currentUserId | - | CommentThreadResp_Public | comment-controller |
| POST | `/comment/layer/list` | listLayer | currentUserId | CommentLayerQueryReq_Public | CommentLayerResp_Public | comment-controller |
| POST | `/comment/like` | like | commentId*, userId* | - | - | comment-controller |
| POST | `/comment/like/list` | listLikedRecord | userId* | PageUserBehaviorRecord_Public | PageResultUserBehaviorRecord_Public | comment-controller |
| GET | `/comment/nested/children` | getNestedChildren | commentId*, offset, currentUserId | - | CommentLayerResp_Public | comment-controller |
| GET | `/comment/nested/detail` | getNestedDetail | commentId*, currentUserId | - | CommentNodeResp_Public | comment-controller |
| GET | `/comment/nested/list` | listNestedRoot | bizType*, bizId*, offset, currentUserId | - | NestedCommentListResp_Public | comment-controller |
| POST | `/comment/reply` | reply | - | CommentReplyReq_Public | Comment_Public | comment-controller |
| POST | `/comment/unlike` | unlike | commentId*, userId* | - | - | comment-controller |
<a id="module-feedback"></a>
## feedback
共 5 个接口,路径前缀 `/feedback/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/feedback/create` | create | - | CaptchaDataFeedback_Public | - | feedback-controller |
| POST | `/feedback/delete` | delete | id* | - | - | feedback-controller |
| POST | `/feedback/detail` | detail | id* | - | Feedback_Admin | feedback-controller |
| POST | `/feedback/list` | list | - | PageFeedback_Admin | PageResultFeedback_Admin | feedback-controller |
| POST | `/feedback/update` | update | - | Feedback | - | feedback-controller |
<a id="module-fmc"></a>
## fmc
共 1 个接口,路径前缀 `/fmc/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/fmc/server/report` | report | - | - | - | server-controller |
<a id="module-icon"></a>
## icon
共 4 个接口,路径前缀 `/icon/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET | `/icon/export/ttf` | exportTtf | - | - | - | icon-controller |
| GET | `/icon/name/list` | listName | - | - | Array<string> | icon-controller |
| GET | `/icon/svg/map` | mapSvg | - | - | Map<String, string> | icon-controller |
| GET | `/icon/unicode/map` | mapUnicode | - | - | Map<String, string> | icon-controller |
<a id="module-journal"></a>
## journal
共 7 个接口,路径前缀 `/journal/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET | `/journal/tool/memo` | getMemo | - | - | string | tool-controller |
| POST | `/journal/tool/memo/update` | updateMemo | data* | - | - | tool-controller |
| POST | `/journal/travel/create` | create | - | Travel | - | travel-controller |
| POST | `/journal/travel/delete` | delete | - | string | - | travel-controller |
| POST | `/journal/travel/list` | list | - | PageTravel | PageResultTravel | travel-controller |
| POST | `/journal/travel/update` | update | - | Travel | - | travel-controller |
| GET | `/journal/travel/{id}` | detail | id* | - | Travel | travel-controller |
<a id="module-log"></a>
## log
共 1 个接口,路径前缀 `/log/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/log/create` | create | - | ClientLogRequest | - | logger-controller |
<a id="module-mcp"></a>
## mcp
共 5 个接口,路径前缀 `/mcp/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/mcp/gao-ai` | handle | header:Authorization, header:X-Timi-AI-Session | JsonNode | object | gao-ai-mcp-controller |
| POST | `/mcp/gao-ai-commit` | handle | header:Authorization, header:X-Timi-AI-Session | JsonNode | object | gao-ai-mcp-commit-controller |
| GET | `/mcp/gao-ai/.well-known/oauth-authorization-server` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
| GET | `/mcp/gao-ai/.well-known/oauth-protected-resource` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
| GET | `/mcp/gao-ai/.well-known/openid-configuration` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
<a id="module-mirror"></a>
## mirror
共 2 个接口,路径前缀 `/mirror/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET | `/mirror/list` | list | - | - | Array<MirrorView> | mirror-controller |
| GET | `/mirror/{mirrorName}` | get | mirrorName* | - | JsonNode | mirror-controller |
<a id="module-notify"></a>
## notify
共 15 个接口,路径前缀 `/notify/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/notify/cancel` | cancel | id* | - | - | notify-controller |
| POST | `/notify/create` | create | - | Notify | Notify | notify-controller |
| POST | `/notify/delete` | delete | id* | - | - | notify-controller |
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/notify/detail` | detail | id* | - | Notify_Public | notify-controller |
| POST | `/notify/internal/delete` | deleteInternal | id* | - | - | notify-controller |
| POST | `/notify/internal/detail` | internalDetail | id* | - | NotifyDetail_Public | notify-controller |
| POST | `/notify/internal/internal` | listInternal | unreadOnly | PageNotifyDetail | PageResultNotifyDetail | notify-controller |
| POST | `/notify/internal/read` | markSiteRead | id* | - | - | notify-controller |
| POST | `/notify/internal/read/all` | markAllSiteRead | - | - | - | notify-controller |
| POST | `/notify/internal/unread/count` | countUnreadSite | - | - | integer | notify-controller |
| POST | `/notify/management/cancel` | managementCancel | id* | - | - | notify-controller |
| POST | `/notify/management/delete` | managementDelete | id* | - | - | notify-controller |
| POST | `/notify/management/detail` | managementDetail | id* | - | Notify_Admin | notify-controller |
| POST | `/notify/management/list` | managementList | - | PageNotify_Admin | PageResultNotifyManagementItem_Admin | notify-controller |
| POST | `/notify/sms/captcha/create` | smsCaptchaCreate | - | CaptchaDataNotify | string | notify-controller |
<a id="module-root"></a>
## root
共 1 个接口,路径前缀 `/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/` | root | - | - | string | common-controller |
<a id="module-setting"></a>
## setting
共 6 个接口,路径前缀 `/setting/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/setting/create` | 创建配置 | - | Setting_Admin | Setting_Admin | 系统-配置 |
| POST | `/setting/delete` | 删除配置 | - | string | - | 系统-配置 |
| POST | `/setting/detail` | 查询配置详情 | - | string | Setting_Admin | 系统-配置 |
| POST | `/setting/list` | 查询配置列表 | - | PageSetting_Admin | PageResultSetting_Admin | 系统-配置 |
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/setting/map` | [公开] 查询公开配置映射 | bizType*, bizId, code | - | Map<String, Setting_Public> | 系统-配置 |
| POST | `/setting/update` | 更新配置 | - | Setting | - | 系统-配置 |
<a id="module-tag"></a>
## tag
共 7 个接口,路径前缀 `/tag/`。
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
| --- | --- | --- | --- | --- | --- | --- |
| POST | `/tag/apply` | apply | - | TagApply | - | tag-controller |
| POST | `/tag/create` | create | - | Tag_Public | Tag_Public | tag-controller |
| POST | `/tag/delete` | delete | id* | - | - | tag-controller |
| POST | `/tag/detail` | detail | id* | - | Tag_Public | tag-controller |
| POST | `/tag/list` | list | - | PageTag_Public | PageResultTag_Public | tag-controller |
| GET | `/tag/list/biz/id` | listByBizType | bizType*, bizId* | - | Array<Tag_Public> | tag-controller |
| POST | `/tag/update` | update | - | Tag | - | tag-controller |
+7
View File
@@ -0,0 +1,7 @@
# Lombok 全局配置
config.stopBubbling = true
# 将字段上的 @Qualifier 复制到 @RequiredArgsConstructor 生成的构造器参数,
# 避免多个同泛型 Redis Bean 注入歧义
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
+140 -7
View File
@@ -11,15 +11,16 @@
<groupId>com.imyeyu.timiserverapi</groupId>
<artifactId>TimiServerAPI</artifactId>
<version>1.0.0</version>
<version>1.0.82</version>
<packaging>jar</packaging>
<name>TimiServerAPI</name>
<description>imyeyu.com API</description>
<properties>
<java.version>25</java.version>
<springboot.version>3.5.11</springboot.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.multilingualField>21</maven.compiler.multilingualField>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -91,6 +92,47 @@
<build>
<defaultGoal>compile</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
<configuration>
<proc>full</proc>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.46</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.20.0</version>
<configuration>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
<addOutputDirectory>false</addOutputDirectory>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.46</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -125,23 +167,82 @@
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>e2ins_nexus</id>
<url>https://nexus.e2ins.com/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.openhtmltopdf</groupId>
<artifactId>openhtmltopdf-pdfbox</artifactId>
<version>1.0.10</version>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.29</version>
</dependency>
<dependency>
<groupId>com.imyeyu.spring</groupId>
<artifactId>timi-spring</artifactId>
<version>0.0.10</version>
<version>0.0.20</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.imyeyu.network</groupId>
<artifactId>timi-network</artifactId>
<version>0.0.8</version>
<version>0.0.14</version>
</dependency>
<dependency>
<groupId>com.imyeyu.lang</groupId>
<artifactId>timi-lang</artifactId>
<version>0.0.2</version>
<version>0.0.5</version>
</dependency>
<dependency>
<groupId>com.imyeyu.java</groupId>
<artifactId>timi-java</artifactId>
<version>0.0.11</version>
</dependency>
<dependency>
<groupId>com.imyeyu.utils</groupId>
<artifactId>timi-utils</artifactId>
<version>0.0.13</version>
</dependency>
<dependency>
<groupId>me.majiajie</groupId>
<artifactId>tinypinyin</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>cn.6tail</groupId>
<artifactId>lunar</artifactId>
<version>1.7.8</version>
</dependency>
<dependency>
<groupId>com.hankcs</groupId>
<artifactId>hanlp</artifactId>
<version>portable-1.8.4</version>
</dependency>
<dependency>
<groupId>com.imyeyu.font.icon</groupId>
<artifactId>timi-icon-font</artifactId>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -155,16 +256,43 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
</dependency>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java-sms</artifactId>
<version>3.1.1281</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
@@ -187,7 +315,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.34</version>
<version>1.18.46</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -263,6 +391,11 @@
<artifactId>jsoup</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
+124
View File
@@ -0,0 +1,124 @@
<#
.SYNOPSIS
导出本地 OpenAPI 文档。
.DESCRIPTION
从本地已启动的服务获取 /v3/api-docs.yaml(或 JSON),写入 docs 目录。
默认同时生成面向 AI Agent 的接口索引 docs/openapi.index.md。
生成的 OpenAPI 快照已被 .gitignore 忽略;索引文件可按需提交或单独发送。
.PARAMETER BaseUrl
服务地址,默认 http://localhost:18092。
.PARAMETER OutFile
输出文件路径,默认 docs/openapi.local.yaml。
扩展名为 .json 时导出 JSON,否则导出 YAML。
.PARAMETER IndexFile
接口索引输出路径,默认 docs/openapi.index.md。
.PARAMETER NoIndex
跳过接口索引生成。
.EXAMPLE
.\scripts\export-openapi.ps1
.EXAMPLE
.\scripts\export-openapi.ps1 -BaseUrl http://192.168.1.10:18092 -OutFile docs/openapi.local.json
.EXAMPLE
.\scripts\export-openapi.ps1 -NoIndex
#>
param(
[string]$BaseUrl = "http://localhost:18092",
[string]$OutFile,
[string]$IndexFile,
[switch]$NoIndex
)
$ErrorActionPreference = "Stop"
$RootDir = Split-Path -Parent $PSScriptRoot
if ([string]::IsNullOrWhiteSpace($OutFile)) {
$OutFile = Join-Path $RootDir "docs\openapi.local.yaml"
}
if ([string]::IsNullOrWhiteSpace($IndexFile)) {
$IndexFile = Join-Path $RootDir "docs\openapi.index.md"
}
$BaseUrl = $BaseUrl.TrimEnd("/")
$OutFile = [System.IO.Path]::GetFullPath($OutFile)
$IndexFile = [System.IO.Path]::GetFullPath($IndexFile)
$OutDir = Split-Path -Parent $OutFile
if (-not (Test-Path -LiteralPath $OutDir)) {
New-Item -ItemType Directory -Path $OutDir -Force | Out-Null
}
if ([System.IO.Path]::GetExtension($OutFile) -ieq ".json") {
$ApiPath = "/v3/api-docs"
} else {
$ApiPath = "/v3/api-docs.yaml"
}
$Url = "$BaseUrl$ApiPath"
Write-Host "Fetching $Url"
Invoke-WebRequest -Uri $Url -OutFile $OutFile -UseBasicParsing
Write-Host "OpenAPI exported to $OutFile"
if ($NoIndex) {
exit 0
}
if ($IndexFile -eq $OutFile) {
Write-Warning "接口索引不能与 OpenAPI 输出文件相同,跳过接口索引生成。"
exit 0
}
$IndexScript = Join-Path $PSScriptRoot "openapi-index.py"
if (-not (Test-Path -LiteralPath $IndexScript)) {
Write-Warning "未找到 $IndexScript,跳过接口索引生成。"
exit 0
}
$Python = $null
foreach ($Candidate in @("python", "python3")) {
$Command = Get-Command $Candidate -ErrorAction SilentlyContinue
if ($Command) {
$Python = $Command.Source
break
}
}
if (-not $Python) {
Write-Warning "未找到 Python,跳过接口索引生成。安装 Python 或使用 -NoIndex 关闭该提示。"
exit 0
}
$IndexDir = Split-Path -Parent $IndexFile
if (-not (Test-Path -LiteralPath $IndexDir)) {
New-Item -ItemType Directory -Path $IndexDir -Force | Out-Null
}
$IndexInput = $OutFile
$TempIndexInput = $null
if ([System.IO.Path]::GetExtension($OutFile) -ine ".json") {
$TempIndexInput = [System.IO.Path]::GetTempFileName()
try {
Invoke-WebRequest -Uri "$BaseUrl/v3/api-docs" -OutFile $TempIndexInput -UseBasicParsing
$IndexInput = $TempIndexInput
} catch {
Write-Warning "获取 OpenAPI JSON 失败,跳过接口索引生成:$($_.Exception.Message)"
$IndexInput = $null
}
}
if ($IndexInput) {
& $Python $IndexScript $IndexInput $IndexFile
if ($LASTEXITCODE -ne 0) {
Write-Warning "接口索引生成失败(退出码 $LASTEXITCODE)。"
}
}
if ($TempIndexInput -and (Test-Path -LiteralPath $TempIndexInput)) {
Remove-Item -LiteralPath $TempIndexInput -Force
}
+79
View File
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# 导出本地 OpenAPI 文档,并默认生成面向 AI Agent 的接口索引。
#
# 用法:
# scripts/export-openapi.sh [baseUrl] [outFile] [indexFile]
#
# 输出文件扩展名为 .json 时导出 JSON,否则导出 YAML。
# 索引默认输出到 docs/openapi.index.md;设置 SKIP_INDEX=1 可跳过。
# 生成的 OpenAPI 快照已被 .gitignore 忽略;索引文件可按需提交或单独发送。
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BASE_URL="${1:-http://localhost:18092}"
OUT_FILE="${2:-$ROOT_DIR/docs/openapi.local.yaml}"
INDEX_FILE="${3:-$ROOT_DIR/docs/openapi.index.md}"
BASE_URL="${BASE_URL%/}"
mkdir -p "$(dirname "$OUT_FILE")"
case "$OUT_FILE" in
*.json)
API_PATH="/v3/api-docs"
;;
*)
API_PATH="/v3/api-docs.yaml"
;;
esac
echo "Fetching ${BASE_URL}${API_PATH}"
curl -fsS "${BASE_URL}${API_PATH}" -o "$OUT_FILE"
echo "OpenAPI exported to $OUT_FILE"
if [[ "${SKIP_INDEX:-0}" == "1" ]]; then
exit 0
fi
if [[ "$INDEX_FILE" == "$OUT_FILE" ]]; then
echo "warning: 接口索引不能与 OpenAPI 输出文件相同,跳过接口索引生成。" >&2
exit 0
fi
INDEX_SCRIPT="$ROOT_DIR/scripts/openapi-index.py"
if [[ ! -f "$INDEX_SCRIPT" ]]; then
echo "warning: 未找到 $INDEX_SCRIPT,跳过接口索引生成。" >&2
exit 0
fi
PYTHON="$(command -v python3 2>/dev/null || command -v python 2>/dev/null || true)"
if [[ -z "$PYTHON" ]]; then
echo "warning: 未找到 Python,跳过接口索引生成。安装 Python 或设置 SKIP_INDEX=1 关闭该提示。" >&2
exit 0
fi
INDEX_INPUT="$OUT_FILE"
TEMP_JSON=""
cleanup() {
if [[ -n "$TEMP_JSON" ]]; then
rm -f "$TEMP_JSON"
fi
}
trap cleanup EXIT
if [[ "$OUT_FILE" != *.json ]]; then
TEMP_JSON="$(mktemp)"
if curl -fsS "${BASE_URL}/v3/api-docs" -o "$TEMP_JSON"; then
INDEX_INPUT="$TEMP_JSON"
else
echo "warning: 获取 OpenAPI JSON 失败,跳过接口索引生成。" >&2
INDEX_INPUT=""
fi
fi
if [[ -n "$INDEX_INPUT" ]]; then
mkdir -p "$(dirname "$INDEX_FILE")"
if ! "$PYTHON" "$INDEX_SCRIPT" "$INDEX_INPUT" "$INDEX_FILE"; then
echo "warning: 接口索引生成失败。" >&2
fi
fi
+356
View File
@@ -0,0 +1,356 @@
#!/usr/bin/env python3
"""从 OpenAPI 文档生成供 AI Agent 使用的接口索引。
默认优先读取 JSON(标准库即可解析);读取 YAML 时需要安装 PyYAML。
导出脚本会优先传入 /v3/api-docs 的 JSON,避免额外依赖。
"""
from __future__ import annotations
import argparse
import json
import re
import sys
from pathlib import Path
from typing import Any
HTTP_METHODS = ("get", "head", "post", "put", "patch", "delete", "options", "trace")
REQUEST_MEDIA = ("application/json", "multipart/form-data", "application/x-www-form-urlencoded", "*/*")
RESPONSE_MEDIA = ("application/json", "*/*", "text/event-stream", "application/octet-stream")
def load_spec(path: Path) -> dict[str, Any]:
text = path.read_text(encoding="utf-8")
try:
data = json.loads(text)
except json.JSONDecodeError:
try:
import yaml
except ImportError as exc:
raise SystemExit(
"无法解析 YAML:请安装 PyYAML(pip install pyyaml),"
"或改用 /v3/api-docs 的 JSON 输出。"
) from exc
data = yaml.safe_load(text)
if not isinstance(data, dict):
raise SystemExit("OpenAPI 文档格式不正确:根节点必须是对象")
return data
def resolve(spec: dict[str, Any], value: Any) -> Any:
"""解析本地 $ref,最多跟随 32 层,避免循环引用。"""
for _ in range(32):
if not isinstance(value, dict) or "$ref" not in value:
return value
ref = value["$ref"]
if not isinstance(ref, str) or not ref.startswith("#/"):
return value
current: Any = spec
for part in ref[2:].split("/"):
part = part.replace("~1", "/").replace("~0", "~")
if not isinstance(current, dict) or part not in current:
return value
current = current[part]
value = current
return value
def ref_name(ref: str) -> str:
return ref.rsplit("/", 1)[-1].replace("~1", "/").replace("~0", "~")
def schema_label(spec: dict[str, Any], schema: Any, depth: int = 0) -> str:
if not isinstance(schema, dict) or depth > 4:
return "-"
if "$ref" in schema:
return ref_name(str(schema["$ref"]))
schema_type = schema.get("type")
if isinstance(schema_type, list):
schema_type = "/".join(str(item) for item in schema_type)
if schema_type == "array":
return f"Array<{schema_label(spec, schema.get('items'), depth + 1)}>"
if schema_type == "object" or "properties" in schema:
additional = schema.get("additionalProperties")
if isinstance(additional, dict):
return f"Map<String, {schema_label(spec, additional, depth + 1)}>"
if additional is True:
return "Map<String, any>"
properties = schema.get("properties")
if isinstance(properties, dict) and properties:
names = list(properties)
if len(names) > 8:
names = names[:8] + ["..."]
return "object{" + ", ".join(names) + "}"
return "object"
for keyword in ("oneOf", "anyOf", "allOf"):
items = schema.get(keyword)
if isinstance(items, list) and items:
joiner = " | " if keyword == "oneOf" else " & "
return "(" + joiner.join(schema_label(spec, item, depth + 1) for item in items) + ")"
if schema_type == "string" and schema.get("format") in ("binary", "byte"):
return "binary"
if schema_type:
return str(schema_type)
return "-"
def pick_media(content: Any, preferred: tuple[str, ...]) -> tuple[str | None, Any]:
if not isinstance(content, dict) or not content:
return None, None
for media in preferred:
if media in content:
return media, content[media]
media = next(iter(content))
return media, content[media]
def request_label(spec: dict[str, Any], operation: dict[str, Any]) -> str:
body = resolve(spec, operation.get("requestBody"))
if not isinstance(body, dict):
return "-"
media, entry = pick_media(body.get("content"), REQUEST_MEDIA)
if media is None:
return "-"
schema = entry.get("schema") if isinstance(entry, dict) else None
label = schema_label(spec, schema)
if label == "-":
return media
if media in ("application/json", "*/*"):
return label
return f"{label} ({media})"
def response_label(spec: dict[str, Any], operation: dict[str, Any]) -> str:
responses = operation.get("responses")
if not isinstance(responses, dict) or not responses:
return "-"
response = None
for code in ("200", "201", "202", "204"):
if code in responses:
response = responses[code]
break
if response is None:
for code, candidate in responses.items():
if str(code).startswith("2"):
response = candidate
break
if response is None and "default" in responses:
response = responses["default"]
response = resolve(spec, response)
if not isinstance(response, dict):
return "-"
media, entry = pick_media(response.get("content"), RESPONSE_MEDIA)
if media is None:
return "-"
if media == "text/event-stream":
return "SSE"
schema = entry.get("schema") if isinstance(entry, dict) else None
label = schema_label(spec, schema)
if label == "-":
return media
if media in ("application/json", "*/*"):
return label
return f"{label} ({media})"
def parameter_label(spec: dict[str, Any], path_item: dict[str, Any], operation: dict[str, Any]) -> str:
merged: dict[tuple[str, str], dict[str, Any]] = {}
for source in (path_item.get("parameters"), operation.get("parameters")):
if not isinstance(source, list):
continue
for raw in source:
parameter = resolve(spec, raw)
if not isinstance(parameter, dict):
continue
name = parameter.get("name")
location = parameter.get("in")
if name and location:
merged[(str(name), str(location))] = parameter
if not merged:
return "-"
parts = []
for (name, location), parameter in merged.items():
prefix = ""
if location in ("header", "cookie"):
prefix = f"{location}:"
suffix = "*" if parameter.get("required") else ""
parts.append(f"{prefix}{name}{suffix}")
return ", ".join(parts)
def cell(value: Any) -> str:
text = "" if value is None else str(value)
text = re.sub(r"\s+", " ", text).strip()
text = text.replace("|", "\\|")
return text or "-"
def module_key(path: str) -> str:
segments = [segment for segment in path.split("/") if segment]
if not segments:
return "root"
if segments[0] == "gao" and len(segments) > 1:
return f"gao-{segments[1]}"
return segments[0]
def module_prefix(key: str) -> str:
if key == "root":
return "/"
if key.startswith("gao-"):
return f"/gao/{key[4:]}/"
return f"/{key}/"
def module_sort(key: str) -> tuple[int, str]:
if key.startswith("gao-"):
return 0, key
order = {"system": 1, "user": 2, "app": 3}
return order.get(key, 4), key
def collect_operations(spec: dict[str, Any]) -> list[dict[str, Any]]:
paths = spec.get("paths")
if not isinstance(paths, dict):
return []
operations = []
for path, path_item in paths.items():
if not isinstance(path_item, dict):
continue
path_item = resolve(spec, path_item)
if not isinstance(path_item, dict):
continue
for method in HTTP_METHODS:
operation = path_item.get(method)
if not isinstance(operation, dict):
continue
operation = resolve(spec, operation)
if not isinstance(operation, dict):
continue
summary = operation.get("summary") or operation.get("operationId") or ""
if operation.get("summary") is None and isinstance(summary, str):
summary = re.sub(r"_\d+$", "", summary)
if operation.get("deprecated"):
summary = f"[已废弃] {summary}"
public = operation["security"] == [] if "security" in operation else not spec.get("security")
if public:
summary = f"[公开] {summary}"
operations.append({
"methods": [method.upper()],
"path": path,
"summary": summary,
"parameters": parameter_label(spec, path_item, operation),
"request": request_label(spec, operation),
"response": response_label(spec, operation),
"tag": ", ".join(operation.get("tags") or []),
"module": module_key(path),
"order": (path, HTTP_METHODS.index(method)),
})
# 同一个处理器的多个 HTTP 方法(如 @RequestMapping 未限定 method)合并为一行。
merged: dict[tuple[Any, ...], dict[str, Any]] = {}
for operation in operations:
key = (
operation["path"],
operation["summary"],
operation["parameters"],
operation["request"],
operation["response"],
operation["tag"],
operation["module"],
)
if key in merged:
merged[key]["methods"].append(operation["methods"][0])
else:
merged[key] = operation
return list(merged.values())
def render(spec: dict[str, Any], source: str) -> str:
info = spec.get("info") if isinstance(spec.get("info"), dict) else {}
title = info.get("title") or "OpenAPI"
version = info.get("version") or "-"
openapi_version = spec.get("openapi") or "-"
paths = spec.get("paths") if isinstance(spec.get("paths"), dict) else {}
operations = collect_operations(spec)
groups: dict[str, list[dict[str, Any]]] = {}
for operation in operations:
groups.setdefault(operation["module"], []).append(operation)
for items in groups.values():
items.sort(key=lambda item: item["order"])
lines = [
f"# {title} 接口索引",
"",
"> 本文件由 `scripts/openapi-index.py` 从 OpenAPI 快照生成,请勿手工编辑。",
f"> 数据来源:`{source}`。完整字段定义以 OpenAPI 原文为准。",
"",
f"- 服务版本:`{version}`",
f"- OpenAPI 版本:`{openapi_version}`",
f"- 路径数:{len(paths)}",
f"- 接口数:{len(operations)}(同一路径的同一处理器会合并多个 HTTP 方法)",
f"- 模块数:{len(groups)}",
"",
"## 使用说明",
"",
"- 先按模块定位接口,再读取 `docs/openapi.local.yaml` 中对应的 `path` 或 `components/schemas`,不要整文件加载。",
"- 参数列中 `*` 表示必填;`header:`、`cookie:` 为参数位置前缀,其余为 path/query 参数。",
"- 摘要前的 `[公开]` 表示 OpenAPI 中显式标记为无需登录;未标记的接口默认使用 `Token` 鉴权。",
"- 方法列出现多个 HTTP 方法,表示 Controller 使用了未限定 method 的 `@RequestMapping`。",
"- 请求体和响应列展示顶层 schema 名称;`binary` 表示二进制响应,`SSE` 表示 `text/event-stream`。",
"- 普通 JSON 接口的响应仍由 `TimiResponse` 包装,鉴权、错误码、分页等约定见 `docs/api-integration.md`。",
"",
"## 模块导航",
"",
"| 模块 | 接口数 | 路径前缀 |",
"| --- | ---: | --- |",
]
for key in sorted(groups, key=module_sort):
lines.append(f"| [`{cell(key)}`](#module-{key}) | {len(groups[key])} | `{module_prefix(key)}` |")
for key in sorted(groups, key=module_sort):
lines.extend([
"",
f'<a id="module-{key}"></a>',
f"## {key}",
"",
f"共 {len(groups[key])} 个接口,路径前缀 `{module_prefix(key)}`。",
"",
"| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |",
"| --- | --- | --- | --- | --- | --- | --- |",
])
for operation in groups[key]:
lines.append(
"| {method} | `{path}` | {summary} | {parameters} | {request} | {response} | {tag} |".format(
method="/".join(operation["methods"]),
path=cell(operation["path"]),
summary=cell(operation["summary"]),
parameters=cell(operation["parameters"]),
request=cell(operation["request"]),
response=cell(operation["response"]),
tag=cell(operation["tag"]),
)
)
lines.append("")
return "\n".join(lines)
def main() -> int:
parser = argparse.ArgumentParser(description="从 OpenAPI 文档生成 AI Agent 接口索引")
parser.add_argument("input", type=Path, help="OpenAPI JSON/YAML 文件")
parser.add_argument("output", type=Path, help="输出的 Markdown 文件")
parser.add_argument(
"--source-label",
default="docs/openapi.local.yaml",
help="索引中显示的数据来源(默认 docs/openapi.local.yaml)",
)
args = parser.parse_args()
spec = load_spec(args.input)
args.output.parent.mkdir(parents=True, exist_ok=True)
args.output.write_text(render(spec, args.source_label), encoding="utf-8", newline="\n")
print(f"OpenAPI index written to {args.output}")
return 0
if __name__ == "__main__":
sys.exit(main())
+82
View File
@@ -0,0 +1,82 @@
# GAO 门店智能助手 Dify DSL 配置说明
`main_agent.yml` 是 Advanced Chat 应用,支持:
- 知识库规则回答
- 实时业务查询 Agent
- 规则 + 实时数据混合分析
- 带预览和人工确认的写操作
## 1. MCP Provider
导入 DSL 后需要配置两个 MCP Provider。
| DSL 中的 Provider | 后端地址 | 服务密钥 |
|---|---|---|
| `gao-mcp-server-dev` | `http(s)://<backend>/mcp/gao-ai` | 系统设置 `DIFY_MCP_SERVICE_KEY` |
| `gao-mcp-commit-dev` | `http(s)://<backend>/mcp/gao-ai-commit` | 系统设置 `DIFY_MCP_COMMIT_SERVICE_KEY` |
要求:
1. `gao-mcp-server-dev` 只暴露查询工具和 `operation_prepare`。
2. `gao-mcp-commit-dev` 只暴露 `operation_commit`、`operation_cancel`。
3. **提交 Provider 不得绑定到任何 Agent 节点**,只允许 `main_agent.yml` 中的确定性工具节点调用。
4. 如果 Dify 中的 Provider ID 与 DSL 不一致,请同时修改 DSL 中 `commit_tool`、`cancel_tool`、`prepare_tool` 的 `provider_id` 和 `provider_name`。
## 2. 写能力开关
后端默认关闭写能力:
```yaml
gao:
ai:
write:
enabled: true
confirmation-ttl-seconds: 600
result-ttl-seconds: 1800
max-prepares-per-10-minutes: 10
max-commits-per-10-minutes: 10
order-max-sale-amount: 1000000
order-max-discount-rate: 0.30
point-adjust-max-abs: 10000
stock-change-max-quantity: 1000
attachment-max-count: 10
attachment-max-size-mb: 10
attachment-ttl-seconds: 86400
```
## 3. 附件
Dify 内置文件上传保持关闭。前端流程:
1. 调用 `POST /gao/ai/attachment/upload` 上传凭证,获得 `token`。
2. 聊天请求携带 `attachmentTokenList`。
3. 后端把附件 token 注入 Dify start 输入 `attachmentTokensJson`。
4. `operation_prepare` 解析并校验附件,token 不进入模型提示词。
## 4. 确认流程
### 文本确认
1. 用户发起写操作。
2. `operation_prepare` 返回 `PENDING_CONFIRMATION`、`previewText`、`requiredPhrase`。
3. 下一轮聊天后端注入 `pendingOperationToken` 等 start 输入。
4. `pending_gate` 判断是否存在待确认操作。
5. `pending_action` 规则判断确认/取消。
6. 确认时调用 `operation_commit`;取消时调用 `operation_cancel`。
### 卡片确认
1. 后端在 SSE 结束前推送 `operation_preview`。
2. 卡片调用 `GET /gao/ai/operation/pending` 恢复状态。
3. 确认调用 `POST /gao/ai/operation/commit`。
4. 取消调用 `POST /gao/ai/operation/cancel`。
卡片使用公开 `operationId`,确认 token 不进入浏览器。
## 5. 安全边界
- 模型不可传 `storeId`、`operatorUserId`、`requestNo`、`confirmationToken`。
- 提交工具只接受确认 token,不接受业务参数。
- 破坏性和敏感操作必须精确短语,并重新校验权限、门店、价格、库存和状态。
- 物理删除不在操作注册表中。
File diff suppressed because it is too large Load Diff
@@ -1,22 +0,0 @@
package com.imyeyu.api.annotation;
import com.imyeyu.api.bean.CaptchaFrom;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 图形验证码校验注解
*
* @author 夜雨
* @since 2023-07-15 10:09
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CaptchaValid {
/** @return 验证码来源 */
CaptchaFrom value();
}
@@ -1,20 +1,13 @@
package com.imyeyu.api.annotation;
import lombok.extern.slf4j.Slf4j;
import com.imyeyu.api.bean.CaptchaFrom;
import com.imyeyu.api.util.CaptchaManager;
import com.imyeyu.spring.bean.CaptchaData;
import org.aspectj.lang.JoinPoint;
import com.imyeyu.spring.annotation.CaptchaValidAbstractInterceptor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
/**
* 图形验证码校验注解处理器
*
@@ -24,47 +17,19 @@ import java.lang.reflect.Method;
@Slf4j
@Aspect
@Component
public class CaptchaValidInterceptor {
@RequiredArgsConstructor
public class CaptchaValidInterceptor extends CaptchaValidAbstractInterceptor {
@Value("${spring.profiles.active}")
private String env;
@Autowired
private CaptchaManager captchaManager;
private final CaptchaManager captchaManager;
/** 注入注解 */
@Pointcut("@annotation(com.imyeyu.api.annotation.CaptchaValid)")
public void captchaPointCut() {
}
/**
* 执行前
*
* @param joinPoint 切入点
*/
@Before("captchaPointCut()")
public void doBefore(JoinPoint joinPoint) {
try {
if (env.startsWith("dev")) {
// 开发环境不校验
return;
}
if (joinPoint.getSignature() instanceof MethodSignature ms) {
Method method = joinPoint.getTarget().getClass().getMethod(ms.getName(), ms.getParameterTypes());
CaptchaValid annotation = method.getAnnotation(CaptchaValid.class);
CaptchaFrom from = annotation.value();
Object[] args = joinPoint.getArgs();
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof CaptchaData<?> captchaData) {
// 校验请求参数的验证码
captchaManager.test(captchaData.getCaptcha(), from.toString());
break;
}
}
}
} catch (NoSuchMethodException e) {
throw new RuntimeException("TODO CaptchaValidInterceptor error");
@Override
protected void verify(String captchaId, String captcha) {
if (!env.equals("prod")) {
return;
}
captchaManager.verify(captchaId, captcha);
}
}
@@ -1,25 +0,0 @@
package com.imyeyu.api.annotation;
import com.imyeyu.api.modules.common.bean.SettingKey;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 启用配置注解
*
* @author 夜雨
* @since 2023-07-15 10:00
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface EnableSetting {
/** @return 配置键 */
SettingKey value();
/** @return 未启用配置时响应消息语言映射键 */
String message() default "service.offline";
}
@@ -1,40 +0,0 @@
package com.imyeyu.api.annotation;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.api.modules.common.service.SettingService;
import org.springframework.context.annotation.Lazy;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
/**
* 启用配置注解处理器
*
* @author 夜雨
* @since 2023-07-15 10:01
*/
@Component
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class EnableSettingInterceptor implements HandlerInterceptor {
private final SettingService service;
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) {
if (handler instanceof HandlerMethod handlerMethod) {
EnableSetting annotation = handlerMethod.getMethodAnnotation(EnableSetting.class);
if (annotation == null) {
return true;
}
if (service.is(annotation.value())) {
return true;
}
throw new TimiException(TimiCode.ERROR_SERVICE_OFF, annotation.message());
}
return true;
}
}
@@ -0,0 +1,31 @@
package com.imyeyu.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 标记需要在响应阶段自动回填的多语言字段
*
* @author 夜雨
* @since 2026-07-17 00:00
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MultilingualField {
/**
* 多语言 ID 来源字段名
*
* @return 来源字段名
*/
String value();
/**
* 模板参数来源字段名
*
* @return 同类中的 Map 字段名
*/
String argMap() default "";
}
@@ -23,27 +23,33 @@ import org.springframework.stereotype.Component;
@Component
public class RequestRateLimitInterceptor extends RequestRateLimitAbstractInterceptor {
private static final String KEY_PREFIX = "REQUEST:RATE_LIMIT:";
@Autowired
@Qualifier("redisRateLimit")
private Redis<String, Integer> redisRequestRateLimit;
private Redis<String, Integer> redis;
@Override
public boolean beforeRun(HttpServletRequest req, HttpServletResponse resp, String id, int cycle, int limit) {
// 键
String key = "TimiServerAPI." + TimiSpring.getRequestIP() + "." + id;
if (redisRequestRateLimit.has(key)) {
Integer count = redisRequestRateLimit.get(key);
String key = getKey(id);
if (redis.has(key)) {
Integer count = redis.get(key);
if (count != null) {
if (count < limit) {
redisRequestRateLimit.setAndKeepTTL(key, ++count);
redis.setAndKeepTTL(key, ++count);
} else {
log.warn("请求频率过高:[" + key + "].C" + count + "L" + limit);
throw new TimiException(TimiCode.REQUEST_BAD).msgKey("request_rate_limit");
throw new TimiException(TimiCode.REQUEST_BAD, "request_rate_limit");
}
}
return true;
}
redisRequestRateLimit.set(key, 0, Time.S * cycle);
redis.set(key, 0, Time.S * cycle);
return true;
}
private String getKey(String id) {
return "%sTIMISERVERAPI:%s:%s".formatted(KEY_PREFIX, TimiSpring.getRequestIP(), id);
}
}
@@ -0,0 +1,29 @@
package com.imyeyu.api.annotation;
import com.imyeyu.api.bean.PermissionMatchMode;
import com.imyeyu.api.bean.CorePermissionCode;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
///
/// 要求 CORE 模块权限
///
/// @author Codex
/// @since 2026-07-26
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequireCorePermission {
/// 所需权限
///
/// @return 权限列表
CorePermissionCode[] value();
/// 匹配模式
///
/// @return 匹配模式
PermissionMatchMode mode() default PermissionMatchMode.ALL;
}
@@ -0,0 +1,64 @@
package com.imyeyu.api.annotation;
import com.imyeyu.api.bean.PermissionMatchMode;
import com.imyeyu.api.bean.CorePermissionCode;
import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.modules.user.service.PermissionChecker;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import java.io.IOException;
///
/// CORE 权限注解处理器
///
/// @author Codex
/// @since 2026-07-27
@Component
public class RequireCorePermissionInterceptor implements HandlerInterceptor {
private final PermissionChecker permissionChecker;
public RequireCorePermissionInterceptor(PermissionChecker permissionChecker) {
this.permissionChecker = permissionChecker;
}
@Override
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) {
if (!(handler instanceof HandlerMethod handlerMethod)) {
return true;
}
RequireCorePermission annotation = handlerMethod.getMethodAnnotation(RequireCorePermission.class);
if (annotation == null) {
annotation = handlerMethod.getBeanType().getAnnotation(RequireCorePermission.class);
}
if (annotation == null || TimiJava.isEmpty(annotation.value())) {
return true;
}
String[] permissionCodeList = java.util.Arrays.stream(annotation.value()).map(CorePermissionCode::getValue).toArray(String[]::new);
try {
if (annotation.mode() == PermissionMatchMode.ANY) {
permissionChecker.checkAny(ModuleCode.CORE, permissionCodeList);
} else {
permissionChecker.checkAll(ModuleCode.CORE, permissionCodeList);
}
} catch (TimiException e) {
if (handlerMethod.hasMethodAnnotation(IgnoreGlobalReturn.class) && !resp.isCommitted()) {
try {
resp.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());
} catch (IOException ignored) {
}
return false;
}
throw e;
}
return true;
}
}
@@ -1,39 +0,0 @@
package com.imyeyu.api.annotation;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.api.modules.blog.util.UserToken;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.RequiredToken;
import com.imyeyu.spring.annotation.RequiredTokenAbstractInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 令牌验证注解处理器
*
* @author 夜雨
* @since 2021-08-16 18:07
*/
@Slf4j
@Component
public class RequiredTokenInterceptor extends RequiredTokenAbstractInterceptor<RequiredToken> {
@Autowired
private UserToken userToken;
public RequiredTokenInterceptor() {
super(RequiredToken.class);
}
@Override
protected boolean beforeRun(HttpServletRequest req, HttpServletResponse resp) {
if (userToken.isInvalid(TimiSpring.getToken())) {
throw new TimiException(TimiCode.ARG_MISS).msgKey("token.illegal");
}
return true;
}
}
@@ -0,0 +1,17 @@
package com.imyeyu.api.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
///
///
/// @author 夜雨
/// @since 2026-09-08 15:22
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface SettingBizType {
String value();
}
@@ -1,34 +0,0 @@
package com.imyeyu.api.bean;
/**
* 验证码来源
*
* @author 夜雨
* @since 2023-07-16 10:12
*/
public enum CaptchaFrom {
/** 注册 */
REGISTER,
/** 登录 */
LOGIN,
/** 忘记密码 */
RESET_PASSWORD,
/** 评论 */
COMMENT,
/** 评论回复 */
COMMENT_REPLY,
/** Git 反馈 */
GIT_ISSUE,
/** Git 合并请求 */
GIT_MERGE,
/** 歌词修正申请 */
LYRIC_CORRECT
}
@@ -0,0 +1,106 @@
package com.imyeyu.api.bean;
import com.imyeyu.api.modules.user.bean.BuiltinPermissionCode;
import lombok.AllArgsConstructor;
///
/// CORE 模块权限枚举
///
/// @author Codex
/// @since 2026-07-26
@AllArgsConstructor
public enum CorePermissionCode implements BuiltinPermissionCode {
PERMISSION_READ("PERMISSION:READ", "权限读取", false, true),
PERMISSION_UPDATE("PERMISSION:UPDATE", "权限修改", false, true),
ROLE_CREATE("ROLE:CREATE", "角色创建", false, true),
ROLE_READ("ROLE:READ", "角色读取", false, true),
ROLE_UPDATE("ROLE:UPDATE", "角色修改", false, true),
ROLE_DELETE("ROLE:DELETE", "角色删除", false, true),
ROLE_PERMISSION_CREATE("ROLE_PERMISSION:CREATE", "角色权限创建", false, true),
ROLE_PERMISSION_READ("ROLE_PERMISSION:READ", "角色权限读取", false, true),
ROLE_PERMISSION_DELETE("ROLE_PERMISSION:DELETE", "角色权限删除", false, true),
ROLE_PERMISSION_INHERIT_CREATE("ROLE_PERMISSION_INHERIT:CREATE", "角色权限继承创建", false, true),
ROLE_PERMISSION_INHERIT_READ("ROLE_PERMISSION_INHERIT:READ", "角色权限继承读取", false, true),
ROLE_PERMISSION_INHERIT_DELETE("ROLE_PERMISSION_INHERIT:DELETE", "角色权限继承删除", false, true),
SETTING_READ("SETTING:READ", "设置读取", false, true),
SETTING_UPDATE("SETTING:UPDATE", "设置修改", false, true),
MULTILINGUAL_CREATE("MULTILINGUAL:CREATE", "多语言创建", false, true),
MULTILINGUAL_READ("MULTILINGUAL:READ", "多语言读取", false, true),
MULTILINGUAL_UPDATE("MULTILINGUAL:UPDATE", "多语言修改", false, true),
MULTILINGUAL_DELETE("MULTILINGUAL:DELETE", "多语言删除", false, true),
TAG_CREATE("TAG:CREATE", "标签创建", false, true),
TAG_READ("TAG:READ", "标签读取", false, true),
TAG_APPLY("TAG:APPLY", "标签应用", false, true),
TAG_UPDATE("TAG:UPDATE", "标签修改", false, true),
TAG_DELETE("TAG:DELETE", "标签删除", false, true),
ARTICLE_CREATE("ARTICLE:CREATE", "文章创建", false, true),
ARTICLE_READ("ARTICLE:READ", "文章读取", false, true),
ARTICLE_UPDATE("ARTICLE:UPDATE", "文章修改", false, true),
ARTICLE_DELETE("ARTICLE:DELETE", "文章删除", false, true),
USER_CREATE("USER:CREATE", "用户创建", false, true),
USER_READ("USER:READ", "用户读取", false, true),
USER_UPDATE("USER:UPDATE", "用户修改", false, true),
USER_DELETE("USER:DELETE", "用户删除", false, true),
API_KEY_CREATE("API_KEY:CREATE", "API 密钥创建", false, true),
API_KEY_READ("API_KEY:READ", "API 密钥读取", false, true),
API_KEY_DELETE("API_KEY:DELETE", "API 密钥删除", false, true),
FEEDBACK_CREATE("FEEDBACK:CREATE", "反馈创建", false, true),
FEEDBACK_READ("FEEDBACK:READ", "反馈读取", false, true),
FEEDBACK_UPDATE("FEEDBACK:UPDATE", "反馈修改", false, true),
FEEDBACK_DELETE("FEEDBACK:DELETE", "反馈删除", false, true),
NOTIFY_CREATE("NOTIFY:CREATE", "通知创建", false, true),
NOTIFY_READ("NOTIFY:READ", "通知读取", false, true),
NOTIFY_DELETE("NOTIFY:DELETE", "通知删除", false, true),
NOTIFY_CANCEL("NOTIFY:CANCEL", "通知取消", false, true),
FILE_READ("FILE:READ", "文件读取", false, true),
FILE_WRITE("FILE:WRITE", "文件写入", false, true),
FILE_DELETE("FILE:DELETE", "文件删除", false, true),
FILE_SHARE("FILE:SHARE", "文件分享", false, true),
USER_ROLE_CREATE("USER_ROLE:CREATE", "用户角色创建", true, true),
USER_ROLE_READ("USER_ROLE:READ", "用户角色读取", true, true),
USER_ROLE_DELETE("USER_ROLE:DELETE", "用户角色删除", true, true);
final String value;
final String defaultName;
final boolean grantToSystem;
final boolean grantToAdmin;
@Override
public ModuleCode getModuleCode() {
return ModuleCode.CORE;
}
@Override
public String getValue() {
return value;
}
@Override
public String getDefaultName() {
return defaultName;
}
@Override
public boolean isGrantToSystem() {
return grantToSystem;
}
@Override
public boolean isGrantToAdmin() {
return grantToAdmin;
}
}
@@ -0,0 +1,42 @@
package com.imyeyu.api.bean;
import com.imyeyu.api.modules.user.bean.BuiltinRoleCode;
import lombok.AllArgsConstructor;
///
/// CORE 模块角色枚举
///
/// @author Codex
/// @since 2026-07-26
@AllArgsConstructor
public enum CoreRoleCode implements BuiltinRoleCode {
SYSTEM("系统", true, null),
ADMIN("管理员", false, SYSTEM.name());
final String defaultName;
final boolean protectedRole;
final String parentCode;
@Override
public ModuleCode getModuleCode() {
return ModuleCode.CORE;
}
@Override
public String getDefaultName() {
return defaultName;
}
@Override
public boolean isProtected() {
return protectedRole;
}
@Override
public String getParentCode() {
return parentCode;
}
}
@@ -0,0 +1,15 @@
package com.imyeyu.api.bean;
///
/// 模块代码
///
/// @author Codex
/// @since 2026-07-26
public enum ModuleCode {
CORE,
GAO,
APP,
}
@@ -1,26 +0,0 @@
package com.imyeyu.api.bean;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author 夜雨
* @since 2023-10-25 10:10
*/
public interface MultilingualHandler {
/**
*
*
* @author 夜雨
* @since 2023-10-25 10:25
*/
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@interface MultilingualField {
String[] args() default {};
}
}
@@ -0,0 +1,16 @@
package com.imyeyu.api.bean;
/**
* 权限匹配模式
*
* @author 夜雨
* @since 2026-06-05 17:45
*/
public enum PermissionMatchMode {
/** 全部满足 */
ALL,
/** 满足任意一个 */
ANY,
}
@@ -0,0 +1,16 @@
package com.imyeyu.api.bean;
/**
* 角色匹配模式
*
* @author 夜雨
* @since 2026-06-05 17:45
*/
public enum RoleMatchMode {
/** 全部满足 */
ALL,
/** 满足任意一个 */
ANY,
}
@@ -0,0 +1,36 @@
package com.imyeyu.api.bean;
import com.imyeyu.api.annotation.SettingBizType;
import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.utils.Text;
///
///
/// @author 夜雨
/// @since 2026-09-08 15:18
public interface SettingEnum {
default String getBizType() {
Class<? extends SettingEnum> implEnum = getClass();
SettingBizType bizType = implEnum.getAnnotation(SettingBizType.class);
if (bizType == null) {
return Text.bizClassName(implEnum);
}
return bizType.value();
}
String name();
String getDefaultValue();
Setting.ValueType getValueType();
/// 配置作用域
///
/// 业务级配置由业务对象自己维护,启动时不初始化记录
///
/// @return 配置作用域
default Setting.Scope getScope() {
return Setting.Scope.SYSTEM;
}
}
@@ -2,7 +2,10 @@ package com.imyeyu.api.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.imyeyu.utils.Time;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -17,11 +20,13 @@ public class BeanConfig {
@Bean
public ObjectMapper jackson() {
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(Time.dateTime);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper;
return JsonMapper.builder()
.addModule(new JavaTimeModule())
.serializationInclusion(JsonInclude.Include.NON_NULL)
.defaultDateFormat(Time.dateTime)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.enable(MapperFeature.USE_STD_BEAN_NAMING)
.build();
}
@Bean
@@ -0,0 +1,96 @@
package com.imyeyu.api.config;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
/**
* OpenAPI 接口文档配置
*
* @author 夜雨
* @since 2026-11-24
*/
@Configuration
public class OpenApiConfig {
/**
* 移除 timi-spring 默认的全局返回处理器,由 {@link OpenApiGlobalReturnHandler} 替代。
*
* <p>默认处理器会把所有响应包装为 TimiResponse,导致 SpringDoc 的接口描述无法被 Swagger UI 解析。</p>
*
* @return Bean 定义注册后处理器
*/
@Bean
public static BeanDefinitionRegistryPostProcessor openApiGlobalReturnHandlerReplacer() {
return new BeanDefinitionRegistryPostProcessor() {
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
for (String beanName : registry.getBeanDefinitionNames()) {
BeanDefinition definition = registry.getBeanDefinition(beanName);
if ("globalReturnHandler".equals(beanName)
|| "com.imyeyu.spring.util.GlobalReturnHandler".equals(definition.getBeanClassName())) {
registry.removeBeanDefinition(beanName);
}
}
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
}
};
}
/**
* 接口文档信息与认证方式
*
* @return OpenAPI 配置
*/
@Bean
public OpenAPI timiServerOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("TimiServerAPI")
.description("夜雨综合数据中心接口")
.version("1.0.79"))
.components(new Components()
.addSecuritySchemes("Token", new SecurityScheme()
.name("Token")
.type(SecurityScheme.Type.APIKEY)
.in(SecurityScheme.In.HEADER)
.description("登录令牌或 API Key,也可通过 URL 参数 token 传递")))
.addSecurityItem(new SecurityRequirement().addList("Token"));
}
/**
* 注册字节数组消息转换器,确保接口文档以原始 JSON 输出。
*
* <p>项目的消息转换器配置仅注册了 Jackson 转换器,{@code byte[]} 会被序列化为 Base64 字符串,
* 导致 Swagger UI 无法解析接口文档。</p>
*
* @return Web MVC 配置
*/
@Bean
public WebMvcConfigurer openApiByteArrayMessageConverter() {
return new WebMvcConfigurer() {
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(0, new ByteArrayHttpMessageConverter());
}
};
}
}
@@ -0,0 +1,28 @@
package com.imyeyu.api.config;
import com.imyeyu.spring.util.GlobalReturnHandler;
import org.springframework.core.MethodParameter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.lang.NonNull;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 全局返回处理器,跳过 SpringDoc 接口。
*
* <p>接口文档响应需要保持原始 JSON 结构,不能包装为 TimiResponse。</p>
*
* @author 夜雨
* @since 2026-11-24
*/
@RestControllerAdvice
public class OpenApiGlobalReturnHandler extends GlobalReturnHandler {
@Override
public boolean supports(@NonNull MethodParameter returnType, @NonNull Class<? extends HttpMessageConverter<?>> converterType) {
Class<?> containingClass = returnType.getContainingClass();
if (containingClass != null && containingClass.getName().startsWith("org.springdoc.")) {
return false;
}
return super.supports(returnType, converterType);
}
}
@@ -1,8 +1,11 @@
package com.imyeyu.api.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.imyeyu.api.modules.blog.entity.ArticleRanking;
import com.imyeyu.api.modules.common.entity.Multilingual;
import com.imyeyu.api.modules.gao.ai.entity.GaoAiSession;
import com.imyeyu.api.modules.gao.ai.operation.GaoAiAttachmentToken;
import com.imyeyu.api.modules.gao.ai.operation.GaoAiPendingOperation;
import com.imyeyu.api.modules.gao.bean.GaoUserInviteCache;
import com.imyeyu.spring.bean.RedisConfigParams;
import com.imyeyu.spring.config.AbstractRedisConfig;
import com.imyeyu.spring.util.Redis;
@@ -11,18 +14,13 @@ import com.imyeyu.utils.Time;
import io.lettuce.core.api.StatefulConnection;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.serializer.support.DeserializingConverter;
import org.springframework.core.serializer.support.SerializingConverter;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;
import org.springframework.lang.Nullable;
import java.time.Duration;
@@ -36,11 +34,11 @@ import java.time.Duration;
@Configuration
@EqualsAndHashCode(callSuper = true)
@EnableAutoConfiguration
@RequiredArgsConstructor
@ConfigurationProperties(prefix = "spring.redis")
public class RedisConfig extends AbstractRedisConfig {
private final ObjectMapper jackson;
@Autowired
private ObjectMapper jackson;
// ---------- 连接配置 ----------
@@ -53,57 +51,8 @@ public class RedisConfig extends AbstractRedisConfig {
/** 密码 */
private String password;
/** 数据库 */
private Database database;
/**
* 数据库
*
* @author 夜雨
* @since 2023-08-21 16:25
*/
@Data
public static class Database {
/** 分布式锁 */
private int locker;
/** 多语言环境 */
private int language;
/** 多语言键环境 */
private int languageMap;
/** 文章排位 */
private int articleRanking;
/** 文章阅读记录 */
private int articleRead;
/** 用户登录令牌 */
private int userToken;
/** 用户经验值标记 */
private int userExpFlag;
/** 用户邮箱验证 */
private int userEmailVerify;
/** 用户重置密码验证 */
private int userResetPWVerify;
/** 访问频率控制 */
private int rateLimit;
/** 系统配置 */
private int setting;
/** Minecraft 登录 */
private int fmcPlayerToken;
/** 共享剪切板 */
private int clipboard;
}
/** Redis 逻辑库 */
private int database;
@Override
protected RedisConfigParams configParams() {
@@ -149,96 +98,113 @@ public class RedisConfig extends AbstractRedisConfig {
/** @return 分布式锁, ID: 尝试加锁次数 */
@Bean("redisLocker")
public Redis<String, Integer> getLockerRedisTemplate() {
return getRedis(database.locker, RedisSerializers.STRING, RedisSerializers.INTEGER);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.INTEGER);
}
/** @return 多语言环境,ID: {@link Multilingual} */
@Bean("redisLanguage")
public Redis<Long, Multilingual> getLanguageRedisTemplate() {
return getRedis(database.language, RedisSerializers.LONG, new RedisSerializer<>() {
public Redis<String, Multilingual> getLanguageRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, Multilingual.class));
}
public Multilingual deserialize(@Nullable byte[] bytes) {
if (bytes == null || bytes.length == 0) {
return null;
}
try {
return (Multilingual) new DeserializingConverter().convert(bytes);
} catch (Exception var3) {
throw new SerializationException("Cannot deserialize", var3);
}
}
public byte[] serialize(@Nullable Multilingual multilingual) {
if (multilingual == null) {
return new byte[0];
} else {
try {
return new SerializingConverter().convert(multilingual);
} catch (Exception var3) {
throw new SerializationException("Cannot serialize", var3);
}
}
}
});
@Bean("redisCaptcha")
public Redis<String, String> getCaptchaRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
}
/** @return 文章访问记录,IP: [文章 ID] */
@Bean("redisLanguageMap")
public Redis<String, Long> getLanguageMapRedisTemplate() {
return getRedis(database.languageMap, RedisSerializers.STRING, RedisSerializers.LONG);
}
/** @return 文章访问统计,文章 ID: {@link ArticleRanking}(JSON) */
@Bean("redisArticleRanking")
public Redis<Long, ArticleRanking> getArticleRankingRedisTemplate() {
return getRedis(database.articleRanking, RedisSerializers.LONG, RedisSerializers.jacksonSerializer(jackson, ArticleRanking.class));
return getRedis(database, RedisSerializers.STRING, RedisSerializers.LONG);
}
/** @return 文章访问记录,IP: [文章 ID] */
@Bean("redisArticleRead")
public Redis<String, Long> getArticleReadRedisTemplate() {
return getRedis(database.articleRead, RedisSerializers.STRING, RedisSerializers.LONG);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.LONG);
}
/** @return 用户登录经验标记,UID: NULL,暂时没有值,数据死亡时间为次日零时 */
@Bean("redisUserExpFlag")
public Redis<Long, String> getUserExpFlagRedisTemplate() {
return getRedis(database.userExpFlag, RedisSerializers.LONG, RedisSerializers.STRING);
return getRedis(database, RedisSerializers.LONG, RedisSerializers.STRING);
}
/** @return 用户登录令牌,令牌: 用户 ID */
@Bean("redisUserToken")
public Redis<String, String> getUserTokenRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
}
/** @return 用户邮箱验证密钥,密钥: UID */
@Bean("redisUserEmailVerify")
public Redis<String, Long> getUserEmailVerifyRedisTemplate() {
return getRedis(database.userEmailVerify, RedisSerializers.STRING, RedisSerializers.LONG);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.LONG);
}
/** @return 用户重置密码密钥,密钥: UID */
@Bean("redisUserResetPWVerify")
public Redis<String, Long> getUserResetPWVerifyRedisTemplate() {
return getRedis(database.userResetPWVerify, RedisSerializers.STRING, RedisSerializers.LONG);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.LONG);
}
/** @return 用户手机号验证码,手机号: 验证码 */
@Bean("redisUserPhoneVerify")
public Redis<String, String> getUserPhoneVerifyRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
}
/** @return 接口访问控制,IP#方法: 生命周期内访问次数 */
@Bean("redisRateLimit")
public Redis<String, Integer> getRateLimitRedisTemplate() {
return getRedis(database.rateLimit, RedisSerializers.STRING, RedisSerializers.INTEGER);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.INTEGER);
}
/** @return 系统配置,Key 枚举: String 配置值 */
@Bean("redisSetting")
public Redis<String, String> getSettingRedisTemplate() {
return getRedis(database.setting, RedisSerializers.STRING, RedisSerializers.STRING);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
}
/** @return Minecraft 登录,令牌: 玩家 ID */
@Bean("redisMCPlayerToken")
public Redis<String, Long> getMCPlayerLoginRedisTemplate() {
return getRedis(database.fmcPlayerToken, RedisSerializers.STRING, RedisSerializers.LONG);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.LONG);
}
/** @return 共享剪切板,会话 ID: 内容 */
@Bean("redisClipboard")
public Redis<String, String> getClipboardRedisTemplate() {
return getRedis(database.clipboard, RedisSerializers.STRING, RedisSerializers.STRING);
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
}
/// @return GAO 用户邀请,code: 邀请缓存
@Bean("redisGaoUserInvite")
public Redis<String, GaoUserInviteCache> getGaoUserInviteRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoUserInviteCache.class));
}
/// @return AI 会话,AI 会话 ID: 会话授权内容
@Bean("redisGaoAiSession")
public Redis<String, GaoAiSession> getGaoAiSessionRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoAiSession.class));
}
/// @return AI 待确认操作,token 摘要/公开 ID: 待确认操作
@Bean("redisGaoAiOperation")
public Redis<String, GaoAiPendingOperation> getGaoAiOperationRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoAiPendingOperation.class));
}
/// @return AI 待确认操作索引,用户+门店/来源会话: 公开操作 ID
@Bean("redisGaoAiOperationIndex")
public Redis<String, String> getGaoAiOperationIndexRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
}
/// @return AI 附件凭证,token 摘要: 附件凭证
@Bean("redisGaoAiAttachment")
public Redis<String, GaoAiAttachmentToken> getGaoAiAttachmentRedisTemplate() {
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoAiAttachmentToken.class));
}
}
@@ -32,4 +32,22 @@ public class ThreadPoolConfig {
executor.initialize();
return executor;
}
/// 创建操作审计线程池
///
/// @return 操作审计线程池
@Bean(name = "auditTaskExecutor")
public ThreadPoolTaskExecutor auditTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(4);
executor.setMaxPoolSize(8);
executor.setQueueCapacity(2000);
executor.setKeepAliveSeconds(60);
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setAwaitTerminationSeconds(60);
executor.setThreadNamePrefix("audit-task-executor-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize();
return executor;
}
}
@@ -5,12 +5,12 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.imyeyu.api.annotation.EnableSettingInterceptor;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.imyeyu.api.annotation.RequestRateLimitInterceptor;
import com.imyeyu.api.annotation.RequiredTokenInterceptor;
import com.imyeyu.api.annotation.RequireCorePermissionInterceptor;
import com.imyeyu.api.modules.app.annotation.RequireAppPermissionInterceptor;
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermissionInterceptor;
import com.imyeyu.api.modules.journal.util.JournalAPIInterceptor;
import com.imyeyu.api.modules.minecraft.annotation.RequiredFMCServerTokenInterceptor;
import com.imyeyu.api.modules.system.util.SystemAPIInterceptor;
import com.imyeyu.spring.annotation.RequestBodyValueArgumentResolver;
import com.imyeyu.utils.Time;
import lombok.RequiredArgsConstructor;
@@ -37,12 +37,11 @@ import java.util.List;
public class WebConfig implements WebMvcConfigurer {
private final ObjectMapper jackson;
private final SystemAPIInterceptor systemAPIInterceptor;
private final JournalAPIInterceptor journalAPIInterceptor;
private final RequiredTokenInterceptor requiredTokenInterceptor;
private final EnableSettingInterceptor enableSettingInterceptor;
private final RequestRateLimitInterceptor requestRateLimitInterceptor;
private final RequiredFMCServerTokenInterceptor requiredFMCServerTokenInterceptor;
private final RequireGaoPermissionInterceptor requireGaoPermissionInterceptor;
private final RequireCorePermissionInterceptor requireCorePermissionInterceptor;
private final RequireAppPermissionInterceptor requireAppPermissionInterceptor;
/**
* 过滤器
@@ -51,11 +50,10 @@ public class WebConfig implements WebMvcConfigurer {
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(systemAPIInterceptor).addPathPatterns(SystemAPIInterceptor.PATH);
registry.addInterceptor(journalAPIInterceptor).addPathPatterns(JournalAPIInterceptor.PATH);
registry.addInterceptor(requiredFMCServerTokenInterceptor).addPathPatterns("/fmc/server/**");
registry.addInterceptor(requiredTokenInterceptor).addPathPatterns("/**");
registry.addInterceptor(enableSettingInterceptor).addPathPatterns("/**");
registry.addInterceptor(requireCorePermissionInterceptor).addPathPatterns("/**");
registry.addInterceptor(requireGaoPermissionInterceptor).addPathPatterns("/**");
registry.addInterceptor(requireAppPermissionInterceptor).addPathPatterns("/**");
registry.addInterceptor(requestRateLimitInterceptor).addPathPatterns("/**");
}
@@ -72,6 +70,7 @@ public class WebConfig implements WebMvcConfigurer {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
JsonMapper jsonMapper = JsonMapper.builder()
.addModule(new JavaTimeModule())
// 设置默认属性包含规则:忽略 null 值
.serializationInclusion(JsonInclude.Include.NON_NULL)
// 日期格式化
@@ -30,7 +30,6 @@ public class ForeverMCDBConfig {
public static final String ROLLBACKER = "foreverMCTransactionManager";
@Bean(name = "foreverMCDataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.forevermc")
public DataSource getPrimaryDateSource() throws SQLException {
HikariDataSource dataSource = new HikariDataSource();
@@ -50,7 +49,6 @@ public class ForeverMCDBConfig {
@Bean(name = "foreverMCSqlSessionFactory")
@Primary
public SqlSessionFactory primarySqlSessionFactory(@Qualifier("foreverMCDataSource") DataSource datasource) throws Exception {
org.apache.ibatis.session.Configuration config = new org.apache.ibatis.session.Configuration();
config.setUseGeneratedKeys(true);
@@ -64,7 +62,6 @@ public class ForeverMCDBConfig {
}
@Bean("foreverMCSqlSessionTemplate")
@Primary
public SqlSessionTemplate primarySqlSessionTemplate(@Qualifier("foreverMCSqlSessionFactory") SqlSessionFactory sessionfactory) {
return new SqlSessionTemplate(sessionfactory);
}
@@ -38,7 +38,6 @@ public class GiteaDBConfig {
public static final String ROLLBACKER = "giteaTransactionManager";
@Bean(name = "giteaDataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.gitea")
public DataSource dateSource() throws SQLException {
HikariDataSource dataSource = new HikariDataSource();
@@ -58,7 +57,6 @@ public class GiteaDBConfig {
@Bean(name = "giteaSqlSessionFactory")
@Primary
public SqlSessionFactory sessionFactory(@Qualifier("giteaDataSource") DataSource datasource) throws Exception {
org.apache.ibatis.session.Configuration config = new org.apache.ibatis.session.Configuration();
config.setUseGeneratedKeys(true);
@@ -69,7 +67,7 @@ public class GiteaDBConfig {
{
ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
List<String> mapperLocations = new ArrayList<>();
mapperLocations.add("classpath:mapper/gitea/**/*.xml");
// mapperLocations.add("classpath:mapper/gitea/**/*.xml");
for (String mapperLocation : mapperLocations) {
resources.addAll(List.of(resourceResolver.getResources(mapperLocation)));
}
@@ -92,7 +90,6 @@ public class GiteaDBConfig {
@Bean("giteaSqlSessionTemplate")
@Primary
public SqlSessionTemplate sessionTemplate(@Qualifier("giteaSqlSessionFactory") SqlSessionFactory sessionfactory) {
return new SqlSessionTemplate(sessionfactory);
}
@@ -8,6 +8,7 @@ import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.flyway.FlywayDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -20,6 +21,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
import java.sql.SQLException;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -31,15 +33,14 @@ import java.util.List;
*/
@Configuration
@MapperScan(basePackages = {
"com.imyeyu.api.modules.git.mapper",
"com.imyeyu.api.modules.bill.mapper",
"com.imyeyu.api.modules.blog.mapper",
"com.imyeyu.api.modules.gao.mapper",
"com.imyeyu.api.modules.user.mapper",
"com.imyeyu.api.modules.lyric.mapper",
"com.imyeyu.api.modules.mirror.mapper",
"com.imyeyu.api.modules.system.mapper",
"com.imyeyu.api.modules.common.mapper",
"com.imyeyu.api.modules.app.mapper",
"com.imyeyu.api.modules.journal.mapper",
"com.imyeyu.api.modules.minecraft.mapper"
}, sqlSessionFactoryRef = "timiServerSqlSessionFactory")
public class TimiServerDBConfig {
@@ -47,6 +48,7 @@ public class TimiServerDBConfig {
@Bean(name = "timiServerDataSource")
@Primary
@FlywayDataSource
@ConfigurationProperties(prefix = "spring.datasource.timiserver")
public DataSource getPrimaryDateSource() throws SQLException {
HikariDataSource dataSource = new HikariDataSource();
@@ -54,6 +56,9 @@ public class TimiServerDBConfig {
dataSource.setMinimumIdle(10);
dataSource.setMaximumPoolSize(100);
dataSource.setConnectionTestQuery("SELECT 1");
// 日统计按后端时区划分日期
String offset = OffsetDateTime.now().getOffset().getId();
dataSource.setConnectionInitSql("SET time_zone = '%s'".formatted("Z".equals(offset) ? "+00:00" : offset));
dataSource.setMaxLifetime(Time.S * 180);
dataSource.setIdleTimeout(Time.S * 120);
@@ -77,19 +82,16 @@ public class TimiServerDBConfig {
{
ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
List<String> mapperLocations = new ArrayList<>();
mapperLocations.add("classpath:mapper/git/**/*.xml");
mapperLocations.add("classpath:mapper/blog/**/*.xml");
mapperLocations.add("classpath:mapper/common/**/*.xml");
mapperLocations.add("classpath:mapper/system/**/*.xml");
mapperLocations.add("classpath:mapper/journal/**/*.xml");
mapperLocations.add("classpath:mapper/minecraft/**/*.xml");
mapperLocations.add("classpath:mapper/timi-server/**/*.xml");
for (String mapperLocation : mapperLocations) {
resources.addAll(List.of(resourceResolver.getResources(mapperLocation)));
}
}
String[] typeAliases = {
"com.imyeyu.api.modules.git.entity",
"com.imyeyu.api.modules.gao.entity",
"com.imyeyu.api.modules.bill.entity",
"com.imyeyu.api.modules.user.entity",
"com.imyeyu.api.modules.blog.entity",
"com.imyeyu.api.modules.lyric.entity",
"com.imyeyu.api.modules.mirror.entity",
@@ -0,0 +1,29 @@
package com.imyeyu.api.modules.app.annotation;
import com.imyeyu.api.bean.PermissionMatchMode;
import com.imyeyu.api.modules.app.bean.AppPermissionCode;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
///
/// 要求 APP 模块权限
///
/// @author Codex
/// @since 2026-11-06
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequireAppPermission {
/// 所需权限
///
/// @return 权限列表
AppPermissionCode[] value();
/// 匹配模式
///
/// @return 匹配模式
PermissionMatchMode mode() default PermissionMatchMode.ALL;
}
@@ -0,0 +1,48 @@
package com.imyeyu.api.modules.app.annotation;
import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.bean.PermissionMatchMode;
import com.imyeyu.api.modules.app.bean.AppPermissionCode;
import com.imyeyu.api.modules.user.service.PermissionChecker;
import com.imyeyu.java.TimiJava;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import java.util.Arrays;
///
/// APP 权限注解处理器
///
/// @author Codex
/// @since 2026-11-06
@Component
public class RequireAppPermissionInterceptor implements HandlerInterceptor {
private final PermissionChecker permissionChecker;
public RequireAppPermissionInterceptor(PermissionChecker permissionChecker) {
this.permissionChecker = permissionChecker;
}
@Override
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) {
if (!(handler instanceof HandlerMethod handlerMethod)) {
return true;
}
RequireAppPermission annotation = handlerMethod.getMethodAnnotation(RequireAppPermission.class);
if (annotation == null || TimiJava.isEmpty(annotation.value())) {
return true;
}
String[] permissionCodeList = Arrays.stream(annotation.value()).map(AppPermissionCode::getValue).toArray(String[]::new);
if (annotation.mode() == PermissionMatchMode.ANY) {
permissionChecker.checkAny(ModuleCode.APP, permissionCodeList);
} else {
permissionChecker.checkAll(ModuleCode.APP, permissionCodeList);
}
return true;
}
}
@@ -0,0 +1,47 @@
package com.imyeyu.api.modules.app.bean;
import com.imyeyu.api.bean.ModuleCode;
import com.imyeyu.api.modules.user.bean.BuiltinPermissionCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
///
/// APP 模块权限枚举
///
/// @author Codex
/// @since 2026-11-06
@Getter
@AllArgsConstructor
public enum AppPermissionCode implements BuiltinPermissionCode {
APP_PRODUCT_CREATE("APP_PRODUCT:CREATE", "应用产品创建", false, true),
APP_PRODUCT_READ("APP_PRODUCT:READ", "应用产品读取", false, true),
APP_PRODUCT_UPDATE("APP_PRODUCT:UPDATE", "应用产品修改", false, true),
APP_PRODUCT_DELETE("APP_PRODUCT:DELETE", "应用产品删除", false, true),
APP_CHANNEL_CREATE("APP_CHANNEL:CREATE", "应用通道创建", false, true),
APP_CHANNEL_DELETE("APP_CHANNEL:DELETE", "应用通道删除", false, true),
APP_RELEASE_CREATE("APP_RELEASE:CREATE", "应用发布创建", false, true),
APP_RELEASE_READ("APP_RELEASE:READ", "应用发布读取", false, true),
APP_RELEASE_PUBLISH("APP_RELEASE:PUBLISH", "应用发布上线", false, true),
APP_RELEASE_ROLLBACK("APP_RELEASE:ROLLBACK", "应用发布回滚", false, true),
APP_RELEASE_REVOKE("APP_RELEASE:REVOKE", "应用发布撤回", false, true),
APP_RELEASE_DELETE("APP_RELEASE:DELETE", "应用发布删除", false, true);
private final String value;
private final String defaultName;
private final boolean grantToSystem;
private final boolean grantToAdmin;
/// 权限模块
///
/// @return 模块代码
@Override
public ModuleCode getModuleCode() {
return ModuleCode.APP;
}
}
@@ -0,0 +1,184 @@
package com.imyeyu.api.modules.app.controller;
import com.imyeyu.api.modules.app.annotation.RequireAppPermission;
import com.imyeyu.api.modules.app.bean.AppPermissionCode;
import com.imyeyu.api.modules.app.entity.AppChannel;
import com.imyeyu.api.modules.app.entity.AppProduct;
import com.imyeyu.api.modules.app.entity.AppRelease;
import com.imyeyu.api.modules.app.service.AppVersionService;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
///
/// 应用发布管理接口
///
/// 操作人一律取当前登录身份,不接受请求参数指定
/// 用 API Key 调用时为密钥归属用户,用登录令牌调用时为登录用户
///
/// @author Codex
/// @since 2026-11-06
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/app")
public class AppReleaseController {
private final AppVersionService service;
private final UserLoginService userLoginService;
/// 查询产品列表
///
/// @return 产品列表
@RequireAppPermission(AppPermissionCode.APP_PRODUCT_READ)
@RequestRateLimit
@PostMapping("/product/list")
public List<AppProduct> productList() {
return service.listProducts();
}
/// 保存产品
///
/// @param product 产品
/// @return 保存后的产品
@AOPLog
@RequireAppPermission({AppPermissionCode.APP_PRODUCT_CREATE, AppPermissionCode.APP_PRODUCT_UPDATE})
@RequestRateLimit
@PostMapping("/product/save")
public AppProduct productSave(@RequestBody AppProduct product) {
return service.saveProduct(product);
}
/// 查询发布列表
///
/// @param productId 产品 ID
/// @return 发布列表
@RequireAppPermission(AppPermissionCode.APP_RELEASE_READ)
@RequestRateLimit
@GetMapping("/release/list")
public List<AppRelease> releaseList(@RequestParam String productId) {
return service.listReleases(productId);
}
/// 创建发布记录
///
/// @param release 发布记录
/// @return 创建后的记录
@AOPLog
@RequireAppPermission(AppPermissionCode.APP_RELEASE_CREATE)
@RequestRateLimit
@PostMapping("/release/create")
public AppRelease releaseCreate(@RequestBody AppRelease release) {
return service.create(release, operator());
}
/// 发布版本
///
/// @param releaseId 发布 ID
/// @param channelCode 通道代码
/// @param grayPermille 灰度比例,万分比
/// @param note 变更说明
@AOPLog
@RequireAppPermission(AppPermissionCode.APP_RELEASE_PUBLISH)
@RequestRateLimit
@PostMapping("/release/publish")
public void publish(
@RequestParam String releaseId,
@RequestParam(defaultValue = AppVersionService.DEFAULT_CHANNEL) String channelCode,
@RequestParam(required = false) Integer grayPermille,
@RequestParam(required = false) String note
) {
service.publish(releaseId, channelCode, grayPermille, operator(), note);
}
/// 回滚通道到指定版本
///
/// @param productId 产品 ID
/// @param channelCode 通道代码
/// @param targetReleaseId 目标发布 ID
@AOPLog
@RequireAppPermission(AppPermissionCode.APP_RELEASE_ROLLBACK)
@RequestRateLimit
@PostMapping("/release/rollback")
public void rollback(
@RequestParam String productId,
@RequestParam(defaultValue = AppVersionService.DEFAULT_CHANNEL) String channelCode,
@RequestParam String targetReleaseId
) {
service.rollback(productId, channelCode, targetReleaseId, operator());
}
/// 撤回发布
///
/// @param releaseId 发布 ID
@AOPLog
@RequireAppPermission(AppPermissionCode.APP_RELEASE_REVOKE)
@RequestRateLimit
@PostMapping("/release/revoke")
public void revoke(@RequestParam String releaseId) {
service.revoke(releaseId, operator());
}
/// 查询通道列表
///
/// @param productId 产品 ID
/// @return 通道列表
@RequireAppPermission(AppPermissionCode.APP_RELEASE_READ)
@RequestRateLimit
@GetMapping("/channel/list")
public List<AppChannel> channelList(@RequestParam String productId) {
return service.listChannels(productId);
}
/// 删除草稿发布
///
/// @param releaseId 发布 ID
@AOPLog
@RequireAppPermission(AppPermissionCode.APP_RELEASE_DELETE)
@RequestRateLimit
@PostMapping("/release/delete")
public void releaseDelete(@RequestParam String releaseId) {
service.deleteRelease(releaseId, operator());
}
/// 删除通道
///
/// @param channelId 通道 ID
@AOPLog
@RequireAppPermission(AppPermissionCode.APP_CHANNEL_DELETE)
@RequestRateLimit
@PostMapping("/channel/delete")
public void channelDelete(@RequestParam String channelId) {
service.deleteChannel(channelId, operator());
}
/// 删除产品
///
/// @param productId 产品 ID
@AOPLog
@RequireAppPermission(AppPermissionCode.APP_PRODUCT_DELETE)
@RequestRateLimit
@PostMapping("/product/delete")
public void productDelete(@RequestParam String productId) {
service.deleteProduct(productId, operator());
}
/// 取当前操作人
///
/// 接口都带权限注解,执行到这里一定已登录,取不到会直接抛错
///
/// @return 当前登录用户 ID
private String operator() {
return userLoginService.getRequireLoginUserId();
}
}
@@ -0,0 +1,56 @@
package com.imyeyu.api.modules.app.controller;
import com.imyeyu.api.modules.app.service.AppVersionService;
import com.imyeyu.api.modules.app.vo.AppUpdateCheckRequest;
import com.imyeyu.api.modules.app.vo.AppUpdateCheckResponse;
import com.imyeyu.api.modules.app.vo.AppUpdateNotesResponse;
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
import com.imyeyu.spring.annotation.RequestRateLimit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
///
/// 应用更新接口
///
/// 供 Capacitor 插件直接调用,不要求登录态,因此不加权限注解
///
/// @author Codex
/// @since 2026-11-06
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/app/update")
public class AppUpdateController {
private final AppVersionService service;
/// 检查更新
///
/// 直接返回插件要求的原始 JSON,不能套通用响应包装
///
/// @param req 插件上报信息
/// @return 插件协议响应
@IgnoreGlobalReturn
@RequestRateLimit
@PostMapping("/check")
public AppUpdateCheckResponse check(@RequestBody AppUpdateCheckRequest req) {
return service.check(req);
}
/// 查询更新日志
///
/// 返回当前运行版本到目标版本之间的变更说明,供版本历史页使用
/// 目标版本与 check 用同一套规则解析,包含灰度与兼容区间,保证「有日志」和「能更新」一致
///
/// @param req 插件上报信息,version_name 为当前运行版本
/// @return 更新日志
@RequestRateLimit
@PostMapping("/notes")
public AppUpdateNotesResponse notes(@RequestBody AppUpdateCheckRequest req) {
return service.notes(req);
}
}
@@ -0,0 +1,38 @@
package com.imyeyu.api.modules.app.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
///
/// 应用发布通道
///
/// 通道分别持有热更包和原生包指针
///
/// @author Codex
/// @since 2026-11-06
@Data
@EqualsAndHashCode(callSuper = true)
public class AppChannel extends UUIDEntity {
/// 产品 ID
protected String productId;
/// 通道代码,如 stable、beta
protected String code;
/// 通道名称
protected String name;
/// 当前热更包发布 ID
protected String bundleReleaseId;
/// 当前原生包发布 ID
protected String nativeReleaseId;
/// 过渡期旧指针
protected String releaseId;
/// 最后操作人用户 ID
protected String updatedBy;
}
@@ -0,0 +1,43 @@
package com.imyeyu.api.modules.app.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
///
/// 应用产品
///
/// @author Codex
/// @since 2026-11-06
@Data
@EqualsAndHashCode(callSuper = true)
public class AppProduct extends UUIDEntity {
/// 平台
public enum Platform {
/// Android
ANDROID,
/// iOS
IOS
}
/// 产品标识,取 Capacitor appId
protected String appKey;
/// 产品名称
protected String name;
/// 平台
protected Platform platform;
/// 包名
protected String packageName;
/// 检查接口密钥,为空时不校验
protected String updateKey;
/// true 为允许检查更新
protected Boolean enabled;
}
@@ -0,0 +1,85 @@
package com.imyeyu.api.modules.app.entity;
import com.imyeyu.spring.entity.UUIDEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
///
/// 应用发布记录
///
/// 创建后不可变,回滚只改通道指针,不修改本记录
///
/// @author Codex
/// @since 2026-11-06
@Data
@EqualsAndHashCode(callSuper = true)
public class AppRelease extends UUIDEntity {
/// 产物类型
public enum Kind {
/// 原生安装包
NATIVE,
/// Web 热更包
BUNDLE
}
/// 发布状态
public enum Status {
/// 待发布
DRAFT,
/// 已发布
PUBLISHED,
/// 已撤回
REVOKED
}
/// 产品 ID
protected String productId;
/// 产物类型
protected Kind kind;
/// 版本号,热更包为 semver
protected String versionName;
/// 原生 versionCode,kind 为 NATIVE 时必填
protected Integer versionCode;
/// 兼容的最低原生 versionCode,kind 为 BUNDLE 时必填
protected Integer minVersionCode;
/// 兼容的最高原生 versionCode,为空表示不限
protected Integer maxVersionCode;
/// 产物附件 ID
protected String attachmentId;
/// 产物字节数
protected Long artifactSize;
/// 产物 SHA-256
protected String sha256;
/// 灰度比例,万分比,10000 为全量
protected Integer grayPermille;
/// true 为强制更新,仅 kind 为 NATIVE 时有效
protected Boolean mandatory;
/// 发布状态
protected Status status;
/// 变更说明
protected String note;
/// 发布人用户 ID
protected String createdBy;
/// 首次发布时间
protected Long publishedAt;
}
@@ -0,0 +1,54 @@
package com.imyeyu.api.modules.app.mapper;
import com.imyeyu.api.modules.app.entity.AppChannel;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
///
/// 应用发布通道
///
/// @author Codex
/// @since 2026-11-06
public interface AppChannelMapper extends BaseMapper<AppChannel, String> {
/// 按产品与通道代码查询
///
/// @param productId 产品 ID
/// @param code 通道代码
/// @return 通道
@Select("SELECT * FROM app_channel WHERE product_id = #{productId} AND code = #{code} AND deleted_at IS NULL LIMIT 1")
AppChannel selectByProductAndCode(@Param("productId") String productId, @Param("code") String code);
/// 按产品查询通道列表
///
/// @param productId 产品 ID
/// @return 通道列表
@Select("SELECT * FROM app_channel WHERE product_id = #{productId} AND deleted_at IS NULL ORDER BY code")
List<AppChannel> selectByProduct(@Param("productId") String productId);
/// 切换通道指针
///
/// @param id 通道 ID
/// @param releaseId 目标发布 ID,为空表示指向空
/// @param updatedBy 操作人用户 ID
/// @param updatedAt 更新时间
/// @return 影响行数
@Update("UPDATE app_channel SET release_id = #{releaseId}, updated_by = #{updatedBy}, updated_at = #{updatedAt} WHERE id = #{id}")
int updateReleaseId(
@Param("id") String id,
@Param("releaseId") String releaseId,
@Param("updatedBy") String updatedBy,
@Param("updatedAt") Long updatedAt
);
/// 按类型切换指针并同步旧指针
@Update("UPDATE app_channel SET bundle_release_id = CASE WHEN #{nativeRelease} = false THEN #{releaseId} ELSE bundle_release_id END, native_release_id = CASE WHEN #{nativeRelease} = true THEN #{releaseId} ELSE native_release_id END, release_id = #{releaseId}, updated_by = #{updatedBy}, updated_at = #{updatedAt} WHERE id = #{id}")
int updatePointers(@Param("id") String id, @Param("releaseId") String releaseId, @Param("nativeRelease") boolean nativeRelease, @Param("updatedBy") String updatedBy, @Param("updatedAt") Long updatedAt);
/// 清除所有通道中指向撤回记录的指针
@Update("UPDATE app_channel SET bundle_release_id = CASE WHEN bundle_release_id = #{releaseId} THEN NULL ELSE bundle_release_id END, native_release_id = CASE WHEN native_release_id = #{releaseId} THEN NULL ELSE native_release_id END, release_id = CASE WHEN release_id = #{releaseId} THEN NULL ELSE release_id END, updated_by = #{updatedBy}, updated_at = #{updatedAt} WHERE product_id = #{productId} AND deleted_at IS NULL AND (bundle_release_id = #{releaseId} OR native_release_id = #{releaseId} OR release_id = #{releaseId})")
int clearRelease(@Param("productId") String productId, @Param("releaseId") String releaseId, @Param("updatedBy") String updatedBy, @Param("updatedAt") Long updatedAt);
}
@@ -0,0 +1,22 @@
package com.imyeyu.api.modules.app.mapper;
import com.imyeyu.api.modules.app.entity.AppProduct;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
///
/// 应用产品
///
/// @author Codex
/// @since 2026-11-06
public interface AppProductMapper extends BaseMapper<AppProduct, String> {
/// 按产品标识查询
///
/// @param appKey 产品标识
/// @param platform 平台
/// @return 产品
@Select("SELECT * FROM app_product WHERE app_key = #{appKey} AND platform = #{platform} AND deleted_at IS NULL LIMIT 1")
AppProduct selectByAppKey(@Param("appKey") String appKey, @Param("platform") AppProduct.Platform platform);
}
@@ -0,0 +1,44 @@
package com.imyeyu.api.modules.app.mapper;
import com.imyeyu.api.modules.app.entity.AppRelease;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
///
/// 应用发布记录
///
/// @author Codex
/// @since 2026-11-06
public interface AppReleaseMapper extends BaseMapper<AppRelease, String> {
/// 查询产品下已发布的同类型产物
///
/// @param productId 产品 ID
/// @param kind 产物类型
/// @return 发布列表,按发布时间倒序
@Select("SELECT * FROM app_release WHERE product_id = #{productId} AND kind = #{kind} AND status = 'PUBLISHED' AND deleted_at IS NULL ORDER BY published_at DESC")
List<AppRelease> selectPublished(@Param("productId") String productId, @Param("kind") AppRelease.Kind kind);
/// 按版本号查询
///
/// @param productId 产品 ID
/// @param kind 产物类型
/// @param versionName 版本号
/// @return 发布记录
@Select("SELECT * FROM app_release WHERE product_id = #{productId} AND kind = #{kind} AND version_name = #{versionName} AND deleted_at IS NULL LIMIT 1")
AppRelease selectByVersion(
@Param("productId") String productId,
@Param("kind") AppRelease.Kind kind,
@Param("versionName") String versionName
);
/// 查询产品下全部发布记录
///
/// @param productId 产品 ID
/// @return 发布列表,按创建时间倒序
@Select("SELECT * FROM app_release WHERE product_id = #{productId} AND deleted_at IS NULL ORDER BY created_at DESC")
List<AppRelease> selectByProduct(@Param("productId") String productId);
}
@@ -0,0 +1,573 @@
package com.imyeyu.api.modules.app.service;
import com.imyeyu.api.modules.app.entity.AppChannel;
import com.imyeyu.api.modules.app.entity.AppProduct;
import com.imyeyu.api.modules.app.entity.AppRelease;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.app.mapper.AppChannelMapper;
import com.imyeyu.api.modules.app.mapper.AppProductMapper;
import com.imyeyu.api.modules.app.mapper.AppReleaseMapper;
import com.imyeyu.api.modules.app.vo.AppUpdateCheckRequest;
import com.imyeyu.api.modules.app.vo.AppUpdateCheckResponse;
import com.imyeyu.api.modules.app.vo.AppUpdateNote;
import com.imyeyu.api.modules.app.vo.AppUpdateNotesResponse;
import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService;
import com.imyeyu.java.TimiJava;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.zip.CRC32;
///
/// 应用版本服务
///
/// 核心只有一个判断:给定设备当前状态和通道,它此刻应该运行哪一份产物
///
/// @author Codex
/// @since 2026-11-06
@Slf4j
@Service
@RequiredArgsConstructor
public class AppVersionService {
/// 默认通道
public static final String DEFAULT_CHANNEL = "stable";
/// 内置包版本标识
public static final String BUILTIN_VERSION = "builtin";
/// 首个能处理外壳安装包的 Web 包版本
///
/// 更早的包不认识 shell 标记,只会把 url 当热更 zip 交给插件解压,拿到 APK 必然失败。
/// 通道指向原生包时,低于这个版本的设备改为下发热更包,先把它升到能自升级为止
public static final String SHELL_AWARE_VERSION = "1.3.2";
/// 首个按独立字段接收外壳更新的 Web 包版本
///
/// 从这版起响应把安装包放到 shellUrl,主字段 url 永远给热更包;
/// 更早的包只认「主字段 + shell 标记」,所以两套语义要并存到 1.5.0 铺开为止
public static final String SHELL_JSON_AWARE_VERSION = "1.5.0";
/// 更新日志最多返回的版本条数
public static final int MAX_NOTES = 8;
/// 已是最新时展示的版本条数
public static final int TAIL_NOTES = 8;
/// 灰度基数
private static final long GRAY_BASE = 10000L;
private final AppProductMapper productMapper;
private final AppChannelMapper channelMapper;
private final AppReleaseMapper releaseMapper;
private final LoggerService loggerService;
/// 检查更新
///
/// @param req 插件上报信息
/// @return 插件协议响应,无更新时回显当前版本
public AppUpdateCheckResponse check(AppUpdateCheckRequest req) {
String currentVersion = currentVersion(req);
AppProduct product = resolveProduct(req);
if (product == null) {
return AppUpdateCheckResponse.none(currentVersion);
}
int currentCode = parseInt(req.getVersionCode(), 0);
AppRelease bundlePointer = resolvePointer(product, req, AppRelease.Kind.BUNDLE);
AppRelease nativePointer = resolvePointer(product, req, AppRelease.Kind.NATIVE);
AppRelease bundle = bundlePointer == null ? null : resolveBundle(bundlePointer, product, currentCode, currentVersion, req.getDeviceId());
AppRelease nativeTarget = nativePointer == null ? null : resolveNative(nativePointer, currentCode);
boolean shellAware = 0 <= compareVersion(currentVersion, SHELL_AWARE_VERSION);
boolean jsonAware = 0 <= compareVersion(currentVersion, SHELL_JSON_AWARE_VERSION);
// 认识 shell 标记但还不认识独立字段的包,主字段继续给安装包
if (nativeTarget != null && shellAware && !jsonAware) {
return buildResponse(nativeTarget, Boolean.TRUE.equals(nativeTarget.getMandatory()), true);
}
AppUpdateCheckResponse response = bundle == null ? AppUpdateCheckResponse.none(currentVersion) : buildResponse(bundle, false, false);
if (nativeTarget != null && jsonAware) {
AppUpdateCheckResponse shell = buildResponse(nativeTarget, false, true);
response.setShellUrl(shell.getUrl());
response.setShellVersion(shell.getVersion());
response.setShellChecksum(shell.getChecksum());
response.setShellMandatory(Boolean.TRUE.equals(nativeTarget.getMandatory()));
}
return response;
}
/// 查询更新日志
///
/// 区间上界取通道当前版本,不走灰度与兼容区间判断。
/// 原因:客户端拿不到原生 versionCode,也无法保证命中灰度分桶,套用检查更新的判定会让日志
/// 大面积为空。日志是「这个产品最近发了什么」,不是「你这台设备能装什么」,分发决策仍由 check 负责
///
/// 有更新时返回 (当前版本, 通道版本] 区间;已是最新时区间为空,改为返回最近 TAIL_NOTES 个版本,
/// 否则更新完就看不到任何说明
///
/// @param req 插件上报信息
/// @return 变更说明,按版本号从新到旧
public AppUpdateNotesResponse notes(AppUpdateCheckRequest req) {
String currentVersion = currentVersion(req);
AppProduct product = resolveProduct(req);
if (product == null) {
return new AppUpdateNotesResponse(null, Collections.emptyList());
}
AppRelease target = resolvePointer(product, req, AppRelease.Kind.BUNDLE);
// 指针为空(刚建通道还没发过热更)时退回最近一次发布,日志不该跟着空
if (target == null) {
target = latestPublishedBundle(product);
}
if (target == null) {
return new AppUpdateNotesResponse(null, Collections.emptyList());
}
// 当前版本不低于通道版本:已是最新,或回滚后反而超前
boolean upToDate = 0 <= compareVersion(currentVersion, target.getVersionName());
List<AppUpdateNote> notes = new ArrayList<>();
for (AppRelease item : releaseMapper.selectPublished(product.getId(), AppRelease.Kind.BUNDLE)) {
// 上界恒定:不展示比通道版本更新的记录
if (0 < compareVersion(item.getVersionName(), target.getVersionName())) {
continue;
}
// 有更新时才设下界,已是最新则不限
if (!upToDate && 0 >= compareVersion(item.getVersionName(), currentVersion)) {
continue;
}
notes.add(new AppUpdateNote(item.getVersionName(), item.getNote(), item.getPublishedAt()));
}
// 按版本号倒序,最新的在最前
notes.sort((a, b) -> compareVersion(b.getVersion(), a.getVersion()));
int limit = upToDate ? TAIL_NOTES : MAX_NOTES;
List<AppUpdateNote> limited = limit < notes.size() ? notes.subList(0, limit) : notes;
return new AppUpdateNotesResponse(target.getVersionName(), limited);
}
/// 取当前运行的 Web 包版本
///
/// @param req 插件上报信息
/// @return 版本号,未上报时为内置包标识
private String currentVersion(AppUpdateCheckRequest req) {
return TimiJava.isEmpty(req.getVersionName()) ? BUILTIN_VERSION : req.getVersionName();
}
/// 解析并校验产品
///
/// @param req 插件上报信息
/// @return 产品,不存在、已停用或密钥不匹配时为 null
private AppProduct resolveProduct(AppUpdateCheckRequest req) {
AppProduct product = productMapper.selectByAppKey(req.getAppId(), parsePlatform(req.getPlatform()));
if (product == null || !Boolean.TRUE.equals(product.getEnabled())) {
log.warn("应用不存在或已停用,appId={}", req.getAppId());
return null;
}
if (!TimiJava.isEmpty(product.getUpdateKey()) && !product.getUpdateKey().equals(req.getKey())) {
log.warn("更新密钥不匹配,appId={}", req.getAppId());
return null;
}
return product;
}
/// 取通道当前指向的发布记录
///
/// @param product 产品
/// @param req 插件上报信息
/// @return 发布记录,通道为空或指向的记录不可用时为 null
private AppRelease resolvePointer(AppProduct product, AppUpdateCheckRequest req, AppRelease.Kind kind) {
String channelCode = TimiJava.isEmpty(req.getChannel()) ? DEFAULT_CHANNEL : req.getChannel();
AppChannel channel = channelMapper.selectByProductAndCode(product.getId(), channelCode);
if (channel == null) {
return null;
}
String id = kind == AppRelease.Kind.BUNDLE ? channel.getBundleReleaseId() : channel.getNativeReleaseId();
// 兼容旧代码在回滚期间仅更新旧指针的情况
if (TimiJava.isEmpty(id)) {
id = channel.getReleaseId();
}
if (TimiJava.isEmpty(id)) {
return null;
}
AppRelease release = releaseMapper.select(id);
return release != null && release.getKind() == kind && release.getStatus() == AppRelease.Status.PUBLISHED ? release : null;
}
/// 原生包是否需要更新
///
/// @param release 通道当前发布记录
/// @param currentCode 当前原生 versionCode
/// @return 需要更新时返回发布记录,否则返回 null
private AppRelease resolveNative(AppRelease release, int currentCode) {
if (release.getVersionCode() == null || release.getVersionCode() <= currentCode) {
return null;
}
return release;
}
/// 热更包是否需要更新
///
/// @param release 通道当前发布记录
/// @param product 产品
/// @param currentCode 当前原生 versionCode
/// @param currentVersion 当前 Web 包版本
/// @param deviceId 设备标识
/// @return 需要更新时返回发布记录,否则返回 null
private AppRelease resolveBundle(
AppRelease release,
AppProduct product,
int currentCode,
String currentVersion,
String deviceId
) {
// 原生版本不在兼容区间内,装了会崩
if (release.getMinVersionCode() != null && currentCode < release.getMinVersionCode()) {
return null;
}
if (release.getMaxVersionCode() != null && release.getMaxVersionCode() < currentCode) {
return null;
}
// 已是最新,或低于当前版本时不做降级
if (release.getVersionName().equals(currentVersion)) {
return null;
}
if (0 < compareVersion(currentVersion, release.getVersionName())) {
return null;
}
// 灰度分桶不能含 releaseId,否则每次发版都会重排用户
if (!hitGray(release.getGrayPermille(), deviceId, product.getAppKey())) {
return null;
}
return release;
}
/// 取最近一次发布的热更包
///
/// 通道指向原生包时,更新日志没有「通道版本」可用,改用这里兜底。
/// 日志是「这个产品最近发了什么」,与设备能不能装无关,所以不套灰度与兼容区间
///
/// @param product 产品
/// @return 版本最高的已发布热更包,没有则返回 null
private AppRelease latestPublishedBundle(AppProduct product) {
AppRelease latest = null;
for (AppRelease item : releaseMapper.selectPublished(product.getId(), AppRelease.Kind.BUNDLE)) {
if (latest == null || 0 < compareVersion(item.getVersionName(), latest.getVersionName())) {
latest = item;
}
}
return latest;
}
/// 判断设备是否命中灰度
///
/// @param grayPermille 灰度比例,万分比
/// @param deviceId 设备标识
/// @param appKey 产品标识
/// @return true 为命中
private boolean hitGray(Integer grayPermille, String deviceId, String appKey) {
if (grayPermille == null || GRAY_BASE <= grayPermille) {
return true;
}
if (TimiJava.isEmpty(deviceId)) {
return false;
}
CRC32 crc = new CRC32();
crc.update((deviceId + ":" + appKey).getBytes(StandardCharsets.UTF_8));
return crc.getValue() % GRAY_BASE < grayPermille;
}
/// 构造更新响应
///
/// note 为历史构建号时不下发,避免客户端把它当成更新说明展示
///
/// @param release 发布记录
/// @param mandatory true 为强制更新
/// @param shell true 为外壳安装包,客户端需要下载后覆盖安装
/// @return 更新响应
private AppUpdateCheckResponse buildResponse(AppRelease release, boolean mandatory, boolean shell) {
String url = ServletUriComponentsBuilder.fromCurrentContextPath()
.path("/attach/download/")
.path(release.getAttachmentId())
.toUriString();
return new AppUpdateCheckResponse(release.getVersionName(), url, release.getSha256(), mandatory, shell, release.getNote(), null, null, null, null);
}
/// 比较版本号
///
/// 只处理数字段,预发布标识按 0 处理
///
/// @param a 版本 A
/// @param b 版本 B
/// @return 负数表示 A 小于 B
private int compareVersion(String a, String b) {
if (BUILTIN_VERSION.equals(a)) {
return -1;
}
if (BUILTIN_VERSION.equals(b)) {
return 1;
}
String[] left = a.split("\\.");
String[] right = b.split("\\.");
int length = Math.max(left.length, right.length);
for (int i = 0; i < length; i++) {
int x = i < left.length ? parseInt(left[i], 0) : 0;
int y = i < right.length ? parseInt(right[i], 0) : 0;
if (x != y) {
return 0 < Integer.compare(x, y) ? 1 : -1;
}
}
return 0;
}
/// 安全解析整数
///
/// @param value 原始值
/// @param defaultValue 默认值
/// @return 解析结果
private int parseInt(String value, int defaultValue) {
if (TimiJava.isEmpty(value)) {
return defaultValue;
}
try {
return Integer.parseInt(value.trim());
} catch (NumberFormatException e) {
return defaultValue;
}
}
/// 解析平台
///
/// @param platform 平台字符串
/// @return 平台枚举
private AppProduct.Platform parsePlatform(String platform) {
if (TimiJava.isEmpty(platform)) {
return AppProduct.Platform.ANDROID;
}
try {
return AppProduct.Platform.valueOf(platform.trim().toUpperCase());
} catch (IllegalArgumentException e) {
return AppProduct.Platform.ANDROID;
}
}
/// 发布版本
///
/// @param releaseId 发布 ID
/// @param channelCode 通道代码
/// @param grayPermille 灰度比例,为空时保持原值
/// @param operatorId 操作人用户 ID
/// @param note 变更说明
@Transactional(TimiServerDBConfig.ROLLBACKER)
public void publish(String releaseId, String channelCode, Integer grayPermille, String operatorId, String note) {
AppRelease release = releaseMapper.select(releaseId);
if (release == null) {
throw new IllegalArgumentException("发布记录不存在");
}
AppChannel channel = channelMapper.selectByProductAndCode(release.getProductId(), channelCode);
if (channel == null) {
throw new IllegalArgumentException("通道不存在");
}
checkCompatibility(release);
Long now = System.currentTimeMillis();
// 发布不指定灰度按全量处理:草稿默认是 0,直接沿用会让所有设备都拿不到包
release.setGrayPermille(grayPermille == null ? (int) GRAY_BASE : grayPermille);
release.setStatus(AppRelease.Status.PUBLISHED);
if (release.getPublishedAt() == null) {
release.setPublishedAt(now);
}
release.setNote(TimiJava.isEmpty(note) ? release.getNote() : note);
release.setUpdatedAt(now);
releaseMapper.updateSelective(release);
channelMapper.updatePointers(channel.getId(), releaseId, release.getKind() == AppRelease.Kind.NATIVE, operatorId, now);
log("APP_RELEASE_PUBLISH", releaseId);
}
/// 回滚通道到指定发布
///
/// 回滚只改指针,同时把目标版本灰度拉满,否则只有部分设备能回退
///
/// @param productId 产品 ID
/// @param channelCode 通道代码
/// @param targetReleaseId 目标发布 ID
/// @param operatorId 操作人用户 ID
@Transactional(TimiServerDBConfig.ROLLBACKER)
public void rollback(String productId, String channelCode, String targetReleaseId, String operatorId) {
AppChannel channel = channelMapper.selectByProductAndCode(productId, channelCode);
if (channel == null) {
throw new IllegalArgumentException("通道不存在");
}
AppRelease target = releaseMapper.select(targetReleaseId);
if (target == null || !target.getProductId().equals(productId)) {
throw new IllegalArgumentException("目标发布不存在");
}
Long now = System.currentTimeMillis();
target.setGrayPermille((int) GRAY_BASE);
target.setStatus(AppRelease.Status.PUBLISHED);
target.setUpdatedAt(now);
releaseMapper.updateSelective(target);
channelMapper.updatePointers(channel.getId(), targetReleaseId, target.getKind() == AppRelease.Kind.NATIVE, operatorId, now);
log("APP_RELEASE_ROLLBACK", targetReleaseId);
}
/// 撤回发布
///
/// @param releaseId 发布 ID
/// @param operatorId 操作人用户 ID
@Transactional(TimiServerDBConfig.ROLLBACKER)
public void revoke(String releaseId, String operatorId) {
AppRelease release = releaseMapper.select(releaseId);
if (release == null) {
throw new IllegalArgumentException("发布记录不存在");
}
Long now = System.currentTimeMillis();
release.setStatus(AppRelease.Status.REVOKED);
release.setUpdatedAt(now);
releaseMapper.updateSelective(release);
channelMapper.clearRelease(release.getProductId(), releaseId, operatorId, now);
log("APP_RELEASE_REVOKE", releaseId);
}
/// 创建发布记录
///
/// @param release 发布记录
/// @param operatorId 操作人用户 ID
/// @return 创建后的记录
public AppRelease create(AppRelease release, String operatorId) {
AppRelease exists = releaseMapper.selectByVersion(release.getProductId(), release.getKind(), release.getVersionName());
if (exists != null) {
throw new IllegalArgumentException("版本已存在,不可重复使用版本号");
}
checkCompatibility(release);
Long now = System.currentTimeMillis();
release.setStatus(AppRelease.Status.DRAFT);
release.setGrayPermille(release.getGrayPermille() == null ? 0 : release.getGrayPermille());
release.setMandatory(Boolean.TRUE.equals(release.getMandatory()));
release.setCreatedBy(operatorId);
release.setCreatedAt(now);
releaseMapper.insert(release);
return release;
}
/// 查询产品列表
///
/// @return 产品列表
public List<AppProduct> listProducts() {
return productMapper.selectAll();
}
/// 保存产品
///
/// @param product 产品
/// @return 保存后的产品
public AppProduct saveProduct(AppProduct product) {
Long now = System.currentTimeMillis();
if (TimiJava.isEmpty(product.getId())) {
product.setEnabled(product.getEnabled() == null || product.getEnabled());
product.setCreatedAt(now);
productMapper.insert(product);
return product;
}
product.setUpdatedAt(now);
productMapper.updateSelective(product);
return productMapper.select(product.getId());
}
/// 查询产品发布列表
///
/// @param productId 产品 ID
/// @return 发布列表
public List<AppRelease> listReleases(String productId) {
return releaseMapper.selectByProduct(productId);
}
/// 查询产品通道列表
///
/// @param productId 产品 ID
/// @return 通道列表
public List<AppChannel> listChannels(String productId) {
return channelMapper.selectByProduct(productId);
}
/// 删除草稿发布
///
/// 已发布的版本不允许删除,必须走撤回
///
/// @param releaseId 发布 ID
/// @param operatorId 操作人用户 ID
public void deleteRelease(String releaseId, String operatorId) {
AppRelease release = releaseMapper.select(releaseId);
if (release == null) {
throw new IllegalArgumentException("发布记录不存在");
}
if (release.getStatus() == AppRelease.Status.PUBLISHED) {
throw new IllegalArgumentException("已发布的版本不能删除,请先撤回");
}
releaseMapper.delete(releaseId);
log("APP_RELEASE_DELETE", releaseId);
}
/// 删除通道
///
/// @param channelId 通道 ID
/// @param operatorId 操作人用户 ID
public void deleteChannel(String channelId, String operatorId) {
AppChannel channel = channelMapper.select(channelId);
if (channel == null) {
throw new IllegalArgumentException("通道不存在");
}
if (DEFAULT_CHANNEL.equals(channel.getCode())) {
throw new IllegalArgumentException("默认通道不能删除");
}
channelMapper.destroy(channelId);
log("APP_CHANNEL_DELETE", channelId);
}
/// 删除产品
///
/// 产品下仍有未删除的发布记录时拒绝删除,避免留下孤儿数据
///
/// @param productId 产品 ID
/// @param operatorId 操作人用户 ID
public void deleteProduct(String productId, String operatorId) {
AppProduct product = productMapper.select(productId);
if (product == null) {
throw new IllegalArgumentException("产品不存在");
}
if (!releaseMapper.selectByProduct(productId).isEmpty()) {
throw new IllegalArgumentException("产品下仍有发布记录,不能删除");
}
productMapper.destroy(productId);
log("APP_PRODUCT_DELETE", productId);
}
/// 校验兼容区间
///
/// @param release 发布记录
private void checkCompatibility(AppRelease release) {
if (release.getKind() != AppRelease.Kind.BUNDLE) {
if (release.getVersionCode() == null) {
throw new IllegalArgumentException("原生包必须指定 versionCode");
}
return;
}
if (release.getMinVersionCode() == null) {
throw new IllegalArgumentException("热更包必须指定兼容的最低原生 versionCode");
}
if (release.getMaxVersionCode() != null && release.getMaxVersionCode() < release.getMinVersionCode()) {
throw new IllegalArgumentException("兼容区间上限不能小于下限");
}
}
/// 写操作日志
///
/// @param action 操作标识
/// @param result 操作对象
private void log(String action, String result) {
Logger logger = new Logger(Logger.Module.APP, Logger.Level.INFO, action);
logger.setResult(result);
loggerService.create(logger);
}
}
@@ -0,0 +1,61 @@
package com.imyeyu.api.modules.app.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
///
/// 应用更新检查请求
///
/// 字段名遵循 Capgo 插件的上报协议,不可随意改名
///
/// @author Codex
/// @since 2026-11-06
@Data
public class AppUpdateCheckRequest {
/// 平台
@JsonProperty("platform")
protected String platform;
/// 设备标识,用于灰度分桶
@JsonProperty("device_id")
protected String deviceId;
/// 产品标识,取 Capacitor appId
@JsonProperty("app_id")
protected String appId;
/// 当前运行的 Web 包版本,内置包为 builtin
@JsonProperty("version_name")
protected String versionName;
/// 当前原生 versionCode
@JsonProperty("version_code")
protected String versionCode;
/// 当前原生版本名
@JsonProperty("version_build")
protected String versionBuild;
/// 插件版本
@JsonProperty("plugin_version")
protected String pluginVersion;
/// 系统版本
@JsonProperty("version_os")
protected String versionOs;
/// true 为模拟器
@JsonProperty("is_emulator")
protected Boolean emulator;
/// true 为生产包
@JsonProperty("is_prod")
protected Boolean prod;
/// 通道代码,为空时取 stable
protected String channel;
/// 检查接口密钥
protected String key;
}
@@ -0,0 +1,61 @@
package com.imyeyu.api.modules.app.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
///
/// 应用更新检查响应
///
/// Capgo 插件要求 url 必须存在,无更新时回显当前版本号让插件跳过下载
///
/// @author Codex
/// @since 2026-11-06
@Data
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AppUpdateCheckResponse {
/// 版本号
protected String version;
/// 产物下载地址
protected String url;
/// 产物 SHA-256
protected String checksum;
/// 是否为强制更新
protected Boolean mandatory;
/// 是否为外壳安装包
///
/// 客户端据此判断走热更还是下载安装包。字段名不能叫 kind:
/// Capgo 插件把 kind 视为错误响应的标记,收到后会直接判为检查失败
protected Boolean shell;
/// 变更说明,供 App 展示更新日志
///
/// 字段名不能叫 message:Capgo 插件把 message 当作错误信息,收到会直接判为检查失败
protected String note;
/// 外壳下载地址
protected String shellUrl;
/// 外壳版本
protected String shellVersion;
/// 外壳 SHA-256
protected String shellChecksum;
/// true 为强制更新
protected Boolean shellMandatory;
/// 构建无更新响应,version 与当前一致时插件不会下载
///
/// @param currentVersion 当前运行的 Web 包版本
/// @return 无更新响应
public static AppUpdateCheckResponse none(String currentVersion) {
return new AppUpdateCheckResponse(currentVersion, "", null, false, null, null, null, null, null, null);
}
}
@@ -0,0 +1,23 @@
package com.imyeyu.api.modules.app.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
///
/// 单条版本变更说明
///
/// @author Codex
/// @since 2026-11-13
@Data
@AllArgsConstructor
public class AppUpdateNote {
/// 版本号
protected String version;
/// 变更说明,来自发布记录的 note
protected String note;
/// 首次发布时间
protected Long publishedAt;
}
@@ -0,0 +1,24 @@
package com.imyeyu.api.modules.app.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
///
/// 应用更新日志响应
///
/// 供 App 的版本历史页使用,返回当前运行版本到目标版本之间的全部变更说明
///
/// @author Codex
/// @since 2026-11-13
@Data
@AllArgsConstructor
public class AppUpdateNotesResponse {
/// 目标版本号,为空表示当前没有可更新到的版本
protected String version;
/// 变更说明,按版本号从新到旧
protected List<AppUpdateNote> notes;
}
@@ -1,93 +0,0 @@
package com.imyeyu.api.modules.blog.controller;
import com.imyeyu.api.modules.blog.entity.Article;
import com.imyeyu.api.modules.blog.entity.ArticleRanking;
import com.imyeyu.api.modules.blog.service.ArticleService;
import com.imyeyu.api.modules.blog.vo.article.ArticleView;
import com.imyeyu.api.modules.blog.vo.article.KeywordPage;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 文章接口
*
* @author 夜雨
* @since 2021-02-17 17:47
*/
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/article")
public class ArticleController {
private final ArticleService service;
/**
* 查看
*
* @param id 文章 ID
* @return 文章
*/
@AOPLog
@RequestRateLimit
@RequestMapping("/{id}")
public ArticleView view(@Min(1) @NotNull @PathVariable Long id) {
return service.view(id);
}
/**
* 喜欢文章
*
* @param id 文章 ID
* @return 最新喜欢数量
*/
@AOPLog
@RequestRateLimit
@RequestMapping("/like/{id}")
public int like(@Min(1) @NotNull @PathVariable Long id) {
return service.like(id);
}
/**
* 主列表
*
* @param page 页面参数
* @return 文章列表
*/
@RequestRateLimit
@RequestMapping("/list")
public PageResult<Article> list(@Valid @RequestBody Page page) {
return service.page(page);
}
/**
* 根据关键字获取列表
*
* @param page 关键字页面参数
* @return 文章列表
*/
@RequestRateLimit
@RequestMapping("/list/search")
public PageResult<Article> listByKeyword(@Valid @RequestBody KeywordPage page) {
return service.pageByKeyword(page);
}
/** @return 每周访问排位 */
@RequestMapping("/list/ranking")
public List<ArticleRanking> ranking() {
return service.listRanking();
}
}
@@ -1,32 +0,0 @@
package com.imyeyu.api.modules.blog.controller;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.imyeyu.api.modules.blog.entity.Friend;
import com.imyeyu.api.modules.blog.service.FriendService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 主控
*
* @author 夜雨
* @since 2023-02-04 10:28
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/")
public class BlogController {
private final FriendService friendService;
/** @return 所有友链列表 */
@GetMapping("/friend")
public List<Friend> friend() {
return friendService.listAll();
}
}
@@ -1,92 +0,0 @@
package com.imyeyu.api.modules.blog.entity;
import com.fasterxml.jackson.databind.JsonNode;
import com.imyeyu.api.modules.common.bean.CommentSupport;
import com.imyeyu.spring.entity.Destroyable;
import com.imyeyu.spring.entity.Entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 文章
*
* @author 夜雨
* @since 2021-03-01 17:10
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class Article extends Entity implements CommentSupport, Destroyable {
/**
* 文章渲染类型,对应前端模板
*
* @author 夜雨
* @since 2021-07-04 09:23
*/
public enum Type {
/** 公版 */
PUBLIC,
/** 音乐 */
MUSIC,
/** 软件 */
SOFTWARE
}
/** 标题 */
protected String title;
/** 类型 */
protected Type type;
/** 摘要 */
protected String digest;
/** 数据 */
protected String data;
/** 扩展数据 */
protected JsonNode extendData;
/** 阅读数量 */
protected int reads;
/** 喜欢数量 */
protected int likes;
/** true 为显示评论 */
protected boolean showComment;
/** true 为可评论 */
protected boolean canComment;
/** true 为可排位 */
protected boolean canRanking;
/** true 为可通过列表查询 */
protected boolean canList;
/** @return true 为可评论 */
@Override
public boolean canComment() {
return canComment;
}
/** @return true 为不可评论 */
@Override
public boolean canNotComment() {
return !canComment;
}
/** @return true 为可排位 */
public boolean canRanking() {
return canRanking;
}
/** @return true 为不可排位 */
public boolean canNotRanking() {
return !canRanking;
}
}
@@ -1,35 +0,0 @@
package com.imyeyu.api.modules.blog.entity;
import com.imyeyu.spring.entity.Entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 访问排行(每周)
* 只记录访问次数、标题和最近访问,具体文章由 Redis key 记录
*
* @author 夜雨
* @since 2021-03-01 17:10
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ArticleRanking extends Entity {
private String title;
private Article.Type type;
private int count = 1;
private Long recentAt; // 最近访问
public ArticleRanking(Long id, String title, Article.Type type) {
setId(id);
this.title = title;
this.type = type;
}
/** 访问计数 + 1 */
public void read() {
count++;
}
}
@@ -1,36 +0,0 @@
package com.imyeyu.api.modules.blog.entity;
import com.imyeyu.api.modules.common.entity.CommentReply;
import com.imyeyu.spring.annotation.table.AutoUUID;
import com.imyeyu.spring.annotation.table.Id;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 评论回复提醒队列,和 CommentReplyRecord 不一样,本队列在推送消息后就删除,而后者会持久保存
*
* <p>基本逻辑:
* <pre>
* 触发:用户回复一条评论
* 条件:被回复者是注册用户 && 不是回复自己 && 邮箱已验证 && 接收回复提醒邮件
* 事件:添加本对象到队列列表,等待邮件推送服务调度,邮件推送服务
* </pre>
* 会针对用户收集本队列消息组合成邮件再一并推送
*
* @author 夜雨
* @since 2021-08-25 00:00
*/
@Data
@NoArgsConstructor
public class CommentRemindQueue {
@Id
@AutoUUID
private String UUID;
private Long userId;
private Long replyId;
private CommentReply reply;
}
@@ -1,21 +0,0 @@
package com.imyeyu.api.modules.blog.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import com.imyeyu.spring.entity.Entity;
/**
* 夜雨 创建于 2021-07-15 15:59
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class Friend extends Entity {
private String icon;
private String name;
private String link;
}
@@ -1,33 +0,0 @@
package com.imyeyu.api.modules.blog.mapper;
import com.imyeyu.api.modules.blog.entity.Article;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 文章
*
* @author 夜雨
* @since 2021-02-23 21:34
*/
public interface ArticleMapper extends BaseMapper<Article, Long> {
@Override
long countByPage(Page page);
@Override
List<Article> selectByPage(Page page);
long countByKeyword(String keyword);
List<Article> selectByKeyword(String keyword, Long offset, long limit);
@Select("UPDATE `article` SET `likes` = `likes` + 1 WHERE `id` = #{articleId}")
void like(Long articleId);
@Select("UPDATE `article` SET `reads` = `reads` + 1 WHERE `id` = #{articleId}")
void read(Long articleId);
}
@@ -1,20 +0,0 @@
package com.imyeyu.api.modules.blog.mapper;
import com.imyeyu.api.modules.blog.entity.Friend;
import com.imyeyu.spring.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 友链
*
* @author 夜雨
* @since 2021-07-15 16:11
*/
public interface FriendMapper extends BaseMapper<Friend, Long> {
@Select("SELECT * FROM friend WHERE 1 = 1" + NOT_DELETE)
List<Friend> listAll();
}
@@ -1,48 +0,0 @@
package com.imyeyu.api.modules.blog.service;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.api.modules.blog.entity.Article;
import com.imyeyu.api.modules.blog.entity.ArticleRanking;
import com.imyeyu.api.modules.blog.vo.article.ArticleView;
import com.imyeyu.api.modules.blog.vo.article.KeywordPage;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.service.GettableService;
import com.imyeyu.spring.service.PageableService;
import java.util.List;
/**
* 文章服务
*
* @author 夜雨
* @since 2021-02-23 21:33
*/
public interface ArticleService extends GettableService<Article, Long>, PageableService<Article> {
/**
* 获取文章,此方法触发阅读计数,包括触发每周热门排行统计,同一 IP 3 小时内访问多次的文章只计一次
*
* @param id 文章 ID
* @throws TimiException 服务异常
*/
ArticleView view(long id);
PageResult<Article> pageByKeyword(KeywordPage page);
/**
* 获取每周阅读排行
*
* @return 热门文章列表
* @throws TimiException 服务异常
*/
List<ArticleRanking> listRanking();
/**
* 喜欢文章
*
* @param articleId 文章 ID
* @return 最新喜欢数量
* @throws TimiException 服务异常
*/
int like(Long articleId);
}
@@ -1,41 +0,0 @@
package com.imyeyu.api.modules.blog.service;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.api.modules.blog.entity.CommentRemindQueue;
import com.imyeyu.spring.service.CreatableService;
import java.util.List;
/**
* 评论回复队列服务
*
* @author 夜雨
* @since 2021-08-25 00:11
*/
public interface CommentRemindQueueService extends CreatableService<CommentRemindQueue> {
/**
* 根据用户 ID 获取
*
* @param userId 用户 ID
* @return 回复提醒列表
* @throws TimiException 服务异常
*/
List<CommentRemindQueue> listByUserId(Long userId);
/**
* 根据用户 ID 移出队列
*
* @param uid 用户 ID
* @throws TimiException 服务异常
*/
void destroyByUserId(Long uid);
/**
* 根据回复 ID 移出队列
*
* @param rid 回复 ID
* @throws TimiException 服务异常
*/
void destroyByReplyId(Long rid);
}
@@ -1,16 +0,0 @@
package com.imyeyu.api.modules.blog.service;
import com.imyeyu.api.modules.blog.entity.Friend;
import java.util.List;
/**
* 友链服务
*
* @author 夜雨
* @since 2021-07-15 16:04
*/
public interface FriendService {
List<Friend> listAll();
}
@@ -1,122 +0,0 @@
package com.imyeyu.api.modules.blog.service.implement;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.blog.entity.Article;
import com.imyeyu.api.modules.blog.entity.ArticleRanking;
import com.imyeyu.api.modules.blog.mapper.ArticleMapper;
import com.imyeyu.api.modules.blog.service.ArticleService;
import com.imyeyu.api.modules.blog.vo.article.ArticleView;
import com.imyeyu.api.modules.blog.vo.article.KeywordPage;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.entity.Comment;
import com.imyeyu.api.modules.common.entity.Tag;
import com.imyeyu.api.modules.common.mapper.CommentMapper;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.common.service.TagService;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.mapper.BaseMapper;
import com.imyeyu.spring.service.AbstractEntityService;
import com.imyeyu.spring.util.Redis;
import com.imyeyu.utils.Time;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Comparator;
import java.util.List;
/**
* 文章服务实现
*
* @author 夜雨
* @since 2021-02-17 17:48
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ArticleServiceImplement extends AbstractEntityService<Article, Long> implements ArticleService {
private final TagService tagService;
private final AttachmentService attachmentService;
private final ArticleMapper mapper;
private final CommentMapper commentMapper;
private final Redis<String, Long> redisArticleRead;
private final Redis<Long, ArticleRanking> redisArticleRanking;
@Override
protected BaseMapper<Article, Long> mapper() {
return mapper;
}
@Override
public PageResult<Article> page(Page page) {
PageResult<Article> result = new PageResult<>();
result.setList(mapper.selectByPage(page));
result.setTotal(mapper.countByPage(page));
return result;
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public ArticleView view(long id) {
String ip = TimiSpring.getRequestIP();
Article article = get(id);
TimiException.required(article, "article.not_found");
// 计数
if (!redisArticleRead.contains(ip, article.getId())) {
// 3 小时内访问记录
redisArticleRead.add(ip, article.getId());
redisArticleRead.setExpire(ip, Time.H * 3);
mapper.read(article.getId());
// 每周访问计数
if (article.canRanking()) {
ArticleRanking ranking = redisArticleRanking.get(article.getId());
if (ranking == null) {
ranking = new ArticleRanking(article.getId(), article.getTitle(), article.getType());
ranking.setRecentAt(Time.now());
redisArticleRanking.set(article.getId(), ranking, Time.D * 7);
} else {
ranking.read();
ranking.setRecentAt(Time.now());
redisArticleRanking.setAndKeepTTL(article.getId(), ranking);
}
}
}
ArticleView view = new ArticleView();
BeanUtils.copyProperties(article, view);
view.setComments(commentMapper.countAll(Comment.BizType.ARTICLE, article.getId()));
view.setTagList(tagService.listByBizID(Tag.BizType.ARTICLE, String.valueOf(article.getId())));
view.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.ARTICLE, article.getId()));
return view;
}
@Override
public PageResult<Article> pageByKeyword(KeywordPage page) {
PageResult<Article> result = new PageResult<>();
result.setList(mapper.selectByKeyword(page.getKeyword(), page.getOffset(), page.getLimit()));
result.setTotal(mapper.countByKeyword(page.getKeyword()));
return result;
}
@Override
public List<ArticleRanking> listRanking() {
List<ArticleRanking> list = redisArticleRanking.values();
list.sort(Comparator.comparing(ArticleRanking::getCount).reversed());
return list.subList(0, Math.min(10, list.size()));
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public int like(Long articleId) {
mapper.like(articleId);
return get(articleId).getLikes();
}
}
@@ -1,52 +0,0 @@
package com.imyeyu.api.modules.blog.service.implement;
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
import com.imyeyu.api.modules.blog.entity.CommentRemindQueue;
import com.imyeyu.api.modules.blog.service.CommentRemindQueueService;
import com.imyeyu.api.modules.common.mapper.CommentRemindQueueMapper;
import com.imyeyu.spring.mapper.BaseMapper;
import com.imyeyu.spring.service.AbstractEntityService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 评论回复队列服务实现
*
* @author 夜雨
* @since 2021-08-25 00:11
*/
@Service
@RequiredArgsConstructor
public class CommentRemindQueueServiceImplement extends AbstractEntityService<CommentRemindQueue, String> implements CommentRemindQueueService {
private final CommentRemindQueueMapper mapper;
@Override
protected BaseMapper<CommentRemindQueue, String> mapper() {
return mapper;
}
@Override
public List<CommentRemindQueue> listByUserId(Long userId) {
return mapper.listByUserId(userId);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void destroyByUserId(Long userId) {
CommentRemindQueue example = new CommentRemindQueue();
example.setUserId(userId);
mapper.deleteAllByExample(example);
}
@Transactional(TimiServerDBConfig.ROLLBACKER)
@Override
public void destroyByReplyId(Long replyId) {
CommentRemindQueue example = new CommentRemindQueue();
example.setReplyId(replyId);
mapper.destroyAllByExample(example);
}
}
@@ -1,27 +0,0 @@
package com.imyeyu.api.modules.blog.service.implement;
import lombok.RequiredArgsConstructor;
import com.imyeyu.api.modules.blog.entity.Friend;
import com.imyeyu.api.modules.blog.mapper.FriendMapper;
import com.imyeyu.api.modules.blog.service.FriendService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 友链服务实现
*
* @author 夜雨
* @since 2021-07-15 16:05
*/
@Service
@RequiredArgsConstructor
public class FriendServiceImplement implements FriendService {
private final FriendMapper mapper;
@Override
public List<Friend> listAll() {
return mapper.listAll();
}
}
@@ -1,147 +0,0 @@
package com.imyeyu.api.modules.blog.util;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.api.config.RedisConfig;
import com.imyeyu.api.modules.common.bean.SettingKey;
import com.imyeyu.api.modules.common.entity.User;
import com.imyeyu.api.modules.common.service.SettingService;
import com.imyeyu.api.modules.common.service.UserService;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.util.Redis;
import com.imyeyu.spring.util.RedisSerializers;
import com.imyeyu.utils.Time;
import jakarta.annotation.Nullable;
import jakarta.annotation.PostConstruct;
import jakarta.servlet.http.Cookie;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.Objects;
/**
* Redis 令牌缓存
*
* <p>一级缓存 Session,二级缓存 Redis,有效期为 {@link SettingKey#TTL_USER_TOKEN} 天,每次触发
* 二级缓存获取时会刷新这个时间,即指定天数内不再访问则视为登出
*
* @author 夜雨
* @since 2023-07-17 16:58
*/
@Component
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class UserToken {
private final RedisConfig redisConfig;
private final UserService userService;
private final SettingService settingService;
private Redis<String, Long> redis;
@PostConstruct
private void postConstruct() {
redis = redisConfig.getRedis(redisConfig.getDatabase().getUserToken(), RedisSerializers.STRING, RedisSerializers.LONG);
}
public Long set(String token, Long userId) {
long ttl = Time.D * settingService.getAsInt(SettingKey.TTL_USER_TOKEN);
// 会话
TimiSpring.setSessionAttr(token, userId);
// 跨站 Cookie
Cookie cookie = Objects.requireNonNullElse(TimiSpring.getCookie("Token"), new Cookie("Token", token));
cookie.setDomain(settingService.getAsString(SettingKey.DOMAIN_ROOT));
cookie.setPath("/");
cookie.setSecure(true);
cookie.setMaxAge((int) (ttl / 1000));
TimiSpring.addCookie(cookie);
// Redis
redis.set(token, userId, ttl);
return Time.now() + ttl;
}
public Long getExpireAt(String token) {
return Time.now() + redis.getExpire(token);
}
/**
* 获取令牌是否有效
*
* @param token 令牌
* @return true 为有效
*/
public boolean isValid(String token) {
return getUserId(token) != null;
}
/**
* 获取令牌是否无效({@link #isValid(String)} 取反)
*
* @param token 令牌
* @return true 为无效
*/
public boolean isInvalid(String token) {
return !isValid(token);
}
/**
* 获取用户 ID
* <p>一级缓存 Session,二级缓存 Redis,每次触发二级缓存获取时会刷新这个时间
* <p>Session 存键为 token,值为 UserId,Redis 也相同
*
* @param token 令牌
* @return 用户 ID
* @throws TimiException 无效 token
*/
public @Nullable Long getRequiredUserId(String token) throws TimiException {
return TimiException.required(getUserId(token), "invalid token");
}
/**
* 获取用户 ID
* <p>一级缓存 Session,二级缓存 Redis,每次触发二级缓存获取时会刷新这个时间
* <p>Session 存键为 token,值为 UserId,Redis 也相同
*
* @param token 令牌
* @return 用户 ID,token 无效时为 null
*/
public @Nullable Long getUserId(String token) {
if (TimiJava.isEmpty(token)) {
return null;
}
Long userId;
// Session
if (TimiSpring.getSessionAttr(token) instanceof Long sessionUserId) {
userId = sessionUserId;
} else {
// Redis
userId = redis.get(token);
}
if (TimiJava.isEmpty(userId)) {
return null;
}
// 刷新
set(token, userId);
return userId;
}
public @NotNull User getUser(String token) {
return userService.get(getRequiredUserId(token));
}
public void clear(String token) {
// 会话
TimiSpring.removeSessionAttr(token);
// 清除跨站 Cookie
Cookie cookie = new Cookie("Token", "DIED");
cookie.setDomain(settingService.getAsString(SettingKey.DOMAIN_ROOT));
cookie.setPath("/");
cookie.setSecure(true);
cookie.setMaxAge(0);
TimiSpring.addCookie(cookie);
// Redis
redis.destroy(token);
}
}
@@ -1,24 +0,0 @@
package com.imyeyu.api.modules.blog.vo.article;
import com.imyeyu.api.modules.blog.entity.Article;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.entity.Tag;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* @author 夜雨
* @since 2023-08-07 17:19
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ArticleView extends Article {
private long comments;
private List<Tag> tagList;
private List<Attachment> attachmentList;
}
@@ -1,16 +0,0 @@
package com.imyeyu.api.modules.blog.vo.article;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.imyeyu.spring.bean.Page;
/**
* @author 夜雨
* @since 2023-07-14 17:52
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class ClassPage extends Page {
private long classId;
}
@@ -1,18 +0,0 @@
package com.imyeyu.api.modules.blog.vo.article;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.imyeyu.spring.bean.Page;
/**
* @author 夜雨
* @since 2023-07-14 17:53
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class KeywordPage extends Page {
@NotBlank(message = "article.keyword.empty")
private String keyword;
}
@@ -1,16 +0,0 @@
package com.imyeyu.api.modules.blog.vo.article;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.imyeyu.spring.bean.Page;
/**
* @author 夜雨
* @since 2023-07-14 17:53
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class LabelPage extends Page {
private long labelId;
}
@@ -1,16 +0,0 @@
package com.imyeyu.api.modules.common.bean;
/**
* 支持评论的实体
*
* @author 夜雨
* @since 2023-10-10 11:39
*/
public interface CommentSupport {
/** @return true 为可评论 */
boolean canComment();
/** @return true 为不可评论 */
boolean canNotComment();
}
@@ -0,0 +1,9 @@
package com.imyeyu.api.modules.common.bean;
/// Groovy 脚本执行结果
///
/// @param <T> 脚本返回值类型
/// @author Codex
/// @since 2026-09-04
public record GroovyScriptExecutionResult<T>(String scriptId, String versionId, Integer version, String checksum, T result) {
}
@@ -1,42 +0,0 @@
package com.imyeyu.api.modules.common.bean;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author 夜雨
* @since 2025-12-11 18:14
*/
public class Metadata {
/**
* 图片
*
* @author 夜雨
* @since 2025-12-11 18:15
*/
@Data
public static class Image {
private int width;
private int height;
}
/**
* 缩略图
*
* @author 夜雨
* @since 2026-01-04 18:10
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class ThumbImage extends Image {
private long sourceId;
private String sourceMongoId;
private String sourceMimeType;
}
}
@@ -1,191 +0,0 @@
package com.imyeyu.api.modules.common.bean;
/**
* 系统设置
*
* @author 夜雨
* @since 2021-07-20 21:46
*/
public enum SettingKey {
// ---------- 通用 ----------
RUN_ENV,
PUBLIC_RESOURCES,
/** 启用注册 */
ENABLE_REGISTER,
/** 启用登录 */
ENABLE_LOGIN,
/** 启用评论 */
ENABLE_COMMENT,
/** 启用测试 */
ENABLE_DEBUG,
/** 启用账号数据更新(User 和 UserProfile) */
ENABLE_USER_UPDATE,
/** 启用灰色滤镜 */
ENABLE_GRAY_FILTER,
TEMP_FILE_PATH,
// ---------- ICP 备案号 ----------
ICP_IMYEYU_COM,
// ---------- 域名 ----------
DOMAIN_ROOT,
DOMAIN_API,
DOMAIN_GIT,
DOMAIN_BLOG,
DOMAIN_SPACE,
DOMAIN_RESOURCE,
DOMAIN_DOWNLOAD,
DOMAIN_FOREVER_MC,
// ---------- ForeverMC ----------
/** 启用登录服务 */
FMC_PLAYER_LOGIN_ENABLE,
/** 最多绑定玩家数量 */
FMC_MAX_BIND,
/** 闪烁标语 */
FMC_SPLASHES,
/** 启动器背景 */
FMC_BG,
FMC_BGM,
FMC_BG_SWIPER,
/** JRE 列表 */
FMC_JRE,
/** 辅助登录模组 */
FMC_LOGIN_FABRIC,
/** 启用图片地图上传 */
FMC_ENABLE_IMAGE_MAP_UPLOAD,
/** 玩家登录令牌有效期(天) */
FMC_PLAYER_LOGIN_TOKEN_TTL,
/** 服务器与数据中心的通信令牌 */
FMC_SERVER_TOKEN,
// ---------- 生存时间 ----------
TTL_USER_TOKEN,
TTL_SETTING,
TTL_MULTILINGUAL,
// ---------- 多语言翻译 ----------
MULTILINGUAL_TRANSLATE_API,
MULTILINGUAL_TRANSLATE_APP_ID,
MULTILINGUAL_TRANSLATE_KEY,
// ---------- 账单 ----------
BILL_API_TOKEN,
// ---------- Git ----------
GIT_API,
GIT_ABOUT_ARTICLE,
GIT_REPO_PATH,
// ---------- 远程音乐 ----------
MUSIC_MAX_FRAME_LENGTH,
MUSIC_PLAYER_PORT,
MUSIC_PLAYER_IP,
MUSIC_CONTROLLER_PORT,
MUSIC_CONTROLLER_IP,
MUSIC_CONTROLLER_URI,
// ---------- 日记 ----------
JOURNAL_KEY,
JOURNAL_APP_ID,
JOURNAL_APP_SECRET,
JOURNAL_MEMO,
JOURNAL_OPEN_ID_WHITE_LIST,
// ---------- 临时文件 ----------
/** 临时文件最小缓存时间 */
TEMP_FILE_TTL_MIN,
/** 临时文件最长缓存时间 */
TEMP_FILE_TTL_MAX,
/** 临时文件默认缓存时间 */
TEMP_FILE_TTL_DEFAULT,
/** 已过期的临时文件保留时间 */
TEMP_FILE_RESIDUE_TIME,
/** 每个 IP 限制有效临时文件容量 */
TEMP_FILE_LIMIT,
// ---------- 系统 ----------
SYSTEM_FILE_BASE,
SYSTEM_FILE_TYPE,
SYSTEM_FILE_SYNC,
/** 文件过滤(通过密钥类型) */
SYSTEM_FILE_FILTER,
SYSTEM_STATUS_RATE,
SYSTEM_STATUS_LIMIT,
SYSTEM_STATUS_NETWORK_MAC,
SYSTEM_TERMINAL_TTL,
SYSTEM_TERMINAL_FILTERS,
/** 一般密钥 */
SYSTEM_API_KEY,
/** 超级密钥 */
SYSTEM_API_SUPER_KEY,
SYSTEM_REBOOT_COMMAND,
}
@@ -0,0 +1,41 @@
package com.imyeyu.api.modules.common.bean;
import com.imyeyu.api.annotation.SettingBizType;
import com.imyeyu.api.bean.SettingEnum;
import com.imyeyu.api.modules.common.entity.Setting;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
*
*
* @author 夜雨
* @since 2026-04-24 14:47
*/
@Getter
@SettingBizType("TEMP_FILE")
@AllArgsConstructor
public enum TempFileSetting implements SettingEnum {
/** 启用服务 */
ENABLE(Boolean.TRUE.toString(), Setting.ValueType.BOOLEAN),
/** 最小缓存时长 */
TTL_MIN("1h", Setting.ValueType.TIME),
/** 默认缓存时长 */
TTL_DEFAULT("3d", Setting.ValueType.TIME),
/** 最大缓存时长 */
TTL_MAX("7d", Setting.ValueType.TIME),
/** 已过期文件残留时长 */
RESIDUE_TTL("90d", Setting.ValueType.TIME),
/** 每个 IP 限制有效临时文件容量 */
LIMIT_SIZE_OF_IP("10 GB", Setting.ValueType.BYTE_SIZE);
final String defaultValue;
final Setting.ValueType valueType;
}
@@ -0,0 +1,28 @@
package com.imyeyu.api.modules.common.bean.attachment;
import lombok.Data;
/**
* 附件访问密钥 VO
*
* @author 夜雨
* @since 2026-01-13 10:05
*/
@Data
public class AccessKey {
/** 访问密钥 */
private String value;
/** 附件 ID */
private String attachmentId;
/** true 为一次性访问 */
private boolean isDisposable;
/** 过期时间戳 */
private Long expiredAt;
/** 创建时间戳 */
private Long createdAt;
}
@@ -1,4 +1,4 @@
package com.imyeyu.api.modules.common.bean;
package com.imyeyu.api.modules.common.bean.attachment;
/**
* @author 夜雨
@@ -0,0 +1,18 @@
package com.imyeyu.api.modules.common.bean.attachment;
import com.imyeyu.api.modules.common.entity.Setting;
import java.util.List;
/**
*
*
* @author 夜雨
* @since 2026-05-13 17:27
*/
public interface SettingSupport {
String getId();
List<Setting> getSettingList();
}
@@ -0,0 +1,25 @@
package com.imyeyu.api.modules.common.bean.attachment;
import lombok.Data;
/**
* 临时文件元数据
*
* @author 夜雨
* @since 2025-09-27 01:47
*/
@Data
public class TempFileMetaData {
/** 附件 ID */
private String id;
/** 文件名 */
private String name;
/** 原始文件名 */
private String originalName;
/** 储存 ID */
private String mongoId;
}
@@ -0,0 +1,17 @@
package com.imyeyu.api.modules.common.bean.attachment;
/// 缩略图缩放模式
///
/// @author 夜雨
/// @since 2026-08-21
public enum ThumbnailFitMode {
/// 保持比例完整放入目标尺寸
FIT,
/// 保持比例裁剪填满目标尺寸
COVER,
/// 强制缩放到目标尺寸,可能导致图片变形
STRETCH
}
@@ -0,0 +1,81 @@
package com.imyeyu.api.modules.common.config;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/// 通知消息队列配置
///
/// @author 夜雨
/// @since 2026-08-20
@Data
@Configuration
@ConfigurationProperties(prefix = "notify.queue")
public class NotifyQueueConfig {
private Mail mail = new Mail();
private Sms sms = new Sms();
private Wechat wechat = new Wechat();
private HTTP http = new HTTP();
/// 邮件队列配置
@Data
@EqualsAndHashCode(callSuper = true)
public static class Mail extends Queue {
private String defaultFrom;
}
/// 短信队列配置
@Data
@EqualsAndHashCode(callSuper = true)
public static class Sms extends Queue {
private String appId;
private String sign;
private String secretId;
private String secretKey;
private Captcha captcha;
/// 短信验证码
@Data
public static class Captcha {
private String templateId;
private int ttlMinute;
private int argIndex;
}
}
/// 微信队列配置
@Data
@EqualsAndHashCode(callSuper = true)
public static class Wechat extends Queue {
}
/// HTTP 队列配置
@Data
@EqualsAndHashCode(callSuper = true)
public static class HTTP extends Queue {
}
/// 通用队列配置
@Data
public static class Queue {
/// true 为启用
private boolean enable;
private String cron = "0/30 * * * * ?";
}
}
@@ -0,0 +1,96 @@
package com.imyeyu.api.modules.common.controller;
import com.fasterxml.jackson.annotation.JsonView;
import com.imyeyu.api.annotation.RequireCorePermission;
import com.imyeyu.api.bean.CorePermissionCode;
import com.imyeyu.api.modules.common.entity.Article;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.ArticleService;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.util.ResponseView;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/// 文章接口
///
/// @author Codex
/// @since 2026-09-09
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/article")
public class ArticleController {
private final ArticleService service;
private final AttachmentService attachmentService;
/// 查询文章列表
///
/// @param page 分页参数
/// @return 文章分页
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ARTICLE_READ)
@PostMapping("/list")
public PageResult<Article> list(@RequestBody Page<Article> page) {
return service.page(page);
}
/// 查询文章详情
///
/// @param id 文章 ID
/// @return 文章详情
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@RequestMapping("/detail")
public Article detail(@RequestParam String id) {
Article article = service.get(id);
article.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.ARTICLE, article.getId()));
return article;
}
/// 创建文章
///
/// @param article 文章
/// @return 创建后的文章
@AOPLog
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ARTICLE_CREATE)
@PostMapping("/create")
public Article create(@RequestBody Article article) {
service.create(article);
return article;
}
/// 更新文章
///
/// @param article 文章
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ARTICLE_UPDATE)
@PostMapping("/update")
public void update(@RequestBody Article article) {
service.update(article);
}
/// 删除文章
///
/// @param id 文章 ID
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.ARTICLE_DELETE)
@PostMapping("/delete")
public void delete(@RequestParam String id) {
service.delete(id);
}
}
@@ -0,0 +1,320 @@
package com.imyeyu.api.modules.common.controller;
import com.imyeyu.api.modules.common.bean.attachment.ThumbnailFitMode;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.common.service.AttachmentVariantService;
import com.imyeyu.api.modules.common.service.TempFileService;
import com.imyeyu.api.modules.common.vo.attach.TempFileResp;
import com.imyeyu.java.TimiJava;
import com.imyeyu.network.Network;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.utils.Time;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.UnsupportedEncodingException;
import java.util.List;
///
///
/// @author 夜雨
/// @since 2026-07-27 19:26
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/attach")
public class AttachmentController {
private final TempFileService tempFileService;
private final AttachmentService service;
private final AttachmentVariantService variantService;
/**
* 查询附件详情
*
* @param id 附件 ID
* @return 附件详情
*/
@RequestRateLimit
@PostMapping("/detail")
public Attachment detail(@RequestParam String id) {
return service.get(id);
}
/**
* 创建附件
*
* @param attachment 附件
* @return 创建结果
*/
@AOPLog
@RequestRateLimit
@PostMapping(value = "/create", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Attachment create(Attachment attachment) {
service.create(attachment);
attachment.setFile(null);
attachment.setInputStream(null);
return attachment;
}
/**
* 更新附件
*
* @param attachment 附件
*/
@AOPLog
@RequestRateLimit
@PostMapping(value = "/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void update(Attachment attachment) {
service.update(attachment);
}
/**
* 删除附件
*
* @param id 附件 ID
*/
@AOPLog
@RequestRateLimit
@PostMapping("/delete")
public void delete(@RequestParam String id) {
service.delete(id);
}
/**
* 按业务查询单个附件
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @return 附件详情
*/
@RequestRateLimit
@GetMapping("/detail/byBiz")
public Attachment detailByBiz(@RequestParam Attachment.BizType bizType, @RequestParam String bizId) {
return service.getByBizId(bizType, bizId);
}
/**
* 按业务和附件类型查询单个附件
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @param attachType 附件类型
* @return 附件详情
*/
@RequestRateLimit
@GetMapping("/detail/byAttachType")
public Attachment detailByAttachType(
@RequestParam Attachment.BizType bizType,
@RequestParam String bizId,
@RequestParam String attachType
) {
return service.getByAttachType(bizType, bizId, attachType);
}
/**
* 按业务查询附件列表
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @param attachTypeList 附件类型列表
* @return 附件列表
*/
@RequestRateLimit
@GetMapping("/list/biz")
public List<Attachment> listByBiz(
@RequestParam Attachment.BizType bizType,
@RequestParam String bizId,
@RequestParam(required = false) List<String> attachTypeList
) {
List<String> types = TimiJava.defaultIfNull(attachTypeList, List.of());
return service.listByBizId(bizType, bizId, types.toArray(String[]::new));
}
/**
* 按业务统计附件数量
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @param attachTypeList 附件类型列表
* @return 附件数量
*/
@RequestRateLimit
@GetMapping("/count/biz")
public long countByBiz(
@RequestParam Attachment.BizType bizType,
@RequestParam String bizId,
@RequestParam(required = false) List<String> attachTypeList
) {
List<String> types = TimiJava.defaultIfNull(attachTypeList, List.of());
return service.countByBizId(bizType, bizId, types.toArray(String[]::new));
}
/**
* 按业务分页查询附件
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @param attachTypeList 附件类型列表
* @param page 分页参数
* @return 分页结果
*/
@RequestRateLimit
@PostMapping("/page/biz")
public PageResult<Attachment> pageByBiz(
@RequestParam Attachment.BizType bizType,
@RequestParam String bizId,
@RequestParam(required = false) List<String> attachTypeList,
@RequestBody Page<Attachment> page
) {
return service.pageByBizId(bizType, bizId, attachTypeList, page);
}
@AOPLog
@IgnoreGlobalReturn
@GetMapping({"/read/{id}", "/download/{id}"})
public void readById(
@PathVariable String id,
@RequestParam(required = false) Integer thumbWidth,
@RequestParam(required = false) Integer thumbHeight,
@RequestParam(defaultValue = "FIT") ThumbnailFitMode fitMode
) throws UnsupportedEncodingException {
HttpServletResponse resp = TimiSpring.getResponse();
Attachment attach = service.get(id);
if (attach == null) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
responseAttachment(attach, thumbWidth, thumbHeight, fitMode);
}
@AOPLog
@PostMapping("/temp/upload")
public List<TempFileResp> upload(@RequestParam("file") List<MultipartFile> files, @RequestParam(value = "ttl", required = false) String ttl) {
return tempFileService.create(files, Time.D);
}
@AOPLog
@RequestRateLimit
@IgnoreGlobalReturn
@GetMapping({"/temp/read", "/temp/download"})
public void read(@RequestParam String id) throws UnsupportedEncodingException {
HttpServletResponse resp = TimiSpring.getResponse();
Attachment attach = service.get(id);
if (attach == null) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if (TimiSpring.getRequest().getRequestURI().endsWith("/download")) {
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(attach.getName()));
}
response(attach, false);
}
private void responseAttachment(
Attachment attach,
Integer thumbWidth,
Integer thumbHeight,
ThumbnailFitMode fitMode
) throws UnsupportedEncodingException {
responseThumb(attach, thumbWidth, thumbHeight, fitMode);
}
protected void responseThumb(
Attachment attachment,
Integer thumbWidth,
Integer thumbHeight,
ThumbnailFitMode fitMode
) throws UnsupportedEncodingException {
HttpServletResponse resp = TimiSpring.getResponse();
if (TimiJava.isEmpty(attachment)) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if (thumbWidth == null && thumbHeight == null) {
// 原图
setDownloadHeader(attachment);
response(attachment);
return;
}
// 缩略图
Attachment thumb = variantService.fetchThumb(attachment, thumbWidth, thumbHeight, fitMode);
setDownloadHeader(thumb);
response(thumb);
}
private void setDownloadHeader(Attachment attachment) throws UnsupportedEncodingException {
// 路径带 /download 就强制下载:/download/{id} 的结尾是 id,用 endsWith 匹配不到
boolean download = TimiSpring.getRequest().getRequestURI().contains("/download");
if (attachment != null && download && attachment.getName() != null) {
TimiSpring.getResponse().setHeader("Content-Disposition", Network.getFileDownloadHeader(attachment.getName()));
}
}
/// 设置附件缓存头并处理条件请求
///
/// @param attachment 实际响应附件
/// @return true 表示客户端缓存仍有效,已返回 304
private boolean responseCache(Attachment attachment) {
HttpServletResponse resp = TimiSpring.getResponse();
resp.setHeader("Cache-Control", "private, no-cache");
String md5 = attachment.getMd5();
if (md5 == null || md5.isBlank()) {
return false;
}
String etag = "\"%s\"".formatted(md5);
resp.setHeader("ETag", etag);
String ifNoneMatch = TimiSpring.getHeader("If-None-Match");
if (ifNoneMatch == null) {
return false;
}
for (String value : ifNoneMatch.split(",")) {
String candidate = value.trim();
if ("*".equals(candidate) || etag.equals(candidate) || ("W/" + etag).equals(candidate)) {
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return true;
}
}
return false;
}
protected void response(Attachment attachment) {
response(attachment, true);
}
private void response(Attachment attachment, boolean cacheable) {
HttpServletResponse resp = TimiSpring.getResponse();
try {
if (TimiJava.isEmpty(attachment)) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if (!cacheable) {
resp.setHeader("Cache-Control", "private, no-store");
} else if (responseCache(attachment)) {
return;
}
resp.setContentType(attachment.getMimeType());
attachment.doResponse();
} catch (Exception e) {
log.error("response attachment error", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
@@ -1,87 +1,264 @@
package com.imyeyu.api.modules.common.controller;
import com.imyeyu.api.annotation.CaptchaValid;
import com.imyeyu.api.annotation.EnableSetting;
import com.imyeyu.api.bean.CaptchaFrom;
import com.imyeyu.api.modules.common.bean.SettingKey;
import com.fasterxml.jackson.annotation.JsonView;
import com.imyeyu.api.modules.common.entity.Comment;
import com.imyeyu.api.modules.common.entity.CommentReply;
import com.imyeyu.api.modules.common.service.CommentReplyService;
import com.imyeyu.api.modules.user.entity.UserBehaviorRecord;
import com.imyeyu.api.modules.common.service.CommentService;
import com.imyeyu.api.modules.common.vo.comment.CommentCreateReq;
import com.imyeyu.api.modules.common.vo.comment.CommentLayerQueryReq;
import com.imyeyu.api.modules.common.vo.comment.CommentLayerResp;
import com.imyeyu.api.modules.common.vo.comment.CommentNodeResp;
import com.imyeyu.api.modules.common.vo.comment.CommentReplyReq;
import com.imyeyu.api.modules.common.vo.comment.CommentThreadResp;
import com.imyeyu.api.modules.common.vo.comment.FlatCommentListResp;
import com.imyeyu.api.modules.common.vo.comment.NestedCommentListResp;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.CaptchaData;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.util.ResponseView;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 评论操作接口
* <p>*评论回复只依赖评论而不含业务关联,评论有关联业务,所以此接口是通用接口
*
* @author 夜雨
* @since 2021-02-23 21:36
*/
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/comment")
public class CommentController {
private final CommentService service;
private final CommentReplyService replyService;
/**
* 创建主评论
*
* @param req 创建请求
* @return 评论树详情
*/
@AOPLog
@CaptchaValid(CaptchaFrom.COMMENT)
@EnableSetting(value = SettingKey.ENABLE_COMMENT, message = "comment.off_service")
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@PostMapping("/create")
public void create(@Valid @RequestBody CaptchaData<Comment> captchaData) {
service.create(captchaData.getData());
}
@RequestRateLimit
@PostMapping("/list")
public PageResult<Comment> list(@Valid @RequestBody Page<Comment> page) {
return service.page(page);
public Comment create(@RequestBody @Valid CommentCreateReq req) {
Comment entity = new Comment();
entity.setBizType(req.getBizType());
entity.setBizId(req.getBizId());
entity.setUserId(req.getUserId());
entity.setUserNick(req.getUserNick());
entity.setContent(req.getContent());
entity.setIp(TimiSpring.getRequestIP());
service.create(entity);
return service.detailTree(entity.getId(), req.getUserId());
}
/**
* 创建评论回复
* 回复评论
*
* @param request 回复数据
* @param req 回复请求
* @return 评论树详情
*/
@AOPLog
@CaptchaValid(CaptchaFrom.COMMENT_REPLY)
@EnableSetting(value = SettingKey.ENABLE_COMMENT, message = "comment.off_service")
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@PostMapping("/reply/create")
public void createReply(@Valid @RequestBody CaptchaData<CommentReply> request) {
replyService.create(request.getData());
@PostMapping("/reply")
public Comment reply(@RequestBody @Valid CommentReplyReq req) {
Comment entity = new Comment();
entity.setParentId(req.getParentId());
entity.setUserId(req.getUserId());
entity.setUserNick(req.getUserNick());
entity.setContent(req.getContent());
entity.setIp(TimiSpring.getRequestIP());
service.create(entity);
return service.detailTree(entity.getId(), req.getUserId());
}
/**
* 获取回复列表
* 删除当前用户自己的评论
*
* @param page 页面参数
* @return 回复列表
* @param id 评论 ID
* @param userId 用户 ID
*/
@AOPLog
@RequestRateLimit
@RequestMapping("/reply/list")
public PageResult<CommentReply> pageReplies(@Valid @RequestBody Page<CommentReply> page) {
// 通用接口,只允许查询评论的回复
CommentReply example = new CommentReply();
if (page.getEqualsExample() != null) {
example.setCommentId(page.getEqualsExample().getCommentId());
}
page.setEqualsExample(example);
page.setLikesExample(null);
return replyService.page(page);
@PostMapping("/delete")
public void delete(@RequestParam String id, @RequestParam String userId) {
service.deleteOwned(id, userId);
}
/**
* 点赞评论
*
* @param commentId 评论 ID
* @param userId 用户 ID
*/
@AOPLog
@RequestRateLimit
@PostMapping("/like")
public void like(@RequestParam String commentId, @RequestParam String userId) {
service.like(commentId, userId);
}
/**
* 不喜欢评论
*
* @param commentId 评论 ID
* @param userId 用户 ID
*/
@AOPLog
@RequestRateLimit
@PostMapping("/unlike")
public void unlike(@RequestParam String commentId, @RequestParam String userId) {
service.unlike(commentId, userId);
}
/**
* 查询用户点赞评论记录
*
* @param page 分页参数
* @param userId 用户 ID
* @return 点赞评论记录分页
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@PostMapping("/like/list")
public PageResult<UserBehaviorRecord> listLikedRecord(@RequestBody Page<UserBehaviorRecord> page, @RequestParam String userId) {
return service.listLikedRecord(page, userId);
}
/**
* 查询扁平主评论列表
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @param offset 起始偏移量
* @param currentUserId 当前用户 ID,可为 null
* @return 扁平主评论列表
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@GetMapping("/flat/list")
public FlatCommentListResp listFlatRoot(
@RequestParam String bizType,
@RequestParam String bizId,
@RequestParam(defaultValue = "0") int offset,
@RequestParam(required = false) String currentUserId
) {
return service.listFlatRoot(bizType, bizId, offset, currentUserId);
}
/**
* 查询扁平评论线程
*
* @param commentId 评论 ID
* @param offset 起始偏移量
* @param currentUserId 当前用户 ID,可为 null
* @return 评论线程
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@GetMapping("/flat/thread")
public CommentThreadResp getFlatThread(
@RequestParam String commentId,
@RequestParam(defaultValue = "0") int offset,
@RequestParam(required = false) String currentUserId
) {
return service.getUserThread(commentId, offset, currentUserId);
}
/**
* 查询层级主评论列表
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @param offset 起始偏移量
* @param currentUserId 当前用户 ID,可为 null
* @return 层级主评论列表
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@GetMapping("/nested/list")
public NestedCommentListResp listNestedRoot(
@RequestParam String bizType,
@RequestParam String bizId,
@RequestParam(defaultValue = "0") int offset,
@RequestParam(required = false) String currentUserId
) {
return service.listNestedRoot(bizType, bizId, offset, currentUserId);
}
/**
* 查询评论节点
*
* @param commentId 评论 ID
* @param currentUserId 当前用户 ID,可为 null
* @return 评论节点
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@GetMapping("/nested/detail")
public CommentNodeResp getNestedDetail(@RequestParam String commentId, @RequestParam(required = false) String currentUserId) {
return service.getUserNode(commentId, currentUserId);
}
/**
* 查询直属子评论分页
*
* @param commentId 评论 ID
* @param offset 起始偏移量
* @param currentUserId 当前用户 ID,可为 null
* @return 子评论分页
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@GetMapping("/nested/children")
public CommentLayerResp getNestedChildren(
@RequestParam String commentId,
@RequestParam(defaultValue = "0") int offset,
@RequestParam(required = false) String currentUserId
) {
return service.getUserChildren(commentId, offset, currentUserId);
}
/**
* 查询单层评论列表
*
* @param req 查询请求
* @param currentUserId 当前用户 ID,可为 null
* @return 评论层
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@PostMapping("/layer/list")
public CommentLayerResp listLayer(@RequestBody CommentLayerQueryReq req, @RequestParam(required = false) String currentUserId) {
return service.listSdkLayer(req, currentUserId);
}
/**
* 查询评论树详情
*
* @param id 评论 ID
* @param currentUserId 当前用户 ID,可为 null
* @return 评论树详情
*/
@JsonView(ResponseView.Public.class)
@RequestRateLimit
@GetMapping("/detail/tree")
public Comment detailTree(@RequestParam String id, @RequestParam(required = false) String currentUserId) {
return service.detailTree(id, currentUserId);
}
}
@@ -1,77 +1,23 @@
package com.imyeyu.api.modules.common.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.imyeyu.api.bean.CaptchaFrom;
import com.imyeyu.api.modules.common.bean.ImageType;
import com.imyeyu.api.modules.common.bean.SettingKey;
import com.imyeyu.api.modules.common.entity.Attachment;
import com.imyeyu.api.modules.common.entity.Setting;
import com.imyeyu.api.modules.common.entity.Task;
import com.imyeyu.api.modules.common.entity.Template;
import com.imyeyu.api.modules.common.entity.Version;
import com.imyeyu.api.modules.common.service.AttachmentService;
import com.imyeyu.api.modules.common.service.ClipboardService;
import com.imyeyu.api.modules.common.service.FeedbackService;
import com.imyeyu.api.modules.common.service.SettingService;
import com.imyeyu.api.modules.common.service.TaskService;
import com.imyeyu.api.modules.common.service.TempFileService;
import com.imyeyu.api.modules.common.service.TemplateService;
import com.imyeyu.api.modules.common.service.VersionService;
import com.imyeyu.api.modules.common.vo.ClipboardRequest;
import com.imyeyu.api.modules.common.vo.FeedbackRequest;
import com.imyeyu.api.modules.common.vo.TempFileResponse;
import com.imyeyu.api.modules.system.util.ResourceHandler;
import com.imyeyu.api.util.CaptchaManager;
import com.imyeyu.io.IO;
import com.imyeyu.java.TimiJava;
import com.imyeyu.java.bean.timi.TimiCode;
import com.imyeyu.java.bean.timi.TimiException;
import com.imyeyu.java.ref.Ref;
import com.imyeyu.network.Network;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.CaptchaData;
import com.imyeyu.spring.bean.RequestRange;
import com.mongodb.client.gridfs.GridFSBucket;
import com.mongodb.client.gridfs.GridFSDownloadStream;
import com.mongodb.client.gridfs.model.GridFSFile;
import jakarta.servlet.http.HttpServletRequest;
import com.imyeyu.utils.Decoder;
import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Cleanup;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.tika.Tika;
import org.springframework.http.MediaType;
import org.springframework.data.mongodb.gridfs.GridFsResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import org.yaml.snakeyaml.Yaml;
import javax.imageio.ImageIO;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 系统接口
@@ -86,36 +32,7 @@ import java.util.stream.Collectors;
@RequestMapping("/")
public class CommonController {
private final TaskService taskService;
private final VersionService versionService;
private final SettingService settingService;
private final FeedbackService feedbackService;
private final TemplateService templateService;
private final TempFileService tempFileService;
private final AttachmentService attachmentService;
private final ClipboardService clipboardService;
private final ObjectMapper jackson;
private final Yaml yaml;
private final GridFSBucket gridFSBucket;
private final CaptchaManager captchaManager;
private final ResourceHandler resourceHandler;
private String writeJson(Object value) {
try {
return jackson.writeValueAsString(value);
} catch (IOException e) {
throw new TimiException(TimiCode.ERROR, "write json error", e);
}
}
private Map<String, Object> readJsonMap(String value) {
try {
return jackson.readValue(value, new TypeReference<>() {});
} catch (IOException e) {
throw new TimiException(TimiCode.ERROR, "read json error", e);
}
}
@AOPLog
@RequestMapping("")
@@ -123,399 +40,56 @@ public class CommonController {
return "IT WORKING! " + TimiSpring.getRequestIP();
}
/**
* 获取共享剪切板内容
*
* @param id 会话 ID
* @return 剪切板内容
*/
@AOPLog
@RequestRateLimit
@GetMapping("/clipboard/{id}")
public String clipboardGet(@Valid @NotBlank @PathVariable("id") String id) {
return clipboardService.getContent(id);
}
/**
* 设置共享剪切板内容
*
* @param id 会话 ID
* @param request 请求内容
*/
@AOPLog
@RequestRateLimit
@PostMapping("/clipboard/{id}")
public void clipboardSet(@Valid @NotBlank @PathVariable("id") String id, @Valid @RequestBody ClipboardRequest request) {
clipboardService.setContent(id, request.getContent());
}
/**
* 订阅共享剪切板实时更新
*
* @param id 会话 ID
* @return SSE 发射器
*/
@AOPLog
@IgnoreGlobalReturn
@GetMapping(value = "/clipboard/stream/{id}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter clipboardStream(@Valid @NotBlank @PathVariable("id") String id) {
return clipboardService.subscribe(id);
}
/**
* 获取验证码
*
* @param width 宽度
* @param height 高度
* @param from 来源
* @param response 返回对象
* @param width 宽度
* @param height 高度
* @return Base64 编码的图形验证码和唯一识别 ID
*/
@IgnoreGlobalReturn
@GetMapping("/captcha")
public void captcha(int width, int height, CaptchaFrom from, HttpServletResponse response) {
// 返回图像流
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache"); // 禁止缓存
response.setDateHeader("Expires", -1);
response.setContentType("image/jpg");
public CaptchaManager.Result captcha(Integer width, Integer height) {
TimiException.requiredTrue(width != null && 64 < width, "not found width or less than 64");
TimiException.requiredTrue(height != null && 19 < height, "not found height or less than 19");
return captchaManager.generate(width, height);
}
/**
* 获取验证码(返回图形数据流,唯一识别 ID 在返回头 X-Captcha-ID)
*
* @param width 宽度
* @param height 高度
*/
@GetMapping("/captcha/img")
public void captchaImg(Integer width, Integer height, HttpServletResponse resp) {
CaptchaManager.Result result = captchaManager.generate(width, height);
resp.setHeader("Pragma", "no-cache");
resp.setHeader("Cache-Control", "no-cache");
resp.setHeader("X-Captcha-ID", result.id());
resp.setHeader("Access-Control-Expose-Headers", "X-Captcha-ID");
resp.setDateHeader("Expires", -1);
resp.setContentType("image/png");
try {
// 宽度
ServletOutputStream os = resp.getOutputStream();
if (width < 64) {
ImageIO.write(captchaManager.error(TimiCode.ARG_BAD), "jpg", response.getOutputStream());
ImageIO.write(captchaManager.error(TimiCode.ARG_BAD), "png", os);
return;
}
// 高度
if (height < 19) {
ImageIO.write(captchaManager.error(TimiCode.ARG_BAD), "jpg", response.getOutputStream());
return;
}
// 来自
if (TimiJava.isEmpty(from)) {
ImageIO.write(captchaManager.error(TimiCode.ARG_MISS), "jpg", response.getOutputStream());
ImageIO.write(captchaManager.error(TimiCode.ARG_BAD), "png", os);
return;
}
// 输出图像流
ImageIO.write(captchaManager.generate(from, width, height), "jpg", response.getOutputStream());
} catch (Exception e) {
log.error("CommonController.getCaptcha", e);
IO.toOutputStream(os, Decoder.base64(result.data().split(",")[1]));
} catch (IOException e) {
log.error("captcha img error", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
try {
ImageIO.write(captchaManager.error(TimiCode.ERROR), "jpg", response.getOutputStream());
ImageIO.write(captchaManager.error(TimiCode.ERROR), "png", resp.getOutputStream());
} catch (IOException subE) {
log.error("write error image fail", subE);
}
}
}
/**
* 获取软件最新版本状态
*
* @param name 软件名称
* @return 最新版本状态
* @deprecated 兼容旧程序
*/
@AOPLog
@GetMapping("/versions/{name}")
@Deprecated
public Version versions(@Valid @NotBlank @PathVariable("name") String name) {
return versionService.getByName(name);
}
/**
* 获取软件最新版本状态
*
* @param name 软件名称
* @return 最新版本状态
*/
@AOPLog
@GetMapping("/version/{name}")
public Version version(@Valid @NotBlank @PathVariable("name") String name) {
return versionService.getByName(name);
}
@AOPLog
@RequestRateLimit
@PostMapping("/feedback")
public void createFeedback(@Valid @NotNull @RequestBody CaptchaData<FeedbackRequest> request) {
captchaManager.test(request.getCaptcha(), request.getCaptchaId());
feedbackService.create(request.getData());
}
/** @return 公开任务信息 */
@AOPLog
@RequestRateLimit
@GetMapping("/tasklist")
public List<Task> getTasks() {
return taskService.listAll4Public();
}
@RequestRateLimit
@GetMapping("/template")
public String viewTemplate(@RequestParam Template.BizType bizType, @RequestParam String bizCode) {
return templateService.get(bizType, bizCode).getData();
}
@RequestRateLimit
@GetMapping("/setting/{key}")
public String settingByKey(@PathVariable("key") String key, @RequestParam(value = "as", required = false) Setting.Type asType) {
Setting setting = settingService.getByKey(SettingKey.valueOf(key.toUpperCase()));
if (setting.isPrivate()) {
throw new TimiException(TimiCode.PERMISSION_ERROR);
}
String result = setting.getValue();
if (asType == null) {
return result;
}
switch (asType) {
case JSON -> {
if (setting.getType() == Setting.Type.YAML) {
Map<String, Object> obj = yaml.load(setting.getValue());
result = writeJson(obj);
}
}
case YAML -> {
if (setting.getType() == Setting.Type.JSON) {
Map<String, Object> obj = readJsonMap(setting.getValue());
result = yaml.dump(obj);
}
}
}
return result;
}
@RequestRateLimit
@PostMapping("/setting/map")
public Map<SettingKey, String> mapSettingByKeys(@RequestBody Map<SettingKey, Map<String, Object>> settingMap) {
List<Setting> result = settingService.listByKeys(new ArrayList<>(settingMap.keySet()));
for (int i = 0; i < result.size(); i++) {
Setting setting = result.get(i);
if (setting.isPrivate()) {
throw new TimiException(TimiCode.PERMISSION_ERROR);
}
Map<String, Object> args = settingMap.get(setting.getKey());
if (args == null) {
continue;
}
if (args.containsKey("as")) {
switch (Ref.toType(Setting.Type.class, args.get("as").toString())) {
case JSON -> {
if (setting.getType() == Setting.Type.YAML) {
Map<String, Object> obj = new Yaml().load(setting.getValue());
setting.setValue(writeJson(obj));
}
}
case YAML -> {
if (setting.getType() == Setting.Type.JSON) {
Map<String, Object> obj = readJsonMap(setting.getValue());
setting.setValue(new Yaml().dump(obj));
}
}
}
}
}
return result.stream().collect(Collectors.toMap(Setting::getKey, Setting::getValue));
}
@AOPLog
@RequestRateLimit
@GetMapping("/attachment/{mongoId}")
public Attachment getAttachment(@PathVariable String mongoId) {
return attachmentService.getByMongoId(mongoId);
}
@AOPLog
@IgnoreGlobalReturn
@GetMapping("/attachment/read/{mongoId}")
public void readAttachment(
@PathVariable String mongoId,
@RequestParam(name = "size", required = false) Integer size,
@RequestParam(name = "type", required = false) String type,
HttpServletRequest req,
HttpServletResponse resp
) {
try {
GridFSFile file = attachmentService.readByMongoId(mongoId);
if (file == null) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
return;
}
GridFSDownloadStream mimeReadStream = gridFSBucket.openDownloadStream(file.getObjectId());
String mimeType = new Tika().detect(mimeReadStream);
if (TimiJava.isNotEmpty(mimeType)) {
resp.setContentType(mimeType);
}
if (size != null) {
String fileType = switch (mimeType) {
case "image/png" -> "png";
case "image/jpeg" -> "jpg";
default -> throw new TimiException(TimiCode.ARG_BAD).msgKey("TODO not support Re render mineType");
};
switch (mimeType) {
case "image/png", "image/jpeg" -> {
// 图片缩放
GridFSDownloadStream stream = gridFSBucket.openDownloadStream(file.getObjectId());
byte[] bytes = IO.toBytes(stream);
BufferedImage imgSrc = ImageIO.read(new ByteArrayInputStream(bytes));
double scale;
if (imgSrc.getHeight() < imgSrc.getWidth()) {
// 横向
scale = 1D * size / imgSrc.getWidth();
} else {
scale = 1D * size / imgSrc.getHeight();
}
int width = (int) (imgSrc.getWidth() * scale);
int height = (int) (imgSrc.getHeight() * scale);
BufferedImage imgResult = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = imgResult.createGraphics();
if (ImageType.PIXELATED == Ref.toType(ImageType.class, type)) {
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
} else {
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}
g.drawImage(imgSrc, 0, 0, width, height, null);
ImageIO.write(imgResult, fileType, resp.getOutputStream());
}
default -> throw new TimiException(TimiCode.ARG_BAD).msgKey("TODO not support Re render mineType");
}
} else {
GridFSDownloadStream downloadStream = gridFSBucket.openDownloadStream(file.getObjectId());
GridFsResource gridFsResource = new GridFsResource(file, downloadStream);
req.setAttribute(ResourceHandler.ATTR_TYPE, ResourceHandler.Type.MONGO);
req.setAttribute(ResourceHandler.ATTR_VALUE, gridFsResource);
resourceHandler.handleRequest(req, resp);
}
} catch (Exception e) {
log.error("read attachment error", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
}
}
@AOPLog
@RequestRateLimit
@IgnoreGlobalReturn
@GetMapping("/attachment/download/{mongoId}")
public void downloadAttachment(@PathVariable String mongoId, HttpServletResponse resp) {
try {
Attachment attachment = attachmentService.getByMongoId(mongoId);
GridFSFile file = attachmentService.readByMongoId(mongoId);
if (file == null) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
return;
}
{
GridFSDownloadStream downloadStream = gridFSBucket.openDownloadStream(file.getObjectId());
String mimeType = new Tika().detect(downloadStream);
if (TimiJava.isNotEmpty(mimeType)) {
resp.setContentType(mimeType);
}
}
GridFSDownloadStream downloadStream = gridFSBucket.openDownloadStream(file.getObjectId());
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(file.getFilename()));
resp.setHeader("Content-Range", String.valueOf(attachment.getSize()));
resp.setHeader("Accept-Ranges", "bytes");
resp.setContentLengthLong(attachment.getSize());
IO.toOutputStream(downloadStream, resp.getOutputStream());
resp.flushBuffer();
} catch (Exception e) {
log.error("read attachment error", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());
}
}
/**
* 上传临时文件
*
* @param files 文件列表
* @param ttl 缓存时长(毫秒),最长 3 天(259200000ms)
* @return 临时文件响应列表
*/
@AOPLog
@PostMapping("/temp/file/upload")
public List<TempFileResponse> tempFileUpload(@RequestParam("file") List<MultipartFile> files, @RequestParam(value = "ttl", required = false) Long ttl) {
return tempFileService.store(files, ttl);
}
/**
* 读取临时文件
*
* @param mongoId mongoId
* @param req 请求
* @param resp 返回
*/
@AOPLog
@RequestRateLimit
@IgnoreGlobalReturn
@GetMapping("/temp/file/read/{mongoId}")
public void tempFileRead(@PathVariable String mongoId, HttpServletRequest req, HttpServletResponse resp) {
try {
Attachment attach = attachmentService.getByMongoId(mongoId);
if (TimiJava.isEmpty(attach)) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
GridFSFile file = attachmentService.readByMongoId(attach.getMongoId());
GridFSDownloadStream downloadStream = gridFSBucket.openDownloadStream(file.getObjectId());
GridFsResource gridFsResource = new GridFsResource(file, downloadStream);
req.setAttribute(ResourceHandler.ATTR_TYPE, ResourceHandler.Type.MONGO);
req.setAttribute(ResourceHandler.ATTR_VALUE, gridFsResource);
resp.setContentType(attach.getMimeType());
resourceHandler.handleRequest(req, resp);
} catch (Exception e) {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
/**
* 下载临时文件
*
* @param mongoId
* @param resp
*/
@AOPLog
@RequestRateLimit
@IgnoreGlobalReturn
@RequestMapping("/temp/file/download/{mongoId}")
public void tempFileDownload(@PathVariable String mongoId, HttpServletResponse resp) {
try {
Attachment attach = attachmentService.getByMongoId(mongoId);
if (TimiJava.isEmpty(attach)) {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
resp.setContentType(attach.getMimeType());
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(attach.getName()));
resp.setHeader("Accept-Ranges", "bytes");
GridFSFile file = attachmentService.readByMongoId(mongoId);
@Cleanup
GridFSDownloadStream downloadStream = gridFSBucket.openDownloadStream(file.getObjectId());
RequestRange range = TimiSpring.getRequestRange(attach.getSize());
if (range == null) {
// 完整文件
resp.setContentLengthLong(attach.getSize());
resp.setStatus(HttpServletResponse.SC_OK);
IO.toOutputStream(downloadStream, resp.getOutputStream());
} else {
// 分片文件
resp.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
resp.setHeader("Content-Range", "bytes %s-%s/%s".formatted(range.getStart(), range.getEnd(), attach.getSize()));
resp.setContentLengthLong(range.getLength());
IO.toOutputStream(downloadStream, resp.getOutputStream(), range.getStart(), range.getEnd());
resp.flushBuffer();
}
} catch (Exception e) {
log.error("download error", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
@@ -0,0 +1,100 @@
package com.imyeyu.api.modules.common.controller;
import com.fasterxml.jackson.annotation.JsonView;
import com.imyeyu.api.annotation.RequireCorePermission;
import com.imyeyu.api.bean.CorePermissionCode;
import com.imyeyu.api.modules.common.entity.Feedback;
import com.imyeyu.api.modules.common.service.FeedbackService;
import com.imyeyu.api.modules.user.service.UserLoginService;
import com.imyeyu.spring.TimiSpring;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.CaptchaValid;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.CaptchaData;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import com.imyeyu.spring.util.ResponseView;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/// 通用反馈接口
///
/// @author Codex
/// @since 2026-08-19
@RestController
@RequiredArgsConstructor
@RequestMapping("/feedback")
public class FeedbackController {
private final FeedbackService service;
private final UserLoginService userLoginService;
/// 提交反馈。登录用户和匿名用户均需提交图形验证码,匿名用户按 IP 限流
///
/// @param captchaData 带图形验证码的反馈请求
@AOPLog
@JsonView(ResponseView.Public.class)
@CaptchaValid
@RequestRateLimit(value = 3, inSeconds = 60)
@PostMapping("/create")
public void create(@RequestBody @Valid CaptchaData<Feedback> captchaData) {
Feedback feedback = captchaData.getData();
feedback.setIp(TimiSpring.getRequestIP());
if (userLoginService.isLogged()) {
feedback.setUserId(userLoginService.getRequireLoginUserId());
}
service.create(feedback);
}
/// 查询反馈列表
///
/// @param page 分页参数
/// @return 反馈分页
@JsonView(ResponseView.Admin.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
@PostMapping("/list")
public PageResult<Feedback> list(@RequestBody Page<Feedback> page) {
return service.page(page);
}
/// 查询反馈详情
///
/// @param id 反馈 ID
/// @return 反馈详情
@JsonView(ResponseView.Admin.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
@PostMapping("/detail")
public Feedback detail(@RequestParam String id) {
return service.get(id);
}
/// 更新反馈
///
/// @param feedback 反馈
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_UPDATE)
@PostMapping("/update")
public void update(@RequestBody Feedback feedback) {
feedback.setRespondedBy(userLoginService.getRequireLoginUserId());
service.update(feedback);
}
/// 删除反馈
///
/// @param id 反馈 ID
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.FEEDBACK_DELETE)
@PostMapping("/delete")
public void delete(@RequestParam String id) {
service.delete(id);
}
}
@@ -1,26 +1,19 @@
package com.imyeyu.api.modules.common.controller;
import com.imyeyu.api.modules.common.entity.Icon;
import com.imyeyu.api.modules.common.service.IconService;
import com.imyeyu.api.modules.common.vo.icon.AllResponse;
import com.imyeyu.api.modules.common.vo.icon.NamePage;
import com.imyeyu.api.modules.common.vo.icon.UnicodePage;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.bean.Page;
import com.imyeyu.spring.bean.PageResult;
import jakarta.validation.Valid;
import com.imyeyu.network.Network;
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* timi-icon 前端接口
@@ -38,60 +31,38 @@ public class IconController {
private final IconService service;
/**
* 获取图标列表
* 查询全部图标名称
*
* @param page 查询列表参数
* @return 图标列表
* @return 图标名称列表
*/
@RequestRateLimit
@PostMapping("/list")
public PageResult<Icon> list(@RequestBody Page page) {
return service.page(page);
@GetMapping("/name/list")
public List<String> listName() {
return service.listName();
}
@GetMapping("/svg/map")
public Map<String, String> mapSvg() {
return service.mapSvg();
}
@GetMapping("/unicode/map")
public Map<String, String> mapUnicode() {
return service.mapUnicode();
}
/**
* 获取所有图标,为了减小传输数据,此接口只返回 name 名称、Unicode 代码和 SVG 路径
* 导出 TTF 字体文件
*
* @param latest 请求缓存的最新数据时间
* @return 所有图标,如果请求缓存的最新时间等于数据库的最新数据时间,不返回任何数据
* @param resp HTTP 响应
* @throws IOException 写出字体文件失败
*/
@RequestRateLimit
@GetMapping("/list/all")
public AllResponse listAll(@Valid @RequestParam Long latest) {
AllResponse resp = service.listAll(latest);
List<Icon> icons = resp.getIcons();
for (int i = 0; i < icons.size(); i++) {
Icon icon = icons.get(i);
icon.setId(null);
icon.setCreatedAt(null);
icon.setUpdatedAt(null);
}
return resp;
}
/**
* 根据名称获取查询列表参数列表
*
* @param page 查询列表参数
* @return 图标列表
*/
@AOPLog
@RequestRateLimit
@PostMapping("/list/name")
public PageResult<Icon> listByName(@Valid @RequestBody NamePage page) {
return service.pageByName(page);
}
/**
* 根据 Unicode 获取图标列表
*
* @param page 查询列表参数
* @return 图标列表
*/
@AOPLog
@RequestRateLimit
@PostMapping("/list/unicode")
public PageResult<Icon> listByUnicode(@Valid @RequestBody UnicodePage page) {
return service.pageByUnicode(page);
@IgnoreGlobalReturn
@GetMapping(value = "/export/ttf", produces = "font/ttf")
public void exportTtf(HttpServletResponse resp) throws IOException {
byte[] body = service.exportTtf();
resp.setContentType("font/ttf");
resp.setContentLength(body.length);
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader("timi-icon.ttf"));
resp.getOutputStream().write(body);
}
}
@@ -0,0 +1,38 @@
package com.imyeyu.api.modules.common.controller;
import com.imyeyu.api.modules.common.vo.ClientLogRequest;
import com.imyeyu.api.modules.system.entity.Logger;
import com.imyeyu.api.modules.system.service.LoggerService;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequiredToken;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
*
*
* @author 夜雨
* @since 2026-06-13 09:31
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/log")
public class LoggerController {
private final LoggerService service;
@AOPLog
@RequiredToken
@PostMapping("/create")
public void create(@Valid @RequestBody ClientLogRequest request) {
Logger logger = Logger.info(Logger.Module.COMMON, "CLIENT_LOG");
logger.setContent(request.getContent());
service.create(logger);
}
}
@@ -0,0 +1,88 @@
package com.imyeyu.api.modules.common.controller;
import com.fasterxml.jackson.annotation.JsonView;
import com.imyeyu.api.annotation.RequireCorePermission;
import com.imyeyu.api.bean.CorePermissionCode;
import com.imyeyu.api.modules.common.entity.Multilingual;
import com.imyeyu.api.modules.common.service.MultilingualService;
import com.imyeyu.spring.annotation.AOPLog;
import com.imyeyu.spring.annotation.RequestRateLimit;
import com.imyeyu.spring.util.ResponseView;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 多语言管理接口
*
* @author Codex
* @since 2026-07-27
*/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/system/multilingual")
public class MultilingualController {
private final MultilingualService service;
/**
* 查询多语言详情
*
* @param id 多语言 ID
* @return 多语言详情
*/
@JsonView(ResponseView.Admin.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_READ)
@PostMapping("/detail")
public Multilingual detail(@RequestParam String id) {
return service.get(id);
}
/**
* 创建多语言
*
* @param multilingual 多语言
* @return 创建结果
*/
@AOPLog
@JsonView(ResponseView.Admin.class)
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_CREATE)
@PostMapping("/create")
public Multilingual create(@RequestBody Multilingual multilingual) {
service.create(multilingual);
return multilingual;
}
/**
* 更新多语言
*
* @param multilingual 多语言
*/
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_UPDATE)
@PostMapping("/update")
public void update(@RequestBody Multilingual multilingual) {
service.update(multilingual);
}
/**
* 删除多语言
*
* @param id 多语言 ID
*/
@AOPLog
@RequestRateLimit
@RequireCorePermission(CorePermissionCode.MULTILINGUAL_DELETE)
@PostMapping("/delete")
public void delete(@RequestParam String id) {
service.delete(id);
}
}

Some files were not shown because too many files have changed in this diff Show More