generated from Bamdoliro/repository-generator
-
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 branch 'feat/group' into feat/#63-add
- Loading branch information
Showing
8 changed files
with
142 additions
and
4 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
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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/soogung/simblue/domain/group/presentation/dto/request/GroupRequest.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,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 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 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 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 { | ||
|
||
private final GroupRepository groupRepository; | ||
|
||
@Transactional | ||
public void execute(GroupRequest request) { | ||
groupRepository.save(request.toEntity()); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/soogung/simblue/domain/group/service/QueryGroupService.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,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()) | ||
); | ||
} | ||
|
||
} |