Skip to content

Commit e0f3d3d

Browse files
committed
refactor:근무지명, 색갈 유저 알바스케줄에 추가
1 parent 7b7970f commit e0f3d3d

5 files changed

Lines changed: 67 additions & 43 deletions

File tree

prisma/schema.prisma

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ model user_alba_schedule {
167167
memo String? @db.VarChar(256)
168168
address String? @db.Text
169169
category String? @db.Text
170+
workplace_name String? @db.VarChar(100)
171+
workplace_color String? @db.VarChar(7)
170172
user user @relation(fields: [user_id], references: [user_id], onDelete: Cascade, onUpdate: NoAction, map: "FK_user_TO_alba_schedule")
171173
user_work_log user_work_log[]
172174

src/DTO/user_alba_schedule_dto.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export interface CreateManualScheduleBody {
55
workplace?: string;
66
work_date?: string;
77
work_time?: string;
8+
workplace_name?: string;
9+
workplace_color?: string;
810
day_of_week?: user_alba_schedule_day_of_week; // 실제 enum 타입으로 바꿔도 됨
911
repeat_type?: user_alba_schedule_repeat_type; // 실제 enum 타입으로 바꿔도 됨
1012
repeat_days?: string | null;
@@ -16,6 +18,8 @@ export interface UserAlbaScheduleItemDTO {
1618
workplace?: string;
1719
work_date?: string;
1820
work_time?: string;
21+
workplace_name?: string;
22+
workplace_color?: string;
1923
day_of_week?: user_alba_schedule_day_of_week; // 실제 enum 타입으로 바꿔도 됨
2024
repeat_type?: user_alba_schedule_repeat_type; // 실제 enum 타입으로 바꿔도 됨
2125
repeat_days?: string | null;
@@ -27,6 +31,8 @@ export interface UpdateManualScheduleBody {
2731
workplace?: string;
2832
work_date?: string;
2933
work_time?: string;
34+
workplace_name?: string;
35+
workplace_color?: string;
3036
day_of_week?: user_alba_schedule_day_of_week; // 실제 enum 타입으로 바꿔도 됨
3137
repeat_type?: user_alba_schedule_repeat_type; // 실제 enum 타입으로 바꿔도 됨
3238
repeat_days?: string | null;

src/controller/user_alba_schedule_controller.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,35 +81,35 @@ export class UserAlbaScheduleController extends Controller {
8181
/**
8282
* 내 유저 알바 스케줄 단건 조회(상세)
8383
*/
84-
@Security('jwt')
85-
@Get('{userAlbaScheduleId}')
86-
@SuccessResponse(200, '유저 알바 스케줄 단건 조회 성공')
87-
@Response<TsoaFailResponse<any>>(401, 'Unauthorized', {
88-
resultType: 'FAIL' as any,
89-
error: { errorCode: 'EC401', errorMessage: '인증이 필요합니다.', data: null },
90-
success: null,
91-
})
92-
@Response<TsoaFailResponse<any>>(404, 'Not Found', {
93-
resultType: 'FAIL' as any,
94-
error: { errorCode: 'EC404', errorMessage: '스케줄을 찾을 수 없습니다.', data: null },
95-
success: null,
96-
})
97-
@Response<TsoaFailResponse<any>>(500, 'Internal Server Error', {
98-
resultType: 'FAIL' as any,
99-
error: { errorCode: 'EC500', errorMessage: '서버 오류가 발생했습니다.', data: null },
100-
success: null,
101-
})
102-
public async getMySchedule(
103-
@Request() req: ExpressRequest,
104-
@Path() userAlbaScheduleId: string,
105-
): Promise<TsoaSuccessResponse<any>> {
106-
const userUuid = (req as any).user?.id as string;
84+
// @Security('jwt')
85+
// @Get('{userAlbaScheduleId}')
86+
// @SuccessResponse(200, '유저 알바 스케줄 단건 조회 성공')
87+
// @Response<TsoaFailResponse<any>>(401, 'Unauthorized', {
88+
// resultType: 'FAIL' as any,
89+
// error: { errorCode: 'EC401', errorMessage: '인증이 필요합니다.', data: null },
90+
// success: null,
91+
// })
92+
// @Response<TsoaFailResponse<any>>(404, 'Not Found', {
93+
// resultType: 'FAIL' as any,
94+
// error: { errorCode: 'EC404', errorMessage: '스케줄을 찾을 수 없습니다.', data: null },
95+
// success: null,
96+
// })
97+
// @Response<TsoaFailResponse<any>>(500, 'Internal Server Error', {
98+
// resultType: 'FAIL' as any,
99+
// error: { errorCode: 'EC500', errorMessage: '서버 오류가 발생했습니다.', data: null },
100+
// success: null,
101+
// })
102+
// public async getMySchedule(
103+
// @Request() req: ExpressRequest,
104+
// @Path() userAlbaScheduleId: string,
105+
// ): Promise<TsoaSuccessResponse<any>> {
106+
// const userUuid = (req as any).user?.id as string;
107107

108-
const schedule = await userAlbaScheduleService.getMyScheduleById(userUuid, userAlbaScheduleId);
108+
// //const schedule = await userAlbaScheduleService.getMyScheduleById(userUuid, userAlbaScheduleId);
109109

110-
this.setStatus(200);
111-
return new TsoaSuccessResponse(schedule);
112-
}
110+
// this.setStatus(200);
111+
// // return new TsoaSuccessResponse(schedule);
112+
// }
113113

114114

115115

src/repository/user_alba_schedule_repository.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface CreateUserAlbaScheduleRepoInput {
99
workplace?: string;
1010
work_date?: string;
1111
work_time?: string;
12+
workplace_name?: string;
13+
workplace_color?: string;
1214

1315
day_of_week?: user_alba_schedule_day_of_week;
1416
repeat_type?: user_alba_schedule_repeat_type;
@@ -52,6 +54,8 @@ export class UserAlbaScheduleRepository {
5254
select: {
5355
user_alba_schedule_id: true,
5456
workplace: true,
57+
workplace_name: true,
58+
workplace_color: true,
5559
work_date: true,
5660
work_time: true,
5761
day_of_week: true,
@@ -68,6 +72,8 @@ export class UserAlbaScheduleRepository {
6872
user_id: uuidToBin(userId),
6973

7074
workplace: input.workplace ?? null,
75+
workplace_name: input.workplace_name ?? null,
76+
workplace_color: input.workplace_color ?? null,
7177
work_date: input.work_date ?? null,
7278
work_time: input.work_time ?? null,
7379

@@ -109,6 +115,8 @@ export class UserAlbaScheduleRepository {
109115
data: {
110116
user_id: userIdBin,
111117
workplace: input.workplace ?? null,
118+
workplace_name: input.workplace_name ?? null,
119+
workplace_color: input.workplace_color ?? null,
112120
work_date: input.work_date ?? null,
113121
work_time: input.work_time ?? null,
114122
day_of_week: input.day_of_week ?? null,
@@ -169,6 +177,8 @@ export class UserAlbaScheduleRepository {
169177
data: {
170178
workplace: body.workplace,
171179
work_date: body.work_date,
180+
workplace_name: body.workplace_name, // ✅ [CHANGED]
181+
workplace_color: body.workplace_color,
172182
work_time: body.work_time,
173183

174184
day_of_week: body.day_of_week,

src/service/user_alba_schedule_service.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ export async function listMySchedules(userId: string, q: { month?: string }) {
151151
const schedules = rows.map((s: any) => ({
152152
user_alba_schedule_id: binToUuid(s.user_alba_schedule_id),
153153
workplace: s.workplace ?? null,
154+
workplace_name: s.workplace_name ?? null,
155+
workplace_color: s.workplace_color ?? null,
154156
work_date: s.work_date ?? null,
155157
work_time: s.work_time ?? null,
156158
day_of_week: s.day_of_week ?? null,
@@ -164,22 +166,24 @@ export async function listMySchedules(userId: string, q: { month?: string }) {
164166
}
165167

166168
/** 단건 조회 */
167-
export async function getMyScheduleById(userId: string, scheduleId: string) {
168-
const s = await scheduleRepo.findDetailByIdAndUserId(userId, scheduleId);
169-
if (!s) throw new CustomError('EC404', 404, '스케줄을 찾을 수 없습니다.', null);
170-
171-
return {
172-
user_alba_schedule_id: binToUuid(s.user_alba_schedule_id as unknown as Uint8Array),
173-
workplace: s.workplace ?? null,
174-
work_date: s.work_date ?? null,
175-
work_time: s.work_time ?? null,
176-
day_of_week: s.day_of_week ?? null,
177-
repeat_type: s.repeat_type ?? null,
178-
repeat_days: s.repeat_days ?? null,
179-
hourly_wage: s.hourly_wage ?? null,
180-
memo: s.memo ?? null,
181-
};
182-
}
169+
// export async function getMyScheduleById(userId: string, scheduleId: string) {
170+
// const s = await scheduleRepo.findDetailByIdAndUserId(userId, scheduleId);
171+
// if (!s) throw new CustomError('EC404', 404, '스케줄을 찾을 수 없습니다.', null);
172+
173+
// return {
174+
// user_alba_schedule_id: binToUuid(s.user_alba_schedule_id as unknown as Uint8Array),
175+
// workplace: s.workplace ?? null,
176+
// work_date: s.work_date ?? null,
177+
// work_time: s.work_time ?? null,
178+
// workplace_name: s.workplace_name ?? null,
179+
// workplace_color: s.workplace_color ?? null,
180+
// day_of_week: s.day_of_week ?? null,
181+
// repeat_type: s.repeat_type ?? null,
182+
// repeat_days: s.repeat_days ?? null,
183+
// hourly_wage: s.hourly_wage ?? null,
184+
// memo: s.memo ?? null,
185+
// };
186+
// }
183187

184188
// 유저 수동 입력 스케줄 생성
185189
export async function createManual(
@@ -190,6 +194,8 @@ export async function createManual(
190194

191195
const scheduleInput = {
192196
workplace: body.workplace,
197+
workplace_name: body.workplace_name,
198+
workplace_color: body.workplace_color,
193199
work_date: body.work_date,
194200
work_time: body.work_time,
195201
day_of_week: body.day_of_week,

0 commit comments

Comments
 (0)