Skip to content

Commit 8d70a0d

Browse files
kyumin1227claude
andcommitted
style: Prettier 포맷 일괄 적용
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 469b038 commit 8d70a0d

14 files changed

Lines changed: 136 additions & 56 deletions

src/cleaning/controller/cleaning-rule.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { formatClassLabel } from '../../common/class-label.util';
1616
import { StudentClassStatus } from '../../student-class/student-class.entity';
1717
import { UserRole } from '../../user/user.entity';
1818
import { CleaningAssignmentStatus } from '../entity/cleaning-assignment.entity';
19-
import { BusinessError, CleaningErrorCode } from '../../common/errors'
20-
import { ErrorView } from '../../common/error.view'
19+
import { BusinessError, CleaningErrorCode } from '../../common/errors';
20+
import { ErrorView } from '../../common/error.view';
2121
@Controller()
2222
export class CleaningRuleController {
2323
constructor(

src/cleaning/controller/cleaning-trade.controller.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ export class CleaningTradeController {
170170

171171
await ack();
172172

173-
const details = await this.cleaningTradeService.getTradeWithDetails(
174-
tradeId,
175-
);
173+
const details =
174+
await this.cleaningTradeService.getTradeWithDetails(tradeId);
176175
if (details) {
177176
await Promise.allSettled([
178177
client.chat.postMessage({
@@ -208,9 +207,8 @@ export class CleaningTradeController {
208207
const user = await this.userService.findBySlackId(body.user.id);
209208
if (!user) return;
210209

211-
const details = await this.cleaningTradeService.getTradeWithDetails(
212-
tradeId,
213-
);
210+
const details =
211+
await this.cleaningTradeService.getTradeWithDetails(tradeId);
214212

215213
try {
216214
await this.cleaningTradeService.respondTrade(tradeId, user.id, true);
@@ -249,7 +247,12 @@ export class CleaningTradeController {
249247
client.chat.postMessage({
250248
channel: requester.userSlackId,
251249
text: '교환 요청이 수락되었습니다.',
252-
blocks: CleaningTradeView.tradeResultBlocks(requester, target, true, 'requester'),
250+
blocks: CleaningTradeView.tradeResultBlocks(
251+
requester,
252+
target,
253+
true,
254+
'requester',
255+
),
253256
}),
254257
]);
255258
}
@@ -269,9 +272,8 @@ export class CleaningTradeController {
269272
const user = await this.userService.findBySlackId(body.user.id);
270273
if (!user) return;
271274

272-
const details = await this.cleaningTradeService.getTradeWithDetails(
273-
tradeId,
274-
);
275+
const details =
276+
await this.cleaningTradeService.getTradeWithDetails(tradeId);
275277

276278
try {
277279
await this.cleaningTradeService.respondTrade(tradeId, user.id, false);
@@ -308,7 +310,13 @@ export class CleaningTradeController {
308310
client.chat.postMessage({
309311
channel: requester.userSlackId,
310312
text: '교환 요청이 거절되었습니다.',
311-
blocks: CleaningTradeView.tradeResultBlocks(requester, target, false, 'requester', target.userSlackId),
313+
blocks: CleaningTradeView.tradeResultBlocks(
314+
requester,
315+
target,
316+
false,
317+
'requester',
318+
target.userSlackId,
319+
),
312320
}),
313321
]);
314322
}

src/cleaning/service/cleaning-rule.service.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export class CleaningRuleService {
4444
private readonly userAdminService: UserAdminService,
4545
) {}
4646

47-
async findAllWithDetails(studentClassId?: number): Promise<RuleWithDetails[]> {
47+
async findAllWithDetails(
48+
studentClassId?: number,
49+
): Promise<RuleWithDetails[]> {
4850
const rules = await this.ruleRepo.find({
4951
where: studentClassId ? { studentClassId } : undefined,
5052
relations: ['studentClass'],
@@ -129,7 +131,10 @@ export class CleaningRuleService {
129131
});
130132
} else {
131133
await this.ruleResourceRepo.save(
132-
this.ruleResourceRepo.create({ ruleId: id, resourceId: dto.resourceId }),
134+
this.ruleResourceRepo.create({
135+
ruleId: id,
136+
resourceId: dto.resourceId,
137+
}),
133138
);
134139
}
135140
}
@@ -170,7 +175,10 @@ export class CleaningRuleService {
170175
studentClassId?: number,
171176
): Promise<{ label: string; value: string }[]> {
172177
const { users } = await this.userAdminService.findFiltered(
173-
{ status: UserStatus.ACTIVE, ...(studentClassId ? { studentClassId } : {}) },
178+
{
179+
status: UserStatus.ACTIVE,
180+
...(studentClassId ? { studentClassId } : {}),
181+
},
174182
0,
175183
1000,
176184
);
@@ -179,8 +187,7 @@ export class CleaningRuleService {
179187
? formatClassLabel({
180188
admissionYear: u.studentClass.admissionYear,
181189
section: u.studentClass.section,
182-
graduated:
183-
u.studentClass.status === StudentClassStatus.GRADUATED,
190+
graduated: u.studentClass.status === StudentClassStatus.GRADUATED,
184191
})
185192
: null;
186193
const parts = [classLabel, u.code].filter(Boolean).join(' | ');

src/cleaning/service/cleaning-schedule.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ export class CleaningScheduleService {
6363

6464
const ruleUsers = await this.ruleUserRepo.find({ where: { ruleId } });
6565
if (ruleUsers.length === 0) return { count: 0, scheduleIds: [] };
66-
66+
6767
// 담당인원이 필요 인원 수 보다 적은 경우 비즈니스 에러 처리
6868
if (ruleUsers.length < rule.needPeoples) {
6969
throw new BusinessError(CleaningErrorCode.NOT_ENOUGH_USERS);
70-
};
71-
70+
}
71+
7272
const existing = await this.scheduleRepo.find({
7373
where: { ruleId },
7474
order: { cleaningDate: 'DESC' },

src/cleaning/service/cleaning-schedule.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import {
1212
CleaningAssignment,
1313
CleaningAssignmentStatus,
1414
} from '../entity/cleaning-assignment.entity';
15-
import {
16-
CleaningTrade,
17-
} from '../entity/cleaning-trade.entity';
15+
import { CleaningTrade } from '../entity/cleaning-trade.entity';
1816
import { In } from 'typeorm';
1917

2018
describe('CleaningScheduleService', () => {

src/cleaning/service/cleaning-trade.service.ts

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import {
55
CleaningAssignment,
66
CleaningAssignmentStatus,
77
} from '../entity/cleaning-assignment.entity';
8-
import { CleaningTrade, CleaningTradeStatus } from '../entity/cleaning-trade.entity';
8+
import {
9+
CleaningTrade,
10+
CleaningTradeStatus,
11+
} from '../entity/cleaning-trade.entity';
912
import { CleaningScheduleStatus } from '../entity/cleaning-schedule.entity';
1013
import { BusinessError, CleaningErrorCode } from '../../common/errors';
1114

@@ -51,9 +54,13 @@ export class CleaningTradeService {
5154
'res.name AS "resourceName"',
5255
])
5356
.where('a.userId = :userId', { userId })
54-
.andWhere('a.status = :status', { status: CleaningAssignmentStatus.ASSIGNED })
57+
.andWhere('a.status = :status', {
58+
status: CleaningAssignmentStatus.ASSIGNED,
59+
})
5560
.andWhere('s.cleaningDate >= :today', { today })
56-
.andWhere('s.status = :schedStatus', { schedStatus: CleaningScheduleStatus.SCHEDULED })
61+
.andWhere('s.status = :schedStatus', {
62+
schedStatus: CleaningScheduleStatus.SCHEDULED,
63+
})
5764
.andWhere('r.deletedAt IS NULL')
5865
.orderBy('s.cleaningDate', 'ASC')
5966
.getRawMany<{
@@ -101,7 +108,11 @@ export class CleaningTradeService {
101108
.select('t.id')
102109
.getRawMany<{ t_id: number }>();
103110

104-
const result: { trade: { id: number }; myAssignment: AssignmentDetail; targetAssignment: AssignmentDetail }[] = [];
111+
const result: {
112+
trade: { id: number };
113+
myAssignment: AssignmentDetail;
114+
targetAssignment: AssignmentDetail;
115+
}[] = [];
105116
for (const { t_id } of trades) {
106117
const detail = await this.getTradeWithDetails(t_id);
107118
if (detail)
@@ -131,18 +142,28 @@ export class CleaningTradeService {
131142
.createQueryBuilder('a')
132143
.select('a.userId', 'userId')
133144
.where('a.scheduleId = :schedId', { schedId: myAssignment.scheduleId })
134-
.andWhere('a.status != :canceled', { canceled: CleaningAssignmentStatus.CANCELED })
145+
.andWhere('a.status != :canceled', {
146+
canceled: CleaningAssignmentStatus.CANCELED,
147+
})
135148
.getRawMany<{ userId: number }>();
136-
const myScheduleUserIds = new Set(myScheduleUsers.map((r) => Number(r.userId)));
149+
const myScheduleUserIds = new Set(
150+
myScheduleUsers.map((r) => Number(r.userId)),
151+
);
137152

138153
// 이미 처리 대기 중인 배정은 중복 교환 요청을 막기 위해 후보에서 제외한다.
139154
const pendingTrades = await this.tradeRepo
140155
.createQueryBuilder('t')
141156
.select(['t.requesterAssignmentId', 't.targetAssignmentId'])
142157
.where('t.status = :status', { status: CleaningTradeStatus.PENDING })
143-
.getRawMany<{ t_requesterAssignmentId: number; t_targetAssignmentId: number }>();
158+
.getRawMany<{
159+
t_requesterAssignmentId: number;
160+
t_targetAssignmentId: number;
161+
}>();
144162
const pendingIds = new Set<number>();
145-
for (const { t_requesterAssignmentId, t_targetAssignmentId } of pendingTrades) {
163+
for (const {
164+
t_requesterAssignmentId,
165+
t_targetAssignmentId,
166+
} of pendingTrades) {
146167
pendingIds.add(Number(t_requesterAssignmentId));
147168
pendingIds.add(Number(t_targetAssignmentId));
148169
}
@@ -164,10 +185,16 @@ export class CleaningTradeService {
164185
's.cleaningDate AS "cleaningDate"',
165186
'res.name AS "resourceName"',
166187
])
167-
.where('a.status = :status', { status: CleaningAssignmentStatus.ASSIGNED })
168-
.andWhere('a.scheduleId != :mySchedule', { mySchedule: myAssignment.scheduleId })
188+
.where('a.status = :status', {
189+
status: CleaningAssignmentStatus.ASSIGNED,
190+
})
191+
.andWhere('a.scheduleId != :mySchedule', {
192+
mySchedule: myAssignment.scheduleId,
193+
})
169194
.andWhere('s.cleaningDate >= :today', { today })
170-
.andWhere('s.status = :schedStatus', { schedStatus: CleaningScheduleStatus.SCHEDULED })
195+
.andWhere('s.status = :schedStatus', {
196+
schedStatus: CleaningScheduleStatus.SCHEDULED,
197+
})
171198
.andWhere('r.deletedAt IS NULL')
172199
.orderBy('s.cleaningDate', 'ASC')
173200
.getRawMany<{
@@ -212,7 +239,8 @@ export class CleaningTradeService {
212239
status: CleaningTradeStatus.PENDING,
213240
},
214241
});
215-
if (existing) throw new BusinessError(CleaningErrorCode.TRADE_ALREADY_PENDING);
242+
if (existing)
243+
throw new BusinessError(CleaningErrorCode.TRADE_ALREADY_PENDING);
216244

217245
return this.tradeRepo.save(
218246
this.tradeRepo.create({
@@ -242,15 +270,19 @@ export class CleaningTradeService {
242270
throw new BusinessError(CleaningErrorCode.TRADE_FORBIDDEN);
243271

244272
if (!accept) {
245-
await this.tradeRepo.update(tradeId, { status: CleaningTradeStatus.REJECTED });
273+
await this.tradeRepo.update(tradeId, {
274+
status: CleaningTradeStatus.REJECTED,
275+
});
246276
return;
247277
}
248278

249279
await this.swapAssignments(
250280
trade.requesterAssignmentId,
251281
trade.targetAssignmentId,
252282
);
253-
await this.tradeRepo.update(tradeId, { status: CleaningTradeStatus.ACCEPTED });
283+
await this.tradeRepo.update(tradeId, {
284+
status: CleaningTradeStatus.ACCEPTED,
285+
});
254286
}
255287

256288
// 두 배정의 담당자를 바꾸기 전에 같은 일정/중복 담당자 충돌을 먼저 막는다.
@@ -259,7 +291,8 @@ export class CleaningTradeService {
259291
this.assignmentRepo.findOne({ where: { id: id1 } }),
260292
this.assignmentRepo.findOne({ where: { id: id2 } }),
261293
]);
262-
if (!a1 || !a2) throw new BusinessError(CleaningErrorCode.ASSIGNMENT_NOT_FOUND);
294+
if (!a1 || !a2)
295+
throw new BusinessError(CleaningErrorCode.ASSIGNMENT_NOT_FOUND);
263296
if (
264297
a1.status !== CleaningAssignmentStatus.ASSIGNED ||
265298
a2.status !== CleaningAssignmentStatus.ASSIGNED
@@ -366,9 +399,13 @@ export class CleaningTradeService {
366399
'res.name AS "resourceName"',
367400
])
368401
.where('s.ruleId = :ruleId', { ruleId })
369-
.andWhere('a.status = :status', { status: CleaningAssignmentStatus.ASSIGNED })
402+
.andWhere('a.status = :status', {
403+
status: CleaningAssignmentStatus.ASSIGNED,
404+
})
370405
.andWhere('s.cleaningDate >= :today', { today })
371-
.andWhere('s.status = :schedStatus', { schedStatus: CleaningScheduleStatus.SCHEDULED })
406+
.andWhere('s.status = :schedStatus', {
407+
schedStatus: CleaningScheduleStatus.SCHEDULED,
408+
})
372409
.orderBy('s.cleaningDate', 'ASC')
373410
.getRawMany<{
374411
id: number;
@@ -419,7 +456,9 @@ export class CleaningTradeService {
419456
if (!requester || requester.userId !== userId)
420457
throw new BusinessError(CleaningErrorCode.TRADE_FORBIDDEN);
421458

422-
await this.tradeRepo.update(tradeId, { status: CleaningTradeStatus.CANCELED });
459+
await this.tradeRepo.update(tradeId, {
460+
status: CleaningTradeStatus.CANCELED,
461+
});
423462
}
424463

425464
private async getCoAssigneeNames(
@@ -432,7 +471,9 @@ export class CleaningTradeService {
432471
.select('u.name', 'name')
433472
.where('a.scheduleId = :scheduleId', { scheduleId })
434473
.andWhere('a.userId != :excludeUserId', { excludeUserId })
435-
.andWhere('a.status = :status', { status: CleaningAssignmentStatus.ASSIGNED })
474+
.andWhere('a.status = :status', {
475+
status: CleaningAssignmentStatus.ASSIGNED,
476+
})
436477
.getRawMany<{ name: string }>();
437478
return rows.map((r) => r.name);
438479
}

src/cleaning/view/cleaning-trade.view.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export class CleaningTradeView {
6565
});
6666
} else {
6767
for (const { trade, myAssignment, targetAssignment } of requests) {
68-
const [myY, myM, myD] = myAssignment.cleaningDate.split('-').map(Number);
68+
const [myY, myM, myD] = myAssignment.cleaningDate
69+
.split('-')
70+
.map(Number);
6971
const [tgtY, tgtM, tgtD] = targetAssignment.cleaningDate
7072
.split('-')
7173
.map(Number);

src/common/errors/user.errors.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { createErrorDomain } from './base.error';
22

33
const { codes, messages } = createErrorDomain('USER', {
44
ADMIN_REQUIRED: '이 기능은 조교 이상 권한이 필요합니다.',
5-
ADMIN_OR_CLASS_REP_REQUIRED: '이 기능은 교수, 조교 또는 반대표만 사용할 수 있습니다.',
6-
ACTIVE_REQUIRED: '활성화된 사용자만 이용 가능합니다. 먼저 회원가입을 완료해주세요.',
5+
ADMIN_OR_CLASS_REP_REQUIRED:
6+
'이 기능은 교수, 조교 또는 반대표만 사용할 수 있습니다.',
7+
ACTIVE_REQUIRED:
8+
'활성화된 사용자만 이용 가능합니다. 먼저 회원가입을 완료해주세요.',
79
USER_NOT_FOUND: '사용자 정보를 찾을 수 없습니다.',
810
CANNOT_EDIT_PENDING_USER:
911
'승인 대기 또는 미가입 상태의 유저는 편집할 수 없습니다.\n가입 승인 관리에서 먼저 처리해주세요.',

src/migrations/1778064597031-AddCleaningEntities.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ export class AddCleaningEntities1778064597031 implements MigrationInterface {
9595
`ALTER TABLE "cleaning_rules" DROP CONSTRAINT "FK_cleaning_rules_studentClass"`,
9696
);
9797
await queryRunner.query(`DROP TABLE "cleaning_trades"`);
98-
await queryRunner.query(
99-
`DROP TYPE "public"."cleaning_trades_status_enum"`,
100-
);
98+
await queryRunner.query(`DROP TYPE "public"."cleaning_trades_status_enum"`);
10199
await queryRunner.query(`DROP TABLE "cleaning_assignments"`);
102100
await queryRunner.query(
103101
`DROP TYPE "public"."cleaning_assignments_status_enum"`,

src/resource/resource.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import { UserModule } from '../user/user.module';
1313
import { GoogleModule } from '../google/google.module';
1414

1515
@Module({
16-
imports: [TypeOrmModule.forFeature([Resource]), forwardRef(() => UserModule), GoogleModule],
16+
imports: [
17+
TypeOrmModule.forFeature([Resource]),
18+
forwardRef(() => UserModule),
19+
GoogleModule,
20+
],
1721
controllers: [
1822
ResourceController,
1923
StudyRoomController,

0 commit comments

Comments
 (0)