-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from 403project/develop
feat: repositories & user service
- Loading branch information
Showing
26 changed files
with
339 additions
and
20 deletions.
There are no files selected for viewing
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
76 changes: 76 additions & 0 deletions
76
src/main/java/byulbyul/byulbyulpoll/controller/MemberController.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,76 @@ | ||
package byulbyul.byulbyulpoll.controller; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import byulbyul.byulbyulpoll.controller.dto.MemberLoginDto; | ||
import byulbyul.byulbyulpoll.controller.dto.MemberRequestDto; | ||
import byulbyul.byulbyulpoll.controller.dto.MessageDto; | ||
import byulbyul.byulbyulpoll.service.MemberService; | ||
import jakarta.servlet.http.HttpSession; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController("users") | ||
@RequiredArgsConstructor | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
@GetMapping("/unique-email") | ||
public MessageDto isUniqueEmail(@RequestParam String email) { | ||
MessageDto response = new MessageDto(); | ||
try { | ||
memberService.isValidEmail(email); | ||
response.setSuccess(true); | ||
} catch (IllegalArgumentException e) { | ||
response.setSuccess(false); | ||
response.setMessage(e.getMessage()); | ||
|
||
} | ||
return response; | ||
} | ||
|
||
@GetMapping("/unique-nickname") | ||
public MessageDto isUniqueNickname(@RequestParam String nickname) { | ||
MessageDto response = new MessageDto(); | ||
try { | ||
memberService.isValidNickname(nickname); | ||
response.setSuccess(true); | ||
} catch (IllegalArgumentException e) { | ||
response.setSuccess(false); | ||
response.setMessage(e.getMessage()); | ||
} | ||
return response; | ||
} | ||
|
||
@PostMapping("/sign-up") | ||
public MessageDto signUp(@RequestBody MemberRequestDto memberRequestDto) { | ||
MessageDto response = new MessageDto(); | ||
try { | ||
memberService.signUp(memberRequestDto.toDto()); | ||
response.setSuccess(true); | ||
response.setMessage("회원가입에 성공했습니다."); | ||
} catch (IllegalArgumentException e) { | ||
response.setSuccess(false); | ||
response.setMessage(e.getMessage()); | ||
} | ||
return response; | ||
} | ||
|
||
@PostMapping("/login") | ||
public MessageDto login(@RequestBody MemberLoginDto memberLoginDto, HttpSession session) { | ||
MessageDto response = new MessageDto(); | ||
try { | ||
memberService.login(memberLoginDto.getEmail(), memberLoginDto.getPassword(), session); | ||
response.setSuccess(true); | ||
response.setMessage("로그인에 성공했습니다."); | ||
} catch (IllegalArgumentException e) { | ||
response.setSuccess(false); | ||
response.setMessage(e.getMessage()); | ||
} | ||
return response; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/byulbyul/byulbyulpoll/controller/dto/MemberLoginDto.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,10 @@ | ||
package byulbyul.byulbyulpoll.controller.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class MemberLoginDto { | ||
private final String email; | ||
private final String password; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/byulbyul/byulbyulpoll/controller/dto/MemberRequestDto.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,20 @@ | ||
package byulbyul.byulbyulpoll.controller.dto; | ||
|
||
import byulbyul.byulbyulpoll.service.dto.MemberDto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class MemberRequestDto { | ||
private String email; | ||
private String password; | ||
private String nickname; | ||
private String gender; | ||
private Integer birthYear; | ||
private String occupation; | ||
|
||
public MemberDto toDto() { | ||
return new MemberDto(email, password, nickname, gender, birthYear, occupation); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/byulbyul/byulbyulpoll/controller/dto/MessageDto.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,12 @@ | ||
package byulbyul.byulbyulpoll.controller.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class MessageDto { | ||
private boolean success; | ||
private String message; | ||
} |
5 changes: 2 additions & 3 deletions
5
...yul/byulbyulpoll/endpoint/helloworld.java → ...l/byulbyulpoll/controller/helloworld.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
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
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
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
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/CommentRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.Comment; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CommentRepository extends JpaRepository<Comment, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/LikeRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.Like; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface LikeRepository extends JpaRepository<Like, Long> { | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/byulbyul/byulbyulpoll/repository/MemberRepository.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,16 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.Member; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, String> { | ||
|
||
boolean existsByEmail(String email); | ||
|
||
boolean existsByNickname(String nickname); | ||
|
||
Optional<Member> findByEmail(String email); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/NonMemberRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.NonMember; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface NonMemberRepository extends JpaRepository<NonMember, String> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/PollRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.Poll; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PollRepository extends JpaRepository<Poll, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/ProjectImageRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.ProjectImage; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ProjectImageRepository extends JpaRepository<ProjectImage, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/ProjectRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.Project; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ProjectRepository extends JpaRepository<Project, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/TagRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.Tag; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface TagRepository extends JpaRepository<Tag, Long> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/byulbyul/byulbyulpoll/repository/VoteRepository.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,7 @@ | ||
package byulbyul.byulbyulpoll.repository; | ||
|
||
import byulbyul.byulbyulpoll.entity.Vote; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface VoteRepository extends JpaRepository<Vote, Long> { | ||
} |
Oops, something went wrong.