• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

khu-khlug / sight-backend / 13616929463

02 Mar 2025 03:40PM UTC coverage: 57.19% (-1.0%) from 58.222%
13616929463

push

github

web-flow
chore: yarn에서 npm으로 롤백 (#105)

637 of 1702 branches covered (37.43%)

Branch coverage included in aggregate %.

1797 of 2554 relevant lines covered (70.36%)

15.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.0
/src/app/application/group/command/changeGroupState/ChangeGroupStateCommandHandler.ts
1
import {
2
  ForbiddenException,
1✔
3
  Inject,
4
  NotFoundException,
5
  UnprocessableEntityException,
1✔
6
} from '@nestjs/common';
7
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
8

2✔
9
import { Transactional } from '@khlug/core/persistence/transaction/Transactional';
10

11
import { ChangeGroupStateCommand } from '@khlug/app/application/group/command/changeGroupState/ChangeGroupStateCommand';
1✔
12
import { ChangeGroupStateCommandResult } from '@khlug/app/application/group/command/changeGroupState/ChangeGroupStateCommandResult';
1✔
13

1✔
14
import {
1✔
15
  GroupLogger,
1✔
16
  IGroupLogger,
1✔
17
} from '@khlug/app/domain/group/IGroupLogger';
1✔
18
import {
1✔
19
  GroupRepository,
1✔
20
  IGroupRepository,
21
} from '@khlug/app/domain/group/IGroupRepository';
2!
22
import { GroupState } from '@khlug/app/domain/group/model/constant';
×
23

24
import { Message } from '@khlug/constant/message';
25

26
@CommandHandler(ChangeGroupStateCommand)
27
export class ChangeGroupStateCommandHandler
28
  implements
29
    ICommandHandler<ChangeGroupStateCommand, ChangeGroupStateCommandResult>
2✔
30
{
31
  constructor(
2✔
32
    @Inject(GroupRepository)
33
    private readonly groupRepository: IGroupRepository,
34
    @Inject(GroupLogger)
2!
35
    private readonly groupLogger: IGroupLogger,
2!
36
  ) {}
×
37

2✔
38
  @Transactional()
39
  async execute(
40
    command: ChangeGroupStateCommand,
5!
41
  ): Promise<ChangeGroupStateCommandResult> {
42
    const { requester, groupId, nextState } = command;
43

2✔
44
    const group = await this.groupRepository.findById(groupId);
2✔
45
    if (!group) {
46
      throw new NotFoundException(Message.GROUP_NOT_FOUND);
47
    }
48

49
    if (group.isCustomerServiceGroup() || group.isPracticeGroup()) {
8✔
50
      throw new UnprocessableEntityException(Message.GROUP_NOT_EDITABLE);
8✔
51
    }
8✔
52

1✔
53
    if (group.adminUserId !== requester.userId && !requester.isManager) {
54
      throw new ForbiddenException(Message.ONLY_GROUP_ADMIN_CAN_EDIT_GROUP);
7✔
55
    }
2✔
56

57
    if (nextState === GroupState.SUSPEND && !requester.isManager) {
5✔
58
      throw new ForbiddenException(Message.ONLY_MANAGER_CAN_SUSPEND_GROUP);
1✔
59
    }
60

4✔
61
    group.changeState(nextState);
1✔
62
    group.wake();
63
    await this.groupRepository.save(group);
3✔
64

3✔
65
    await this.groupLogger.log(groupId, this.buildMessage(nextState));
3✔
66

3✔
67
    return new ChangeGroupStateCommandResult(group);
3✔
68
  }
69

70
  private buildMessage(nextState: GroupState): string {
3!
71
    switch (nextState) {
72
      case 'PROGRESS':
×
73
        return '그룹이 진행 중입니다.';
74
      case 'END_SUCCESS':
2✔
75
        return '그룹이 종료(성공)되었습니다.';
76
      case 'END_FAIL':
×
77
        return '그룹이 종료(실패)되었습니다.';
78
      case 'SUSPEND':
1✔
79
        return '그룹이 중단 처리되었습니다.';
80
      case 'PENDING':
×
81
        return 'not reachable';
82
    }
83
  }
84
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc