Commit d70bebb5 authored by nanahira's avatar nanahira

fix

parent a29c689c
Pipeline #7688 passed with stages
in 1 minute and 36 seconds
...@@ -111,11 +111,11 @@ export const EnumColumn = <T>( ...@@ -111,11 +111,11 @@ export const EnumColumn = <T>(
IsEnum(targetEnum), IsEnum(targetEnum),
]); ]);
export const NotColumn = ( export const NotColumn = (
description?: string, description?: string,
swaggerExtras: ApiPropertyOptions = {}, swaggerExtras: ApiPropertyOptions = {},
): PropertyDecorator => ): PropertyDecorator =>
MergePropertyDecorators([ MergePropertyDecorators([
Exclude(), Exclude(),
ApiProperty({ description, required: false, ...swaggerExtras }), ApiProperty({ description, required: false, ...swaggerExtras }),
]); ]);
import { import { MergePropertyDecorators, StringColumn } from './base';
MergePropertyDecorators,
StringColumn,
} from './base';
import { Index } from 'typeorm'; import { Index } from 'typeorm';
export const EntityName = (length = 32, description = '名称') => export const EntityName = (length = 32, description = '名称') =>
......
import { Column } from 'typeorm'; import { Column } from 'typeorm';
import { MergePropertyDecorators } from './base'; import { MergePropertyDecorators } from './base';
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty, ApiPropertyOptions } from '@nestjs/swagger';
import { IsInt, IsNotEmpty, IsOptional, IsPositive } from 'class-validator'; import { IsInt, IsNotEmpty, IsOptional, IsPositive } from 'class-validator';
import { BigintTransformer } from '../utility/bigint-transform'; import { BigintTransformer } from '../utility/bigint-transform';
import { ColumnCommonOptions } from 'typeorm/decorator/options/ColumnCommonOptions';
import { ColumnWithLengthOptions } from 'typeorm/decorator/options/ColumnWithLengthOptions';
import { ColumnWithWidthOptions } from 'typeorm/decorator/options/ColumnWithWidthOptions';
export const RelationColumn = (description = '对应编号', notNull = false) => export const RelationColumn = (
description = '对应编号',
notNull = false,
columnExtras: ColumnCommonOptions & ColumnWithWidthOptions = {},
propertyExtras: ApiPropertyOptions = {},
) =>
MergePropertyDecorators([ MergePropertyDecorators([
Column('bigint', { Column('bigint', {
nullable: !notNull, nullable: !notNull,
unsigned: true, unsigned: true,
transformer: new BigintTransformer(), transformer: new BigintTransformer(),
...columnExtras,
}), }),
ApiProperty({ type: Number, description }), ApiProperty({ type: Number, description, ...propertyExtras }),
...(notNull ? [] : [IsOptional()]), ...(notNull ? [] : [IsOptional()]),
IsInt(), IsInt(),
IsPositive(), IsPositive(),
...@@ -19,10 +28,12 @@ export const RelationColumn = (description = '对应编号', notNull = false) => ...@@ -19,10 +28,12 @@ export const RelationColumn = (description = '对应编号', notNull = false) =>
export const StringRelationColumn = ( export const StringRelationColumn = (
description = '对应编号', description = '对应编号',
notNull = false, notNull = false,
columnExtras: ColumnCommonOptions & ColumnWithLengthOptions = {},
propertyExtras: ApiPropertyOptions = {},
) => ) =>
MergePropertyDecorators([ MergePropertyDecorators([
Column('varchar', { length: 32, nullable: !notNull }), Column('varchar', { length: 32, nullable: !notNull, ...columnExtras }),
ApiProperty({ type: String, description }), ApiProperty({ type: String, description, ...propertyExtras }),
...(notNull ? [] : [IsOptional()]), ...(notNull ? [] : [IsOptional()]),
IsNotEmpty(), IsNotEmpty(),
]); ]);
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