Skip to content

Commit

Permalink
dynamic club
Browse files Browse the repository at this point in the history
  • Loading branch information
PleBea committed Feb 25, 2025
1 parent 670c2f9 commit 858bcfb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/server/src/admin/admin.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Admin, AdminRole } from './entities/admin.entity';
import { Admin } from './entities/admin.entity';

@Injectable()
export class AdminService {
Expand All @@ -10,7 +10,7 @@ export class AdminService {
private readonly adminRepository: Repository<Admin>,
) {}

async createAdmin(email: string, role: AdminRole = AdminRole.ADMIN) {
async createAdmin(email: string, role = 'admin') {
const admin = new Admin();
admin.email = email;
admin.role = role;
Expand Down
12 changes: 4 additions & 8 deletions packages/server/src/admin/dto/create-admin.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { AdminRole } from '../entities/admin.entity';
import { IsEmail, IsEnum } from 'class-validator';
import { IsEmail } from 'class-validator';

export class CreateAdminDto {
@ApiProperty({
Expand All @@ -16,13 +15,10 @@ export class CreateAdminDto {
)
email: string;

@ApiProperty({ example: 'admin', description: '권한', enum: AdminRole })
@IsEnum(AdminRole, {
message: '권한이 올바르지 않습니다.',
})
role: AdminRole;
@ApiProperty({ example: 'admin', description: 'admin | none | club.name' })
role: string;

constructor(email: string, role: AdminRole) {
constructor(email: string, role: string) {
this.email = email;
this.role = role;
}
Expand Down
25 changes: 11 additions & 14 deletions packages/server/src/admin/entities/admin.entity.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';

export enum AdminRole {
NONE = 'none',
// export enum AdminRole {
// NONE = 'none',

ADMIN = 'admin',
// ADMIN = 'admin',

LAYER7 = 'layer7',
TEAMLOG = 'teamlog',
UNIFOX = 'unifox',
NEFUS = 'nefus',
EMOTION = 'emotion',
}
// LAYER7 = 'layer7',
// TEAMLOG = 'teamlog',
// UNIFOX = 'unifox',
// NEFUS = 'nefus',
// EMOTION = 'emotion',
// }
@Entity()
export class Admin {
@PrimaryColumn()
email!: string;

@Column('enum', {
enum: AdminRole,
default: AdminRole.NONE,
})
role!: AdminRole;
@Column('varchar')
role!: string;
}

0 comments on commit 858bcfb

Please sign in to comment.