Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@Column({ nullable: true })
description: string;
@MetaInfo({ name: '权限', type: 'Authorities' })
@Column(jsonType(), { nullable: true })
authorities: JsonMap;
@ManyToMany(
// eslint-disable-next-line @typescript-eslint/no-use-before-define
type => AdminUser,
user => user.roles,
)
users: AdminUser[];
@BeforeInsert()
@BeforeUpdate()
preSave(): void {
safeReloadObject(this, 'authorities');
}
}
@EntityMetaInfo({ name: 'auth__users' })
@Entity('auth__t_users')
export class AdminUser extends AbstractTimeBasedAuthUser {
constructor() {
super('sa');
}
@MetaInfo({ name: 'Tenant' })
@ManyToOne(
type => Tenant,
tenant => tenant.users,
@MetaInfo({ name: 'File', type: 'File' })
@Column(jsonType(), { nullable: false, name: 'paths' })
paths: JsonArray;
@MetaInfo({ name: '所属应用' })
@ManyToOne(
type => AppInfo,
info => info.releases,
{ onDelete: 'CASCADE' },
)
@JoinColumn({ name: 'app_info__id' })
appInfo: AppInfo;
// TODO try reload in entity subscribers
@BeforeInsert()
@BeforeUpdate()
preSave(): void {
safeReloadArray(this, 'paths');
}
}
createdAt: number
@Column()
updatedAt: number
constructor(file: Partial) {
Object.assign(this, file)
}
@BeforeInsert()
save() {
this._id = uuid.v1()
this.createdAt = +new Date()
this.updatedAt = +new Date()
}
@BeforeUpdate()
update() {
this.updatedAt = +new Date()
}
}
inverseJoinColumn: {
name: 'group_id',
referencedColumnName: 'id'
}
})
groups: Group[];
@BeforeInsert()
doBeforeInsertion() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors)
}
}
@BeforeUpdate()
doBeforeUpdate() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors)
}
}
}
scope: string = undefined;
@ManyToOne(type => User, { eager: true })
@IsNotEmpty()
@JoinColumn({ name: 'user_id' })
user: User = undefined;
@BeforeInsert()
doBeforeInsertion() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors);
}
}
@BeforeUpdate()
doBeforeUpdate() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors);
}
}
}
@IsDefined()
status: ContributionStatus;
@ManyToOne(type => Government, government => government.contributions)
government: Government;
@ManyToOne(type => Campaign, campaign => campaign.contributions)
campaign: Campaign;
@OneToMany(type => Activity, activity => activity.contribution)
activities: Activity[];
public errors: ValidationError[] = [];
@BeforeInsert()
@BeforeUpdate()
async validate() {
await this.validateAsync();
if (this.errors.length > 0) {
throw new Error('contribution has one or more validation problems');
}
}
async isValidAsync(): Promise {
await this.validateAsync();
return this.errors.length === 0;
}
async validateAsync(): Promise {
const errors = await validate(this);
this.errors = errors;
await this.validateCampaignAsync();
@Column({...dbConf.json, name: 'json_content'})
jsonContent: any = {};
isLiked!: boolean;
@OneToMany(type => DbNote, n => n.notebook, {onDelete: 'CASCADE'})
notes!: INote[];
@OneToOne(type => DbFileTreeNode, node => node.notebook, {
onDelete: 'CASCADE',
})
fileNode!: DbFileTreeNode;
path: IFilePathItem[] = [];
@BeforeUpdate()
@BeforeInsert()
updateContentOnSave() {
this.jsonContent = this.jsonContent || {};
}
constructor(base?: INotebook) {
if (base) {
const {id, dateCreated, dateUpdated, name, notes, owner, path} = base;
this.id = id;
this.dateCreated = dateCreated;
this.dateUpdated = dateUpdated;
this.name = name;
this.notes = notes;
this.owner = owner;
this.path = path;
}
inverseJoinColumn: {
name: 'user_id',
referencedColumnName: 'id'
}
})
users: User[];
@BeforeInsert()
doBeforeInsertion() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors);
}
}
@BeforeUpdate()
doBeforeUpdate() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors);
}
}
}
@IsNotEmpty()
@MaxLength(255)
title: string = undefined;
@OneToMany(type => Permission, permission => permission.contentType)
permissions: Permission[];
@BeforeInsert()
doBeforeInsertion() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors);
}
}
@BeforeUpdate()
doBeforeUpdate() {
const errors = validateSync(this, { validationError: { target: false } });
if (errors.length > 0) {
throw new CustomValidationError(errors);
}
}
}
@Column()
notebookId!: string;
@Column({type: 'integer'})
rank!: number;
content: any;
@AfterLoad()
updateContentOnLoad() {
this.content = this.textContent;
}
@BeforeInsert()
@BeforeUpdate()
updateContent() {
this.jsonContent = this.jsonContent || {};
this.textContent = this.content;
}
constructor(base?: INote) {
if (base) {
const {
id,
dateCreated,
dateUpdated,
name,
owner,
content,
notebookId,
type,