Skip to content

Commit

Permalink
Fix/calendar setting (#770)
Browse files Browse the repository at this point in the history
### ๐Ÿšฉ ๊ด€๋ จ์‚ฌํ•ญ


### ๐Ÿ“ข ์ „๋‹ฌ์‚ฌํ•ญ

๊ธฐ์กด์— ํŒŒ์ผ๊ณผ ๊ฐ™์ด ์—…๋กœ๋“œ ํ•  ๊ฒฝ์šฐ, json ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•ด application/octet-stream ์œผ๋กœ ์ž๋™ ๋ณ€๊ฒฝ์ด ๋˜์–ด
๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์—†๋Š” ๋ฌธ์ œ์ƒํ™ฉ์„ ๋ฐœ๊ฒฌํ•˜์—ฌ ํ•ด๋‹น ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ์„ค์ •ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

swagger์™€ postman ๋ชจ๋‘ ์ •์ƒ ์ž‘๋™ ํ™•์ธํ•˜์˜€์Šต๋‹ˆ๋‹ค.

### ๐Ÿ“ธ ์Šคํฌ๋ฆฐ์ƒท

<img width="1280" alt="image"
src="https://github.com/user-attachments/assets/946e1c20-41f8-4f10-b400-fdaca29ff817">

<img width="1665" alt="image"
src="https://github.com/user-attachments/assets/9aa5aee7-0d92-4002-86a3-4a22beae688a">



### ๐Ÿ“ƒ ์ง„ํ–‰์‚ฌํ•ญ
- [ ] done1
- [ ] done2 (์ง„ํ–‰๋˜์—ˆ์–ด์•ผ ํ•˜๋Š”๋ฐ ๋ฏธ์ฒ˜ ํ•˜์ง€ ๋ชปํ•œ ๋ถ€๋ถ„ ํ˜น์€ ๊ด€๋ จํ•˜์—ฌ ์•ž์œผ๋กœ ์ง„ํ–‰๋˜์–ด์•ผ ํ•˜๋Š” ๋ถ€๋ถ„๋„ ์ „๋ถ€ ์ ์–ด์„œ ์ฒดํฌ
ํ‘œ์‹œ๋กœ ๊ด€๋ฆฌํ•ด์ฃผ์„ธ์š”.)


### โš™๏ธ ๊ธฐํƒ€์‚ฌํ•ญ
๊ธฐํƒ€ ์ฐธ๊ณ ์‚ฌํ•ญ์„ ์ ์–ด์ฃผ์„ธ์š”.

๊ฐœ๋ฐœ๊ธฐ๊ฐ„:
  • Loading branch information
sanggae4133 authored Nov 27, 2024
2 parents b962756 + 2400c58 commit c50a9c5
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/main/java/net/causw/adapter/web/CalendarController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.causw.application.dto.calendar.CalendarsResponseDto;
import net.causw.domain.exceptions.BadRequestException;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -68,7 +69,7 @@ public CalendarResponseDto findHomeCalendar() {
return calendarService.findCalendar();
}

@PostMapping
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
@Operation(summary = "์บ˜๋ฆฐ๋” ์ƒ์„ฑ API", description = "์บ˜๋ฆฐ๋” ์ƒ์„ฑ API ์ž…๋‹ˆ๋‹ค.")
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified() and " +
Expand All @@ -87,7 +88,7 @@ public CalendarResponseDto createCalendar(
return calendarService.createCalendar(calendarCreateRequestDto, image);
}

@PutMapping("/{calendarId}")
@PutMapping(value = "/{calendarId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "์บ˜๋ฆฐ๋” ์ˆ˜์ • API", description = "์บ˜๋ฆฐ๋” ์ˆ˜์ • API ์ž…๋‹ˆ๋‹ค.")
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified() and " +
"hasAnyRole('ADMIN','PERSIDENT', 'VICE_PRESIDENT')")
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/causw/adapter/web/CircleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -240,7 +241,7 @@ public List<CircleMemberResponseDto> findCircleMemberList(
* @param circleCreateRequestDto ๋™์•„๋ฆฌ ์ƒ์„ฑ ์ •๋ณด
* @return Long
*/
@PostMapping
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified() and " +
"hasAnyRole('ADMIN','PERSIDENT', 'VICE_PRESIDENT')")
Expand Down Expand Up @@ -279,7 +280,7 @@ public void create(
* @param circleUpdateRequestDto ๋™์•„๋ฆฌ ์ƒ์„ฑ ์ •๋ณด
* @return Long
*/
@PutMapping(value = "/{circleId}")
@PutMapping(value = "/{circleId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified() and " +
"hasAnyRole('ADMIN','PERSIDENT', 'VICE_PRESIDENT', 'LEADER_CIRCLE')")
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/causw/adapter/web/EventController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.causw.application.dto.event.EventsResponseDto;
import net.causw.application.event.EventService;
import net.causw.domain.exceptions.BadRequestException;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -37,7 +38,7 @@ public EventsResponseDto findEvents() {
return eventService.findEvents();
}

@PostMapping
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "์ด๋ฒคํŠธ ์ƒ์„ฑ API", description = "์ด๋ฒคํŠธ ์ƒ์„ฑ API ์ž…๋‹ˆ๋‹ค.")
@ApiResponses({
@ApiResponse(responseCode = "201", description = "CREATED", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))),
Expand All @@ -54,7 +55,7 @@ public EventResponseDto createEvent(
return eventService.createEvent(eventCreateRequestDto, eventImage);
}

@PutMapping("/{eventId}")
@PutMapping(value = "/{eventId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "์ด๋ฒคํŠธ ์ˆ˜์ • API", description = "์ด๋ฒคํŠธ ์ˆ˜์ • API ์ž…๋‹ˆ๋‹ค.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))),
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/causw/adapter/web/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.causw.domain.exceptions.InternalServerException;
import net.causw.domain.exceptions.UnauthorizedException;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -126,7 +127,7 @@ public BoardPostsResponseDto findAllAppNotice(
return this.postService.findAllAppNotice(userDetails.getUser(), pageNum);
}

@PostMapping
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified()")
@Operation(summary = "๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ API(์™„๋ฃŒ)",
Expand Down Expand Up @@ -157,7 +158,7 @@ public PostCreateResponseDto createPost(
return this.postService.createPost(userDetails.getUser(), postCreateRequestDto, attachImageList);
}

@PostMapping("/form")
@PostMapping(value = "/form", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified()")
@Operation(summary = "์‹ ์ฒญ์„œ ์ฒจ๋ถ€ ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ API(์™„๋ฃŒ)",
Expand Down Expand Up @@ -220,7 +221,7 @@ public void deletePost(
postService.deletePost(userDetails.getUser(), id);
}

@PutMapping(value = "/{id}")
@PutMapping(value = "/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified()")
@Operation(summary = "๊ฒŒ์‹œ๊ธ€ ์—…๋ฐ์ดํŠธ API(์™„๋ฃŒ)",
Expand Down Expand Up @@ -263,7 +264,7 @@ public void updatePost(
);
}

@PutMapping(value = "/{id}/form")
@PutMapping(value = "/{id}/form", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified()")
@Operation(summary = "์‹ ์ฒญ์„œ ์ฒจ๋ถ€ ๊ฒŒ์‹œ๊ธ€ ์—…๋ฐ์ดํŠธ API(์™„๋ฃŒ)",
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/causw/adapter/web/StorageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.causw.application.dto.file.FileResponseDto;
import net.causw.application.uuidFile.UuidFileService;
import net.causw.domain.model.enums.uuidFile.FilePath;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -17,7 +18,7 @@ public class StorageController {

private final UuidFileService uuidFileService;

@PostMapping(value = "/upload", consumes = "multipart/form-data")
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('ADMIN')")
public FileResponseDto post(
@RequestPart("file") MultipartFile multipartFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -214,7 +215,7 @@ public CurrentUserAcademicRecordApplicationResponseDto getCurrentUserAcademicRec
* @param imageFileList
* @return
*/
@PostMapping(value = "/application/create")
@PostMapping(value = "/application/create", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
@PreAuthorize("@securityService.isActiveAndNotNoneUser()")
@Operation(summary = "์‚ฌ์šฉ์ž ๋ณธ์ธ์˜ ํ•™์  ์ฆ๋น™ ์„œ๋ฅ˜ ์ œ์ถœ",
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/causw/adapter/web/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -301,7 +302,7 @@ public DuplicatedCheckResponseDto isDuplicatedStudentId(@PathVariable("studentId
* @param userUpdateDto
* @return UserResponseDto
*/
@PutMapping
@PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.OK)
@PreAuthorize("@securityService.isActiveAndNotNoneUserAndAcademicRecordCertified()")
@Operation(summary = "์‚ฌ์šฉ์ž ์ •๋ณด ์—…๋ฐ์ดํŠธ API (์™„๋ฃŒ)")
Expand Down Expand Up @@ -479,7 +480,7 @@ public Page<UserAdmissionsResponseDto> findAllAdmissions(
return this.userService.findAllAdmissions(userDetails.getUser(), name, pageNum);
}

@PostMapping(value = "/admissions/apply")
@PostMapping(value = "/admissions/apply", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
@Operation(summary = "์Šน์ธ ์‹ ์ฒญ์„œ ์ž‘์„ฑ API (์™„๋ฃŒ)", description = "๊ฐ€์ž… ์‹ ์ฒญ api์ž…๋‹ˆ๋‹ค.")
@ApiResponses({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.causw.config.security;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;

import java.lang.reflect.Type;

@Component
public class OctetStreamReadMsgConverter extends AbstractJackson2HttpMessageConverter {
@Autowired
public OctetStreamReadMsgConverter(ObjectMapper objectMapper) {
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM);
}

@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
return false;
}

@Override
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) {
return false;
}

@Override
protected boolean canWrite(MediaType mediaType) {
return false;
}
}
23 changes: 23 additions & 0 deletions src/main/java/net/causw/config/security/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.causw.config.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class WebConfig implements WebMvcConfigurer {
private OctetStreamReadMsgConverter octetStreamReadMsgConverter;

@Autowired
public WebConfig(OctetStreamReadMsgConverter octetStreamReadMsgConverter) {
this.octetStreamReadMsgConverter = octetStreamReadMsgConverter;
}

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(octetStreamReadMsgConverter);
}
}

0 comments on commit c50a9c5

Please sign in to comment.