create-aiko 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/README.md +46 -0
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +7 -0
  4. package/dist/create.d.ts +1 -0
  5. package/dist/create.js +174 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +2 -0
  8. package/dist/scaffold.d.ts +7 -0
  9. package/dist/scaffold.js +310 -0
  10. package/package.json +37 -0
  11. package/template/README.md +63 -0
  12. package/template/docs/better-sqlite3-design.md +101 -0
  13. package/template/docs/shared-vs-shared-auth.md +54 -0
  14. package/template/package.json +23 -0
  15. package/template/packages/admin/.env.dev +1 -0
  16. package/template/packages/admin/.env.prod +4 -0
  17. package/template/packages/admin/.env.stage +4 -0
  18. package/template/packages/admin/Dockerfile +37 -0
  19. package/template/packages/admin/README.MD +27 -0
  20. package/template/packages/admin/components.json +21 -0
  21. package/template/packages/admin/eslint.config.js +28 -0
  22. package/template/packages/admin/index.html +50 -0
  23. package/template/packages/admin/package.json +100 -0
  24. package/template/packages/admin/public/vite.svg +1 -0
  25. package/template/packages/admin/src/App.css +82 -0
  26. package/template/packages/admin/src/App.tsx +128 -0
  27. package/template/packages/admin/src/app.config.ts +3 -0
  28. package/template/packages/admin/src/components/admin-ui/approval-flow.tsx +205 -0
  29. package/template/packages/admin/src/components/admin-ui/data-table/data-table-pagination.tsx +148 -0
  30. package/template/packages/admin/src/components/admin-ui/data-table/data-table-sorter.tsx +50 -0
  31. package/template/packages/admin/src/components/admin-ui/data-table/index.tsx +296 -0
  32. package/template/packages/admin/src/components/admin-ui/editable-table.tsx +292 -0
  33. package/template/packages/admin/src/components/admin-ui/form/input-password.tsx +38 -0
  34. package/template/packages/admin/src/components/admin-ui/form/sign-in-form.tsx +104 -0
  35. package/template/packages/admin/src/components/admin-ui/layout/error-component.tsx +71 -0
  36. package/template/packages/admin/src/components/admin-ui/layout/header.tsx +148 -0
  37. package/template/packages/admin/src/components/admin-ui/layout/language-switcher.tsx +47 -0
  38. package/template/packages/admin/src/components/admin-ui/layout/layout.tsx +42 -0
  39. package/template/packages/admin/src/components/admin-ui/layout/loading-overlay.tsx +36 -0
  40. package/template/packages/admin/src/components/admin-ui/layout/shell-bar.tsx +232 -0
  41. package/template/packages/admin/src/components/admin-ui/layout/sidebar.tsx +193 -0
  42. package/template/packages/admin/src/components/admin-ui/layout/user-avatar.tsx +31 -0
  43. package/template/packages/admin/src/components/admin-ui/list-report.tsx +313 -0
  44. package/template/packages/admin/src/components/admin-ui/master-detail.tsx +382 -0
  45. package/template/packages/admin/src/components/admin-ui/notification/toaster.tsx +23 -0
  46. package/template/packages/admin/src/components/admin-ui/notification/undoable-notification.tsx +84 -0
  47. package/template/packages/admin/src/components/admin-ui/object-page.tsx +539 -0
  48. package/template/packages/admin/src/components/admin-ui/process-stepper.tsx +204 -0
  49. package/template/packages/admin/src/components/admin-ui/theme/theme-provider.tsx +160 -0
  50. package/template/packages/admin/src/components/admin-ui/theme/theme-select.tsx +129 -0
  51. package/template/packages/admin/src/components/admin-ui/theme/theme-toggle.tsx +90 -0
  52. package/template/packages/admin/src/components/admin-ui/timeline.tsx +137 -0
  53. package/template/packages/admin/src/components/admin-ui/tree-navigator.tsx +243 -0
  54. package/template/packages/admin/src/components/ui/accordion.tsx +64 -0
  55. package/template/packages/admin/src/components/ui/alert-dialog.tsx +157 -0
  56. package/template/packages/admin/src/components/ui/alert.tsx +66 -0
  57. package/template/packages/admin/src/components/ui/aspect-ratio.tsx +9 -0
  58. package/template/packages/admin/src/components/ui/avatar.tsx +53 -0
  59. package/template/packages/admin/src/components/ui/badge.tsx +47 -0
  60. package/template/packages/admin/src/components/ui/breadcrumb.tsx +111 -0
  61. package/template/packages/admin/src/components/ui/button.tsx +59 -0
  62. package/template/packages/admin/src/components/ui/calendar.tsx +74 -0
  63. package/template/packages/admin/src/components/ui/card.tsx +92 -0
  64. package/template/packages/admin/src/components/ui/carousel.tsx +237 -0
  65. package/template/packages/admin/src/components/ui/chart.tsx +351 -0
  66. package/template/packages/admin/src/components/ui/checkbox.tsx +32 -0
  67. package/template/packages/admin/src/components/ui/collapsible.tsx +33 -0
  68. package/template/packages/admin/src/components/ui/command.tsx +182 -0
  69. package/template/packages/admin/src/components/ui/context-menu.tsx +252 -0
  70. package/template/packages/admin/src/components/ui/dialog.tsx +141 -0
  71. package/template/packages/admin/src/components/ui/drawer.tsx +130 -0
  72. package/template/packages/admin/src/components/ui/dropdown-menu.tsx +255 -0
  73. package/template/packages/admin/src/components/ui/form.tsx +166 -0
  74. package/template/packages/admin/src/components/ui/hover-card.tsx +42 -0
  75. package/template/packages/admin/src/components/ui/input-otp.tsx +77 -0
  76. package/template/packages/admin/src/components/ui/input.tsx +21 -0
  77. package/template/packages/admin/src/components/ui/label.tsx +22 -0
  78. package/template/packages/admin/src/components/ui/menubar.tsx +274 -0
  79. package/template/packages/admin/src/components/ui/navigation-menu.tsx +168 -0
  80. package/template/packages/admin/src/components/ui/pagination.tsx +127 -0
  81. package/template/packages/admin/src/components/ui/popover.tsx +48 -0
  82. package/template/packages/admin/src/components/ui/progress.tsx +29 -0
  83. package/template/packages/admin/src/components/ui/radio-group.tsx +45 -0
  84. package/template/packages/admin/src/components/ui/resizable.tsx +54 -0
  85. package/template/packages/admin/src/components/ui/scroll-area.tsx +58 -0
  86. package/template/packages/admin/src/components/ui/select.tsx +183 -0
  87. package/template/packages/admin/src/components/ui/separator.tsx +26 -0
  88. package/template/packages/admin/src/components/ui/sheet.tsx +139 -0
  89. package/template/packages/admin/src/components/ui/sidebar.tsx +740 -0
  90. package/template/packages/admin/src/components/ui/skeleton.tsx +13 -0
  91. package/template/packages/admin/src/components/ui/slider.tsx +63 -0
  92. package/template/packages/admin/src/components/ui/sonner.tsx +23 -0
  93. package/template/packages/admin/src/components/ui/switch.tsx +31 -0
  94. package/template/packages/admin/src/components/ui/table.tsx +114 -0
  95. package/template/packages/admin/src/components/ui/tabs.tsx +66 -0
  96. package/template/packages/admin/src/components/ui/textarea.tsx +18 -0
  97. package/template/packages/admin/src/components/ui/toggle-group.tsx +73 -0
  98. package/template/packages/admin/src/components/ui/toggle.tsx +45 -0
  99. package/template/packages/admin/src/components/ui/tooltip.tsx +59 -0
  100. package/template/packages/admin/src/hooks/use-mobile.ts +21 -0
  101. package/template/packages/admin/src/i18n.ts +20 -0
  102. package/template/packages/admin/src/index.tsx +18 -0
  103. package/template/packages/admin/src/layouts/menu-layout.tsx +211 -0
  104. package/template/packages/admin/src/layouts/tile-layout.tsx +355 -0
  105. package/template/packages/admin/src/lib/utils.ts +6 -0
  106. package/template/packages/admin/src/locales/en.json +68 -0
  107. package/template/packages/admin/src/locales/zh.json +68 -0
  108. package/template/packages/admin/src/pages/dashboard.tsx +12 -0
  109. package/template/packages/admin/src/pages/goods-receipt/CreatePage.tsx +302 -0
  110. package/template/packages/admin/src/pages/goods-receipt/EditPage.tsx +221 -0
  111. package/template/packages/admin/src/pages/goods-receipt/ListPage.tsx +283 -0
  112. package/template/packages/admin/src/pages/goods-receipt/ViewPage.tsx +280 -0
  113. package/template/packages/admin/src/pages/goods-receipt/index.ts +4 -0
  114. package/template/packages/admin/src/pages/home-page.tsx +244 -0
  115. package/template/packages/admin/src/pages/login-page.tsx +91 -0
  116. package/template/packages/admin/src/pages/master-data/cost-centers/index.tsx +461 -0
  117. package/template/packages/admin/src/pages/master-data/currencies/index.tsx +255 -0
  118. package/template/packages/admin/src/pages/master-data/materials/ListPage.tsx +271 -0
  119. package/template/packages/admin/src/pages/master-data/materials/ViewPage.tsx +240 -0
  120. package/template/packages/admin/src/pages/master-data/materials/index.ts +2 -0
  121. package/template/packages/admin/src/pages/master-data/plants/ListPage.tsx +279 -0
  122. package/template/packages/admin/src/pages/master-data/plants/ViewPage.tsx +380 -0
  123. package/template/packages/admin/src/pages/master-data/plants/index.ts +2 -0
  124. package/template/packages/admin/src/pages/master-data/purchase-organizations/index.tsx +341 -0
  125. package/template/packages/admin/src/pages/master-data/units-of-measure/index.tsx +295 -0
  126. package/template/packages/admin/src/pages/master-data/vendors/ListPage.tsx +266 -0
  127. package/template/packages/admin/src/pages/master-data/vendors/ViewPage.tsx +274 -0
  128. package/template/packages/admin/src/pages/master-data/vendors/index.ts +2 -0
  129. package/template/packages/admin/src/pages/placeholder-page.tsx +13 -0
  130. package/template/packages/admin/src/pages/purchase-orders/ListPage.tsx +289 -0
  131. package/template/packages/admin/src/pages/purchase-orders/ViewPage.tsx +343 -0
  132. package/template/packages/admin/src/pages/purchase-orders/index.ts +2 -0
  133. package/template/packages/admin/src/pages/purchase-requisitions/CreatePage.tsx +398 -0
  134. package/template/packages/admin/src/pages/purchase-requisitions/EditPage.tsx +473 -0
  135. package/template/packages/admin/src/pages/purchase-requisitions/ListPage.tsx +307 -0
  136. package/template/packages/admin/src/pages/purchase-requisitions/ViewPage.tsx +304 -0
  137. package/template/packages/admin/src/pages/purchase-requisitions/constants.ts +51 -0
  138. package/template/packages/admin/src/pages/purchase-requisitions/index.ts +4 -0
  139. package/template/packages/admin/src/pages/reports/PurchaseOrderReport.tsx +312 -0
  140. package/template/packages/admin/src/pages/reports/PurchaseRequisitionReport.tsx +303 -0
  141. package/template/packages/admin/src/pages/reports/index.ts +2 -0
  142. package/template/packages/admin/src/pages/settings-page.tsx +335 -0
  143. package/template/packages/admin/src/providers/app-config.tsx +50 -0
  144. package/template/packages/admin/src/routes/auth.ts +6 -0
  145. package/template/packages/admin/src/routes/index.ts +85 -0
  146. package/template/packages/admin/src/routes/menu.ts +176 -0
  147. package/template/packages/admin/src/routes/modules/goods-receipt.ts +31 -0
  148. package/template/packages/admin/src/routes/modules/master-data.ts +41 -0
  149. package/template/packages/admin/src/routes/modules/purchase-orders.ts +27 -0
  150. package/template/packages/admin/src/routes/modules/purchase-requisitions.ts +39 -0
  151. package/template/packages/admin/src/routes/modules/reports.ts +33 -0
  152. package/template/packages/admin/src/routes/modules/settings.ts +19 -0
  153. package/template/packages/admin/src/routes/withSuspense.tsx +21 -0
  154. package/template/packages/admin/src/theme/amber.css +27 -0
  155. package/template/packages/admin/src/theme/blue.css +27 -0
  156. package/template/packages/admin/src/theme/default.css +75 -0
  157. package/template/packages/admin/src/theme/fiori.css +180 -0
  158. package/template/packages/admin/src/theme/green.css +27 -0
  159. package/template/packages/admin/src/theme/index.css +12 -0
  160. package/template/packages/admin/src/theme/rose.css +27 -0
  161. package/template/packages/admin/src/theme/violet.css +27 -0
  162. package/template/packages/admin/src/vite-env.d.ts +1 -0
  163. package/template/packages/admin/tsconfig.json +28 -0
  164. package/template/packages/admin/tsconfig.node.json +21 -0
  165. package/template/packages/admin/vite.config.ts +26 -0
  166. package/template/packages/api/.eslintrc.json +6 -0
  167. package/template/packages/api/.swcrc +17 -0
  168. package/template/packages/api/app.config.ts +160 -0
  169. package/template/packages/api/docs/api-document.md +497 -0
  170. package/template/packages/api/examples/security/README.md +664 -0
  171. package/template/packages/api/examples/security/complete/.env.example +26 -0
  172. package/template/packages/api/examples/security/complete/PROJECT_STRUCTURE.md +220 -0
  173. package/template/packages/api/examples/security/complete/README.md +847 -0
  174. package/template/packages/api/examples/security/complete/app.config.ts +69 -0
  175. package/template/packages/api/examples/security/complete/app.ts +63 -0
  176. package/template/packages/api/examples/security/complete/controller/auth.controller.ts +131 -0
  177. package/template/packages/api/examples/security/complete/controller/index.ts +4 -0
  178. package/template/packages/api/examples/security/complete/controller/permission.controller.ts +41 -0
  179. package/template/packages/api/examples/security/complete/controller/role.controller.ts +53 -0
  180. package/template/packages/api/examples/security/complete/controller/user.controller.ts +53 -0
  181. package/template/packages/api/examples/security/complete/dto/change-password.dto.ts +10 -0
  182. package/template/packages/api/examples/security/complete/dto/create-permission.dto.ts +14 -0
  183. package/template/packages/api/examples/security/complete/dto/create-role.dto.ts +11 -0
  184. package/template/packages/api/examples/security/complete/dto/create-user.dto.ts +15 -0
  185. package/template/packages/api/examples/security/complete/dto/index.ts +7 -0
  186. package/template/packages/api/examples/security/complete/dto/login.dto.ts +10 -0
  187. package/template/packages/api/examples/security/complete/dto/oauth-profile.dto.ts +7 -0
  188. package/template/packages/api/examples/security/complete/dto/register.dto.ts +17 -0
  189. package/template/packages/api/examples/security/complete/entity/index.ts +6 -0
  190. package/template/packages/api/examples/security/complete/entity/oauth-account.entity.ts +39 -0
  191. package/template/packages/api/examples/security/complete/entity/permission.entity.ts +31 -0
  192. package/template/packages/api/examples/security/complete/entity/role-permission.entity.ts +19 -0
  193. package/template/packages/api/examples/security/complete/entity/role.entity.ts +25 -0
  194. package/template/packages/api/examples/security/complete/entity/user-role.entity.ts +19 -0
  195. package/template/packages/api/examples/security/complete/entity/user.entity.ts +46 -0
  196. package/template/packages/api/examples/security/complete/init.sql +81 -0
  197. package/template/packages/api/examples/security/complete/middleware/auth.interceptor.ts +39 -0
  198. package/template/packages/api/examples/security/complete/middleware/index.ts +2 -0
  199. package/template/packages/api/examples/security/complete/middleware/permission.interceptor.ts +61 -0
  200. package/template/packages/api/examples/security/complete/package.json +54 -0
  201. package/template/packages/api/examples/security/complete/seed.sql +42 -0
  202. package/template/packages/api/examples/security/complete/service/auth.service.ts +41 -0
  203. package/template/packages/api/examples/security/complete/service/index.ts +5 -0
  204. package/template/packages/api/examples/security/complete/service/oauth.service.ts +82 -0
  205. package/template/packages/api/examples/security/complete/service/permission.service.ts +113 -0
  206. package/template/packages/api/examples/security/complete/service/role.service.ts +85 -0
  207. package/template/packages/api/examples/security/complete/service/user.service.ts +132 -0
  208. package/template/packages/api/examples/security/complete/tests/TEST_REPORT.md +318 -0
  209. package/template/packages/api/examples/security/complete/tests/generate-report.js +335 -0
  210. package/template/packages/api/examples/security/complete/tests/helpers/api-helpers.ts +116 -0
  211. package/template/packages/api/examples/security/complete/tests/helpers/index.ts +2 -0
  212. package/template/packages/api/examples/security/complete/tests/helpers/test-helpers.ts +129 -0
  213. package/template/packages/api/examples/security/complete/tests/integration/auth.api.test.ts +429 -0
  214. package/template/packages/api/examples/security/complete/tests/integration/role.api.test.ts +400 -0
  215. package/template/packages/api/examples/security/complete/tests/integration/user.api.test.ts +459 -0
  216. package/template/packages/api/examples/security/complete/tests/jest.config.js +40 -0
  217. package/template/packages/api/examples/security/complete/tests/run-all-tests.js +135 -0
  218. package/template/packages/api/examples/security/complete/tests/run-tests.js +109 -0
  219. package/template/packages/api/examples/security/complete/tests/setup.ts +19 -0
  220. package/template/packages/api/examples/security/complete/tests/unit/auth.service.test.ts +199 -0
  221. package/template/packages/api/examples/security/complete/tests/unit/permission.service.test.ts +377 -0
  222. package/template/packages/api/examples/security/complete/tests/unit/user.service.test.ts +288 -0
  223. package/template/packages/api/examples/security/complete/tsconfig.json +35 -0
  224. package/template/packages/api/examples/security/jwt/README.md +424 -0
  225. package/template/packages/api/examples/security/local/README.md +499 -0
  226. package/template/packages/api/examples/security/oauth2/README.md +637 -0
  227. package/template/packages/api/examples/security/permission/README.md +943 -0
  228. package/template/packages/api/examples/security/session/README.md +753 -0
  229. package/template/packages/api/package.json +56 -0
  230. package/template/packages/api/src/controller/auth.controller.ts +127 -0
  231. package/template/packages/api/src/controller/cache.controller.ts +106 -0
  232. package/template/packages/api/src/controller/menu.controller.ts +46 -0
  233. package/template/packages/api/src/controller/mq.controller.ts +35 -0
  234. package/template/packages/api/src/controller/role.controller.ts +51 -0
  235. package/template/packages/api/src/controller/upload.controller.ts +85 -0
  236. package/template/packages/api/src/controller/user.controller.ts +57 -0
  237. package/template/packages/api/src/dto/auth.dto.ts +30 -0
  238. package/template/packages/api/src/dto/cache.dto.ts +24 -0
  239. package/template/packages/api/src/dto/menu.dto.ts +37 -0
  240. package/template/packages/api/src/dto/mq.dto.ts +16 -0
  241. package/template/packages/api/src/dto/role.dto.ts +16 -0
  242. package/template/packages/api/src/dto/user.dto.ts +35 -0
  243. package/template/packages/api/src/entity/menu.entity.ts +34 -0
  244. package/template/packages/api/src/entity/role-menu.entity.ts +13 -0
  245. package/template/packages/api/src/entity/role.entity.ts +22 -0
  246. package/template/packages/api/src/entity/user-role.entity.ts +13 -0
  247. package/template/packages/api/src/entity/user.entity.ts +31 -0
  248. package/template/packages/api/src/mapper/menu.mapper.ts +6 -0
  249. package/template/packages/api/src/mapper/role-menu.mapper.ts +6 -0
  250. package/template/packages/api/src/mapper/role.mapper.ts +6 -0
  251. package/template/packages/api/src/mapper/user-role.mapper.ts +6 -0
  252. package/template/packages/api/src/mapper/user.mapper.ts +11 -0
  253. package/template/packages/api/src/scripts/init-db.ts +185 -0
  254. package/template/packages/api/src/server.ts +76 -0
  255. package/template/packages/api/src/service/auth.service.ts +106 -0
  256. package/template/packages/api/src/service/cache.service.ts +80 -0
  257. package/template/packages/api/src/service/log.request.service.ts +158 -0
  258. package/template/packages/api/src/service/log.service.ts +123 -0
  259. package/template/packages/api/src/service/menu.service.ts +94 -0
  260. package/template/packages/api/src/service/mq.consumer.service.ts +26 -0
  261. package/template/packages/api/src/service/role.service.ts +88 -0
  262. package/template/packages/api/src/service/user.service.ts +170 -0
  263. package/template/packages/api/src/types/sqljs.d.ts +18 -0
  264. package/template/packages/api/src/utils/auth.utils.js +0 -0
  265. package/template/packages/api/src/utils/jwt.util.ts +29 -0
  266. package/template/packages/api/tsconfig.json +17 -0
  267. package/template/packages/api/tsup.config.ts +9 -0
  268. package/template/packages/api/uploads/.gitkeep +0 -0
  269. package/template/packages/core/package.json +31 -0
  270. package/template/packages/core/src/auth/auth-client-middleware.ts +22 -0
  271. package/template/packages/core/src/auth/auth-service.ts +65 -0
  272. package/template/packages/core/src/auth/default-auth-provider.ts +37 -0
  273. package/template/packages/core/src/auth/index.ts +10 -0
  274. package/template/packages/core/src/auth/types.ts +38 -0
  275. package/template/packages/core/src/authorization/authorization-client-middleware.ts +38 -0
  276. package/template/packages/core/src/authorization/authorization-config.ts +13 -0
  277. package/template/packages/core/src/authorization/authorization-provider.tsx +116 -0
  278. package/template/packages/core/src/authorization/default-authorization-provider.ts +26 -0
  279. package/template/packages/core/src/authorization/index.ts +15 -0
  280. package/template/packages/core/src/authorization/types.ts +42 -0
  281. package/template/packages/core/src/index.ts +3 -0
  282. package/template/packages/core/src/utils/promise-result-cache.ts +18 -0
  283. package/template/packages/core/tsconfig.json +19 -0
  284. package/template/packages/mobile/README.md +55 -0
  285. package/template/packages/mobile/index.html +13 -0
  286. package/template/packages/mobile/package.json +30 -0
  287. package/template/packages/mobile/postcss.config.mjs +7 -0
  288. package/template/packages/mobile/src/App.tsx +5 -0
  289. package/template/packages/mobile/src/app/globals.css +1 -0
  290. package/template/packages/mobile/src/components/LoginForm.tsx +76 -0
  291. package/template/packages/mobile/src/hooks/index.ts +5 -0
  292. package/template/packages/mobile/src/lib/utils.ts +7 -0
  293. package/template/packages/mobile/src/main.tsx +13 -0
  294. package/template/packages/mobile/src/pages/HomePage.tsx +35 -0
  295. package/template/packages/mobile/src/pages/LoginPage.tsx +35 -0
  296. package/template/packages/mobile/src/pages/index.ts +2 -0
  297. package/template/packages/mobile/src/routes/ProtectedRoute.tsx +29 -0
  298. package/template/packages/mobile/src/routes/index.tsx +24 -0
  299. package/template/packages/mobile/src/routes/routes.ts +11 -0
  300. package/template/packages/mobile/src/types/index.ts +5 -0
  301. package/template/packages/mobile/src/vite-env.d.ts +1 -0
  302. package/template/packages/mobile/tsconfig.json +23 -0
  303. package/template/packages/mobile/tsconfig.node.json +11 -0
  304. package/template/packages/mobile/vite.config.ts +19 -0
  305. package/template/packages/shared/package.json +20 -0
  306. package/template/packages/shared/src/constants.ts +8 -0
  307. package/template/packages/shared/src/index.ts +5 -0
  308. package/template/packages/shared/tsconfig.json +13 -0
  309. package/template/packages/shared-auth/package.json +29 -0
  310. package/template/packages/shared-auth/src/AuthContext.tsx +177 -0
  311. package/template/packages/shared-auth/src/AuthProviderWrapper.tsx +29 -0
  312. package/template/packages/shared-auth/src/index.ts +10 -0
  313. package/template/packages/shared-auth/tsconfig.json +14 -0
  314. package/template/pnpm-lock.yaml +16349 -0
  315. package/template/pnpm-workspace.yaml +3 -0
  316. package/template/scripts/postinstall.cjs +42 -0
  317. package/template/scripts/rebuild-sqlite.cjs +23 -0
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@scaffold/api",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "exports": {
7
+ "./client": {
8
+ "import": "./dist/client/index.ts",
9
+ "types": "./dist/client/index.ts"
10
+ }
11
+ },
12
+ "scripts": {
13
+ "dev": "node --import @swc-node/register/esm-register --watch src/server.ts",
14
+ "dev:server": "node --import @swc-node/register/esm-register --watch src/server.ts",
15
+ "init-db": "node --import @swc-node/register/esm-register src/scripts/init-db.ts",
16
+ "build": "tsup",
17
+ "start": "node dist/server.js",
18
+ "lint": "eslint src"
19
+ },
20
+ "dependencies": {
21
+ "@ai-partner-x/aiko-boot": "workspace:*",
22
+ "@ai-partner-x/aiko-boot-starter-orm": "workspace:*",
23
+ "@ai-partner-x/aiko-boot-starter-cache": "workspace:*",
24
+ "@ai-partner-x/aiko-boot-starter-validation": "workspace:*",
25
+ "@ai-partner-x/aiko-boot-starter-web": "workspace:*",
26
+ "@ai-partner-x/aiko-boot-starter-security": "workspace:*",
27
+ "@ai-partner-x/aiko-boot-starter-storage": "workspace:*",
28
+ "@ai-partner-x/aiko-boot-starter-mq": "workspace:*",
29
+ "@ai-partner-x/aiko-boot-starter-log": "workspace:*",
30
+ "bcryptjs": "^2.4.3",
31
+ "jsonwebtoken": "^9.0.2",
32
+ "better-sqlite3": "^12.6.2",
33
+ "ioredis": "^5.4.2",
34
+ "cors": "^2.8.5",
35
+ "date-fns": "^4.1.0",
36
+ "express": "^4.18.0",
37
+ "axios": "^1.6.0",
38
+ "multer": "^1.4.5-lts.1",
39
+ "reflect-metadata": "^0.2.1"
40
+ },
41
+ "devDependencies": {
42
+ "sql.js": "^1.11.0",
43
+ "@swc-node/register": "^1.11.1",
44
+ "@swc/core": "^1.15.18",
45
+ "@types/bcryptjs": "^2.4.6",
46
+ "@types/better-sqlite3": "^7.6.13",
47
+ "@types/cors": "^2.8.17",
48
+ "@types/express": "^4.17.21",
49
+ "@types/jsonwebtoken": "^9.0.5",
50
+ "@types/multer": "^1.4.12",
51
+ "@types/node": "^20.11.0",
52
+ "tsup": "^8.0.0",
53
+ "tsx": "^4.7.0",
54
+ "typescript": "^5.3.0"
55
+ }
56
+ }
@@ -0,0 +1,127 @@
1
+ import 'reflect-metadata';
2
+ import { RestController, PostMapping, GetMapping, RequestBody, RequestParam, QueryParam } from '@ai-partner-x/aiko-boot-starter-web';
3
+ import { Autowired } from '@ai-partner-x/aiko-boot';
4
+ import { Public } from '@ai-partner-x/aiko-boot-starter-security';
5
+ import { AuthService } from '../service/auth.service.js';
6
+ import type { LoginDto, LoginResultDto, RefreshTokenDto } from '../dto/auth.dto.js';
7
+ import { SecurityContext } from '@ai-partner-x/aiko-boot-starter-security';
8
+ import axios from 'axios';
9
+
10
+ @RestController({ path: '/auth' })
11
+ export class AuthController {
12
+ @Autowired()
13
+ private authService!: AuthService;
14
+
15
+ @PostMapping('/login')
16
+ @Public()
17
+ async login(@RequestBody() dto: LoginDto): Promise<LoginResultDto> {
18
+ return this.authService.login(dto);
19
+ }
20
+
21
+ @PostMapping('/refresh')
22
+ @Public()
23
+ async refresh(@RequestBody() dto: RefreshTokenDto): Promise<{ accessToken: string }> {
24
+ return this.authService.refreshToken(dto.refreshToken);
25
+ }
26
+
27
+ @GetMapping('/info')
28
+ async getUserInfo(@RequestParam('_uid') userId: string): Promise<LoginResultDto['userInfo']> {
29
+ return this.authService.getUserInfo(Number(userId));
30
+ }
31
+
32
+ @PostMapping('/logout')
33
+ async logout(@RequestBody() body: { token: string }): Promise<any> {
34
+ return this.authService.logout(body.token);
35
+ }
36
+
37
+ @GetMapping('/github')
38
+ @Public()
39
+ async githubAuth(@QueryParam('redirect') redirect?: string): Promise<any> {
40
+ const clientId = process.env.GITHUB_CLIENT_ID;
41
+ const redirectUri = process.env.GITHUB_CALLBACK_URL;
42
+ const scope = 'user:email';
43
+
44
+ const authUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${scope}${redirect ? `&redirect_uri=${encodeURIComponent(redirect)}` : ''}`;
45
+
46
+ return { authUrl };
47
+ }
48
+
49
+ @GetMapping('/github/callback')
50
+ @Public()
51
+ async githubCallback(@QueryParam('code') code: string): Promise<any> {
52
+ try {
53
+ const clientId = process.env.GITHUB_CLIENT_ID;
54
+ const clientSecret = process.env.GITHUB_CLIENT_SECRET;
55
+ const redirectUri = process.env.GITHUB_CALLBACK_URL;
56
+
57
+ const tokenResponse = await axios.post('https://github.com/login/oauth/access_token', {
58
+ client_id: clientId,
59
+ client_secret: clientSecret,
60
+ code: code,
61
+ redirect_uri: redirectUri,
62
+ }, {
63
+ headers: { Accept: 'application/json' }
64
+ });
65
+
66
+ const tokens = tokenResponse.data;
67
+
68
+ const userResponse = await axios.get('https://api.github.com/user', {
69
+ headers: { Authorization: `Bearer ${tokens.access_token}` }
70
+ });
71
+
72
+ const profile = {
73
+ ...userResponse.data,
74
+ provider: 'github',
75
+ };
76
+
77
+ return this.authService.handleOAuthCallback(profile, tokens);
78
+ } catch (error) {
79
+ throw new Error('GitHub OAuth token exchange failed');
80
+ }
81
+ }
82
+
83
+ @GetMapping('/google')
84
+ @Public()
85
+ async googleAuth(@QueryParam('redirect') redirect?: string): Promise<any> {
86
+ const clientId = process.env.GOOGLE_CLIENT_ID;
87
+ const redirectUri = process.env.GOOGLE_CALLBACK_URL;
88
+ const scope = 'profile email';
89
+
90
+ const authUrl = `https://accounts.google.com/o/oauth2/v2/auth?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}&response_type=code${redirect ? `&redirect_uri=${encodeURIComponent(redirect)}` : ''}`;
91
+
92
+ return { authUrl };
93
+ }
94
+
95
+ @GetMapping('/google/callback')
96
+ @Public()
97
+ async googleCallback(@QueryParam('code') code: string): Promise<any> {
98
+ try {
99
+ const clientId = process.env.GOOGLE_CLIENT_ID;
100
+ const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
101
+ const redirectUri = process.env.GOOGLE_CALLBACK_URL;
102
+
103
+ const tokenResponse = await axios.post('https://oauth2.googleapis.com/token', {
104
+ client_id: clientId,
105
+ client_secret: clientSecret,
106
+ code: code,
107
+ redirect_uri: redirectUri,
108
+ grant_type: 'authorization_code',
109
+ });
110
+
111
+ const tokens = tokenResponse.data;
112
+
113
+ const userResponse = await axios.get('https://www.googleapis.com/oauth2/v2/userinfo', {
114
+ headers: { Authorization: `Bearer ${tokens.access_token}` }
115
+ });
116
+
117
+ const profile = {
118
+ ...userResponse.data,
119
+ provider: 'google',
120
+ };
121
+
122
+ return this.authService.handleOAuthCallback(profile, tokens);
123
+ } catch (error) {
124
+ throw new Error('Google OAuth token exchange failed');
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,106 @@
1
+ import 'reflect-metadata';
2
+ import { RestController, PostMapping, DeleteMapping, GetMapping, RequestBody, RequestParam } from '@ai-partner-x/aiko-boot-starter-web';
3
+ import { Autowired } from '@ai-partner-x/aiko-boot';
4
+ import { CacheService } from '../service/cache.service.js';
5
+ import type { CachePutDto } from '../dto/cache.dto.js';
6
+
7
+ /**
8
+ * Cache 控制器
9
+ *
10
+ * 提供缓存的 CRUD 操作接口,仅在非生产环境下可用。
11
+ * 注意:需要在 app.config.ts 中启用 cache 并配置 Redis 连接
12
+ *
13
+ * 当 NODE_ENV=production 时,所有端点会直接抛出错误拒绝访问,
14
+ * 防止数据泄露、缓存投毒或拒绝服务。
15
+ */
16
+ @RestController({ path: '/cache' })
17
+ export class CacheController {
18
+ @Autowired()
19
+ private cacheService!: CacheService;
20
+
21
+ private assertNonProduction(): void {
22
+ if (process.env.NODE_ENV === 'production') {
23
+ throw new Error('Cache management endpoints are disabled in production.');
24
+ }
25
+ }
26
+
27
+ /**
28
+ * 获取缓存值
29
+ *
30
+ * @example
31
+ * curl "http://localhost:3001/api/cache/get?name=user&key=1"
32
+ */
33
+ @GetMapping('/get')
34
+ async get(
35
+ @RequestParam('name') name: string,
36
+ @RequestParam('key') key: string,
37
+ ): Promise<string | null> {
38
+ this.assertNonProduction();
39
+ return this.cacheService.get({ name, key });
40
+ }
41
+
42
+ /**
43
+ * 设置缓存值
44
+ *
45
+ * @example
46
+ * curl -X POST http://localhost:3001/api/cache/put \
47
+ * -H "Content-Type: application/json" \
48
+ * -d '{"name":"user","key":"1","value":{"id":1,"name":"张三"},"ttlSeconds":300}'
49
+ */
50
+ @PostMapping('/put')
51
+ async put(@RequestBody() dto: CachePutDto): Promise<{ ok: boolean }> {
52
+ this.assertNonProduction();
53
+ await this.cacheService.put(dto);
54
+ return { ok: true };
55
+ }
56
+
57
+ /**
58
+ * 删除缓存条目
59
+ *
60
+ * @example
61
+ * # 删除单个 key
62
+ * curl -X DELETE "http://localhost:3001/api/cache/evict?name=user&key=1"
63
+ *
64
+ * # 删除命名空间下所有条目(无需传 key)
65
+ * curl -X DELETE "http://localhost:3001/api/cache/evict?name=user&allEntries=true"
66
+ */
67
+ @DeleteMapping('/evict')
68
+ async evict(
69
+ @RequestParam('name') name: string,
70
+ @RequestParam('key') key?: string,
71
+ @RequestParam('allEntries') allEntries?: string,
72
+ ): Promise<{ ok: boolean }> {
73
+ this.assertNonProduction();
74
+ const isAllEntries = allEntries === 'true';
75
+ if (!isAllEntries && !key) {
76
+ throw new Error('Query parameter "key" is required when "allEntries" is not true.');
77
+ }
78
+
79
+ return { ok: true };
80
+ }
81
+
82
+ /**
83
+ * 清空缓存命名空间
84
+ *
85
+ * @example
86
+ * curl -X DELETE "http://localhost:3001/api/cache/clear?name=user"
87
+ */
88
+ @DeleteMapping('/clear')
89
+ async clear(@RequestParam('name') name: string): Promise<{ ok: boolean }> {
90
+ this.assertNonProduction();
91
+ await this.cacheService.clear({ name });
92
+ return { ok: true };
93
+ }
94
+
95
+ /**
96
+ * 检查缓存状态
97
+ *
98
+ * @example
99
+ * curl "http://localhost:3001/api/cache/status"
100
+ */
101
+ @GetMapping('/status')
102
+ async status(): Promise<{ initialized: boolean }> {
103
+ this.assertNonProduction();
104
+ return { initialized: this.cacheService.isInitialized() };
105
+ }
106
+ }
@@ -0,0 +1,46 @@
1
+ import 'reflect-metadata';
2
+ import {
3
+ RestController, GetMapping, PostMapping, PutMapping, DeleteMapping,
4
+ PathVariable, RequestBody, RequestParam,
5
+ } from '@ai-partner-x/aiko-boot-starter-web';
6
+ import { Autowired } from '@ai-partner-x/aiko-boot/di/server';
7
+ import { MenuService } from '../service/menu.service.js';
8
+ import type { CreateMenuDto, UpdateMenuDto } from '../dto/menu.dto.js';
9
+
10
+ @RestController({ path: '/sys/menu' })
11
+ export class MenuController {
12
+ @Autowired()
13
+ private menuService!: MenuService;
14
+
15
+ @GetMapping('/tree')
16
+ async getFullTree() {
17
+ return this.menuService.getFullTree();
18
+ }
19
+
20
+ @GetMapping('/user-tree')
21
+ async getUserTree(@RequestParam('_perms') perms: string) {
22
+ const permissions = perms ? perms.split(',').filter(Boolean) : [];
23
+ return this.menuService.getUserMenuTree(permissions);
24
+ }
25
+
26
+ @GetMapping('/:id')
27
+ async getById(@PathVariable('id') id: string) {
28
+ return this.menuService.getById(Number(id));
29
+ }
30
+
31
+ @PostMapping()
32
+ async create(@RequestBody() dto: CreateMenuDto) {
33
+ return this.menuService.createMenu(dto);
34
+ }
35
+
36
+ @PutMapping('/:id')
37
+ async update(@PathVariable('id') id: string, @RequestBody() dto: UpdateMenuDto) {
38
+ return this.menuService.updateMenu(Number(id), dto);
39
+ }
40
+
41
+ @DeleteMapping('/:id')
42
+ async delete(@PathVariable('id') id: string) {
43
+ await this.menuService.deleteMenu(Number(id));
44
+ return { message: '删除成功' };
45
+ }
46
+ }
@@ -0,0 +1,35 @@
1
+ import 'reflect-metadata';
2
+ import { RestController, PostMapping, RequestBody } from '@ai-partner-x/aiko-boot-starter-web';
3
+ import { Autowired } from '@ai-partner-x/aiko-boot';
4
+ import { MqTemplate } from '@ai-partner-x/aiko-boot-starter-mq';
5
+ import type { SendUserEventDto, UserEventDto } from '../dto/mq.dto.js';
6
+
7
+ @RestController({ path: '/mq' })
8
+ export class MqController {
9
+ @Autowired(MqTemplate)
10
+ private mqTemplate!: MqTemplate;
11
+
12
+ /**
13
+ * 发送用户相关消息到 MQ
14
+ * POST /api/mq/send
15
+ */
16
+ @PostMapping('/send')
17
+ async send(@RequestBody() dto: SendUserEventDto): Promise<{ ok: boolean; topic: string }> {
18
+ if (dto.tag) {
19
+ await this.mqTemplate.send(dto.topic, dto.tag, dto.body);
20
+ } else {
21
+ await this.mqTemplate.send(dto.topic, dto.body);
22
+ }
23
+ return { ok: true, topic: dto.topic };
24
+ }
25
+
26
+ /**
27
+ * 快捷发送 user.created 事件(复用 User 实体字段)
28
+ * POST /api/mq/send-user-created
29
+ */
30
+ @PostMapping('/send-user-created')
31
+ async sendUserCreated(@RequestBody() body: UserEventDto): Promise<{ ok: boolean }> {
32
+ await this.mqTemplate.send('user.created', 'add', body);
33
+ return { ok: true };
34
+ }
35
+ }
@@ -0,0 +1,51 @@
1
+ import 'reflect-metadata';
2
+ import {
3
+ RestController, GetMapping, PostMapping, PutMapping, DeleteMapping,
4
+ PathVariable, RequestBody,
5
+ } from '@ai-partner-x/aiko-boot-starter-web';
6
+ import { Autowired } from '@ai-partner-x/aiko-boot/di/server';
7
+ import { RoleService } from '../service/role.service.js';
8
+ import type { CreateRoleDto, UpdateRoleDto } from '../dto/role.dto.js';
9
+
10
+ @RestController({ path: '/sys/role' })
11
+ export class RoleController {
12
+ @Autowired()
13
+ private roleService!: RoleService;
14
+
15
+ @GetMapping('/list')
16
+ async list() {
17
+ return this.roleService.listRoles();
18
+ }
19
+
20
+ @GetMapping('/:id')
21
+ async getById(@PathVariable('id') id: string) {
22
+ return this.roleService.getById(Number(id));
23
+ }
24
+
25
+ @PostMapping()
26
+ async create(@RequestBody() dto: CreateRoleDto) {
27
+ console.log("dto1", dto);
28
+ return this.roleService.createRole(dto);
29
+ }
30
+
31
+ @PutMapping('/:id')
32
+ async update(@PathVariable('id') id: string, @RequestBody() dto: UpdateRoleDto) {
33
+ return this.roleService.updateRole(Number(id), dto);
34
+ }
35
+
36
+ @DeleteMapping('/:id')
37
+ async delete(@PathVariable('id') id: string) {
38
+ await this.roleService.deleteRole(Number(id));
39
+ return { message: '删除成功' };
40
+ }
41
+
42
+ @GetMapping('/:id/menus')
43
+ async getRoleMenus(@PathVariable('id') id: string) {
44
+ return this.roleService.getRoleMenuIds(Number(id));
45
+ }
46
+
47
+ @PutMapping('/:id/menus')
48
+ async assignMenus(@PathVariable('id') id: string, @RequestBody() body: { menuIds: number[] }) {
49
+ return this.roleService.updateRole(Number(id), { menuIds: body.menuIds });
50
+ }
51
+ }
@@ -0,0 +1,85 @@
1
+ import 'reflect-metadata';
2
+ import { RestController, PostMapping, DeleteMapping, GetMapping, RequestParam } from '@ai-partner-x/aiko-boot-starter-web';
3
+ import { Autowired } from '@ai-partner-x/aiko-boot';
4
+ import { StorageService, type UploadResult } from '@ai-partner-x/aiko-boot-starter-storage';
5
+ import type { Request } from 'express';
6
+
7
+ /**
8
+ * 文件上传控制器
9
+ *
10
+ * 提供文件上传、删除、获取 URL 等接口
11
+ */
12
+ @RestController({ path: '/upload' })
13
+ export class UploadController {
14
+ @Autowired()
15
+ private storageService!: StorageService;
16
+
17
+ /**
18
+ * 上传单个文件
19
+ *
20
+ * @example
21
+ * curl -X POST http://localhost:3001/api/upload \
22
+ * -F "file=@/path/to/image.png" \
23
+ * -F "folder=images"
24
+ */
25
+ @PostMapping('/')
26
+ async upload(req: Request): Promise<UploadResult> {
27
+ const file = (req as Request & { file?: Express.Multer.File }).file;
28
+ if (!file) {
29
+ throw new Error('No file uploaded');
30
+ }
31
+
32
+ const folder = (req.body?.folder as string) || 'uploads';
33
+
34
+ return this.storageService.upload(file.buffer, file.originalname, {
35
+ folder,
36
+ maxSize: 10 * 1024 * 1024, // 10MB
37
+ allowedTypes: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'],
38
+ });
39
+ }
40
+
41
+ /**
42
+ * 删除文件
43
+ *
44
+ * @example
45
+ * curl -X DELETE "http://localhost:3001/api/upload?key=images/xxx.png"
46
+ */
47
+ @DeleteMapping('/')
48
+ async delete(@RequestParam('key') key: string): Promise<{ success: boolean }> {
49
+ await this.storageService.delete(key);
50
+ return { success: true };
51
+ }
52
+
53
+ /**
54
+ * 获取文件 URL
55
+ *
56
+ * @example
57
+ * curl "http://localhost:3001/api/upload/url?key=images/xxx.png"
58
+ */
59
+ @GetMapping('/url')
60
+ async getUrl(@RequestParam('key') key: string): Promise<{ url: string }> {
61
+ const url = await this.storageService.getUrl(key);
62
+ return { url };
63
+ }
64
+
65
+ /**
66
+ * 获取图片预览 URL(支持 OSS/COS 的图片处理参数)
67
+ *
68
+ * @example
69
+ * curl "http://localhost:3001/api/upload/preview?key=images/xxx.png&width=200&height=200"
70
+ */
71
+ @GetMapping('/preview')
72
+ async getPreviewUrl(
73
+ @RequestParam('key') key: string,
74
+ @RequestParam('width') width?: string,
75
+ @RequestParam('height') height?: string,
76
+ @RequestParam('quality') quality?: string,
77
+ ): Promise<{ url: string }> {
78
+ const url = await this.storageService.getPreviewUrl(key, {
79
+ width: width ? parseInt(width, 10) : undefined,
80
+ height: height ? parseInt(height, 10) : undefined,
81
+ quality: quality ? parseInt(quality, 10) : undefined,
82
+ });
83
+ return { url };
84
+ }
85
+ }
@@ -0,0 +1,57 @@
1
+ import 'reflect-metadata';
2
+ import {
3
+ RestController, GetMapping, PostMapping, PutMapping, DeleteMapping,
4
+ PathVariable, RequestBody, RequestParam,
5
+ } from '@ai-partner-x/aiko-boot-starter-web';
6
+ import { Autowired } from '@ai-partner-x/aiko-boot/di/server';
7
+ import { UserService } from '../service/user.service.js';
8
+ import type { CreateUserDto, UpdateUserDto, UserPageDto } from '../dto/user.dto.js';
9
+
10
+ @RestController({ path: '/sys/user' })
11
+ export class UserController {
12
+ @Autowired()
13
+ private userService!: UserService;
14
+
15
+ @GetMapping('/page')
16
+ async page(
17
+ @RequestParam('pageNo') pageNo: string,
18
+ @RequestParam('pageSize') pageSize: string,
19
+ @RequestParam('username') username: string,
20
+ @RequestParam('status') status: string,
21
+ ) {
22
+ const params: UserPageDto = {
23
+ pageNo: pageNo ? parseInt(pageNo) : 1,
24
+ pageSize: pageSize ? parseInt(pageSize) : 10,
25
+ username: username || undefined,
26
+ status: status !== undefined && status !== '' ? parseInt(status) : undefined,
27
+ };
28
+ return this.userService.pageUsers(params);
29
+ }
30
+
31
+ @GetMapping('/:id')
32
+ async getById(@PathVariable('id') id: string) {
33
+ return this.userService.getById(Number(id));
34
+ }
35
+
36
+ @PostMapping()
37
+ async create(@RequestBody() dto: CreateUserDto) {
38
+ return this.userService.createUser(dto);
39
+ }
40
+
41
+ @PutMapping('/:id')
42
+ async update(@PathVariable('id') id: string, @RequestBody() dto: UpdateUserDto) {
43
+ return this.userService.updateUser(Number(id), dto);
44
+ }
45
+
46
+ @DeleteMapping('/:id')
47
+ async delete(@PathVariable('id') id: string) {
48
+ await this.userService.deleteUser(Number(id));
49
+ return { message: '删除成功' };
50
+ }
51
+
52
+ @PutMapping('/:id/password')
53
+ async resetPassword(@PathVariable('id') id: string, @RequestBody() body: { newPassword: string }) {
54
+ await this.userService.resetPassword(Number(id), body.newPassword);
55
+ return { message: '密码重置成功' };
56
+ }
57
+ }
@@ -0,0 +1,30 @@
1
+ import { IsNotEmpty, Length, MinLength } from '@ai-partner-x/aiko-boot-starter-validation';
2
+
3
+ export class LoginDto {
4
+ @IsNotEmpty({ message: '用户名不能为空' })
5
+ @Length(1, 50, { message: '用户名长度必须在 1-50 之间' })
6
+ username!: string;
7
+
8
+ @IsNotEmpty({ message: '密码不能为空' })
9
+ @MinLength(6, { message: '密码至少 6 位' })
10
+ password!: string;
11
+ }
12
+
13
+ export class RefreshTokenDto {
14
+ @IsNotEmpty({ message: 'refreshToken不能为空' })
15
+ refreshToken!: string;
16
+ }
17
+
18
+ /** 登录成功返回的用户信息(不含密码) */
19
+ export class LoginResultDto {
20
+ accessToken!: string;
21
+ refreshToken!: string;
22
+ userInfo!: {
23
+ id: number;
24
+ username: string;
25
+ realName?: string;
26
+ email?: string;
27
+ roles: string[];
28
+ permissions: string[];
29
+ };
30
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Cache 操作 DTO
3
+ */
4
+ export interface CacheGetDto {
5
+ name: string;
6
+ key: string;
7
+ }
8
+
9
+ export interface CachePutDto {
10
+ name: string;
11
+ key: string;
12
+ value: unknown;
13
+ ttlSeconds?: number;
14
+ }
15
+
16
+ export interface CacheEvictDto {
17
+ name: string;
18
+ key?: string;
19
+ allEntries?: boolean;
20
+ }
21
+
22
+ export interface CacheClearDto {
23
+ name: string;
24
+ }
@@ -0,0 +1,37 @@
1
+ export class CreateMenuDto {
2
+ parentId: number = 0;
3
+ menuName!: string;
4
+ menuType!: number; // 1目录 2菜单 3按钮
5
+ path?: string;
6
+ component?: string;
7
+ permission?: string;
8
+ icon?: string;
9
+ sortOrder: number = 0;
10
+ status: number = 1;
11
+ }
12
+
13
+ export class UpdateMenuDto {
14
+ parentId?: number;
15
+ menuName?: string;
16
+ menuType?: number;
17
+ path?: string;
18
+ component?: string;
19
+ permission?: string;
20
+ icon?: string;
21
+ sortOrder?: number;
22
+ status?: number;
23
+ }
24
+
25
+ export interface MenuTreeVo {
26
+ id: number;
27
+ parentId: number;
28
+ menuName: string;
29
+ menuType: number;
30
+ path?: string;
31
+ component?: string;
32
+ permission?: string;
33
+ icon?: string;
34
+ sortOrder: number;
35
+ status: number;
36
+ children?: MenuTreeVo[];
37
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * MQ 消息 DTO(复用 User 实体字段,不包含敏感信息)
3
+ */
4
+ export interface UserEventDto {
5
+ id: number;
6
+ username: string;
7
+ email: string;
8
+ createdAt?: string;
9
+ updatedAt?: string;
10
+ }
11
+
12
+ export interface SendUserEventDto {
13
+ topic: string;
14
+ tag?: string;
15
+ body: UserEventDto;
16
+ }