Skip to content

Commit

Permalink
Merge pull request #324 from modern-agile-team/setting/#316/restrict_…
Browse files Browse the repository at this point in the history
…varchar_length

Setting/#316/restrict varchar length
  • Loading branch information
hobiJeong authored Mar 8, 2024
2 parents 660742e + e876116 commit 1dbe7cc
Show file tree
Hide file tree
Showing 170 changed files with 2,749 additions and 2,651 deletions.
2 changes: 1 addition & 1 deletion src/admins/banned-user/dtos/banned-user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { BANNED_USER_REASON_LENGTH } from '@src/admins/banned-user/constants/banned-user.constant';
import { BannedUser } from '@src/admins/banned-user/entities/banned-user.entity';
import { BannedUser } from '@src/entities/BannedUser';

export class BannedUserDto
implements Omit<BannedUser, 'banUser' | 'bannedUser'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { CreateBannedUserBodyDto } from '@src/admins/banned-user/dtos/create-banned-user-body.dto';
import { BannedUser } from '@src/admins/banned-user/entities/banned-user.entity';
import { BannedUser } from '@src/entities/BannedUser';
import { EntityManager, FindOneOptions } from 'typeorm';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/admins/banned-user/services/banned-users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import { ADMIN_ERROR_CODE } from '@src/constants/error/admin/admin-error-code.co
import { HttpForbiddenException } from '@src/http-exceptions/exceptions/http-forbidden.exception';
import { UserRole } from '@src/users/constants/user-role.enum';
import { BannedUserPageQueryDto } from '@src/admins/banned-user/dtos/banned-user-page-query.dto';
import { BannedUser } from '@src/admins/banned-user/entities/banned-user.entity';
import { QueryHelper } from '@src/helpers/query.helper';
import { plainToInstance } from 'class-transformer';
import { BannedUsersItemDto } from '@src/admins/banned-user/dtos/banned-users-item.dto';
import { BannedUsersPaginationResponseDto } from '@src/admins/banned-user/dtos/banned-users-pagination-response.dto';
import { SortOrder } from '@src/common/constants/sort-order.enum';
import { BannedUser } from '@src/entities/BannedUser';

@Injectable()
export class BannedUsersService {
Expand Down
2 changes: 1 addition & 1 deletion src/admins/dtos/put-update-user-for-admin.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum } from 'class-validator';
import { UserStatus } from '@src/users/constants/user-status.enum';
import { User } from '@src/users/entities/user.entity';
import { User } from '@src/entities/User';

export class PutUpdateUserForAdminDto implements Pick<User, 'status'> {
@ApiProperty({
Expand Down
6 changes: 3 additions & 3 deletions src/admins/dtos/user-response-for-admin.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty, OmitType } from '@nestjs/swagger';
import { Provider } from '@src/auth/enums/provider.enum';
import { UserProvider } from '@src/auth/enums/user-provider.enum';
import { UserStatus } from '@src/users/constants/user-status.enum';
import { UserInfoDto } from '@src/users/dtos/user-info.dto';

Expand All @@ -17,9 +17,9 @@ export class UserResponseForAdminDto extends OmitType(UserInfoDto, [

@ApiProperty({
description: '유저 정보 제공자',
enum: Provider,
enum: UserProvider,
})
provider: Provider;
provider: UserProvider;

@ApiProperty({
description: '유저 상태',
Expand Down
14 changes: 7 additions & 7 deletions src/auth/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ApiNaverLogin } from '@src/auth/swagger-decorators/naver-login.decorato
import { ApiNaverLogout } from '@src/auth/swagger-decorators/naver-logout.decorator';
import { ApiNaverUnlink } from '@src/auth/swagger-decorators/naver-unlink.decorator';
import { ApiNewAccessToken } from '@src/auth/swagger-decorators/new-access-token.decorator';
import { Provider } from '@src/auth/enums/provider.enum';
import { UserProvider } from '@src/auth/enums/user-provider.enum';
import { AuthService } from '@src/auth/services/auth.service';

@Controller('auth')
Expand All @@ -48,7 +48,7 @@ export class AuthController {
throw new BadRequestException('인가코드가 없습니다.');
}

return this.authService.login(code, Provider.Naver);
return this.authService.login(code, UserProvider.Naver);
}

@ApiKakaoLogin()
Expand All @@ -59,7 +59,7 @@ export class AuthController {
throw new BadRequestException('인가코드가 없습니다.');
}

return this.authService.login(code, Provider.Kakao);
return this.authService.login(code, UserProvider.Kakao);
}

@ApiGoogleLogin()
Expand All @@ -70,7 +70,7 @@ export class AuthController {
throw new BadRequestException('인가코드가 없습니다.');
}

return this.authService.login(code, Provider.Google);
return this.authService.login(code, UserProvider.Google);
}

@ApiNewAccessToken()
Expand Down Expand Up @@ -102,7 +102,7 @@ export class AuthController {
await this.tokenService.deleteTokens(userId);

return this.authService.unlink(
Provider.Kakao,
UserProvider.Kakao,
socialAccessToken,
socialRefreshToken,
);
Expand All @@ -125,7 +125,7 @@ export class AuthController {
await this.tokenService.deleteTokens(userId);

return this.authService.unlink(
Provider.Naver,
UserProvider.Naver,
socialAccessToken,
socialRefreshToken,
);
Expand All @@ -146,7 +146,7 @@ export class AuthController {

await this.tokenService.deleteTokens(userId);

return this.authService.unlink(Provider.Google, socialAccessToken);
return this.authService.unlink(UserProvider.Google, socialAccessToken);
}

@ApiDeleteAccount()
Expand Down
32 changes: 0 additions & 32 deletions src/auth/entities/token.entity.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum Provider {
export enum UserProvider {
Naver = 'naver',
Kakao = 'kakao',
Google = 'google',
Expand Down
4 changes: 2 additions & 2 deletions src/auth/interfaces/user-info.interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Provider } from '@src/auth/enums/provider.enum';
import { UserProvider } from '@src/auth/enums/user-provider.enum';

export interface UserInfo {
uniqueId: string;
provider: Provider;
provider: UserProvider;
name: string;
email: string;
}
2 changes: 1 addition & 1 deletion src/auth/repositories/token.repository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { Token } from '@src/auth/entities/token.entity';
import { Token } from '@src/entities/Token';
import { DeleteResult, EntityManager, UpdateResult } from 'typeorm';

@Injectable()
Expand Down
30 changes: 15 additions & 15 deletions src/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UserService } from '@src/users/services/user.service';
import { UserImageService } from '@src/users/services/user-image.service';
import { UserStatus } from '@src/users/constants/user-status.enum';
import { UserInfo } from '@src/auth/interfaces/user-info.interface';
import { Provider } from '@src/auth/enums/provider.enum';
import { UserProvider } from '@src/auth/enums/user-provider.enum';
import { TokenService } from '@src/auth/services/token.service';
import { AuthServiceInterface } from '@src/auth/interfaces/auth-service.interface';
import { BannedUserException } from '@src/http-exceptions/exceptions/banned-user.exception';
Expand All @@ -33,15 +33,15 @@ export class AuthService implements AuthServiceInterface {
private readonly userIntroService: UserIntroService,
) {}

async login(authorizeCode: string, provider: Provider) {
async login(authorizeCode: string, provider: UserProvider) {
try {
let tokenUrl: string,
tokenHeader: object,
tokenBody: object,
userInfoUrl: string,
userInfoHeader: object;

if (provider === Provider.Naver) {
if (provider === UserProvider.Naver) {
// 네이버 토큰 발급
tokenUrl = 'https://nid.naver.com/oauth2.0/token';
tokenHeader = {
Expand All @@ -57,7 +57,7 @@ export class AuthService implements AuthServiceInterface {
state: 'test',
redirect_uri: process.env.NAVER_REDIRECT_URI,
};
} else if (provider === Provider.Kakao) {
} else if (provider === UserProvider.Kakao) {
// 카카오 토큰 발급
tokenUrl = 'https://kauth.kakao.com/oauth/token';
tokenHeader = {
Expand All @@ -71,7 +71,7 @@ export class AuthService implements AuthServiceInterface {
redirect_uri: process.env.KAKAO_REDIRECT_URI,
code: authorizeCode,
};
} else if (provider === Provider.Google) {
} else if (provider === UserProvider.Google) {
// 구글 토큰 발급
tokenUrl = 'https://oauth2.googleapis.com/token';
tokenHeader = {
Expand All @@ -93,15 +93,15 @@ export class AuthService implements AuthServiceInterface {
const socialAccessToken = token.access_token;
const socialRefreshToken = token.refresh_token;

if (provider === Provider.Naver) {
if (provider === UserProvider.Naver) {
// 네이버 로그인 사용자 정보 조회
userInfoUrl = 'https://openapi.naver.com/v1/nid/me';
userInfoHeader = {
headers: {
Authorization: `Bearer ${socialAccessToken}`,
},
};
} else if (provider === Provider.Kakao) {
} else if (provider === UserProvider.Kakao) {
// 카카오 로그인 사용자 정보 조회
userInfoUrl = 'https://kapi.kakao.com/v2/user/me';
userInfoHeader = {
Expand All @@ -110,7 +110,7 @@ export class AuthService implements AuthServiceInterface {
'Content-type': 'application/x-www-form-urlencoded;charset=utf-8',
},
};
} else if (provider === Provider.Google) {
} else if (provider === UserProvider.Google) {
// 구글 로그인 사용자 정보 조회
userInfoUrl = 'https://www.googleapis.com/oauth2/v2/userinfo';
userInfoHeader = {
Expand All @@ -129,17 +129,17 @@ export class AuthService implements AuthServiceInterface {
let profileImage = null;
let uniqueId = null;

if (provider === Provider.Naver) {
if (provider === UserProvider.Naver) {
name = socialUserInfo.response.nickname; // 네이버 닉네임
email = socialUserInfo.response.email; // 네이버 이메일
profileImage = socialUserInfo.response.profile_image; // 네이버 프로필 이미지
uniqueId = socialUserInfo.response.id; // 네이버 고유 아이디
} else if (provider === Provider.Kakao) {
} else if (provider === UserProvider.Kakao) {
name = socialUserInfo.kakao_account.profile.nickname; // 카카오 닉네임
email = socialUserInfo.kakao_account.email; // 카카오 이메일
profileImage = socialUserInfo.kakao_account.profile.profile_image_url; // 카카오 프로필 이미지
uniqueId = socialUserInfo.id; // 카카오 고유 아이디
} else if (provider === Provider.Google) {
} else if (provider === UserProvider.Google) {
name = socialUserInfo.name; // Google 닉네임
email = socialUserInfo.email; // Google 이메일
profileImage = socialUserInfo.picture; // Google 프로필 이미지
Expand Down Expand Up @@ -354,7 +354,7 @@ export class AuthService implements AuthServiceInterface {
}

async unlink(
provider: Provider,
provider: UserProvider,
accessToken: string,
refreshToken?: string,
): Promise<object> {
Expand All @@ -364,7 +364,7 @@ export class AuthService implements AuthServiceInterface {
unlinkHeader: object,
unlinkBody: object;

if (provider === Provider.Kakao) {
if (provider === UserProvider.Kakao) {
checkValidAccessToken =
await this.tokenService.checkValidKakaoToken(accessToken);

Expand All @@ -380,7 +380,7 @@ export class AuthService implements AuthServiceInterface {
},
};
unlinkBody = {};
} else if (provider === Provider.Naver) {
} else if (provider === UserProvider.Naver) {
checkValidAccessToken =
await this.tokenService.checkValidNaverToken(accessToken);

Expand All @@ -401,7 +401,7 @@ export class AuthService implements AuthServiceInterface {
grant_type: 'delete',
service_provider: 'NAVER',
};
} else if (provider === Provider.Google) {
} else if (provider === UserProvider.Google) {
unlinkUrl = `https://accounts.google.com/o/oauth2/revoke?token=${accessToken}`;
unlinkHeader = {};
unlinkBody = {};
Expand Down
10 changes: 5 additions & 5 deletions src/boards/boards.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import { TotalCountModule } from '@src/total-count/total-count.module';
import { HelpMeBoardController } from '@src/boards/controllers/help.me.boards.controller';
import { MentorBoardLikeController } from '@src/boards/controllers/mentor-board-likes.controller';
import { MentorBoardController } from '@src/boards/controllers/mentor.board.controller';
import { HelpMeBoardImage } from '@src/boards/entities/help-me-board-image.entity';
import { HelpMeBoard } from '@src/boards/entities/help-me-board.entity';
import { MentorBoardImage } from '@src/boards/entities/mentor-board-image.entity';
import { MentorBoardLike } from '@src/boards/entities/mentor-board-like.entity';
import { MentorBoard } from '@src/boards/entities/mentor-board.entity';
import { BoardImageRepository } from '@src/boards/repository/boardImage.repository';
import { HelpMeBoardRepository } from '@src/boards/repository/help.me.board.repository';
import { MentorBoardLikeRepository } from '@src/boards/repository/mentor.board.likes.repository';
Expand All @@ -23,6 +18,11 @@ import { HelpMeBoardService } from '@src/boards/services/help.me.board.service';
import { MentorBoardLikeService } from '@src/boards/services/mentor-board-likes.service';
import { MentorBoardService } from '@src/boards/services/mentor.board.service';
import { S3Service } from '@src/common/s3/s3.service';
import { MentorBoardImage } from '@src/entities/MentorBoardImage';
import { HelpMeBoard } from '@src/entities/HelpMeBoard';
import { HelpMeBoardImage } from '@src/entities/HelpMeBoardImage';
import { MentorBoard } from '@src/entities/MentorBoard';
import { MentorBoardLike } from '@src/entities/MentorBoardLike';

@Module({
imports: [
Expand Down
2 changes: 1 addition & 1 deletion src/boards/constants/help-me-board-order-field.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export enum HelpMeBoardOrderField {
body = 'body',
createdAt = 'createdAt',
updatedAt = 'updatedAt',
categoryListId = 'categoryId',
categoryId = 'categoryId',
pullingUp = 'pullingUp',
}
2 changes: 1 addition & 1 deletion src/boards/constants/mentor-board-order-field.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export enum MentorBoardOrderField {
body = 'body',
createdAt = 'createdAt',
updatedAt = 'updatedAt',
categoryListId = 'categoryId',
categoryId = 'categoryId',
popularAt = 'popularAt',
random = 'RAND()',
}
2 changes: 1 addition & 1 deletion src/boards/controllers/help.me.boards.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { HelpMeBoardPaginationResponseDto } from '@src/boards/dto/helpMeBoard/he
import { oneHelpMeBoardResponseDTO } from '@src/boards/dto/helpMeBoard/one.response.help.me.board.dto';
import { UpdateHelpMeBoardDto } from '@src/boards/dto/helpMeBoard/update.help.me.board.dto';
import { HelpMeBoardResponseDTO } from '@src/boards/dto/helpMeBoard/update.help.me.board.response.dto';
import { HelpMeBoard } from '@src/boards/entities/help-me-board.entity';
import { BoardImagesService } from '@src/boards/services/BoardImage.service';
import { HelpMeBoardService } from '@src/boards/services/help.me.board.service';
import { ApiAddHelpMeBoard } from '@src/boards/swagger-decorators/helpMeBoard/add-help-me-board-decorator';
Expand All @@ -45,6 +44,7 @@ import { ApiGetOneHelpMeBoard } from '@src/boards/swagger-decorators/helpMeBoard
import { ApiUpdateHelpMeBoardImage } from '@src/boards/swagger-decorators/helpMeBoard/patch-help-me-board-images-decorators';
import { ApiUpdateHelpMeBoard } from '@src/boards/swagger-decorators/helpMeBoard/patch-help-me-board.decorator';
import { ApiPullingUpHelpMeBoard } from '@src/boards/swagger-decorators/helpMeBoard/pulling-up-help-me-board.decorator';
import { HelpMeBoard } from '@src/entities/HelpMeBoard';

/**
* 팀원과 상의되면 주석처리된 옵션도 걸어줌.
Expand Down
2 changes: 1 addition & 1 deletion src/boards/controllers/mentor.board.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { MentorBoardPaginationResponseDto } from '@src/boards/dto/mentorBoard/me
import { oneMentorBoardResponseDTO } from '@src/boards/dto/mentorBoard/one.response.mentor.boards.dto';
import { UpdateMentorBoardDto } from '@src/boards/dto/mentorBoard/update.mentor.board.dto';
import { MentorBoardResponseDTO } from '@src/boards/dto/mentorBoard/update.mentor.board.response.dto';
import { MentorBoard } from '@src/boards/entities/mentor-board.entity';
import { BoardImagesService } from '@src/boards/services/BoardImage.service';
import { MentorBoardService } from '@src/boards/services/mentor.board.service';
import { ApiAddMentorBoard } from '@src/boards/swagger-decorators/mentorBoard/add-mentor-board-decorators';
Expand All @@ -40,6 +39,7 @@ import { ApiGetOneMentorBoard } from '@src/boards/swagger-decorators/mentorBoard
import { ApiGetPageNumberByMentorBoard } from '@src/boards/swagger-decorators/mentorBoard/get-page-number-mentor-board-decorator';
import { ApiUpdateMentorBoard } from '@src/boards/swagger-decorators/mentorBoard/patch-mentor-board-decorators';
import { ParsePositiveIntPipe } from '@src/common/pipes/parse-positive-int.pipe';
import { MentorBoard } from '@src/entities/MentorBoard';

/**
* 추후 리팩토링때
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ApiProperty, PickType } from '@nestjs/swagger';
import { Exclude } from 'class-transformer';
import { HelpMeBoardImage } from '@src/boards/entities/help-me-board-image.entity';
import { UserForJoinDto } from '@src/users/dtos/user-for-join.dto';
import { HelpMeBoardDto } from '@src/boards/dto/helpMeBoard/help-me-board.dto';
import { HelpMeBoardImage } from '@src/entities/HelpMeBoardImage';

/**
* @todo 도와주세요 보드로 통합되면 dto명 수정 및 Property description 수정
Expand Down
Loading

0 comments on commit 1dbe7cc

Please sign in to comment.