create-dp-koa 1.0.0 → 1.0.2

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 (82) hide show
  1. package/package.json +2 -2
  2. package/template/.cursor/commands/cheatsheet-backend-controller.md +45 -0
  3. package/template/.cursor/commands/implement-backend-api-controller.md +60 -0
  4. package/template/.cursor/commands/plan-backend.md +97 -0
  5. package/template/.cursor/rules/00-backend-core.skill.md +61 -0
  6. package/template/.cursor/rules/01-backend-skill-router.skill.md +57 -0
  7. package/template/.cursor/rules/10-backend-api.skill.md +55 -0
  8. package/template/.cursor/rules/11-backend-controller-recipes.skill.md +188 -0
  9. package/template/.cursor/rules/20-backend-repository.skill.md +25 -0
  10. package/template/.cursor/rules/21-backend-service.skill.md +137 -0
  11. package/template/.cursor/rules/25-backend-comments-and-doc.skill.md +98 -0
  12. package/template/.cursor/rules/30-backend-validation.skill.md +342 -0
  13. package/template/.cursor/rules/40-backend-error-logging.skill.md +21 -0
  14. package/template/.cursor/rules/50-backend-bootstrap-lifecycle.skill.md +105 -0
  15. package/template/.cursor/rules/60-backend-router-registration.skill.md +73 -0
  16. package/template/.cursor/rules/70-backend-middleware.skill.md +100 -0
  17. package/template/.cursor/rules/80-backend-utils-and-libs.skill.md +108 -0
  18. package/template/.cursor/rules/85-backend-plugins.rule.md +65 -0
  19. package/template/.cursor/rules/90-backend-testing.skill.md +29 -0
  20. package/template/.cursor/rules/README.md +49 -0
  21. package/template/.trae/skills/11-backend-controller-recipes.skill.md +91 -10
  22. package/template/scripts/sync-template.mjs +0 -1
  23. package/template/src/controllers/example/ExampleController.ts +14 -0
  24. package/template/src/entity/index.ts +1 -15
  25. package/template/src/framework/decorator/processor/AnnotationProcessor.ts +5 -1
  26. package/template/src/routers/index.ts +0 -35
  27. package/template/src/utils/testDataInitializer.ts +2 -269
  28. package/template/test/controllers/example/ExampleController.test.ts +29 -31
  29. package/template/test/framework/annotation/AnnotationDecorators.test.ts +15 -15
  30. package/template/test/framework/annotation/AnnotationExecutor.test.ts +27 -32
  31. package/template/test/framework/annotation/AnnotationProcessor.test.ts +25 -24
  32. package/template/test/framework/annotation/CustomProcessors.test.ts +15 -25
  33. package/template/test/framework/annotation/NewRouter.test.ts +9 -7
  34. package/template/test/framework/annotation/ProcessorManager.test.ts +14 -27
  35. package/template/test/framework/databaseConfig.test.ts +2 -2
  36. package/template/test/integration/integration.test.ts +15 -72
  37. package/template/src/controllers/cacheManagement.controller.ts +0 -131
  38. package/template/src/controllers/captcha.controller.ts +0 -57
  39. package/template/src/controllers/example/NewAnnotationExampleController.ts +0 -159
  40. package/template/src/controllers/example/SwaggerExampleController.ts +0 -205
  41. package/template/src/controllers/example/TransactionExample.controller.ts +0 -336
  42. package/template/src/controllers/health.controller.ts +0 -235
  43. package/template/src/controllers/home/register.controller.ts +0 -58
  44. package/template/src/controllers/home/ytGoods.controller.ts +0 -92
  45. package/template/src/controllers/home/ytShop.controller.ts +0 -135
  46. package/template/src/controllers/home/ytUser.controller.ts +0 -89
  47. package/template/src/controllers/logManagement.controller.ts +0 -396
  48. package/template/src/controllers/public/emailSend.controller.ts +0 -65
  49. package/template/src/controllers/public/ytUserAuth.controller.ts +0 -174
  50. package/template/src/controllers/testData.controller.ts +0 -253
  51. package/template/src/dto/controller/example/NewAnnotationExampleController.dto.ts +0 -73
  52. package/template/src/dto/controller/home/emailSend.controller.dto.ts +0 -40
  53. package/template/src/dto/controller/home/register.controller.dto.ts +0 -45
  54. package/template/src/dto/controller/home/ytGoods.controller.dto.ts +0 -55
  55. package/template/src/dto/controller/home/ytShop.controller.dto.ts +0 -69
  56. package/template/src/dto/controller/home/ytUser.controller.dto.ts +0 -44
  57. package/template/src/dto/controller/public/ytUserAuth.controller.dto.ts +0 -63
  58. package/template/src/dto/goods.dto.ts +0 -212
  59. package/template/src/dto/service/ytService.dto.ts +0 -13
  60. package/template/src/dto/user.dto.ts +0 -177
  61. package/template/src/entity/columnTypes.ts +0 -13
  62. package/template/src/entity/goodsImagesUnlockKey.entity.ts +0 -33
  63. package/template/src/entity/goodsUnlocker.entity.ts +0 -34
  64. package/template/src/entity/shop.entity.ts +0 -52
  65. package/template/src/entity/shopUser.entity.ts +0 -41
  66. package/template/src/entity/ytGoods.entity.ts +0 -94
  67. package/template/src/entity/ytUser.entity.ts +0 -96
  68. package/template/src/examples/SwaggerProcessorExample.ts +0 -169
  69. package/template/src/examples/TransactionManagerDemo.ts +0 -377
  70. package/template/src/framework/utils/dynamicSwagger.ts +0 -410
  71. package/template/src/repository/UserRepository.ts +0 -122
  72. package/template/src/service/paramValidateTest.service.ts +0 -139
  73. package/template/src/service/ytGoods.service.ts +0 -42
  74. package/template/src/service/ytShop.service.ts +0 -90
  75. package/template/src/service/ytUser.service.ts +0 -451
  76. package/template/src/test/swaggerParameterTest.ts +0 -90
  77. package/template/test/controllers/controllers.test.ts +0 -173
  78. package/template/test/controllers/example/NewAnnotationExampleController.test.ts +0 -200
  79. package/template/test/framework/TransactionManagerDemo.test.ts +0 -363
  80. package/template/test/service/business.test.ts +0 -87
  81. package/template/test/service/paramValidateTest.service.test.ts +0 -184
  82. package/template/test/service/ytUser.service.test.ts +0 -566
@@ -1,69 +0,0 @@
1
- import { ShopStatusEnum } from "@src/entity/shop.entity";
2
- import { Transform } from "@src/framework/decorator/controller";
3
- import { IsArray, IsNumber, IsString } from "class-validator";
4
-
5
- export class GetShopInfoByIdQueryDto {
6
-
7
- @Transform((value) => Number(value))
8
- @IsNumber()
9
- id: number
10
- }
11
-
12
- export class GetShopInfoByIdResultDto {
13
-
14
- @IsNumber()
15
- id: number;
16
-
17
- @IsString()
18
- name: string;
19
-
20
- @IsString()
21
- description: string;
22
-
23
- @IsNumber()
24
- userId: number
25
-
26
- @IsString()
27
- status: ShopStatusEnum
28
- }
29
-
30
- export class GetShopGoodsListQueryDto {
31
-
32
- @Transform((value) => Number(value))
33
- @IsNumber()
34
- id: number;
35
-
36
- @Transform((value) => Number(value))
37
- @IsNumber()
38
- page: number;
39
-
40
- @Transform((value) => Number(value))
41
- @IsNumber()
42
- pageSize: number;
43
-
44
- }
45
-
46
-
47
- export class GetShopGoodsListResultDto {
48
- @IsNumber()
49
- id: number;
50
-
51
- @IsString()
52
- name: string;
53
-
54
- @IsString()
55
- description: string;
56
-
57
- @IsNumber()
58
- price: number;
59
-
60
- @IsArray({})
61
- albums: string[];
62
- }
63
-
64
- export class GetShopUserInfoDto {
65
-
66
- @Transform((value) => Number(value))
67
- @IsNumber()
68
- shopId: number;
69
- }
@@ -1,44 +0,0 @@
1
- import { YtUserStatusEnum, YtUserTypeEnum } from "@src/entity/ytUser.entity";
2
- import { Transform } from "@src/framework/decorator/controller";
3
- import { IsEmail, IsNumber, isString, IsString, ValidateIf } from "class-validator";
4
- import { Column } from "typeorm";
5
-
6
- export class GetUserInfoResponseDto {
7
-
8
- @IsNumber()
9
- id: number
10
-
11
- @IsString()
12
- @ValidateIf(o => o.nickName)
13
- nickName: string
14
-
15
- @IsEmail()
16
- @IsString()
17
- email: string
18
-
19
- @IsString()
20
- avatar: string
21
-
22
- @IsNumber()
23
- gender: number
24
-
25
- @IsString()
26
- constellation: string
27
-
28
- @IsNumber()
29
- age: number
30
-
31
- @IsString()
32
- status: YtUserStatusEnum
33
-
34
- @IsString()
35
- type: YtUserTypeEnum
36
- }
37
-
38
- export class getUserInfoByIdDto {
39
-
40
- @Transform((v)=>Number(v))
41
- @IsNumber()
42
- id:number
43
-
44
- }
@@ -1,63 +0,0 @@
1
- import { Transform } from "@src/framework/decorator/controller";
2
- import { Trim } from "@src/framework/utils/transform";
3
- import { IsEmail, IsNumber, IsString, Length } from "class-validator";
4
-
5
- export class YtUserLoginDto {
6
-
7
- @IsString({
8
- message: "邮箱必须是字符串"
9
- })
10
- @Transform((val) => {
11
- const str = String(val);
12
- return Trim(str);
13
- })
14
- @IsEmail({}, {
15
- message: "请输入有效的邮箱"
16
- })
17
- email: string;
18
-
19
-
20
- @Transform((val) => {
21
- const str = String(val);
22
- return Trim(str);
23
- })
24
- @IsString()
25
- vcode: string;
26
-
27
- @IsString()
28
- vcodeToken: string;
29
- }
30
-
31
-
32
- export class YtUserLoginAutoDto {
33
-
34
- @Transform((val) => {
35
- const str = String(val);
36
- return Trim(str);
37
- })
38
- @IsString()
39
- vcode: string;
40
-
41
- @IsString()
42
- vcodeToken: string;
43
- }
44
-
45
- export class GetYtUserBasicInfoDto {
46
- @IsNumber()
47
- @Transform(id => Number(id))
48
- id: number;
49
- }
50
-
51
- export class GetYtUserBasicInfoResponseDto {
52
-
53
- @IsNumber()
54
- id: number
55
-
56
- @IsString()
57
- name: string
58
-
59
- @IsString()
60
- avatar: string
61
-
62
-
63
- }
@@ -1,212 +0,0 @@
1
- import { IsNotEmpty, IsOptional, IsString, IsNumber, IsEnum, IsArray, IsBoolean, MinLength, MaxLength, Min, Max, IsInt } from 'class-validator';
2
- import { YtGoodsStatusEnum } from '@src/entity/ytGoods.entity';
3
- import { ShopStatusEnum } from '@src/entity/shop.entity';
4
-
5
- /**
6
- * 创建商品DTO
7
- */
8
- export class CreateGoodsDto {
9
- @IsNotEmpty({ message: '商品名称不能为空' })
10
- @IsString({ message: '商品名称必须是字符串' })
11
- @MaxLength(200, { message: '商品名称长度不能超过200个字符' })
12
- name: string;
13
-
14
- @IsNotEmpty({ message: '店铺ID不能为空' })
15
- @IsInt({ message: '店铺ID必须是整数' })
16
- @Min(1, { message: '店铺ID不能小于1' })
17
- shopId: number;
18
-
19
- @IsOptional()
20
- @IsArray({ message: '相册必须是数组' })
21
- albums?: string[];
22
-
23
- @IsNotEmpty({ message: '价格不能为空' })
24
- @IsNumber({}, { message: '价格必须是数字' })
25
- @Min(0, { message: '价格不能小于0' })
26
- price: number;
27
-
28
- @IsOptional()
29
- @IsArray({ message: '标签必须是数组' })
30
- tags?: string[];
31
-
32
- @IsOptional()
33
- @IsString({ message: '描述必须是字符串' })
34
- @MaxLength(1000, { message: '描述长度不能超过1000个字符' })
35
- description?: string;
36
-
37
- @IsOptional()
38
- @IsString({ message: '内容必须是字符串' })
39
- content?: string;
40
-
41
- @IsOptional()
42
- @IsArray({ message: '内容图片必须是数组' })
43
- imagesContent?: string[];
44
-
45
- @IsOptional()
46
- @IsEnum(YtGoodsStatusEnum, { message: '状态必须是有效的枚举值' })
47
- status?: YtGoodsStatusEnum;
48
- }
49
-
50
- /**
51
- * 更新商品DTO
52
- */
53
- export class UpdateGoodsDto {
54
- @IsOptional()
55
- @IsString({ message: '商品名称必须是字符串' })
56
- @MaxLength(200, { message: '商品名称长度不能超过200个字符' })
57
- name?: string;
58
-
59
- @IsOptional()
60
- @IsArray({ message: '相册必须是数组' })
61
- albums?: string[];
62
-
63
- @IsOptional()
64
- @IsNumber({}, { message: '价格必须是数字' })
65
- @Min(0, { message: '价格不能小于0' })
66
- price?: number;
67
-
68
- @IsOptional()
69
- @IsArray({ message: '标签必须是数组' })
70
- tags?: string[];
71
-
72
- @IsOptional()
73
- @IsString({ message: '描述必须是字符串' })
74
- @MaxLength(1000, { message: '描述长度不能超过1000个字符' })
75
- description?: string;
76
-
77
- @IsOptional()
78
- @IsString({ message: '内容必须是字符串' })
79
- content?: string;
80
-
81
- @IsOptional()
82
- @IsArray({ message: '内容图片必须是数组' })
83
- imagesContent?: string[];
84
-
85
- @IsOptional()
86
- @IsEnum(YtGoodsStatusEnum, { message: '状态必须是有效的枚举值' })
87
- status?: YtGoodsStatusEnum;
88
- }
89
-
90
- /**
91
- * 商品查询DTO
92
- */
93
- export class QueryGoodsDto {
94
- @IsOptional()
95
- @IsString({ message: '搜索关键词必须是字符串' })
96
- @MaxLength(100, { message: '搜索关键词长度不能超过100个字符' })
97
- keyword?: string;
98
-
99
- @IsOptional()
100
- @IsInt({ message: '店铺ID必须是整数' })
101
- @Min(1, { message: '店铺ID不能小于1' })
102
- shopId?: number;
103
-
104
- @IsOptional()
105
- @IsEnum(YtGoodsStatusEnum, { message: '状态必须是有效的枚举值' })
106
- status?: YtGoodsStatusEnum;
107
-
108
- @IsOptional()
109
- @IsNumber({}, { message: '最低价格必须是数字' })
110
- @Min(0, { message: '最低价格不能小于0' })
111
- minPrice?: number;
112
-
113
- @IsOptional()
114
- @IsNumber({}, { message: '最高价格必须是数字' })
115
- @Min(0, { message: '最高价格不能小于0' })
116
- maxPrice?: number;
117
-
118
- @IsOptional()
119
- @IsArray({ message: '标签过滤必须是数组' })
120
- tags?: string[];
121
-
122
- @IsOptional()
123
- @IsInt({ message: '页码必须是整数' })
124
- @Min(1, { message: '页码不能小于1' })
125
- page?: number = 1;
126
-
127
- @IsOptional()
128
- @IsInt({ message: '每页数量必须是整数' })
129
- @Min(1, { message: '每页数量不能小于1' })
130
- @Max(100, { message: '每页数量不能大于100' })
131
- pageSize?: number = 10;
132
-
133
- @IsOptional()
134
- @IsString({ message: '排序字段必须是字符串' })
135
- sortBy?: string = 'id';
136
-
137
- @IsOptional()
138
- @IsString({ message: '排序方向必须是字符串' })
139
- sortOrder?: 'ASC' | 'DESC' = 'DESC';
140
- }
141
-
142
- /**
143
- * 创建店铺DTO
144
- */
145
- export class CreateShopDto {
146
- @IsNotEmpty({ message: '店铺名称不能为空' })
147
- @IsString({ message: '店铺名称必须是字符串' })
148
- @MaxLength(100, { message: '店铺名称长度不能超过100个字符' })
149
- name: string;
150
-
151
- @IsOptional()
152
- @IsString({ message: '描述必须是字符串' })
153
- @MaxLength(1000, { message: '描述长度不能超过1000个字符' })
154
- description?: string;
155
-
156
- @IsOptional()
157
- @IsEnum(ShopStatusEnum, { message: '状态必须是有效的枚举值' })
158
- status?: ShopStatusEnum;
159
- }
160
-
161
- /**
162
- * 更新店铺DTO
163
- */
164
- export class UpdateShopDto {
165
- @IsOptional()
166
- @IsString({ message: '店铺名称必须是字符串' })
167
- @MaxLength(100, { message: '店铺名称长度不能超过100个字符' })
168
- name?: string;
169
-
170
- @IsOptional()
171
- @IsString({ message: '描述必须是字符串' })
172
- @MaxLength(1000, { message: '描述长度不能超过1000个字符' })
173
- description?: string;
174
-
175
- @IsOptional()
176
- @IsEnum(ShopStatusEnum, { message: '状态必须是有效的枚举值' })
177
- status?: ShopStatusEnum;
178
- }
179
-
180
- /**
181
- * 商品解锁DTO
182
- */
183
- export class UnlockGoodsDto {
184
- @IsNotEmpty({ message: '商品ID不能为空' })
185
- @IsInt({ message: '商品ID必须是整数' })
186
- @Min(1, { message: '商品ID不能小于1' })
187
- goodsId: number;
188
-
189
- @IsNotEmpty({ message: '解锁密钥不能为空' })
190
- @IsString({ message: '解锁密钥必须是字符串' })
191
- @MinLength(1, { message: '解锁密钥不能为空' })
192
- key: string;
193
- }
194
-
195
- /**
196
- * 创建解锁密钥DTO
197
- */
198
- export class CreateUnlockKeyDto {
199
- @IsNotEmpty({ message: '商品ID不能为空' })
200
- @IsInt({ message: '商品ID必须是整数' })
201
- @Min(1, { message: '商品ID不能小于1' })
202
- goodsId: number;
203
-
204
- @IsNotEmpty({ message: '密钥不能为空' })
205
- @IsString({ message: '密钥必须是字符串' })
206
- @MinLength(1, { message: '密钥不能为空' })
207
- key: string;
208
-
209
- @IsOptional()
210
- @IsBoolean({ message: '是否已使用必须是布尔值' })
211
- isUse?: boolean = false;
212
- }
@@ -1,13 +0,0 @@
1
- import { IsNotEmpty, IsNumber, Max, Min } from "class-validator";
2
-
3
- /**
4
- * 测试验证服务DTO
5
- */
6
- export class TestValidateServiceDto {
7
-
8
- @IsNotEmpty({ message: 'ID不能为空' })
9
- @IsNumber({}, { message: 'ID必须是数字' })
10
- @Min(1, { message: 'ID不能小于1' })
11
- @Max(1000000, { message: 'ID不能大于1000000' })
12
- id:number
13
- }
@@ -1,177 +0,0 @@
1
- import { IsEmail, IsNotEmpty, IsOptional, IsString, MinLength, MaxLength, IsEnum, IsNumber, IsBoolean, IsArray, IsInt, Min, Max } from 'class-validator';
2
- import { YtUserTypeEnum, YtUserStatusEnum } from '@src/entity/ytUser.entity';
3
-
4
- /**
5
- * 创建用户DTO
6
- */
7
- export class CreateUserDto {
8
- @IsNotEmpty({ message: '昵称不能为空' })
9
- @IsString({ message: '昵称必须是字符串' })
10
- @MaxLength(50, { message: '昵称长度不能超过50个字符' })
11
- nickName: string;
12
-
13
- @IsNotEmpty({ message: '手机号不能为空' })
14
- @IsString({ message: '手机号必须是字符串' })
15
- @MaxLength(20, { message: '手机号长度不能超过20个字符' })
16
- telnumber: string;
17
-
18
- @IsNotEmpty({ message: '邮箱不能为空' })
19
- @IsEmail({}, { message: '邮箱格式不正确' })
20
- @MaxLength(100, { message: '邮箱长度不能超过100个字符' })
21
- email: string;
22
-
23
- @IsNotEmpty({ message: '密码不能为空' })
24
- @IsString({ message: '密码必须是字符串' })
25
- @MinLength(6, { message: '密码长度不能少于6个字符' })
26
- @MaxLength(100, { message: '密码长度不能超过100个字符' })
27
- password: string;
28
-
29
- @IsOptional()
30
- @IsEnum(YtUserTypeEnum, { message: '用户类型必须是有效的枚举值' })
31
- userType?: YtUserTypeEnum;
32
-
33
- @IsOptional()
34
- @IsInt({ message: '性别必须是整数' })
35
- @Min(0, { message: '性别值不能小于0' })
36
- @Max(2, { message: '性别值不能大于2' })
37
- gender?: number;
38
-
39
- @IsOptional()
40
- @IsInt({ message: '年龄必须是整数' })
41
- @Min(0, { message: '年龄不能小于0' })
42
- @Max(150, { message: '年龄不能大于150' })
43
- age?: number;
44
-
45
- @IsOptional()
46
- @IsString({ message: '星座必须是字符串' })
47
- @MaxLength(20, { message: '星座长度不能超过20个字符' })
48
- constellation?: string;
49
-
50
- @IsOptional()
51
- @IsString({ message: '头像必须是字符串' })
52
- @MaxLength(500, { message: '头像URL长度不能超过500个字符' })
53
- avatar?: string;
54
-
55
- @IsOptional()
56
- @IsEnum(YtUserStatusEnum, { message: '状态必须是有效的枚举值' })
57
- status?: YtUserStatusEnum;
58
- }
59
-
60
- /**
61
- * 更新用户DTO
62
- */
63
- export class UpdateUserDto {
64
- @IsOptional()
65
- @IsString({ message: '昵称必须是字符串' })
66
- @MaxLength(50, { message: '昵称长度不能超过50个字符' })
67
- nickName?: string;
68
-
69
- @IsOptional()
70
- @IsString({ message: '手机号必须是字符串' })
71
- @MaxLength(20, { message: '手机号长度不能超过20个字符' })
72
- telnumber?: string;
73
-
74
- @IsOptional()
75
- @IsEmail({}, { message: '邮箱格式不正确' })
76
- @MaxLength(100, { message: '邮箱长度不能超过100个字符' })
77
- email?: string;
78
-
79
- @IsOptional()
80
- @IsEnum(YtUserTypeEnum, { message: '用户类型必须是有效的枚举值' })
81
- userType?: YtUserTypeEnum;
82
-
83
- @IsOptional()
84
- @IsInt({ message: '性别必须是整数' })
85
- @Min(0, { message: '性别值不能小于0' })
86
- @Max(2, { message: '性别值不能大于2' })
87
- gender?: number;
88
-
89
- @IsOptional()
90
- @IsInt({ message: '年龄必须是整数' })
91
- @Min(0, { message: '年龄不能小于0' })
92
- @Max(150, { message: '年龄不能大于150' })
93
- age?: number;
94
-
95
- @IsOptional()
96
- @IsString({ message: '星座必须是字符串' })
97
- @MaxLength(20, { message: '星座长度不能超过20个字符' })
98
- constellation?: string;
99
-
100
- @IsOptional()
101
- @IsString({ message: '头像必须是字符串' })
102
- @MaxLength(500, { message: '头像URL长度不能超过500个字符' })
103
- avatar?: string;
104
-
105
- @IsOptional()
106
- @IsEnum(YtUserStatusEnum, { message: '状态必须是有效的枚举值' })
107
- status?: YtUserStatusEnum;
108
- }
109
-
110
- /**
111
- * 用户查询DTO
112
- */
113
- export class QueryUserDto {
114
- @IsOptional()
115
- @IsString({ message: '搜索关键词必须是字符串' })
116
- @MaxLength(100, { message: '搜索关键词长度不能超过100个字符' })
117
- keyword?: string;
118
-
119
- @IsOptional()
120
- @IsEnum(YtUserTypeEnum, { message: '用户类型必须是有效的枚举值' })
121
- userType?: YtUserTypeEnum;
122
-
123
- @IsOptional()
124
- @IsEnum(YtUserStatusEnum, { message: '状态必须是有效的枚举值' })
125
- status?: YtUserStatusEnum;
126
-
127
- @IsOptional()
128
- @IsInt({ message: '页码必须是整数' })
129
- @Min(1, { message: '页码不能小于1' })
130
- page?: number = 1;
131
-
132
- @IsOptional()
133
- @IsInt({ message: '每页数量必须是整数' })
134
- @Min(1, { message: '每页数量不能小于1' })
135
- @Max(100, { message: '每页数量不能大于100' })
136
- pageSize?: number = 10;
137
-
138
- @IsOptional()
139
- @IsString({ message: '排序字段必须是字符串' })
140
- sortBy?: string = 'id';
141
-
142
- @IsOptional()
143
- @IsString({ message: '排序方向必须是字符串' })
144
- sortOrder?: 'ASC' | 'DESC' = 'DESC';
145
- }
146
-
147
- /**
148
- * 用户登录DTO
149
- */
150
- export class LoginUserDto {
151
- @IsNotEmpty({ message: '登录凭证不能为空' })
152
- @IsString({ message: '登录凭证必须是字符串' })
153
- credential: string; // 可以是邮箱或手机号
154
-
155
- @IsNotEmpty({ message: '密码不能为空' })
156
- @IsString({ message: '密码必须是字符串' })
157
- password: string;
158
- }
159
-
160
- /**
161
- * 修改密码DTO
162
- */
163
- export class ChangePasswordDto {
164
- @IsNotEmpty({ message: '当前密码不能为空' })
165
- @IsString({ message: '当前密码必须是字符串' })
166
- currentPassword: string;
167
-
168
- @IsNotEmpty({ message: '新密码不能为空' })
169
- @IsString({ message: '新密码必须是字符串' })
170
- @MinLength(6, { message: '新密码长度不能少于6个字符' })
171
- @MaxLength(100, { message: '新密码长度不能超过100个字符' })
172
- newPassword: string;
173
-
174
- @IsNotEmpty({ message: '确认密码不能为空' })
175
- @IsString({ message: '确认密码必须是字符串' })
176
- confirmPassword: string;
177
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * 实体列类型:SQLite + PostgreSQL/MySQL 兼容
3
- *
4
- * 单元测试/内存库使用 SQLite(db_memory=1),调试/生产使用 PostgreSQL 或 MySQL。
5
- * SQLite 用 datetime,PostgreSQL 不支持 datetime 仅支持 timestamp,MySQL 两者都支持。
6
- * 故日期时间列按环境返回不同类型。
7
- *
8
- * 使用方式:@Column({ type: getDateTimeColumnType(), nullable: true })
9
- */
10
- /** 返回 TypeORM 日期时间列类型:SQLite 用 datetime,PostgreSQL/MySQL 用 timestamp */
11
- export function getDateTimeColumnType(): "datetime" | "timestamp" {
12
- return Number(process.env.db_memory) === 1 ? "datetime" : "timestamp";
13
- }
@@ -1,33 +0,0 @@
1
- import { BaseEntity } from "@src/entity/base.entity";
2
- import { Column, Entity, Index, ManyToOne, JoinColumn } from "typeorm";
3
- import { YtGoodsEntity } from "@src/entity/ytGoods.entity";
4
-
5
- @Entity({
6
- name: "goods_images_unlock_key"
7
- })
8
- export class GoodsImagesUnlockKeyEntity extends BaseEntity {
9
-
10
- @Column({ default: "" })
11
- key: string
12
-
13
- @Column({
14
- type: "integer",
15
- default: 0,
16
- })
17
- goodsId: number
18
-
19
- @Column({
20
- type: "boolean",
21
- default: false,
22
- })
23
- isUse: boolean
24
-
25
- // 关系定义
26
- /**
27
- * 关联的商品
28
- */
29
- @ManyToOne(() => YtGoodsEntity, goods => goods.unlockKeys)
30
- @JoinColumn({ name: 'goodsId' })
31
- goods: YtGoodsEntity;
32
-
33
- }
@@ -1,34 +0,0 @@
1
- import { Column, Entity, Index, ManyToOne, JoinColumn } from "typeorm";
2
- import { BaseEntity } from "@src/entity/base.entity";
3
- import { YtGoodsEntity } from "@src/entity/ytGoods.entity";
4
- import { YtUserEntity } from "@src/entity/ytUser.entity";
5
-
6
- @Entity({
7
- name: "yt_goods_unlock"
8
- })
9
- export class YtGoodsUnlockerEntity extends BaseEntity {
10
-
11
- @Index()
12
- @Column({ default: 0 })
13
- goodsId: number;
14
-
15
- @Index()
16
- @Column({ default: 0 })
17
- ytUserId: number;
18
-
19
- // 关系定义
20
- /**
21
- * 关联的商品
22
- */
23
- @ManyToOne(() => YtGoodsEntity, goods => goods.unlockRecords)
24
- @JoinColumn({ name: 'goodsId' })
25
- goods: YtGoodsEntity;
26
-
27
- /**
28
- * 关联的用户
29
- */
30
- @ManyToOne(() => YtUserEntity, user => user.unlockedGoods)
31
- @JoinColumn({ name: 'ytUserId' })
32
- user: YtUserEntity;
33
-
34
- }