Преглед изворни кода

refactor: rename 'type' to 'dataType' in SystemParam DTO and service for clarity

Dave пре 3 часа
родитељ
комит
ab569c2049

+ 3 - 3
apps/box-mgnt-api/src/mgnt-backend/feature/system-params/system-param.dto.ts

@@ -38,7 +38,7 @@ export class SystemParamDto {
 
   @ApiProperty({ enum: ParamDataType, description: '数据类型' })
   @IsEnum(ParamDataType)
-  type: ParamDataType;
+  dataType: ParamDataType;
 
   @ApiProperty({ example: 'login_send', description: '参数名' })
   @IsString()
@@ -79,7 +79,7 @@ export class CreateSystemParamDto {
 
   @ApiProperty({ enum: ParamDataType })
   @IsEnum(ParamDataType)
-  type: ParamDataType;
+  dataType: ParamDataType;
 
   @ApiProperty({ minLength: 1, maxLength: 100 })
   @IsString()
@@ -130,5 +130,5 @@ export class ListSystemParamDto extends PageListDto {
   @ApiPropertyOptional({ enum: ParamDataType })
   @IsOptional()
   @IsEnum(ParamDataType)
-  type?: ParamDataType;
+  dataType?: ParamDataType;
 }

+ 5 - 5
apps/box-mgnt-api/src/mgnt-backend/feature/system-params/system-params.service.ts

@@ -89,7 +89,7 @@ export class SystemParamsService {
   // ---------- CRUD ----------
   async create(dto: CreateSystemParamDto) {
     const now = this.nowSec();
-    const normalized = this.normalizeValue(dto.value, dto.type);
+    const normalized = this.normalizeValue(dto.value, dto.dataType);
 
     // retry up to 3 times in rare duplicate-id races
     for (let attempt = 0; attempt < 3; attempt++) {
@@ -99,7 +99,7 @@ export class SystemParamsService {
           data: {
             id,
             side: dto.side as ParamSide,
-            type: dto.type,
+            dataType: dto.dataType,
             name: dto.name,
             value: normalized,
             remark: dto.remark ?? null,
@@ -124,14 +124,14 @@ export class SystemParamsService {
 
   async update(dto: UpdateSystemParamDto) {
     const now = this.nowSec();
-    const normalized = this.normalizeValue(dto.value, dto.type);
+    const normalized = this.normalizeValue(dto.value, dto.dataType);
 
     try {
       return await this.mongoPrismaService.systemParam.update({
         where: { id: dto.id },
         data: {
           side: dto.side as ParamSide,
-          type: dto.type,
+          dataType: dto.dataType,
           name: dto.name,
           value: normalized,
           remark: dto.remark ?? null,
@@ -167,7 +167,7 @@ export class SystemParamsService {
       where.remark = { contains: dto.remark, mode: 'insensitive' };
     }
     if (dto.side) where.side = dto.side as ParamSide;
-    if (dto.type) where.type = dto.type;
+    if (dto.dataType) where.dataType = dto.dataType;
 
     const [total, data] = await this.mongoPrismaService.$transaction([
       this.mongoPrismaService.systemParam.count({ where }),