算法评测平台前端。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

import * as TypeORM from "typeorm";
import Model from "./common";
import User from "./user";
import Article from "./article";
declare var syzoj: any;
@TypeORM.Entity()
export default class NewReply extends Model {
static cache = false;
@TypeORM.PrimaryGeneratedColumn()
id: number;
@TypeORM.Column({ nullable: true, type: "mediumtext" })
content: string;
@TypeORM.Column({ nullable: true, type: "integer" })
article_id: number;
@TypeORM.Column({ nullable: true, type: "integer" })
from_user_id: number;
@TypeORM.Column({ nullable: true, type: "integer" })
to_user_id: number;
@TypeORM.Column({ nullable: true, type: "integer" })
parent_id: number;
@TypeORM.Column({ nullable: true, type: "integer" })
public_time: number;
@TypeORM.Column({ nullable: true, type: "integer" })
update_time: number;
@TypeORM.Column({ default: 0, type: "integer" })
comments_num: number;
user?: User;
article?: Article;
async loadRelationships() {
this.user = await User.findById(this.from_user_id);
this.article = await Article.findById(this.article_id);
}
async isAllowedEditBy(user) {
await this.loadRelationships();
return user && (user.is_admin || this.from_user_id === user.id || user.id === this.article.user_id);
}
};