Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AppService } from './app.service';
import { AuthModule } from './auth/auth.module';
import { JwtMiddleware } from './auth/middleware/jwt.middleware';
import { UserModule } from './user/user.module';
import { ChannelModule } from './channel/channel.module';

@Module({
imports: [
Expand All @@ -30,6 +31,7 @@ import { UserModule } from './user/user.module';
}),
}),
UserModule,
ChannelModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
4 changes: 4 additions & 0 deletions backend/src/channel/channel.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';

@Controller('channel')
export class ChannelController {}
9 changes: 9 additions & 0 deletions backend/src/channel/channel.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ChannelController } from './channel.controller';
import { ChannelService } from './channel.service';

@Module({
controllers: [ChannelController],
providers: [ChannelService]
})
export class ChannelModule {}
4 changes: 4 additions & 0 deletions backend/src/channel/channel.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class ChannelService {}
41 changes: 41 additions & 0 deletions backend/src/channel/entity/channel.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
Column,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
} from 'typeorm';
import { User } from '../../user/entity/user.entity';

@Entity('channel')
export class Channel {
@PrimaryGeneratedColumn()
id: number;

@Column({ nullable: false })
channelStatus: number;

@Column()
channelPassword: number;

@OneToMany(() => ChannelMembers, (channelMembers) => channelMembers.channelID)
channelIDs: ChannelMembers[];
}

@Entity('channel_members')
export class ChannelMembers {
@ManyToOne(() => Channel, (channel) => channel.channelIDs, { primary: true })
@JoinColumn({ name: 'channelID' })
channelID: Channel;

@ManyToOne(() => User, (user) => user.userIDs, { primary: true })
@JoinColumn({ name: 'userID' })
userID: User;

@Column()
permissionType: number;

@Column()
penalty: number;
}
6 changes: 5 additions & 1 deletion backend/src/user/entity/user.entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { ChannelMembers } from 'src/channel/entity/channel.entity';
import { Column, Entity, OneToMany, PrimaryColumn } from 'typeorm';

@Entity('user')
export class User {
Expand All @@ -25,4 +26,7 @@ export class User {

@Column({ default: 0 })
ladderLevel: number;

@OneToMany(() => ChannelMembers, (channelMembers) => channelMembers.userID)
userIDs: ChannelMembers[];
}