Skip to content

Commit ebace63

Browse files
authored
Merge pull request #215 from TwoSSome/feature/캘린더-플랜
Feature/캘린더 플랜
2 parents 061d5d4 + 7351090 commit ebace63

15 files changed

Lines changed: 347 additions & 1 deletion

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ src/test/
1010
src/test/java/towssome/server/ServerApplicationTests.java
1111
기능-추가.md
1212
버그-수정.md
13+
src/main/java/towssome/server/temp_image/*
1314

1415
### STS ###
1516
.apt_generated

src/main/java/towssome/server/controller/CalendarController.java

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,85 @@ public ResponseEntity<?> deleteCalendarPost(@PathVariable Long id) {
255255
return new ResponseEntity<>(HttpStatus.OK);
256256
}
257257

258+
@Operation(summary = "캘린더 플랜 조회 API",
259+
description = "캘린더 일정 내의 캘린더 플랜을 조회합니다. 해당 캘린더 일정을 찾지 못하면 404 에러를 반환합니다")
260+
@ApiResponses(value = {
261+
@ApiResponse(responseCode = "200", description = "플랜 조회 성공",
262+
content = @Content(schema = @Schema(implementation = CalendarPlanContentsInfoList.class))),
263+
@ApiResponse(responseCode = "404", description = "플랜 아이디가 잘못됨",
264+
content = @Content(schema = @Schema(implementation = ErrorResult.class))
265+
)
266+
})
267+
@Parameter(description = "조회할 캘린더 일정의 id", required = true, name = "id")
268+
@GetMapping("/plan/{id}")
269+
public ResponseEntity<?> getPlan(@PathVariable Long id){
270+
271+
CalendarPlanContentsInfoList result = calendarService.getCalendarPlan(id);
272+
273+
return new ResponseEntity<>(result, HttpStatus.OK);
274+
}
275+
276+
@Operation(summary = "캘린더 플랜 생성 API",
277+
description = "캘린더 플랜을 생성합니다. 캘린더 일정의 ID가 올바르지 않으면 404 에러를 반환합니다")
278+
@ApiResponses(value = {
279+
@ApiResponse(responseCode = "200", description = "플랜 생성 성공",
280+
content = @Content(schema = @Schema(implementation = CreateRes.class))),
281+
@ApiResponse(responseCode = "404", description = "게시글 일정 ID가 잘못됨",
282+
content = @Content(schema = @Schema(implementation = ErrorResult.class))
283+
)
284+
})
285+
@PostMapping("/plan/create")
286+
public ResponseEntity<?> createPlan(@RequestBody createCalendarPlanReq req){
287+
288+
CalendarPlan calendarPlan = calendarService.createCalendarPlan(new CreateCalendarPlanDTO(
289+
req.body(),
290+
req.calendarScheduleId(),
291+
req.localDate()
292+
));
293+
294+
return new ResponseEntity<>(new CreateRes(calendarPlan.getId()), HttpStatus.OK);
295+
}
296+
297+
@Operation(summary = "캘린더 플랜 업데이트 API",
298+
description = "캘린더 플랜을 수정합니다. 해당 플랜을 찾지 못하면 404 코드를 반환합니다")
299+
@ApiResponses(value = {
300+
@ApiResponse(responseCode = "200", description = "플랜 수정 성공"
301+
),
302+
@ApiResponse(responseCode = "404", description = "플랜 아이디가 잘못됨",
303+
content = @Content(schema = @Schema(implementation = ErrorResult.class))
304+
)
305+
})
306+
@Parameter(name = "id", description = "캘린더 플랜의 id", required = true)
307+
@PostMapping("/plan/{id}/update")
308+
public ResponseEntity<?> updatePlan(@PathVariable Long id, @RequestBody UpdateCalendarPlanReq req){
309+
310+
calendarService.updateCalendarPlan(new UpdateCalendarPlanDTO(
311+
id,
312+
req.body(),
313+
req.localDate()
314+
));
315+
316+
return new ResponseEntity<>(HttpStatus.OK);
317+
}
318+
319+
@Operation(summary = "캘린더 플랜 삭제 API",
320+
description = "캘린더 플랜을 삭제합니다. 해당 플랜을 찾지 못하면 404 코드를 반환합니다")
321+
@ApiResponses(value = {
322+
@ApiResponse(responseCode = "200", description = "플랜 수정 성공"
323+
),
324+
@ApiResponse(responseCode = "404", description = "플랜 아이디가 잘못됨",
325+
content = @Content(schema = @Schema(implementation = ErrorResult.class))
326+
)
327+
})
328+
@Parameter(name = "id", description = "캘린더 플랜의 id", required = true)
329+
@PostMapping("/plan/{id}/delete")
330+
public ResponseEntity<?> deletePlan(@PathVariable Long id){
331+
332+
calendarService.deleteCalendarPlan(id);
333+
334+
return new ResponseEntity<>(HttpStatus.OK);
335+
}
336+
258337
@Operation(summary = "캘린더 일정 생성 API",
259338
description = "캘린더 일정을 생성합니다. 캘린더 태그의 ID가 올바르지 않으면 404 에러를 반환합니다")
260339
@ApiResponses(value = {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package towssome.server.controller;
2+
3+
import lombok.RequiredArgsConstructor;
4+
import org.springframework.http.HttpStatus;
5+
import org.springframework.http.ResponseEntity;
6+
import org.springframework.web.bind.annotation.PostMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
import org.springframework.web.multipart.MultipartFile;
9+
import towssome.server.dto.TempImageNameRes;
10+
import towssome.server.service.MarkdownService;
11+
12+
@RestController
13+
@RequiredArgsConstructor
14+
public class MarkdownController {
15+
16+
private final MarkdownService markdownService;
17+
18+
@PostMapping("/markdown/image")
19+
public ResponseEntity<?> saveTempImage(MultipartFile file){
20+
21+
String tempImageName = markdownService.saveAndGetTempImage(file);
22+
23+
return new ResponseEntity<>(new TempImageNameRes(tempImageName), HttpStatus.OK);
24+
}
25+
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package towssome.server.dto;
2+
3+
import java.time.LocalDate;
4+
5+
public record CalendarPlanContentsInfo(
6+
LocalDate planDate,
7+
String body
8+
) {
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package towssome.server.dto;
2+
3+
import java.util.List;
4+
5+
public record CalendarPlanContentsInfoList(
6+
List<CalendarPlanContentsInfo> calendarPlanContents
7+
) {
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package towssome.server.dto;
2+
3+
import towssome.server.entity.CalendarSchedule;
4+
5+
import java.time.LocalDate;
6+
7+
public record CreateCalendarPlanDTO(
8+
String body,
9+
Long calendarScheduleId,
10+
LocalDate localDate
11+
) {
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package towssome.server.dto;
2+
3+
public record TempImageNameRes(
4+
String tempImageName
5+
) {
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package towssome.server.dto;
2+
3+
import java.time.LocalDate;
4+
5+
public record UpdateCalendarPlanDTO(
6+
Long id,
7+
String body,
8+
LocalDate localDate
9+
) {
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package towssome.server.dto;
2+
3+
import java.time.LocalDate;
4+
5+
public record UpdateCalendarPlanReq(
6+
LocalDate localDate,
7+
String body
8+
) {
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package towssome.server.dto;
2+
3+
import java.time.LocalDate;
4+
5+
public record createCalendarPlanReq(
6+
Long calendarScheduleId,
7+
String body,
8+
LocalDate localDate
9+
) {
10+
}

0 commit comments

Comments
 (0)