Skip to content

Commit

Permalink
Docs: 주석 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsong111 committed Mar 21, 2024
1 parent 53b38ec commit 691dbee
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public User login(
@ApiResponse(responseCode = "400", description = "회원가입 실패", content = @Content(schema = @Schema(implementation = CustomErrorResponse.class)))
})
public User signUp(
@Parameter(description = "회원가입 요청 정보") @RequestBody SignUpRequest signUpRequest) {
@Parameter(name = "로그인 객체", description = "회원가입 요청 정보") @RequestBody SignUpRequest signUpRequest) {
return authService.signUp(signUpRequest);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ac/kr/deu/connect/luck/auth/LoginRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

@Schema(description = "로그인 요청 정보 객체")
public record LoginRequest(
@Schema(description = "이메일", example = "test@test.com")
@Schema(description = "이메일", example = "test1@test.com")
String email,
@Schema(description = "비밀번호", example = "test1234")
@Schema(description = "비밀번호", example = "test1")
String password
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class FoodTruckMenu extends BaseEntity {
private String description;
private String imageUrl;
private int price;
private int quantity;
@ManyToOne
private FoodTruck foodTruck;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ac.kr.deu.connect.luck.food_truck;

import io.swagger.v3.oas.annotations.media.Schema;

public record FoodTruckMenuRequest(
@Schema(description = "메뉴 이름", example = "맛있는 푸드트럭")
String name,
@Schema(description = "메뉴 설명", example = "맛있는 음식")
String description,
@Schema(description = "메뉴 사진 URL", example = "https://picsum.photos/1600/900")
String imageUrl,
@Schema(description = "가격", example = "10000")
int price,
@Schema(description = "트럭 ID", example = "1")
Long foodTruckId
) {
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package ac.kr.deu.connect.luck.food_truck;

import io.swagger.v3.oas.annotations.media.Schema;

public record FoodTruckRequest(
@Schema(description = "푸드트럭 이름", example = "맛있는 푸드트럭")
String name,
@Schema(description = "푸드트럭 설명", example = "맛있는 음식")
String description,
@Schema(description = "푸드트럭 이미지 URL", example = "https://picsum.photos/1600/900")
String imageUrl,
@Schema(description = "매니저 ID", example = "4")
Long userId,
@Schema(description = "음식 종류", example = "KOREAN")
FoodType foodType
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ResponseEntity<List<FoodTruck>> getFoodTrucks() {
@GetMapping("/{id}")
@Operation(summary = "Get a food truck by id")
public ResponseEntity<FoodTruck> getFoodTruck(
@PathVariable Long id) {
@Parameter(name = "id", description = "트럭 ID를 조회") @PathVariable Long id) {
return ResponseEntity.ok(foodTruckService.getFoodTruck(id));
}

Expand All @@ -48,10 +48,10 @@ public ResponseEntity<FoodTruck> updateFoodTruck(

@DeleteMapping("/{id}")
@Operation(summary = "Delete a food truck by id")
public ResponseEntity<Void> deleteFoodTruck(
public ResponseEntity<String> deleteFoodTruck(
@PathVariable Long id) {
foodTruckService.deleteFoodTruck(id);
return ResponseEntity.noContent().build();

return ResponseEntity.ok(foodTruckService.deleteFoodTruck(id));
}

@PostMapping("/be-manager")
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/ac/kr/deu/connect/luck/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class UserService {
*/
@Transactional
public String deleteUser(Long id) {
User user = userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.ID_NOT_MATCH));
User user = userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.USER_ID_NOT_MATCH));
foodTruckReviewRepository.deleteAllByAuthor(user);
eventRepository.deleteByManager(user);
for (FoodTruck foodTruck : foodTruckRepository.findByManager(user)) {
Expand All @@ -41,11 +41,11 @@ public String deleteUser(Long id) {
}

public User findUserById(Long id) {
return userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.ID_NOT_MATCH));
return userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.USER_ID_NOT_MATCH));
}

public User updateUser(Long id, SignUpRequest user) {
User findUser = userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.ID_NOT_MATCH));
User findUser = userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.USER_ID_NOT_MATCH));
if (user.email() != null) findUser.setEmail(user.email());
if (user.password() != null) findUser.setPassword(user.password());
if (user.name() != null) findUser.setName(user.name());
Expand All @@ -54,7 +54,7 @@ public User updateUser(Long id, SignUpRequest user) {
}

public UserInfo findUserInfo(Long id) {
User user = userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.ID_NOT_MATCH));
User user = userRepository.findById(id).orElseThrow(() -> new CustomException(CustomErrorCode.USER_ID_NOT_MATCH));
List<FoodTruckReview> reviews = foodTruckReviewRepository.findByAuthor(user);

return new UserInfo(user, reviews);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void getUserInfoFailure() throws Exception {

// then
CustomErrorResponse customErrorResponse = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), CustomErrorResponse.class);
CustomErrorCode customErrorCode = CustomErrorCode.ID_NOT_MATCH;
CustomErrorCode customErrorCode = CustomErrorCode.USER_ID_NOT_MATCH;

Assertions.assertEquals(customErrorResponse.errorType(), customErrorCode);
}
Expand Down

0 comments on commit 691dbee

Please sign in to comment.