forge-codegen-crud-skill-post-contract.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. --- a/.agents/skills/forge-codegen-crud/SKILL.md
  2. +++ b/.agents/skills/forge-codegen-crud/SKILL.md
  3. @@ -25,6 +25,12 @@
  4. - Put query SQL in Mapper XML. Do not generate Service-layer `LambdaQueryWrapper` query chains except MyBatis-Plus built-in `selectById`, `insert`, `updateById`, and `deleteById` style operations.
  5. - Use `pageNum` and `pageSize`; never generate backend `page` as the page parameter.
  6. - Use AiCrudPage URL placeholders with `:id` or `:${rowKey}`. Do not generate `{id}` placeholders.
  7. +- Generated CRUD controllers and frontend API configs must use Forge's POST-safe codegen contract for detail, create, update, and delete:
  8. + - detail: `POST /getById`
  9. + - create: `POST /add`
  10. + - update: `POST /edit`
  11. + - delete: `POST /remove/{id}` and `post@.../remove/:id`
  12. + Do not generate `PUT` or `DELETE` endpoints for generated CRUD modules.
  13. - Use `DictSelect`, `DictTag`, and `useDict()` for dictionary fields. Do not hardcode frontend options or status label maps.
  14. - Generate `sys_dict_type` and `sys_dict_data` seed SQL for new dictionaries, or explicitly reuse an existing dictionary type discovered in migrations.
  15. - Generate `sys_excel_export_config` and `sys_excel_column_config` seed SQL when import/export is enabled.
  16. --- a/.agents/skills/forge-codegen-crud/references/single-table-crud.md
  17. +++ b/.agents/skills/forge-codegen-crud/references/single-table-crud.md
  18. @@ -56,7 +56,7 @@
  19. ## Controller Contract
  20. -Generate standard endpoints:
  21. +Generate Forge codegen-safe endpoints. Do not use `PUT` or `DELETE` for generated CRUD modules because project gateway and security policies expect POST for detail, update, and delete operations.
  22. ```java
  23. @Slf4j
  24. @@ -73,26 +73,26 @@
  25. return RespInfo.success(exampleService.page(pageQuery, query));
  26. }
  27. - @GetMapping("/{id}")
  28. + @PostMapping("/getById")
  29. @OperationLog(module = "示例管理", type = OperationType.QUERY, desc = "查询示例详情")
  30. - public RespInfo<BizExampleVO> detail(@PathVariable Long id) {
  31. + public RespInfo<BizExampleVO> detail(@RequestParam Long id) {
  32. return RespInfo.success(exampleService.getDetail(id));
  33. }
  34. - @PostMapping
  35. + @PostMapping("/add")
  36. @OperationLog(module = "示例管理", type = OperationType.ADD, desc = "新增示例")
  37. public RespInfo<Long> create(@RequestBody BizExampleDTO dto) {
  38. return RespInfo.success(exampleService.create(dto));
  39. }
  40. - @PutMapping
  41. + @PostMapping("/edit")
  42. @OperationLog(module = "示例管理", type = OperationType.UPDATE, desc = "修改示例")
  43. public RespInfo<Void> update(@RequestBody BizExampleDTO dto) {
  44. exampleService.update(dto);
  45. return RespInfo.success();
  46. }
  47. - @DeleteMapping("/{id}")
  48. + @PostMapping("/remove/{id}")
  49. @OperationLog(module = "示例管理", type = OperationType.DELETE, desc = "删除示例")
  50. public RespInfo<Void> delete(@PathVariable Long id) {
  51. exampleService.delete(id);
  52. @@ -146,10 +146,10 @@
  53. <AiCrudPage
  54. :api-config="{
  55. list: 'get@/api/biz/example/page',
  56. - detail: 'get@/api/biz/example/:id',
  57. - add: 'post@/api/biz/example',
  58. - update: 'put@/api/biz/example',
  59. - delete: 'post@/api/biz/example/removeBatch',
  60. + detail: 'post@/api/biz/example/getById',
  61. + add: 'post@/api/biz/example/add',
  62. + update: 'post@/api/biz/example/edit',
  63. + delete: 'post@/api/biz/example/remove/:id',
  64. export: 'post@/api/excel/export/biz_example_export',
  65. import: 'post@/api/excel/import/biz_example_export',
  66. importTemplate: 'get@/api/excel/template/biz_example_export',
  67. --- a/.agents/skills/forge-codegen-crud/references/sql-seeds.md
  68. +++ b/.agents/skills/forge-codegen-crud/references/sql-seeds.md
  69. @@ -208,3 +208,14 @@
  70. ```
  71. If the module uses API permission resources, also generate `resource_type = 4` rows with `api_method` and `api_url`, guarded by method + URL or `perms`.
  72. +For generated CRUD APIs, use POST-safe codegen routes for detail, create, update, and delete permission resources:
  73. +
  74. +- `GET /.../page`
  75. +- `GET /.../list`
  76. +- `POST /.../getById`
  77. +- `POST /.../add`
  78. +- `POST /.../edit`
  79. +- `POST /.../remove/{id}`
  80. +- `POST /.../removeBatch`
  81. +
  82. +Do not seed `PUT` or `DELETE` API resources for generated CRUD modules.
  83. --- a/.agents/skills/forge-codegen-crud/references/validation-checklist.md
  84. +++ b/.agents/skills/forge-codegen-crud/references/validation-checklist.md
  85. @@ -13,7 +13,8 @@
  86. ## Backend
  87. -- [ ] Controller uses `RespInfo.success(data)` / `RespInfo.success()` and standard routes.
  88. +- [ ] Controller uses `RespInfo.success(data)` / `RespInfo.success()` and Forge codegen-safe routes.
  89. +- [ ] Generated detail/update/delete endpoints use POST (`/getById`, `/edit`, `/remove/{id}`); no `@PutMapping` or `@DeleteMapping` is generated.
  90. - [ ] Pagination uses `PageQuery` or `pageNum` + `pageSize`, not `page`.
  91. - [ ] Query SQL lives in Mapper XML.
  92. - [ ] Mapper XML lists explicit columns and includes standard audit fields.
  93. @@ -26,6 +27,7 @@
  94. - [ ] Page uses `AiCrudPage`.
  95. - [ ] `api-config` uses `:id` placeholders, not `{id}`.
  96. +- [ ] Generated `api-config` uses POST for detail/update/delete (`post@.../getById`, `post@.../edit`, `post@.../remove/:id`); no `put@` or `delete@` is generated.
  97. - [ ] Dictionary fields use `useDict()`, `DictSelect`, and `DictTag`.
  98. - [ ] Schemas are `computed` when they depend on dictionaries.
  99. - [ ] Import/export props and API config match generated backend or common Excel endpoints.