-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from ho0010/dev
Feat: UserVoteChoice API
- Loading branch information
Showing
12 changed files
with
154 additions
and
16 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...ain/java/store/itpick/backend/common/exception_handler/VoteExceptionControllerAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package store.itpick.backend.common.exception_handler; | ||
|
||
import jakarta.annotation.Priority; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
import store.itpick.backend.common.exception.VoteException; | ||
import store.itpick.backend.common.response.BaseErrorResponse; | ||
|
||
@Slf4j | ||
@Priority(0) | ||
@RestControllerAdvice | ||
public class VoteExceptionControllerAdvice { | ||
|
||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
@ExceptionHandler(VoteException.class) | ||
public BaseErrorResponse handleDebateException(VoteException e) { | ||
log.error("[VoteException]", e); | ||
return new BaseErrorResponse(e.getExceptionStatus()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/store/itpick/backend/dto/vote/PostUserVoteChoiceRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package store.itpick.backend.dto.vote; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class PostUserVoteChoiceRequest { | ||
@NotNull(message = "User ID는 필수입니다.") | ||
private Long userId; | ||
|
||
@NotNull(message = "Vote Option ID는 필수입니다.") | ||
private Long voteOptionId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/store/itpick/backend/model/UserVoteChoice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package store.itpick.backend.model; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.sql.Timestamp; | ||
|
||
@Entity | ||
@Table(name = "user_vote_choice") | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class UserVoteChoice { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "user_vote_choice_id") | ||
private Long UserVoteChoiceId; | ||
|
||
@Column(name = "status", nullable = false, length = 20) | ||
private String status; | ||
|
||
@Column(name = "create_at", nullable = false) | ||
private Timestamp createAt; | ||
|
||
@Column(name = "update_at") | ||
private Timestamp updateAt; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private User user; | ||
|
||
@ManyToOne | ||
@JoinColumn(name="vote_option_id",nullable = false) | ||
private VoteOption voteOption; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/store/itpick/backend/repository/UserVoteChoiceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package store.itpick.backend.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import store.itpick.backend.model.User; | ||
import store.itpick.backend.model.UserVoteChoice; | ||
import store.itpick.backend.model.Vote; | ||
|
||
public interface UserVoteChoiceRepository extends JpaRepository<UserVoteChoice, Long> { | ||
void deleteByVoteOption_VoteAndUser(Vote vote, User user); | ||
} | ||
|
5 changes: 4 additions & 1 deletion
5
src/main/java/store/itpick/backend/repository/VoteOptionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package store.itpick.backend.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import store.itpick.backend.model.User; | ||
import store.itpick.backend.model.Vote; | ||
import store.itpick.backend.model.VoteOption; | ||
|
||
public interface VoteOptionRepository extends JpaRepository<VoteOption,Long> { | ||
public interface VoteOptionRepository extends JpaRepository<VoteOption, Long> { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters