Commit a27aa9cf authored by nanahira's avatar nanahira

add comment as description

parent 77123080
Pipeline #11453 passed with stages
in 1 minute and 34 seconds
......@@ -9,6 +9,7 @@ import {
IsNotEmpty,
IsOptional,
IsString,
MaxLength,
Min,
} from 'class-validator';
import { ColumnWithWidthOptions } from 'typeorm/decorator/options/ColumnWithWidthOptions';
......@@ -41,6 +42,7 @@ export const StringColumn = (
length,
default: defaultValue,
nullable: !required && defaultValue == null,
comment: description,
...columnExtras,
}),
ApiProperty({
......@@ -48,11 +50,13 @@ export const StringColumn = (
description,
default: defaultValue,
required: required && defaultValue == null,
maxLength: length,
...propertyExtras,
}),
...(required ? [] : [IsOptional()]),
IsString(),
IsNotEmpty(),
MaxLength(length),
]);
export const IntColumn = (
......@@ -69,6 +73,7 @@ export const IntColumn = (
default: defaultValue,
nullable: !required && defaultValue == null,
unsigned,
comment: description,
...(type === 'bigint' ? { transformer: new BigintTransformer() } : {}),
...columnExtras,
}),
......@@ -98,6 +103,7 @@ export const EnumColumn = <T>(
enum: targetEnum,
default: defaultValue,
nullable: !required && !defaultValue,
comment: description,
...columnExtras,
}),
ApiProperty({
......
......@@ -18,6 +18,7 @@ export const RelationColumn = (
nullable: !notNull,
unsigned: true,
transformer: new BigintTransformer(),
comment: description,
...columnExtras,
}),
ApiProperty({
......@@ -30,7 +31,6 @@ export const RelationColumn = (
IsInt(),
IsPositive(),
]);
export const StringRelationColumn = (
description = '对应编号',
notNull = false,
......@@ -38,7 +38,12 @@ export const StringRelationColumn = (
propertyExtras: ApiPropertyOptions = {},
) =>
MergePropertyDecorators([
Column('varchar', { length: 32, nullable: !notNull, ...columnExtras }),
Column('varchar', {
length: 32,
nullable: !notNull,
comment: description,
...columnExtras,
}),
ApiProperty({
type: String,
required: notNull,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment