-
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 all 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,19 @@ | ||
| package com.sequence.anonymous.user.application; | ||
|
|
||
| import com.sequence.anonymous.user.domain.College; | ||
| import com.sequence.anonymous.user.domain.repository.CollegeRepository; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
| @RequiredArgsConstructor | ||
|
Comment on lines
+8
to
+9
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.
|
||
| @Service | ||
| public class CollegeService { | ||
|
|
||
| private final CollegeRepository collegeRepository; | ||
|
|
||
|
|
||
| public List<College> findAll() { | ||
| 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> findAll(){ | ||
| 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,31 @@ | ||
| package com.sequence.anonymous.user.domain; | ||
|
|
||
|
|
||
| import jakarta.persistence.*; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.Getter; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @Table(name = "College") | ||
|
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. 보통 데이터베이스 테이블 이름, 컬럼과 같은 곳에는 소문자만을 사용하는 것이 기본 컨벤션입니다. |
||
| public class College { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "college_id") | ||
| private Long id; | ||
|
|
||
| @Column(unique = true, length = 10) | ||
|
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. 학교의 이름은 어플리케이션에서 수정할 일이 없으므로 |
||
| @NotNull | ||
| private String name; | ||
|
|
||
| @OneToMany(mappedBy = "college") | ||
| private List<Department> departments = new ArrayList<>(); | ||
|
|
||
| protected College() { | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.sequence.anonymous.user.domain; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Entity | ||
| public class Department { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "department_id") | ||
| private Long id; | ||
|
|
||
| @ManyToOne | ||
|
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.
|
||
| @JoinColumn(name = "college_id") | ||
| private College college; | ||
|
|
||
| @Column(unique = true, insertable = false, updatable = false, length = 10) | ||
| @NotNull | ||
| private String name; | ||
|
|
||
| protected Department() { | ||
| } | ||
|
|
||
| @ManyToMany | ||
| @JoinTable(schema = "College") | ||
| private List<College> users = new ArrayList<>(); | ||
|
Comment on lines
+28
to
+30
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,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,10 @@ | ||
| package com.sequence.anonymous.user.domain.repository; | ||
|
|
||
| import com.sequence.anonymous.user.domain.College; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| public interface CollegeRepository extends JpaRepository<College, Long> { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.sequence.anonymous.user.presentation; | ||
|
|
||
|
|
||
| import com.sequence.anonymous.user.application.CollegeService; | ||
| import com.sequence.anonymous.user.domain.College; | ||
| 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("/colleges") | ||
| public class CollegeController { | ||
|
|
||
| private final CollegeService collegeService; | ||
|
|
||
| @GetMapping("") | ||
| public ResponseEntity<List<College>> findAll(){ | ||
|
|
||
| List<College> college = collegeService.findAll(); | ||
| return ResponseEntity.status(HttpStatus.OK).body((List<College>) college); | ||
|
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,14 +1,26 @@ | ||
| package com.sequence.anonymous.user.presentation; | ||
|
|
||
| import com.sequence.anonymous.user.application.TagService; | ||
| 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("/tags") | ||
| @RequestMapping("/personality-tags") | ||
| public class TagController { | ||
| private final TagService tagService; | ||
|
|
||
| @GetMapping("") | ||
| public ResponseEntity<List<Tag>> findAll() { | ||
|
|
||
| private final TagService tagService; | ||
| List<Tag> tag = tagService.findAll(); | ||
| return ResponseEntity.status(HttpStatus.OK).body(tag); | ||
|
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.
|
||
| } | ||
| } | ||
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.
insomnia 사용하실 때만 임시로만 부탁드리겠습니다