import {BaseEntity,Entity,Column,Id,OneToMany,EntityProxy, ManyToMany, JoinTable} from 'relaen'; import { AmGroup } from './amgroup'; import {AmGroupAuthority} from './amgroupauthority'; import { AmResource } from './amresource'; import {AmResourceAuthority} from './amresourceauthority'; @Entity("AM_AUTHORITY") export class AmAuthority extends BaseEntity{ @Id() @Column({ name:'AUTHORITY_ID', type:'int', nullable:false }) public authorityId:number; @Column({ name:'AUTHORITY', type:'string', nullable:false, length:64 }) public authority:string; @ManyToMany({entity:'AmGroup'}) @JoinTable({ //中间表名 table:'AM_GROUP_AUTHORITY', //中间表字段名(本表在中间表的字段名,默认为主键) columnName:'AUTHORITY_ID', //关联字段名 refName:'GROUP_ID' }) public amGroups:Array; @ManyToMany({ entity:'AmResource', mappedBy:'amAuthorities' }) public amResources:Array; constructor(idValue?:number){ super(); this.authorityId = idValue; } public async getAmGroups():Promise>{ return this['amGroups']?this['amGroups']:await EntityProxy.get(this,'amGroups'); } public async getAmResources():Promise>{ return this['amResources']?this['amResources']:await EntityProxy.get(this,'amResources'); } }