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>(
IsEnum(targetEnum),
]);
export const NotColumn = (
description?: string,
swaggerExtras: ApiPropertyOptions = {},
): PropertyDecorator =>
MergePropertyDecorators([
Exclude(),
ApiProperty({ description, required: false, ...swaggerExtras }),
]);
export const NotColumn = (
description?: string,
swaggerExtras: ApiPropertyOptions = {},
): PropertyDecorator =>
MergePropertyDecorators([
Exclude(),
ApiProperty({ description, required: false, ...swaggerExtras }),
]);
import {
MergePropertyDecorators,
StringColumn,
} from './base';
import { MergePropertyDecorators, StringColumn } from './base';
import { Index } from 'typeorm';
export const EntityName = (length = 32, description = '名称') =>
......
import { Column } from 'typeorm';
import { MergePropertyDecorators } from './base';
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptions } from '@nestjs/swagger';
import { IsInt, IsNotEmpty, IsOptional, IsPositive } from 'class-validator';
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([
Column('bigint', {
nullable: !notNull,
unsigned: true,
transformer: new BigintTransformer(),
...columnExtras,
}),
ApiProperty({ type: Number, description }),
ApiProperty({ type: Number, description, ...propertyExtras }),
...(notNull ? [] : [IsOptional()]),
IsInt(),
IsPositive(),
......@@ -19,10 +28,12 @@ export const RelationColumn = (description = '对应编号', notNull = false) =>
export const StringRelationColumn = (
description = '对应编号',
notNull = false,
columnExtras: ColumnCommonOptions & ColumnWithLengthOptions = {},
propertyExtras: ApiPropertyOptions = {},
) =>
MergePropertyDecorators([
Column('varchar', { length: 32, nullable: !notNull }),
ApiProperty({ type: String, description }),
Column('varchar', { length: 32, nullable: !notNull, ...columnExtras }),
ApiProperty({ type: String, description, ...propertyExtras }),
...(notNull ? [] : [IsOptional()]),
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