Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 유저 아이디를 모두 number 타입으로 수정 #89

Merged
merged 2 commits into from
Jan 28, 2025
Merged
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: 1 addition & 1 deletion src/__test__/fixtures/GroupBookmarkFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function generator(
): GroupBookmark {
return new GroupBookmark({
id: faker.string.uuid(),
userId: faker.string.uuid(),
userId: faker.number.int(),
groupId: faker.string.uuid(),
createdAt: faker.date.anytime(),
...params,
Expand Down
6 changes: 3 additions & 3 deletions src/__test__/fixtures/GroupFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ function generator(params: Partial<GroupConstructorParams> = {}): Group {
category: faker.helpers.enumValue(GroupCategory),
state: faker.helpers.enumValue(GroupState),
title: faker.lorem.word(),
authorUserId: faker.string.uuid(),
adminUserId: faker.string.uuid(),
authorUserId: faker.number.int(),
adminUserId: faker.number.int(),
purpose: faker.lorem.sentence(),
interestIds: [faker.string.uuid()],
technology: [faker.lorem.word()],
grade: faker.helpers.enumValue(GroupAccessGrade),
lastUpdaterUserId: faker.string.uuid(),
lastUpdaterUserId: faker.number.int(),
repository: faker.internet.url(),
allowJoin: faker.datatype.boolean(),
hasPortfolio: faker.datatype.boolean(),
Expand Down
2 changes: 1 addition & 1 deletion src/__test__/fixtures/domain/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function generateGroupMember(
): GroupMember {
return new GroupMember({
id: faker.string.uuid(),
userId: faker.string.uuid(),
userId: faker.number.int(),
groupId: faker.string.uuid(),
createdAt: faker.date.anytime(),
...params,
Expand Down
4 changes: 2 additions & 2 deletions src/__test__/fixtures/domain/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { User, UserConstructorParams } from '@khlug/app/domain/user/model/User';

export function generateUser(params?: Partial<UserConstructorParams>): User {
return new User({
id: faker.string.uuid(),
id: faker.number.int(),
name: faker.lorem.word(),
password: faker.lorem.word(),
profile: new Profile({
Expand Down Expand Up @@ -47,7 +47,7 @@ export function generatePointHistory(
): PointHistory {
return new PointHistory({
id: faker.string.uuid(),
userId: faker.string.uuid(),
userId: faker.number.int(),
point: faker.number.int(),
reason: faker.lorem.sentence(),
createdAt: faker.date.anytime(),
Expand Down
2 changes: 1 addition & 1 deletion src/__test__/fixtures/view/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { UserState } from '@khlug/app/domain/user/model/constant';

export function generateUserView(params?: Partial<UserView>): UserView {
return {
id: faker.string.uuid(),
id: faker.number.int(),
name: faker.lorem.word(),
password: faker.lorem.word(),
profile: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class AddBookmarkCommand {
constructor(
readonly groupId: string,
readonly userId: string,
readonly userId: number,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('AddBookmarkCommandHandler', () => {

describe('execute', () => {
const groupId = 'groupId';
const userId = 'userId';
const userId = 123;

test('그룹이 존재하지 않으면 예외가 발생해야 한다', async () => {
groupRepository.findById = jest.fn().mockResolvedValue(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GroupState } from '@khlug/app/domain/group/model/constant';

type ChangeGroupStateRequester = {
userId: string;
userId: number;
isManager: boolean;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('ChangeGroupStateCommandHandler', () => {
describe('execute', () => {
let group: Group;

const requesterUserId = 'requester-user-id';
const requesterUserId = 123;
const groupId = 'group-id';
const nextState = GroupState.END_SUCCESS;

Expand Down Expand Up @@ -124,7 +124,7 @@ describe('ChangeGroupStateCommandHandler', () => {
const isManager = false;

test('요청자가 그룹의 관리자가 아니라면 예외를 발생시켜야 한다', async () => {
const otherUserId = 'other-user-id';
const otherUserId = 101;

const command = new ChangeGroupStateCommand(
{ userId: otherUserId, isManager },
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('ChangeGroupStateCommandHandler', () => {
const isManager = true;

test('요청자가 그룹의 관리자가 아니더라도 상태를 변경할 수 있어야 한다', async () => {
const otherManagerUserId = 'other-manager-user-id';
const otherManagerUserId = 102;

const command = new ChangeGroupStateCommand(
{ userId: otherManagerUserId, isManager },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Typeof } from '@khlug/util/types';

export class CreateGroupCommand implements ICommand {
readonly requesterUserId: string;
readonly requesterUserId: number;
readonly title: string;
readonly category: GroupCategory;
readonly grade: GroupAccessGrade;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('CreateGroupCommandHandler', () => {
interestRepository.findByIds.mockResolvedValue([]);

const command = new CreateGroupCommand({
requesterUserId: 'userId',
requesterUserId: 100,
title: 'title',
category: GroupCategory.DOCUMENTATION,
grade: GroupAccessGrade.MEMBER,
Expand All @@ -111,7 +111,7 @@ describe('CreateGroupCommandHandler', () => {
jest.spyOn(groupFactory, 'create').mockReturnValue(newGroup);

const command = new CreateGroupCommand({
requesterUserId: 'userId',
requesterUserId: 100,
title: 'title',
category: GroupCategory.DOCUMENTATION,
grade: GroupAccessGrade.MEMBER,
Expand All @@ -134,7 +134,7 @@ describe('CreateGroupCommandHandler', () => {
jest.spyOn(groupMemberFactory, 'create').mockReturnValue(newGroupMember);

const command = new CreateGroupCommand({
requesterUserId: 'userId',
requesterUserId: 100,
title: 'title',
category: GroupCategory.DOCUMENTATION,
grade: GroupAccessGrade.MEMBER,
Expand All @@ -160,7 +160,7 @@ describe('CreateGroupCommandHandler', () => {
jest.spyOn(groupFactory, 'create').mockReturnValue(newGroup);

const command = new CreateGroupCommand({
requesterUserId: 'userId',
requesterUserId: 100,
title: 'title',
category: GroupCategory.DOCUMENTATION,
grade: GroupAccessGrade.MEMBER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { ICommand } from '@nestjs/cqrs';
export class DisablePortfolioCommand implements ICommand {
constructor(
readonly groupId: string,
readonly requesterUserId: string,
readonly requesterUserId: number,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ describe('DisablePortfolioCommandHandler', () => {
test('그룹이 존재하지 않으면 예외를 발생시켜야 한다', async () => {
groupRepository.findById.mockResolvedValue(null);

const command = new DisablePortfolioCommand('groupId', 'requesterUserId');
const command = new DisablePortfolioCommand('groupId', 100);
await expect(handler.execute(command)).rejects.toThrow(
Message.GROUP_NOT_FOUND,
);
});

test('요청자가 그룹장이 아니라면 예외를 발생시켜야 한다', async () => {
const group = GroupFixture.inProgressJoinable({ hasPortfolio: true });
const notAdminUserId = 'not-admin-user-id';
const notAdminUserId = 999;

groupRepository.findById.mockResolvedValue(group);

Expand Down Expand Up @@ -131,7 +131,7 @@ describe('DisablePortfolioCommandHandler', () => {
test('모든 그룹원으로부터 포인트를 회수해야 한다', async () => {
const group = GroupFixture.inProgressJoinable({ hasPortfolio: true });
const adminUserId = group.adminUserId;
const groupMemberUserIds = ['user1', 'user2'];
const groupMemberUserIds = [101, 102];

groupRepository.findById.mockResolvedValue(group);
groupMemberRepository.findByGroupId.mockResolvedValue([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class DisablePortfolioCommandHandler
this.sendMessageToAdminUser(group);
}

private checkGroupAdmin(group: Group, requesterUserId: string): void {
private checkGroupAdmin(group: Group, requesterUserId: number): void {
if (group.adminUserId !== requesterUserId) {
throw new ForbiddenException(Message.ONLY_GROUP_ADMIN_CAN_EDIT_GROUP);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class EnablePortfolioCommand {
constructor(
readonly groupId: string,
readonly requesterUserId: string,
readonly requesterUserId: number,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ describe('EnablePortfolioCommandHandler', () => {
test('그룹이 존재하지 않으면 예외를 발생시켜야 한다', async () => {
groupRepository.findById.mockResolvedValue(null);

const command = new EnablePortfolioCommand('groupId', 'requesterUserId');
const command = new EnablePortfolioCommand('groupId', 100);
await expect(handler.execute(command)).rejects.toThrow(
Message.GROUP_NOT_FOUND,
);
});

test('요청자가 그룹장이 아니라면 예외를 발생시켜야 한다', async () => {
const group = GroupFixture.inProgressJoinable({ hasPortfolio: false });
const notAdminUserId = 'not-admin-user-id';
const notAdminUserId = 999;

groupRepository.findById.mockResolvedValue(group);

Expand Down Expand Up @@ -124,7 +124,7 @@ describe('EnablePortfolioCommandHandler', () => {
test('모든 그룹원에게 포인트를 부여해야 한다', async () => {
const group = GroupFixture.inProgressJoinable({ hasPortfolio: false });
const adminUserId = group.adminUserId;
const groupMemberUserIds = ['user1', 'user2'];
const groupMemberUserIds = [101, 102];

groupRepository.findById.mockResolvedValue(group);
groupMemberRepository.findByGroupId.mockResolvedValue([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class EnablePortfolioCommandHandler
this.sendMessageToAdminUser(group);
}

private checkGroupAdmin(group: Group, requesterUserId: string): void {
private checkGroupAdmin(group: Group, requesterUserId: number): void {
if (group.adminUserId !== requesterUserId) {
throw new ForbiddenException(Message.ONLY_GROUP_ADMIN_CAN_EDIT_GROUP);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type ModifyGroupParams = {
export class ModifyGroupCommand implements ICommand {
constructor(
readonly groupId: string,
readonly requesterUserId: string,
readonly requesterUserId: number,
readonly params: ModifyGroupParams,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('ModifyGroupCommandHandler', () => {
test('그룹이 존재하지 않으면 예외를 발생시켜야 한다', async () => {
groupRepository.findById.mockResolvedValue(null);

const command = new ModifyGroupCommand('groupId', 'requesterUserId', {
const command = new ModifyGroupCommand('groupId', 123, {
category: GroupCategory.DOCUMENTATION,
title: 'title',
purpose: 'purpose',
Expand All @@ -95,7 +95,7 @@ describe('ModifyGroupCommandHandler', () => {
const group = GroupFixture.inProgressJoinable({
category: GroupCategory.DOCUMENTATION,
});
const notAdminUserId = 'notAdminUserId';
const notAdminUserId = 124;

groupRepository.findById.mockResolvedValue(group);

Expand All @@ -121,7 +121,7 @@ describe('ModifyGroupCommandHandler', () => {
const group = GroupFixture.inProgressJoinable({
category: GroupCategory.MANAGE,
});
const notAdminUserId = 'notAdminUserId';
const notAdminUserId = 124;

groupRepository.findById.mockResolvedValue(group);
groupMemberRepository.findByGroupIdAndUserId.mockResolvedValue(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class ModifyGroupCommandHandler
return group;
}

private checkGroupAdmin(group: Group, userId: string): void {
private checkGroupAdmin(group: Group, userId: number): void {
// 운영진 간 계층을 나타내지 않기 위해 운영 그룹은 그룹장 개념이 없음
if (group.category === GroupCategory.MANAGE) {
return;
Expand All @@ -136,7 +136,7 @@ export class ModifyGroupCommandHandler
}
}

private async checkGroupMember(group: Group, userId: string): Promise<void> {
private async checkGroupMember(group: Group, userId: number): Promise<void> {
const groupMember = await this.groupMemberRepository.findByGroupIdAndUserId(
group.id,
userId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export class RemoveBookmarkCommand {
constructor(
readonly groupId: string,
readonly userId: string,
readonly userId: number,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('RemoveBookmarkCommandHandler', () => {

describe('execute', () => {
test('그룹이 존재하지 않으면 예외를 발생시켜야 한다', async () => {
const command = new RemoveBookmarkCommand('groupId', 'userId');
const command = new RemoveBookmarkCommand('groupId', 123);

groupRepository.findById.mockResolvedValue(null);

Expand All @@ -65,7 +65,7 @@ describe('RemoveBookmarkCommandHandler', () => {
});

test('대상 그룹이 고객 센터 그룹이라면 예외를 발생시켜야 한다', async () => {
const command = new RemoveBookmarkCommand('groupId', 'userId');
const command = new RemoveBookmarkCommand('groupId', 123);
const group = GroupFixture.customerService();

groupRepository.findById.mockResolvedValue(group);
Expand All @@ -76,7 +76,7 @@ describe('RemoveBookmarkCommandHandler', () => {
});

test('대상 그룹이 실습 그룹이라면 예외를 발생시켜야 한다', async () => {
const command = new RemoveBookmarkCommand('groupId', 'userId');
const command = new RemoveBookmarkCommand('groupId', 123);
const group = GroupFixture.practice();

groupRepository.findById.mockResolvedValue(group);
Expand All @@ -87,7 +87,7 @@ describe('RemoveBookmarkCommandHandler', () => {
});

test('이미 즐겨 찾는 그룹이 아니라면 즐겨찾기를 제거하지 않아야 한다', async () => {
const command = new RemoveBookmarkCommand('groupId', 'userId');
const command = new RemoveBookmarkCommand('groupId', 123);
const group = GroupFixture.inProgressJoinable();

groupRepository.findById.mockResolvedValue(group);
Expand All @@ -99,7 +99,7 @@ describe('RemoveBookmarkCommandHandler', () => {
});

test('그룹 즐겨찾기를 제거해야 한다', async () => {
const command = new RemoveBookmarkCommand('groupId', 'userId');
const command = new RemoveBookmarkCommand('groupId', 123);
const group = GroupFixture.inProgressJoinable();
const bookmark = GroupBookmarkFixture.normal();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ICommand } from '@nestjs/cqrs';

export class UpdateUnitedUserCommand implements ICommand {
constructor(
readonly userId: string,
readonly userId: number,
readonly email: string,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('UpdateUnitedUserCommandHandler', () => {
let user: User;
let command: UpdateUnitedUserCommand;

const userId = 'userId';
const userId = 123;
const newEmail = '[email protected]';

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ICommand } from '@nestjs/cqrs';

export class UpdateUserCommand implements ICommand {
constructor(
readonly userId: string,
readonly userId: number,
readonly email: string,
readonly phone: string | null,
readonly homepage: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('UpdateUserCommandHandler', () => {

const newUserInterestIds = ['new-user-interest-1', 'new-user-interest-2'];

const userId = 'userId';
const userId = 123;
const email = '[email protected]';
const phone = null;
const homepage = 'https://some.home.page/';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class UpdateUserCommandHandler
}

private async updateInterests(
userId: string,
userId: number,
interestIds: string[],
): Promise<void> {
const interests = await this.interestRepository.findByIds(interestIds);
Expand Down
Loading