Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 권한 추가 및 분실물 게시글 작성 response 수정 #1173

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ ResponseEntity<LostItemArticleResponse> getLostItemArticle(
)
@Operation(summary = "분실물 게시글 등록")
@PostMapping("/lost-item")
ResponseEntity<Void> createLostItemArticle(
ResponseEntity<LostItemArticleResponse> createLostItemArticle(
@Auth(permit = {COUNCIL}) Integer councilId,
@RequestBody @Valid LostItemArticlesRequest lostItemArticlesRequest
);

@ApiResponses(
value = {
@ApiResponse(responseCode = "201"),
@ApiResponse(responseCode = "204"),
@ApiResponse(responseCode = "401", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "403", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "404", content = @Content(schema = @Schema(hidden = true))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import static in.koreatech.koin.domain.user.model.UserType.*;

import java.net.URI;
import java.util.List;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -97,12 +99,12 @@ public ResponseEntity<LostItemArticleResponse> getLostItemArticle(
}

@PostMapping("/lost-item")
public ResponseEntity<Void> createLostItemArticle(
public ResponseEntity<LostItemArticleResponse> createLostItemArticle(
@Auth(permit = {COUNCIL}) Integer councilId,
@RequestBody @Valid LostItemArticlesRequest lostItemArticlesRequest
) {
articleService.createLostItemArticle(councilId, lostItemArticlesRequest);
return ResponseEntity.ok().build();
LostItemArticleResponse response = articleService.createLostItemArticle(councilId, lostItemArticlesRequest);
return ResponseEntity.status(HttpStatus.CREATED).body(response);
}

@DeleteMapping("/lost-item/{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public LostItemArticleResponse getLostItemArticle(Integer articleId) {
}

@Transactional
public void createLostItemArticle(Integer userId, LostItemArticlesRequest requests) {
public LostItemArticleResponse createLostItemArticle(Integer userId, LostItemArticlesRequest requests) {
Board lostItemBoard = boardRepository.getById(LOST_ITEM_BOARD_ID);
List<Article> newArticles = new ArrayList<>();
User user = userRepository.getById(userId);
Expand All @@ -331,6 +331,7 @@ public void createLostItemArticle(Integer userId, LostItemArticlesRequest reques
}
);
sendKeywordNotification(newArticles);
return LostItemArticleResponse.from(newArticles.get(0));
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package in.koreatech.koin.domain.community.keyword.controller;

import static in.koreatech.koin.domain.user.model.UserType.ADMIN;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static in.koreatech.koin.domain.user.model.UserType.*;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down Expand Up @@ -40,7 +39,7 @@ public interface KeywordApi {
@PostMapping("/articles/keyword")
ResponseEntity<ArticleKeywordResponse> createKeyword(
@Valid @RequestBody ArticleKeywordCreateRequest request,
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
);

@ApiResponses(
Expand All @@ -56,7 +55,7 @@ ResponseEntity<ArticleKeywordResponse> createKeyword(
@DeleteMapping("/articles/keyword/{id}")
ResponseEntity<Void> deleteKeyword(
@PathVariable(value = "id") Integer keywordUserMapId,
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
);

@ApiResponses(
Expand All @@ -68,7 +67,7 @@ ResponseEntity<Void> deleteKeyword(
@Operation(summary = "자신의 알림 키워드 전체 조회")
@GetMapping("/articles/keyword/me")
ResponseEntity<ArticleKeywordsResponse> getMyKeywords(
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
);

@ApiResponses(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package in.koreatech.koin.domain.community.keyword.controller;

import static in.koreatech.koin.domain.user.model.UserType.ADMIN;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static in.koreatech.koin.domain.user.model.UserType.*;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down Expand Up @@ -32,7 +31,7 @@ public class KeywordController implements KeywordApi{
@PostMapping()
public ResponseEntity<ArticleKeywordResponse> createKeyword(
@Valid @RequestBody ArticleKeywordCreateRequest request,
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
) {
ArticleKeywordResponse response = keywordService.createKeyword(userId, request);
return ResponseEntity.ok(response);
Expand All @@ -41,15 +40,15 @@ public ResponseEntity<ArticleKeywordResponse> createKeyword(
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteKeyword(
@PathVariable(value = "id") Integer keywordUserMapId,
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
) {
keywordService.deleteKeyword(userId, keywordUserMapId);
return ResponseEntity.noContent().build();
}

@GetMapping("/me")
public ResponseEntity<ArticleKeywordsResponse> getMyKeywords(
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
) {
ArticleKeywordsResponse response = keywordService.getMyKeywords(userId);
return ResponseEntity.ok(response);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package in.koreatech.koin.domain.dining.controller;

import static in.koreatech.koin.domain.user.model.UserType.COOP;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static in.koreatech.koin.domain.user.model.UserType.*;

import java.time.LocalDate;
import java.util.List;
Expand Down Expand Up @@ -45,14 +44,14 @@ ResponseEntity<List<DiningResponse>> getDinings(
@Operation(summary = "식단 좋아요")
@PatchMapping("/dining/like")
ResponseEntity<Void> likeDining(
@Auth(permit = {STUDENT, COOP}) Integer userId,
@Auth(permit = {STUDENT, COOP, COUNCIL}) Integer userId,
@RequestParam Integer diningId
);

@Operation(summary = "식단 좋아요 취소")
@PatchMapping("/dining/like/cancel")
ResponseEntity<Void> likeDiningCancel(
@Auth(permit = {STUDENT, COOP}) Integer userId,
@Auth(permit = {STUDENT, COOP, COUNCIL}) Integer userId,
@RequestParam Integer diningId
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package in.koreatech.koin.domain.dining.controller;

import static in.koreatech.koin.domain.user.model.UserType.COOP;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static in.koreatech.koin.domain.user.model.UserType.*;

import java.time.LocalDate;
import java.util.List;
Expand Down Expand Up @@ -39,7 +38,7 @@ public ResponseEntity<List<DiningResponse>> getDinings(

@PatchMapping("/dining/like")
public ResponseEntity<Void> likeDining(
@Auth(permit = {STUDENT, COOP}) Integer userId,
@Auth(permit = {STUDENT, COOP, COUNCIL}) Integer userId,
@RequestParam Integer diningId
) {
diningService.likeDining(userId, diningId);
Expand All @@ -48,7 +47,7 @@ public ResponseEntity<Void> likeDining(

@PatchMapping("/dining/like/cancel")
public ResponseEntity<Void> likeDiningCancel(
@Auth(permit = {STUDENT, COOP}) Integer userId,
@Auth(permit = {STUDENT, COOP, COUNCIL}) Integer userId,
@RequestParam Integer diningId
) {
diningService.likeDiningCancel(userId, diningId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package in.koreatech.koin.domain.shop.controller;

import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static io.swagger.v3.oas.annotations.enums.ParameterIn.PATH;

Expand Down Expand Up @@ -120,6 +121,6 @@ ResponseEntity<RelatedKeywordResponse> getRelatedKeyword(
@PostMapping("/shops/{shopId}/call-notification")
ResponseEntity<Void> createCallNotification(
@Parameter(in = PATH) @PathVariable("shopId") Integer shopId,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package in.koreatech.koin.domain.shop.controller;

import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static io.swagger.v3.oas.annotations.enums.ParameterIn.PATH;

Expand Down Expand Up @@ -74,7 +75,7 @@ public ResponseEntity<RelatedKeywordResponse> getRelatedKeyword(
@PostMapping("/shops/{shopId}/call-notification")
public ResponseEntity<Void> createCallNotification(
@Parameter(in = PATH) @PathVariable("shopId") Integer shopId,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
) {
shopService.publishCallNotification(shopId, studentId);
return ResponseEntity.ok().build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package in.koreatech.koin.domain.shop.controller;

import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static io.swagger.v3.oas.annotations.enums.ParameterIn.PATH;

Expand Down Expand Up @@ -60,7 +61,7 @@ ResponseEntity<ShopReviewsResponse> getReviews(
ResponseEntity<ShopMyReviewsResponse> getMyReviews(
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestParam(name = "sorter", defaultValue = "LATEST") ReviewsSortCriteria sortBy,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
);

@ApiResponses(
Expand Down Expand Up @@ -90,7 +91,7 @@ ResponseEntity<ShopReviewResponse> getReview(
ResponseEntity<Void> createReview(
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestBody @Valid CreateReviewRequest createReviewRequest,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
);

@ApiResponses(
Expand All @@ -108,7 +109,7 @@ ResponseEntity<Void> modifyReview(
@Parameter(in = PATH) @PathVariable Integer reviewId,
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestBody @Valid ModifyReviewRequest modifyReviewRequest,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
);

@ApiResponses(
Expand All @@ -124,7 +125,7 @@ ResponseEntity<Void> modifyReview(
ResponseEntity<Void> deleteReview(
@Parameter(in = PATH) @PathVariable Integer reviewId,
@Parameter(in = PATH) @PathVariable Integer shopId,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
);

@ApiResponses(
Expand Down Expand Up @@ -152,6 +153,6 @@ ResponseEntity<Void> reportReview(
@Parameter(in = PATH) @PathVariable Integer reviewId,
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestBody @Valid ShopReviewReportRequest shopReviewReportRequest,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package in.koreatech.koin.domain.shop.controller;

import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static io.swagger.v3.oas.annotations.enums.ParameterIn.PATH;

Expand Down Expand Up @@ -50,7 +51,7 @@ public ResponseEntity<ShopReviewsResponse> getReviews(
public ResponseEntity<ShopMyReviewsResponse> getMyReviews(
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestParam(name = "sorter", defaultValue = "LATEST") ReviewsSortCriteria sortBy,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
) {
ShopMyReviewsResponse reviewsResponse = shopReviewService.getMyReviewsByShopId(shopId, studentId, sortBy);
return ResponseEntity.ok(reviewsResponse);
Expand All @@ -60,7 +61,7 @@ public ResponseEntity<ShopMyReviewsResponse> getMyReviews(
public ResponseEntity<Void> createReview(
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestBody @Valid CreateReviewRequest createReviewRequest,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
) {
shopReviewService.createReview(createReviewRequest, studentId, shopId);
return ResponseEntity.status(HttpStatus.CREATED).build();
Expand All @@ -71,7 +72,7 @@ public ResponseEntity<Void> modifyReview(
@Parameter(in = PATH) @PathVariable Integer reviewId,
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestBody @Valid ModifyReviewRequest modifyReviewRequest,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
) {
shopReviewService.modifyReview(modifyReviewRequest, reviewId, studentId);
return ResponseEntity.noContent().build();
Expand All @@ -81,7 +82,7 @@ public ResponseEntity<Void> modifyReview(
public ResponseEntity<Void> deleteReview(
@Parameter(in = PATH) @PathVariable Integer reviewId,
@Parameter(in = PATH) @PathVariable Integer shopId,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
) {
shopReviewService.deleteReview(reviewId, studentId);
return ResponseEntity.noContent().build();
Expand All @@ -99,7 +100,7 @@ public ResponseEntity<Void> reportReview(
@Parameter(in = PATH) @PathVariable Integer reviewId,
@Parameter(in = PATH) @PathVariable Integer shopId,
@RequestBody @Valid ShopReviewReportRequest shopReviewReportRequest,
@Auth(permit = {STUDENT}) Integer studentId
@Auth(permit = {STUDENT, COUNCIL}) Integer studentId
) {
shopReviewService.reportReview(shopId, reviewId, studentId, shopReviewReportRequest);
return ResponseEntity.noContent().build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package in.koreatech.koin.domain.student.controller;

import static in.koreatech.koin.domain.user.model.UserType.STUDENT;
import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -42,7 +43,7 @@ public interface StudentApi {
@SecurityRequirement(name = "Jwt Authentication")
@GetMapping("/user/student/me")
ResponseEntity<StudentResponse> getStudent(
@Auth(permit = STUDENT) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
);

@ApiResponses(
Expand All @@ -58,7 +59,7 @@ ResponseEntity<StudentResponse> getStudent(
@SecurityRequirement(name = "Jwt Authentication")
@PutMapping("/user/student/me")
ResponseEntity<StudentUpdateResponse> updateStudent(
@Auth(permit = STUDENT) Integer userId,
@Auth(permit = {STUDENT, COUNCIL}) Integer userId,
@Valid StudentUpdateRequest studentUpdateRequest
);

Expand Down Expand Up @@ -120,6 +121,6 @@ ResponseEntity<Void> findPassword(
@PutMapping("/user/change/password")
ResponseEntity<Void> changePassword(
@RequestBody UserPasswordChangeRequest request,
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package in.koreatech.koin.domain.student.controller;

import static in.koreatech.koin.domain.user.model.UserType.COUNCIL;
import static in.koreatech.koin.domain.user.model.UserType.STUDENT;

import java.net.URI;
Expand Down Expand Up @@ -40,15 +41,15 @@ public class StudentController implements StudentApi{

@GetMapping("/user/student/me")
public ResponseEntity<StudentResponse> getStudent(
@Auth(permit = STUDENT) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
) {
StudentResponse studentResponse = studentService.getStudent(userId);
return ResponseEntity.ok().body(studentResponse);
}

@PutMapping("/user/student/me")
public ResponseEntity<StudentUpdateResponse> updateStudent(
@Auth(permit = STUDENT) Integer userId,
@Auth(permit = {STUDENT, COUNCIL}) Integer userId,
@Valid @RequestBody StudentUpdateRequest request
) {
StudentUpdateResponse studentUpdateResponse = studentService.updateStudent(userId, request);
Expand Down Expand Up @@ -93,7 +94,7 @@ public ResponseEntity<Void> findPassword(
@PutMapping("/user/change/password")
public ResponseEntity<Void> changePassword(
@RequestBody UserPasswordChangeRequest request,
@Auth(permit = {STUDENT}) Integer userId
@Auth(permit = {STUDENT, COUNCIL}) Integer userId
) {
studentService.changePassword(userId, request);
return ResponseEntity.ok().build();
Expand Down
Loading
Loading