Compare commits
No commits in common. "ee5af33a96a2959f2d49a3c86ff80ab4ffcc8d9f" and "89d4a7c78f8f9a971fd35f7b761c826043e9acdf" have entirely different histories.
ee5af33a96
...
89d4a7c78f
@ -1,5 +1,4 @@
|
|||||||
import { Exclude, Expose, Type } from 'class-transformer';
|
import { Exclude, Expose, Type } from 'class-transformer';
|
||||||
import type { Relation } from 'typeorm';
|
|
||||||
import {
|
import {
|
||||||
BaseEntity,
|
BaseEntity,
|
||||||
Column,
|
Column,
|
||||||
@ -12,8 +11,9 @@ import {
|
|||||||
TreeParent,
|
TreeParent,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
|
import type { Relation } from 'typeorm';
|
||||||
|
|
||||||
import { PostEntity } from '@/modules/content/entities/post.entity';
|
import { PostEntity } from '@/modules/content/entities/post.entity';
|
||||||
import { UserEntity } from '@/modules/user/entities/UserEntity';
|
|
||||||
|
|
||||||
@Exclude()
|
@Exclude()
|
||||||
@Entity('content_comment')
|
@Entity('content_comment')
|
||||||
@ -50,11 +50,4 @@ export class CommentEntity extends BaseEntity {
|
|||||||
@Expose({ groups: ['comment-tree'] })
|
@Expose({ groups: ['comment-tree'] })
|
||||||
@TreeChildren({ cascade: true })
|
@TreeChildren({ cascade: true })
|
||||||
children: Relation<CommentEntity>[];
|
children: Relation<CommentEntity>[];
|
||||||
|
|
||||||
@ManyToOne(() => UserEntity, (user) => user.comments, {
|
|
||||||
nullable: false,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
author: Relation<UserEntity>;
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Exclude, Expose, Type } from 'class-transformer';
|
import { Exclude, Expose, Type } from 'class-transformer';
|
||||||
import type { Relation } from 'typeorm';
|
|
||||||
import {
|
import {
|
||||||
BaseEntity,
|
BaseEntity,
|
||||||
Column,
|
Column,
|
||||||
@ -14,11 +13,12 @@ import {
|
|||||||
UpdateDateColumn,
|
UpdateDateColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
|
import type { Relation } from 'typeorm';
|
||||||
|
|
||||||
import { PostBodyType } from '@/modules/content/constants';
|
import { PostBodyType } from '@/modules/content/constants';
|
||||||
import { CategoryEntity } from '@/modules/content/entities/category.entity';
|
import { CategoryEntity } from '@/modules/content/entities/category.entity';
|
||||||
import { CommentEntity } from '@/modules/content/entities/comment.entity';
|
import { CommentEntity } from '@/modules/content/entities/comment.entity';
|
||||||
import { TagEntity } from '@/modules/content/entities/tag.entity';
|
import { TagEntity } from '@/modules/content/entities/tag.entity';
|
||||||
import { UserEntity } from '@/modules/user/entities/UserEntity';
|
|
||||||
|
|
||||||
@Exclude()
|
@Exclude()
|
||||||
@Entity('content_posts')
|
@Entity('content_posts')
|
||||||
@ -89,11 +89,4 @@ export class PostEntity extends BaseEntity {
|
|||||||
|
|
||||||
@OneToMany(() => CommentEntity, (comment) => comment.post, { cascade: true })
|
@OneToMany(() => CommentEntity, (comment) => comment.post, { cascade: true })
|
||||||
comments: Relation<CommentEntity>[];
|
comments: Relation<CommentEntity>[];
|
||||||
|
|
||||||
@ManyToOne(() => UserEntity, (user) => user.posts, {
|
|
||||||
nullable: false,
|
|
||||||
onDelete: 'CASCADE',
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
author: Relation<UserEntity>;
|
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,10 @@ import {
|
|||||||
CreateDateColumn,
|
CreateDateColumn,
|
||||||
DeleteDateColumn,
|
DeleteDateColumn,
|
||||||
Entity,
|
Entity,
|
||||||
OneToMany,
|
|
||||||
PrimaryColumn,
|
PrimaryColumn,
|
||||||
Relation,
|
|
||||||
UpdateDateColumn,
|
UpdateDateColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { CommentEntity, PostEntity } from '@/modules/content/entities';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户实体
|
* 用户实体
|
||||||
*/
|
*/
|
||||||
@ -82,16 +78,4 @@ export class UserEntity {
|
|||||||
@Type(() => Date)
|
@Type(() => Date)
|
||||||
@DeleteDateColumn({ comment: '用户销户时间' })
|
@DeleteDateColumn({ comment: '用户销户时间' })
|
||||||
deletedAt?: Date;
|
deletedAt?: Date;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户发表文章
|
|
||||||
*/
|
|
||||||
@OneToMany(() => PostEntity, (post) => post.author, { cascade: true })
|
|
||||||
posts: Relation<PostEntity>[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户发表评论
|
|
||||||
*/
|
|
||||||
@OneToMany(() => CommentEntity, (comment) => comment.author, { cascade: true })
|
|
||||||
comments: Relation<CommentEntity>[];
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
import { Entity, OneToOne } from 'typeorm';
|
|
||||||
|
|
||||||
import { BaseToken } from '@/modules/user/entities/base.token';
|
|
||||||
import { RefreshTokenEntity } from '@/modules/user/entities/refresh.token.entity';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户认证token模型
|
|
||||||
*/
|
|
||||||
@Entity('user_access_token')
|
|
||||||
export class AccessTokenEntity extends BaseToken {
|
|
||||||
/**
|
|
||||||
* 关联的刷新令牌
|
|
||||||
*/
|
|
||||||
@OneToOne(() => RefreshTokenEntity, (token) => token.accessToken, { cascade: true })
|
|
||||||
refreshToken: string;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
import { Exclude } from 'class-transformer';
|
|
||||||
import { BaseEntity, Column, CreateDateColumn, PrimaryColumn } from 'typeorm';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Token模型
|
|
||||||
*/
|
|
||||||
@Exclude()
|
|
||||||
export abstract class BaseToken extends BaseEntity {
|
|
||||||
@PrimaryColumn({ type: 'varchar', generated: 'uuid', length: 36 })
|
|
||||||
id: string;
|
|
||||||
|
|
||||||
@Column({ length: 500, comment: '令牌字符串' })
|
|
||||||
value: string;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
comment: '令牌过期时间',
|
|
||||||
})
|
|
||||||
expired_at: Date;
|
|
||||||
|
|
||||||
@CreateDateColumn({
|
|
||||||
comment: '令牌创建时间',
|
|
||||||
})
|
|
||||||
createdAt: Date;
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
import { Entity, JoinColumn, OneToOne, Relation } from 'typeorm';
|
|
||||||
|
|
||||||
import { AccessTokenEntity } from '@/modules/user/entities/access.token.entity';
|
|
||||||
import { BaseToken } from '@/modules/user/entities/base.token';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 刷新Token的Token模型
|
|
||||||
*/
|
|
||||||
@Entity('user_refresh_token')
|
|
||||||
export class RefreshTokenEntity extends BaseToken {
|
|
||||||
/**
|
|
||||||
* 关联的登录令牌
|
|
||||||
*/
|
|
||||||
@OneToOne(() => AccessTokenEntity, (token) => token.refreshToken, { onDelete: 'CASCADE' })
|
|
||||||
@JoinColumn()
|
|
||||||
accessToken: Relation<AccessTokenEntity>;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user