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

[FEAT] 작품평가 생성 API 구현 #70

Merged
merged 73 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
e57a97e
[FEAT] 서재 작품 등록을 위한 엔드포인트 추가
rinarina0429 Jun 7, 2024
d38e27c
[FEAT] UserNovel에 builder 추가
rinarina0429 Jun 10, 2024
67590d3
[REFACTOR] line formatting & unused import문 제거
rinarina0429 Jun 10, 2024
618d6ab
[FEAT] novelRating 관련 증감 함수 추가
rinarina0429 Jun 10, 2024
2771676
Merge branch 'dev' of https://github.com/Team-WSS/WSS-Server into fea…
rinarina0429 Jun 10, 2024
756deca
[FEAT] UserNovel 관련 예외처리 추가
rinarina0429 Jun 11, 2024
89a60cd
[REFACTOR] builder에서 정적 메소드로 변경
rinarina0429 Jun 11, 2024
f5adc9f
[FIX] default값 있는 isInterest create 메서드에서 제거
rinarina0429 Jun 11, 2024
e2180bd
[FEAT] 서재에 작품 등록 dto 추가
rinarina0429 Jun 11, 2024
b5c05af
[FEAT] 매력포인트 생성 정적 메서드 추가
rinarina0429 Jun 11, 2024
6bd289f
[FEAT] 읽기 날짜 포맷 어노테이션 추가
rinarina0429 Jun 11, 2024
8b612d3
Merge branch 'dev' of https://github.com/Team-WSS/WSS-Server into fea…
rinarina0429 Jun 12, 2024
836c128
[FEAT] 서재 등록 별졈 validator, contraint 추가
rinarina0429 Jun 12, 2024
78d9532
[FEAT] 서재 작품 등록 dto 추가
rinarina0429 Jun 12, 2024
1bfbe1b
[FEAT] 매력포인트 도메인에 @Setter 추가
rinarina0429 Jun 12, 2024
161a988
[FEAT] UserNovel 내의 attractivePoint에 @Setter 추가
rinarina0429 Jun 12, 2024
9934afe
[FEAT] 서재 작품 등록 서비스 로직 추가
rinarina0429 Jun 12, 2024
b3d8f6a
[FEAT] 유저 통계 findByUser 함수 추가
rinarina0429 Jun 14, 2024
d228cc6
[FEAT] 유저 통계 exception 추가
rinarina0429 Jun 14, 2024
1e41366
[FEAT] UserStatistics의 특정 필드를 증가시키는 함수 추가
rinarina0429 Jun 14, 2024
cdc2cb1
[FEAT] NovelStatistics의 특정 필드를 증가시키는 함수 추가
rinarina0429 Jun 14, 2024
7cb4f18
[FEAT] 서재 작품 등록 과정에서 읽기 상태에 따라 통계값 증가시키는 함수 추가
rinarina0429 Jun 14, 2024
388e1f8
[FEAT] UserStatistics의 특정 필드를 원하는 만큼 증가시키는 함수 추가
rinarina0429 Jun 14, 2024
424bab5
[FEAT] 서재 작품 등록 과정에서 장르, 매력포인트에 따라 통계값 증가시키는 함수 추가
rinarina0429 Jun 14, 2024
5b5a937
[REFACTOR] UserNovelService 내 함수 순서 정렬
rinarina0429 Jun 14, 2024
c723bb7
[REFACTOR] createAndGetAttractivePoint를 AttractivePointService로 이동
rinarina0429 Jun 14, 2024
67d33b8
[FEAT] UserNovel에 @DynamicInsert 적용
rinarina0429 Jun 14, 2024
02f186b
[FIX] EmailGetResponse 경로 수정
rinarina0429 Jun 14, 2024
cf7fea9
[FEAT] AttractivePoint에 @DynamicInsert 적용
rinarina0429 Jun 14, 2024
66a4776
[FEAT] userStatistics에서 별점이 0.0일 경우 필드 올리지 않도록 조건 추가
rinarina0429 Jun 14, 2024
13ec4d9
[REFACTOR] UserNovelService에서 조건식 최소화
rinarina0429 Jun 14, 2024
8946749
[REFACTOR] createUserNovel에서 getById가 아니라 findById로 작품 찾도록 수정
rinarina0429 Jun 14, 2024
1f18f9c
[REFACTOR] increaseStatistics로 함수 분리
rinarina0429 Jun 14, 2024
87e222f
[FEAT] NovelKeywords에서 create 정적 메서드 추가
rinarina0429 Jun 14, 2024
f59bdf7
[FIX]UserNovelCreateRequest에서 문자열 배열이 아니라 id의 배열을 받도록 수정
rinarina0429 Jun 14, 2024
cbcfc38
[FEAT] 작품 평가 시 키워드 추가되는 로직 추가
rinarina0429 Jun 14, 2024
197eb2f
[FEAT] 작품 평가 시 받는 매력포인트와 키워드 개수 제한
rinarina0429 Jun 14, 2024
3034942
[FIX] dto에서 character 단수 취급하도록 수정
rinarina0429 Jun 14, 2024
85f966b
[FEAT] NovelKeywordRepository 추가
rinarina0429 Jun 15, 2024
96b332d
[FEAT] NovelKeywords 테이블 추가할 수 있는 코드 추가
rinarina0429 Jun 15, 2024
a95bbd6
[MERGE] dev 브랜치 병합
rinarina0429 Jun 15, 2024
746a3ea
[FEAT] KeywordRepository에 @Repository 어노테이션 추가
rinarina0429 Jun 15, 2024
c76e346
[FEAT] Keyword 예외처리 추가
rinarina0429 Jun 15, 2024
036db23
[FIX] keywordId 실재 존재하는지 확인하는 로직 추가
rinarina0429 Jun 15, 2024
8583de7
[FEAT] 매력포인트 관련 예외처리 추가
rinarina0429 Jun 15, 2024
a292a47
[REFACTOR] 매력포인트 서비스 내 예외처리 구체화
rinarina0429 Jun 15, 2024
7ff35d0
[FIX] startDate, endDate null일 경우 처리하는 로직 추가
rinarina0429 Jun 15, 2024
0fa68e3
[REFACTOR] UserNovelService에서 @Transactional 어노테이션 컨벤션에 맞춰 수정
rinarina0429 Jun 19, 2024
9ea6c24
Merge branch 'dev' of https://github.com/Team-WSS/WSS-Server into fea…
rinarina0429 Jun 19, 2024
b566a4c
[REFACTOR] AttractivePointService에서 @Transactional 어노테이션 컨벤션에 맞춰 수정
rinarina0429 Jun 19, 2024
656dc97
[REMOVE] 불필요한 static 제거
rinarina0429 Jun 19, 2024
924b7a2
[REMOVE] 불필요한 static 제거
rinarina0429 Jun 19, 2024
0fdf2bf
Revert "[REMOVE] 불필요한 static 제거"
rinarina0429 Jun 19, 2024
05ae06b
[REFACTOR] Flag 모두 static import로 변경
rinarina0429 Jun 19, 2024
d2b576d
[REMOVE] 불필요한 개행 제거
rinarina0429 Jun 19, 2024
9a9e3b1
[REMOVE] erd에 맞춰 UserNovel 도메인에서 매력포인트 제거
rinarina0429 Jun 21, 2024
74263e4
[FIX] UserNovelService에서 매력포인트를 UserNovel에 넘겨주지 않도록 수정
rinarina0429 Jun 21, 2024
735072c
[FEAT] AttractivePointRepository 생성
rinarina0429 Jun 21, 2024
09ace7c
Merge branch 'dev' of https://github.com/Team-WSS/WSS-Server into fea…
rinarina0429 Jun 21, 2024
fc7f1ec
[FEAT] 매력포인트에 @DynamicUpdate 어노테이션 추가
rinarina0429 Jun 21, 2024
95ba53a
[FIX] 매력포인트 서비스 내 함수 하나가 한 역할만 하도록 수정
rinarina0429 Jun 21, 2024
932e528
[FIX] UserNovelService 내에서 UserNovel에 매력포인트 할당하는 코드 제거 및 로직 수정
rinarina0429 Jun 21, 2024
d651bfd
[FEAT] 필드 증가 함수들 추가
rinarina0429 Jun 24, 2024
95a060b
[REFACTOR] 기존 increaseField 함수 대신 각각의 필드 증가 함수 사용
rinarina0429 Jun 24, 2024
49aa5ed
[REMOVE] 미사용 함수 제거
rinarina0429 Jun 24, 2024
a6ec3a9
[FEAT] 필드 증가 함수들 추가
rinarina0429 Jun 24, 2024
3f9f7d0
[REFACTOR] 기존 increaseField, increaseFieldByAmount 함수 대신 각각의 필드 증가 함수 사용
rinarina0429 Jun 24, 2024
7ee7174
[REMOVE] 미사용 함수 제거
rinarina0429 Jun 24, 2024
973c4d5
[MERGE] dev branch merge
rinarina0429 Jun 24, 2024
8a2d5e8
[REFACTOR] AttractivePoint에서 Flag->Boolean으로 변경
rinarina0429 Jun 27, 2024
d7eaa65
[REFACTOR] AttractivePointService에서 Flag값이 아닌 Boolean 값 넣도록 수정
rinarina0429 Jun 27, 2024
79ffeaf
[REFACTOR] UserNovelService 내의 attractivePoint Flag->Boolean으로 변경
rinarina0429 Jun 27, 2024
67b8bc1
[FEAT] .gitignore에 import.sql 추가
rinarina0429 Jun 29, 2024
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 @@ -15,7 +15,7 @@
import org.websoso.WSSServer.domain.User;
import org.websoso.WSSServer.dto.User.LoginResponse;
import org.websoso.WSSServer.dto.User.NicknameValidation;
import org.websoso.WSSServer.dto.user.EmailGetResponse;
import org.websoso.WSSServer.dto.User.EmailGetResponse;
import org.websoso.WSSServer.service.UserService;
import org.websoso.WSSServer.validation.NicknameConstraint;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.websoso.WSSServer.controller;

import static org.springframework.http.HttpStatus.CREATED;

import jakarta.validation.Valid;
import java.security.Principal;
import lombok.RequiredArgsConstructor;
import lombok.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.websoso.WSSServer.domain.User;
import org.websoso.WSSServer.dto.userNovel.UserNovelCreateRequest;
import org.websoso.WSSServer.service.UserNovelService;
import org.websoso.WSSServer.service.UserService;

@RequestMapping("/user-novels")
@RestController
@RequiredArgsConstructor
public class UserNovelController {

private final UserService userService;
private final UserNovelService userNovelService;

@PostMapping
public ResponseEntity<Void> createUserNovel(Principal principal,
@Valid @RequestBody UserNovelCreateRequest request){
User user = userService.getUserOrException(Long.valueOf(principal.getName()));
userNovelService.createUserNovel(user, request);

return ResponseEntity
.status(CREATED)
.build();
}

}
14 changes: 14 additions & 0 deletions src/main/java/org/websoso/WSSServer/domain/AttractivePoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.websoso.WSSServer.domain.common.Flag;

@Entity
@Getter
@Setter
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class AttractivePoint {

Expand Down Expand Up @@ -54,4 +60,12 @@ public class AttractivePoint {
@OneToOne
@JoinColumn(name = "user_novel_id", nullable = false)
private UserNovel userNovel;

private AttractivePoint(UserNovel userNovel) {
this.userNovel = userNovel;
}

public static AttractivePoint create(UserNovel userNovel) {
return new AttractivePoint(userNovel);
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/websoso/WSSServer/domain/Novel.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,21 @@ public class Novel {

@OneToMany(mappedBy = "novel")
private List<NovelGenre> novelGenres = new ArrayList<>();

public void increaseNovelRatingCount() {
this.novelRatingCount++;
}

public void decreaseNovelRatingCount() {
this.novelRatingCount--;
}

public void increaseNovelRatingSum(float rating) {
this.novelRatingSum += rating;
}

public void decreaseNovelRatingSum(float rating) {
this.novelRatingSum -= rating;
}

}
10 changes: 10 additions & 0 deletions src/main/java/org/websoso/WSSServer/domain/NovelKeywords.java
rinarina0429 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ public class NovelKeywords {

@Column
private Long userId;

private NovelKeywords(Long novelId, Integer keywordId, Long userId) {
this.novelId = novelId;
this.keywordId = keywordId;
this.userId = userId;
}

public static NovelKeywords create(Long novelId, Integer keywordId, Long userId) {
return new NovelKeywords(novelId, keywordId, userId);
}
}
12 changes: 12 additions & 0 deletions src/main/java/org/websoso/WSSServer/domain/NovelStatistics.java
Kim-TaeUk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import java.lang.reflect.Field;
import java.util.Optional;
import lombok.AccessLevel;
import lombok.Builder;
Expand Down Expand Up @@ -81,4 +82,15 @@ public void decreaseNovelFeedCount() {
this.novelFeedCount--;
}

public void increaseField(String fieldName) {
try {
Field field = this.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
Integer currentValue = (Integer) field.get(this);
field.set(this, currentValue + 1);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException("Field not found or not accessible", e);
}
}

}
23 changes: 18 additions & 5 deletions src/main/java/org/websoso/WSSServer/domain/UserNovel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.websoso.WSSServer.domain;

import static jakarta.persistence.CascadeType.ALL;
import static jakarta.persistence.GenerationType.IDENTITY;

import jakarta.persistence.Column;
Expand All @@ -11,18 +10,19 @@
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import java.time.LocalDate;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.websoso.WSSServer.domain.common.BaseEntity;
import org.websoso.WSSServer.domain.common.Flag;
import org.websoso.WSSServer.domain.common.ReadStatus;

@Entity
@Getter
@DynamicInsert
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class UserNovel extends BaseEntity {

Expand All @@ -49,14 +49,27 @@ public class UserNovel extends BaseEntity {
@Column
private LocalDate endDate;

@OneToOne(mappedBy = "userNovel", cascade = ALL)
private AttractivePoint attractivePoint;

@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;

@ManyToOne
@JoinColumn(name = "novel_id", nullable = false)
private Novel novel;

private UserNovel(ReadStatus status, Float userNovelRating, LocalDate startDate, LocalDate endDate, User user,
Novel novel) {
this.status = status;
this.userNovelRating = userNovelRating;
this.startDate = startDate;
this.endDate = endDate;
this.user = user;
this.novel = novel;
}

public static UserNovel create(ReadStatus status, Float userNovelRating, LocalDate startDate, LocalDate endDate,
User user, Novel novel) {
return new UserNovel(status, userNovelRating, startDate, endDate, user, novel);
}

}
24 changes: 24 additions & 0 deletions src/main/java/org/websoso/WSSServer/domain/UserStatistics.java
Kim-TaeUk marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import java.lang.reflect.Field;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -91,4 +92,27 @@ public class UserStatistics {
@OneToOne
@JoinColumn(name = "user_id", nullable = false)
private User user;

public void increaseField(String fieldName) {
try {
Field field = this.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
Integer currentValue = (Integer) field.get(this);
field.set(this, currentValue + 1);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException("Field not found or not accessible", e);
}
}

public void increaseFieldByAmount(String fieldName, float amount) {
try {
Field field = this.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
Float currentValue = (Float) field.get(this);
field.set(this, currentValue + amount);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException("Field not found or not accessible", e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.websoso.WSSServer.domain.common;


public enum Flag {
Y, N
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.websoso.WSSServer.dto.user;
package org.websoso.WSSServer.dto.User;

public record EmailGetResponse(
String email
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.websoso.WSSServer.dto.novel;

import static org.websoso.WSSServer.domain.common.Flag.Y;

import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.websoso.WSSServer.domain.Novel;
import org.websoso.WSSServer.domain.NovelStatistics;
import org.websoso.WSSServer.domain.UserNovel;
import org.websoso.WSSServer.domain.common.Flag;

// TODO 이름 변경(작품 정보 조회 뷰에서 상단, 기본정보를 제공하는 부분)
public record NovelGetResponse1(
Expand Down Expand Up @@ -37,7 +38,7 @@ public static NovelGetResponse1 of(Novel novel, UserNovel userNovel, NovelStatis
novel.getNovelImage(),
novelGenres,
novelGenreImage,
novel.getIsCompleted().equals(Flag.Y),
novel.getIsCompleted().equals(Y),
novel.getAuthor(),
novelStatistics.getInterestCount(),
novelRating,
Expand All @@ -56,7 +57,7 @@ public static NovelGetResponse1 of(Novel novel, UserNovel userNovel, NovelStatis
novel.getNovelImage(),
novelGenres,
novelGenreImage,
novel.getIsCompleted().equals(Flag.Y),
novel.getIsCompleted().equals(Y),
novel.getAuthor(),
novelStatistics.getInterestCount(),
novelRating,
Expand All @@ -70,7 +71,7 @@ public static NovelGetResponse1 of(Novel novel, UserNovel userNovel, NovelStatis
userNovel.getEndDate() != null ? userNovel.getEndDate()
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd").withLocale(Locale.forLanguageTag("ko")))
: null,
userNovel.getIsInterest().equals(Flag.Y)
userNovel.getIsInterest().equals(Y)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.websoso.WSSServer.dto.userNovel;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
import java.util.List;
import org.hibernate.annotations.ColumnDefault;
import org.websoso.WSSServer.domain.common.ReadStatus;
import org.websoso.WSSServer.validation.UserNovelRatingConstraint;

public record UserNovelCreateRequest(
@NotNull(message = "작품 id는 null일 수 없습니다.")
Long novelId,
@UserNovelRatingConstraint
@ColumnDefault("0.0")
Float userNovelRating,
@NotNull(message = "읽기 상태는 null일 수 없습니다.")
ReadStatus status,
@Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}", message = "시작 날짜는 yyyy-MM-dd 형식이어야 합니다.")
String startDate,
@Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}", message = "종료 날짜는 yyyy-MM-dd 형식이어야 합니다.")
String endDate,
@JsonSetter(nulls = Nulls.AS_EMPTY)
@Size(max = 3, message = "매력 포인트는 최대 3개까지 가능합니다.")
List<String> attractivePoints,
@JsonSetter(nulls = Nulls.AS_EMPTY)
@Size(max = 10, message = "키워드는 최대 10개까지 가능합니다.")
List<Integer> keywordIds
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.websoso.WSSServer.exception.common.ErrorResult;
import org.websoso.WSSServer.exception.feed.FeedErrorCode;
import org.websoso.WSSServer.exception.feed.exception.InvalidFeedException;
import org.websoso.WSSServer.exception.keyword.KeywordErrorCode;
import org.websoso.WSSServer.exception.keyword.exception.InvalidKeywordException;
import org.websoso.WSSServer.exception.notice.NoticeErrorCode;
import org.websoso.WSSServer.exception.notice.exception.ForbiddenNoticeManipulationException;
import org.websoso.WSSServer.exception.notice.exception.NoticeNotFoundException;
Expand All @@ -32,6 +34,9 @@
import org.websoso.WSSServer.exception.user.exception.InvalidUserException;
import org.websoso.WSSServer.exception.user.exception.InvalidUserIdException;
import org.websoso.WSSServer.exception.user.exception.UserNotFoundException;
import org.websoso.WSSServer.exception.userNovel.UserNovelErrorCode;
import org.websoso.WSSServer.exception.userNovel.exception.InvalidReadStatusException;
import org.websoso.WSSServer.exception.userNovel.exception.NovelAlreadyRegisteredException;

@Slf4j
@RestControllerAdvice
Expand Down Expand Up @@ -128,6 +133,33 @@ public ResponseEntity<ErrorResult> InvalidNovelStatisticsExceptionHandler(Invali
.body(new ErrorResult(novelStatisticsErrorCode.getCode(), novelStatisticsErrorCode.getDescription()));
}

@ExceptionHandler(NovelAlreadyRegisteredException.class)
public ResponseEntity<ErrorResult> NovelAlreadyRegisteredExceptionHandler(NovelAlreadyRegisteredException e) {
log.error("[NovelAlreadyRegisteredException] exception", e);
UserNovelErrorCode userNovelErrorCode = e.getUserNovelErrorCode();
return ResponseEntity
.status(userNovelErrorCode.getStatusCode())
.body(new ErrorResult(userNovelErrorCode.getCode(), userNovelErrorCode.getDescription()));
}

@ExceptionHandler(InvalidReadStatusException.class)
public ResponseEntity<ErrorResult> InvalidReadStatusExceptionHandler(InvalidReadStatusException e) {
log.error("[InvalidReadStatusException] exception", e);
UserNovelErrorCode userNovelErrorCode = e.getUserNovelErrorCode();
return ResponseEntity
.status(userNovelErrorCode.getStatusCode())
.body(new ErrorResult(userNovelErrorCode.getCode(), userNovelErrorCode.getDescription()));
}

@ExceptionHandler(InvalidKeywordException.class)
public ResponseEntity<ErrorResult> InvalidKeywordExceptionHandler(InvalidKeywordException e) {
log.error("[InvalidKeywordException] exception", e);
KeywordErrorCode keywordErrorCode = e.getKeywordErrorCode();
return ResponseEntity
.status(keywordErrorCode.getStatusCode())
.body(new ErrorResult(keywordErrorCode.getCode(), keywordErrorCode.getDescription()));
}

@ExceptionHandler(AlreadyBlockedException.class)
public ResponseEntity<ErrorResult> AlreadyBlockedExceptionHandler(AlreadyBlockedException e) {
log.error("[AlreadyBlockedException] exception ", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.websoso.WSSServer.exception.attractivePoint;

import static org.springframework.http.HttpStatus.BAD_REQUEST;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.websoso.WSSServer.exception.common.IErrorCode;

@Getter
@AllArgsConstructor
public enum AttractivePointErrorCode implements IErrorCode {

INVALID_ATTRACTIVE_POINT("ATTRACTIVE_POINT-001", "해당 매력포인트는 존재하지 않습니다.", BAD_REQUEST);

private final String code;
private final String description;
private final HttpStatus statusCode;
}
Loading
Loading