From 1b4b33458b6219671b66fbd6f70690b82ef24c02 Mon Sep 17 00:00:00 2001 From: fantasticit Date: Wed, 29 Jun 2022 00:56:58 +0800 Subject: [PATCH] server: use shortId --- packages/server/src/entities/template.entity.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/server/src/entities/template.entity.ts b/packages/server/src/entities/template.entity.ts index 77ee93e..9ac379e 100644 --- a/packages/server/src/entities/template.entity.ts +++ b/packages/server/src/entities/template.entity.ts @@ -1,8 +1,14 @@ -import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; +import { getShortId } from '@helpers/shortid.herlper'; +import { BeforeInsert, Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm'; @Entity('template') export class TemplateEntity { - @PrimaryGeneratedColumn('uuid') + @BeforeInsert() + getShortId() { + this.id = getShortId(); + } + + @PrimaryColumn() public id: string; @Column({ type: 'boolean', default: false, comment: '是否公开' })