-
Notifications
You must be signed in to change notification settings - Fork 0
Feat#19 회원,학교 목록 가져오기 #20
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
base: dev
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.sequence.anonymous.user.application; | ||
|
|
||
| import com.sequence.anonymous.user.domain.College; | ||
| import com.sequence.anonymous.user.domain.repository.CollegeRepository; | ||
| import com.sequence.anonymous.user.domain.repository.TagRepository; | ||
| import com.sequence.anonymous.user.domain.tag.Tag; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class CollegeService { | ||
|
|
||
| private CollegeRepository collegeRepository; | ||
|
|
||
|
|
||
| public List<College> printAll(){ | ||
| return collegeRepository.findAll(); | ||
| } | ||
|
Comment on lines
+16
to
+18
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,19 @@ | ||
| package com.sequence.anonymous.user.application; | ||
|
|
||
| import com.sequence.anonymous.user.domain.repository.TagRepository; | ||
| import com.sequence.anonymous.user.domain.tag.Tag; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class TagService { | ||
|
|
||
| private final TagRepository tagRepository; | ||
| } | ||
|
|
||
|
|
||
| public List<Tag> printAll(){ | ||
|
||
| return tagRepository.findAll(); } | ||
| } | ||
|
Comment on lines
+17
to
+19
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.sequence.anonymous.user.domain; | ||
|
|
||
|
|
||
| import jakarta.persistence.*; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| public class College { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(unique = true, insertable = false, updatable = false, length = 10) | ||
|
||
| @NotNull | ||
| private String name; | ||
|
|
||
| protected College() { | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.sequence.anonymous.user.domain.dto; | ||
|
|
||
| import com.sequence.anonymous.user.domain.College; | ||
| import com.sequence.anonymous.user.domain.tag.Tag; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class CollegeResponse { | ||
|
|
||
| private final Long id; | ||
| private final String collegeName; | ||
|
|
||
|
|
||
| public CollegeResponse(College college){ | ||
|
|
||
| this.id = college.getId(); | ||
| this.collegeName = college.getName(); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
|
Comment on lines
+7
to
+22
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요즘 dto를 만들 때는 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.sequence.anonymous.user.domain.dto; | ||
|
|
||
| import com.sequence.anonymous.user.domain.tag.Tag; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class TagResponse { | ||
|
|
||
| private final Long id; | ||
| private final String user; | ||
|
|
||
|
|
||
| public TagResponse(Tag tag){ | ||
| this.id = tag.getId(); | ||
| this.user = tag.getName(); | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
Comment on lines
+6
to
+19
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요즘 dto를 만들 때는 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.sequence.anonymous.user.domain.repository; | ||
|
|
||
| import com.sequence.anonymous.user.domain.College; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface CollegeRepository extends JpaRepository<College, Long> { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.sequence.anonymous.user.presentation; | ||
|
|
||
|
|
||
| import com.sequence.anonymous.user.application.CollegeService; | ||
| import com.sequence.anonymous.user.domain.College; | ||
| import com.sequence.anonymous.user.domain.tag.Tag; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/api/colleges") | ||
|
||
| public class CollegeController { | ||
|
|
||
| private final CollegeService collegeService; | ||
|
|
||
| @GetMapping("/") | ||
|
||
| public ResponseEntity<List<College>> findAll(){ | ||
|
|
||
| List<College> college = collegeService.printAll(); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body((List<College>) college); | ||
|
||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,28 @@ | ||
| package com.sequence.anonymous.user.presentation; | ||
|
|
||
| import com.sequence.anonymous.user.application.TagService; | ||
| import com.sequence.anonymous.user.domain.dto.TagResponse; | ||
| import com.sequence.anonymous.user.domain.tag.Tag; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RestController | ||
| @RequestMapping("/tags") | ||
| @RequestMapping("/api/personality-tags") | ||
| public class TagController { | ||
|
|
||
| private final TagService tagService; | ||
|
|
||
| @GetMapping("/") | ||
| public ResponseEntity<List<Tag>>findAll(){ | ||
|
||
|
|
||
| List<Tag> tag = tagService.printAll(); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body((List<Tag>) tag); | ||
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수의 기능상
printAll()보다findAll()이 더 적합한 것 같습니다!