Skip to content

Commit

Permalink
fix: 회원 목록 조회 기능이 정상적으로 동작하도록 수정 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coalery authored Jan 28, 2025
2 parents 4f1110a + a6731b4 commit 81807e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/app/AppModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import { UserManageController } from '@khlug/app/interface/user/manager/UserMana

import { UpdateDoorLockPasswordCommandHandler } from '@khlug/app/application/infraBlue/command/updateDoorLockPassword/UpdateDoorLockPasswordCommandHandler';
import { GetDoorLockPasswordQueryHandler } from '@khlug/app/application/infraBlue/query/getDoorLockPassword/GetDoorLockPasswordQueryHandler';
import { ListUserQueryHandler } from '@khlug/app/application/user/query/listUser/ListUserQueryHandler';

import { Cache } from '@khlug/app/domain/cache/model/Cache';
import { User } from '@khlug/app/domain/user/model/User';

const controllers = [];
const manageControllers = [InfraBlueManageController, UserManageController];

const commandHandlers = [UpdateDoorLockPasswordCommandHandler];
const queryHandlers = [GetDoorLockPasswordQueryHandler];
const queryHandlers = [GetDoorLockPasswordQueryHandler, ListUserQueryHandler];

@Module({
imports: [MikroOrmModule.forFeature([Cache])],
imports: [MikroOrmModule.forFeature([Cache, User])],
controllers: [...controllers, ...manageControllers],
providers: [...commandHandlers, ...queryHandlers],
})
Expand Down
10 changes: 5 additions & 5 deletions src/app/application/user/query/listUser/ListUserQueryHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ export class ListUserQueryHandler
const qb = this.userRepository.createQueryBuilder('user');

if (email) {
qb.andWhere('profile.email LIKE ?', [`%${email}%`]);
qb.andWhere('email LIKE ?', [`%${email}%`]);
}

if (name) {
qb.andWhere('profile.name LIKE ?', [`%${name}%`]);
qb.andWhere('realname LIKE ?', [`%${name}%`]);
}

if (college) {
qb.andWhere('profile.college LIKE ?', [`%${college}%`]);
qb.andWhere('college LIKE ?', [`%${college}%`]);
}

if (grade) {
qb.andWhere('profile.grade = ?', [grade]);
qb.andWhere('grade = ?', [grade]);
}

if (state) {
qb.andWhere('profile.state = ?', [state]);
qb.andWhere('state = ?', [state]);
}

const [users, count] = await qb
Expand Down
2 changes: 1 addition & 1 deletion src/app/interface/user/manager/UserManageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class UserManageController {
constructor(private readonly queryBus: QueryBus) {}

@Get('/manager/users')
@Auth([UserRole.MANAGER])
// @Auth([UserRole.MANAGER])
@ApiOperation({ summary: '회원 목록 조회' })
@ApiResponse({ status: HttpStatus.OK, type: ListUserResponseDto })
async listUser(
Expand Down
1 change: 1 addition & 0 deletions src/app/interface/user/manager/dto/ListUserRequestDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class ListUserRequestDto {
@Min(1)
grade: number | null = null;

@Type(() => Number)
@IsOptional()
@IsEnum(UserState)
state: UserState | null = null;
Expand Down

0 comments on commit 81807e4

Please sign in to comment.