generated from Bamdoliro/repository-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/group(create, get list) #70
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
Open
YuLim2
wants to merge
15
commits into
develop
Choose a base branch
from
feat/group
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9cedc94
ADD :: 그룹 엔티티 (#63)
gimhanul fb0b852
FIX: name of id is not matching with table
YuLim2 231f849
FEAT: findAll function overloading
YuLim2 e0a8b65
ADD: Create group
YuLim2 b12605c
ADD: Get group list
YuLim2 f8d7f2e
FIX: worng spelling
YuLim2 d82b53f
Update src/main/java/com/soogung/simblue/domain/group/service/CreateG…
YuLim2 622a594
Update src/main/java/com/soogung/simblue/domain/group/service/CreateG…
YuLim2 bf353d0
Update src/main/java/com/soogung/simblue/domain/group/presentation/Gr…
YuLim2 20873b2
ADD :: 사람 추가 api (#63)
Yunyeong-Ko 4e6690e
ADD :: 리뷰 반영 (#63)
Yunyeong-Ko 7e55eb1
ADD :: 리뷰 반영 (#63)
Yunyeong-Ko e862376
Merge branch 'feat/group' into feat/#63-add
Yunyeong-Ko 796ac54
ADD :: 리뷰 반영 (#63)
Yunyeong-Ko a5220c4
Merge pull request #73 from soolung/feat/#63-add
Yunyeong-Ko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/com/soogung/simblue/domain/group/domain/Group.java
This file contains hidden or 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,35 @@ | ||
| package com.soogung.simblue.domain.group.domain; | ||
|
|
||
| import com.soogung.simblue.domain.group.domain.type.GroupType; | ||
| import com.soogung.simblue.global.entity.BaseTimeEntity; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import javax.persistence.*; | ||
|
|
||
| @Entity | ||
| @Table(name = "tbl_group") | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Getter | ||
| public class Group extends BaseTimeEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "group_id") | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false, length = 20) | ||
| private String name; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(nullable = false, length = 10) | ||
| private GroupType type; | ||
|
|
||
| @Builder | ||
| public Group(String name, GroupType type) { | ||
| this.name = name; | ||
| this.type = type; | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/soogung/simblue/domain/group/domain/Member.java
This file contains hidden or 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,36 @@ | ||
| package com.soogung.simblue.domain.group.domain; | ||
|
|
||
| import com.soogung.simblue.domain.user.domain.Student; | ||
| import com.soogung.simblue.global.entity.BaseTimeEntity; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import javax.persistence.*; | ||
|
|
||
| @Entity | ||
| @Table(name = "tbl_member") | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @Getter | ||
| public class Member extends BaseTimeEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "member_id") | ||
| private Long id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "student_id", nullable = false) | ||
| private Student student; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "group_id", nullable = false) | ||
| private Group group; | ||
|
|
||
| @Builder | ||
| public Member(Student student, Group group) { | ||
| this.student = student; | ||
| this.group = group; | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/soogung/simblue/domain/group/domain/repository/GroupRepository.java
This file contains hidden or 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 com.soogung.simblue.domain.group.domain.repository; | ||
|
|
||
| import com.soogung.simblue.domain.group.domain.Group; | ||
| import org.springframework.data.repository.CrudRepository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
|
|
||
| public interface GroupRepository extends CrudRepository<Group, Long> { | ||
|
|
||
| List<Group> findAll(); | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/soogung/simblue/domain/group/domain/repository/MemberRepository.java
This file contains hidden or 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 com.soogung.simblue.domain.group.domain.repository; | ||
|
|
||
| import com.soogung.simblue.domain.group.domain.Member; | ||
| import org.springframework.data.repository.CrudRepository; | ||
|
|
||
| public interface MemberRepository extends CrudRepository<Member, Long> { | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/soogung/simblue/domain/group/domain/type/GroupType.java
This file contains hidden or 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,6 @@ | ||
| package com.soogung.simblue.domain.group.domain.type; | ||
|
|
||
| public enum GroupType { | ||
|
|
||
| CLASS, YEAR, MAJOR, ETC | ||
| } |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/soogung/simblue/domain/group/presentation/GroupController.java
This file contains hidden or 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,32 @@ | ||
| package com.soogung.simblue.domain.group.presentation; | ||
|
|
||
| import com.soogung.simblue.domain.group.presentation.dto.request.GroupRequest; | ||
| import com.soogung.simblue.domain.group.presentation.dto.response.GroupListResponse; | ||
| import com.soogung.simblue.domain.group.service.CreateGroupService; | ||
| import com.soogung.simblue.domain.group.service.QueryGroupService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import javax.validation.Valid; | ||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/group") | ||
| @RequiredArgsConstructor | ||
| public class GroupController { | ||
|
|
||
| private final CreateGroupService createGroupService; | ||
|
|
||
| private final QueryGroupService queryGroupService; | ||
|
|
||
| @PostMapping | ||
| public void createGroup(@RequestBody @Valid GroupRequest request) { | ||
| createGroupService.execute(request); | ||
| } | ||
|
|
||
| @GetMapping | ||
| public GroupListResponse getListGroups(){ | ||
| return queryGroupService.execute(); | ||
| } | ||
|
|
||
| } | ||
31 changes: 31 additions & 0 deletions
31
src/main/java/com/soogung/simblue/domain/group/presentation/dto/request/GroupRequest.java
This file contains hidden or 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,31 @@ | ||
| package com.soogung.simblue.domain.group.presentation.dto.request; | ||
|
|
||
| import com.soogung.simblue.domain.group.domain.Group; | ||
| import com.soogung.simblue.domain.group.domain.type.GroupType; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import javax.validation.constraints.NotNull; | ||
| import javax.validation.constraints.Size; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| public class GroupRequest { | ||
|
|
||
| @NotNull | ||
| @Size(min = 1, max = 20) | ||
| private String name; | ||
|
|
||
| @NotNull | ||
| private GroupType type; | ||
|
|
||
| public Group toEntity() { | ||
| return Group.builder() | ||
| .name(name) | ||
| .type(type) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
17 changes: 17 additions & 0 deletions
17
...in/java/com/soogung/simblue/domain/group/presentation/dto/response/GroupListResponse.java
This file contains hidden or 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,17 @@ | ||
| package com.soogung.simblue.domain.group.presentation.dto.response; | ||
|
|
||
| import com.soogung.simblue.domain.group.domain.Group; | ||
| import com.soogung.simblue.domain.group.domain.type.GroupType; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public class GroupListResponse { | ||
|
|
||
| private List<GroupResponse> groupList; | ||
|
|
||
| } |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/soogung/simblue/domain/group/presentation/dto/response/GroupResponse.java
This file contains hidden or 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,24 @@ | ||
| package com.soogung.simblue.domain.group.presentation.dto.response; | ||
|
|
||
| import com.soogung.simblue.domain.group.domain.Group; | ||
| import com.soogung.simblue.domain.group.domain.type.GroupType; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class GroupResponse { | ||
|
|
||
| private Long id; | ||
| private String name; | ||
| private GroupType type; | ||
|
|
||
| public static GroupResponse of(Group group) { | ||
| return GroupResponse.builder() | ||
| .id(group.getId()) | ||
| .name(group.getName()) | ||
| .type(group.getType()) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/soogung/simblue/domain/group/service/CreateGroupService.java
This file contains hidden or 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,22 @@ | ||
| package com.soogung.simblue.domain.group.service; | ||
|
|
||
| import com.soogung.simblue.domain.group.domain.Group; | ||
| import com.soogung.simblue.domain.group.domain.repository.GroupRepository; | ||
| import com.soogung.simblue.domain.group.presentation.dto.request.GroupRequest; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import javax.transaction.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class CreateGroupService { | ||
|
|
||
| final GroupRepository groupRepository; | ||
YuLim2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @Transactional | ||
| public void execute(GroupRequest request) { | ||
| Group group = groupRepository.save(request.toEntity()); | ||
YuLim2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| } | ||
28 changes: 28 additions & 0 deletions
28
src/main/java/com/soogung/simblue/domain/group/service/QueryGroupService.java
This file contains hidden or 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,28 @@ | ||
| package com.soogung.simblue.domain.group.service; | ||
|
|
||
| import com.soogung.simblue.domain.application.presentation.dto.response.ApplicationResponse; | ||
| import com.soogung.simblue.domain.group.domain.Group; | ||
| import com.soogung.simblue.domain.group.domain.repository.GroupRepository; | ||
| import com.soogung.simblue.domain.group.presentation.dto.response.GroupListResponse; | ||
| import com.soogung.simblue.domain.group.presentation.dto.response.GroupResponse; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import org.springframework.transaction.annotation.Transactional; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class QueryGroupService { | ||
|
|
||
| private final GroupRepository groupRepository; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public GroupListResponse execute(){ | ||
| return new GroupListResponse( | ||
| groupRepository.findAll() | ||
| .stream().map(GroupResponse::of).collect(Collectors.toList()) | ||
| ); | ||
| } | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.