feat(guild-model): add member and role base entities
This commit is contained in:
@@ -4,6 +4,9 @@ import { Channel } from './entities/channel.entity';
|
||||
import { Message } from './entities/message.entity';
|
||||
import { DmConversation } from './entities/dm-conversation.entity';
|
||||
import { DmParticipant } from './entities/dm-participant.entity';
|
||||
import { GuildRole } from './entities/guild-role.entity';
|
||||
import { GuildMember } from './entities/guild-member.entity';
|
||||
import { GuildMemberRole } from './entities/guild-member-role.entity';
|
||||
|
||||
export const buildTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
||||
type: 'mysql',
|
||||
@@ -12,7 +15,16 @@ export const buildTypeOrmConfig = (): TypeOrmModuleOptions => ({
|
||||
username: process.env.DB_USER ?? 'fabric',
|
||||
password: process.env.DB_PASSWORD ?? 'fabric',
|
||||
database: process.env.DB_NAME ?? 'fabric_guild',
|
||||
entities: [Guild, Channel, Message, DmConversation, DmParticipant],
|
||||
entities: [
|
||||
Guild,
|
||||
Channel,
|
||||
Message,
|
||||
DmConversation,
|
||||
DmParticipant,
|
||||
GuildRole,
|
||||
GuildMember,
|
||||
GuildMemberRole,
|
||||
],
|
||||
synchronize: (process.env.DB_SYNC ?? 'true') === 'true',
|
||||
logging: (process.env.DB_LOGGING ?? 'false') === 'true',
|
||||
});
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity('guild_member_roles')
|
||||
export class GuildMemberRole {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Column({ type: 'char', length: 36 })
|
||||
guildId!: string;
|
||||
|
||||
@Column({ type: 'char', length: 36 })
|
||||
memberId!: string;
|
||||
|
||||
@Column({ type: 'char', length: 36 })
|
||||
roleId!: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
}
|
||||
19
Fabric.Backend.Guild/src/entities/guild-member.entity.ts
Normal file
19
Fabric.Backend.Guild/src/entities/guild-member.entity.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity('guild_members')
|
||||
export class GuildMember {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Column({ type: 'char', length: 36 })
|
||||
guildId!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 64 })
|
||||
userId!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 16, default: 'active' })
|
||||
status!: 'active' | 'left' | 'blocked';
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
}
|
||||
22
Fabric.Backend.Guild/src/entities/guild-role.entity.ts
Normal file
22
Fabric.Backend.Guild/src/entities/guild-role.entity.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
@Entity('guild_roles')
|
||||
export class GuildRole {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Column({ type: 'char', length: 36 })
|
||||
guildId!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 64 })
|
||||
code!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 120 })
|
||||
name!: string;
|
||||
|
||||
@Column({ type: 'boolean', default: false })
|
||||
isSystem!: boolean;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user