User - 用户
名称 | 类型 | 是否主键 | 外键关联 | 默认值 | 其它 |
---|
id | INTEGER.UNSIGNED | true | | | autoIncrement |
name | STRING(50) | | | | |
password | STRING(32) | | | | |
createdAt | DATE | | | | |
updatedAt | DATE | | | | |
import {
Model,
Table,
PrimaryKey,
AutoIncrement,
Column,
AllowNull,
Unique,
DataType,
CreatedAt,
UpdatedAt
} from 'sequelize-typescript';
const crypto = require('crypto');
@Table({
tableName:'User',
})
export class User extends Model<User>{
@PrimaryKey
@AutoIncrement
@Column
id:number;
@AllowNull(false)
@Unique
@Column({
type: DataType.STRING(50)
})
name:string;
@Column
set password(val: string) {
let md5 = crypto.createHash('md5');
let newPassword = md5.update(`${val}`).digest('hex');
this.setDataValue('password', newPassword);
}
@CreatedAt
createdAt:Date;
@UpdatedAt
updatedAt:Date
}
Board - 任务面板
名称 | 类型 | 是否主键 | 外键关联 | 默认值 | 其它 |
---|
id | INTEGER.UNSIGNED | true | | | autoIncrement |
userId | INTEGER.UNSIGNED | | User.id | | |
name | STRING(255) | | | | |
createdAt | DATE | | | | |
updatedAt | DATE | | | | |
import {
AutoIncrement,
Column,
CreatedAt,
DataType,
ForeignKey,
Model,
PrimaryKey,
Table,
UpdatedAt
} from "sequelize-typescript";
import {User} from "./User";
@Table({
tableName: 'board'
})
export class Board extends Model<Board> {
@PrimaryKey
@AutoIncrement
@Column
id: number;
@ForeignKey(() => User)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
userId: number;
@Column({
type: DataType.STRING(255),
allowNull: false
})
name: string;
@CreatedAt
createdAt: Date;
@UpdatedAt
updatedAt: Date;
}
BoardList - 任务列表
名称 | 类型 | 是否主键 | 外键关联 | 默认值 | 其它 |
---|
id | INTEGER.UNSIGNED | true | | | autoIncrement |
userId | INTEGER.UNSIGNED | | User.id | | |
boardId | INTEGER.UNSIGNED | | Board.id | | |
name | STRING(255) | | | | |
order | FLOAT | | | | |
createdAt | DATE | | | | |
updatedAt | DATE | | | | |
import {
AutoIncrement,
Column,
CreatedAt,
DataType,
ForeignKey,
Model,
PrimaryKey,
Table,
UpdatedAt
} from "sequelize-typescript";
import {Board} from "./Board";
import {User} from "./User";
@Table({
tableName: 'BoardList',
})
export class BoardList extends Model<BoardList> {
@PrimaryKey
@AutoIncrement
@Column
id: number;
@ForeignKey(() => User)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
userId: number;
@ForeignKey(() => Board)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
boardId: number;
@Column({
type: DataType.STRING(255),
allowNull: false
})
name: string;
@Column({
type: DataType.FLOAT,
allowNull: false,
defaultValue: 0
})
order: number;
@CreatedAt
createdAt: Date;
@UpdatedAt
updatedAt: Date;
}
Attachment - 附件
名称 | 类型 | 是否主键 | 外键关联 | 默认值 | 其它 |
---|
id | INTEGER.UNSIGNED | true | | | autoIncrement |
userId | INTEGER.UNSIGNED | | User.id | | |
originName | STRING(255) | | | ‘’ | |
name | STRING(255) | | | | |
type | STRING(50) | | | | |
size | INTEGER.UNSIGNED | | | 0 | |
createdAt | DATE | | | | |
updatedAt | DATE | | | | |
import {
AutoIncrement, BelongsTo,
Column,
CreatedAt,
DataType,
ForeignKey,
Model,
PrimaryKey,
Table,
UpdatedAt
} from "sequelize-typescript";
import {User} from "./User";
@Table({
tableName: 'Attachment'
})
export class Attachment extends Model<Attachment> {
@PrimaryKey
@AutoIncrement
@Column
id: number;
@ForeignKey(() => User)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
userId: number;
@Column({
type: DataType.STRING(255),
allowNull: false
})
originName: string;
@Column({
type: DataType.STRING(255),
allowNull: false
})
name: string;
@Column({
type: DataType.STRING(50),
allowNull: false
})
type: string;
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false,
defaultValue: 0
})
size: number;
@CreatedAt
createdAt: Date;
@UpdatedAt
updatedAt: Date;
}
CardAttachment - 卡片附件关联
名称 | 类型 | 是否主键 | 外键关联 | 默认值 | 其它 |
---|
id | INTEGER.UNSIGNED | true | | | autoIncrement |
userId | INTEGER.UNSIGNED | | User.id | | |
boardListCardId | INTEGER.UNSIGNED | | BoardListCard.id | | |
attachmentId | INTEGER.UNSIGNED | | Attachment.id | | |
isCover | BOOLEAN | | | 0 | |
createdAt | DATE | | | | |
updatedAt | DATE | | | | |
import {
AutoIncrement, BelongsTo,
Column,
CreatedAt,
DataType,
ForeignKey,
Model,
PrimaryKey,
Table,
UpdatedAt
} from "sequelize-typescript";
import {User} from "./User";
import {BoardListCard} from "./BoardListCard";
import {Attachment} from "./Attachment";
@Table({
tableName: 'CardAttachment'
})
export class CardAttachment extends Model<CardAttachment> {
@PrimaryKey
@AutoIncrement
@Column
id: number;
@ForeignKey(() => User)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
userId: number;
@ForeignKey(() => BoardListCard)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
boardListCardId: number;
@ForeignKey(() => Attachment)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
attachmentId: number;
@Column({
type: DataType.BOOLEAN,
allowNull: false,
defaultValue: 0
})
isCover: boolean;
@BelongsTo(() => Attachment)
detail: Attachment;
@CreatedAt
createdAt: Date;
@UpdatedAt
updatedAt: Date;
}
Comment - 评论
名称 | 类型 | 是否主键 | 外键关联 | 默认值 | 其它 |
---|
id | INTEGER.UNSIGNED | true | | | autoIncrement |
userId | INTEGER.UNSIGNED | | User.id | | |
boardListCardId | INTEGER.UNSIGNED | | BoardListCard.id | | |
content | STRING(2000) | | | | |
createdAt | DATE | | | | |
updatedAt | DATE | | | | |
import {
AutoIncrement, BelongsTo,
Column,
CreatedAt,
DataType,
ForeignKey,
Model,
PrimaryKey,
Table,
UpdatedAt
} from "sequelize-typescript";
import {User} from "./User";
import {BoardListCard} from "./BoardListCard";
@Table({
tableName: 'comment'
})
export class Comment extends Model<Comment> {
@PrimaryKey
@AutoIncrement
@Column
id: number;
@ForeignKey(() => User)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
userId: number;
@BelongsTo(() => User)
user: User;
@ForeignKey(() => BoardListCard)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
boardListCardId: number;
@Column({
type: DataType.STRING(2000),
allowNull: false
})
content: string;
@CreatedAt
createdAt: Date;
@UpdatedAt
updatedAt: Date;
}
BoardListCard - 任务卡片
| 名称 | 类型 | 是否主键
外键关联 | 默认值 | 其它 |
---|
id | INTEGER.UNSIGNED | true |
userId | INTEGER.UNSIGNED | |
boardListId | INTEGER.UNSIGNED | |
name | STRING(255) | |
description | STRING(2000) | |
order | FLOAT | |
createdAt | DATE | |
updatedAt | DATE | |
import {
AutoIncrement,
Column,
CreatedAt,
DataType,
ForeignKey, HasMany,
Model,
PrimaryKey,
Table,
UpdatedAt
} from "sequelize-typescript";
import {BoardList} from "./BoardList";
import {User} from "./User";
import {CardAttachment} from "./CardAttachment";
import {Comment} from "./Comment";
@Table({
tableName: 'BoardListCard'
})
export class BoardListCard extends Model<BoardListCard> {
@PrimaryKey
@AutoIncrement
@Column
id: number;
@ForeignKey(() => User)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
userId: number;
@ForeignKey(() => BoardList)
@Column({
type: DataType.INTEGER.UNSIGNED,
allowNull: false
})
boardListId: number;
@Column({
type: DataType.STRING(255),
allowNull: false
})
name: string;
@Column({
type: DataType.STRING(2000),
allowNull: false,
defaultValue: ''
})
description: string;
@Column({
type: DataType.FLOAT,
allowNull: false,
defaultValue: 0
})
order: number;
@HasMany(() => CardAttachment)
attachments: CardAttachment[];
@HasMany(() => Comment)
comments: Comment[];
@CreatedAt
createdAt: Date;
@UpdatedAt
updatedAt: Date;
}