-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactor] 등록자 프로필 조회 API 클래스 분리 (#143)
- Loading branch information
Showing
5 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/com/ggang/be/api/group/everyGroup/strategy/EveryGroupUserInfoStrategy.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.ggang.be.api.group.everyGroup.strategy; | ||
|
||
import com.ggang.be.api.group.everyGroup.service.EveryGroupService; | ||
import com.ggang.be.api.group.registry.GroupUserInfoStrategy; | ||
import com.ggang.be.domain.constant.GroupType; | ||
import com.ggang.be.global.annotation.Strategy; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Strategy | ||
@RequiredArgsConstructor | ||
public class EveryGroupUserInfoStrategy implements GroupUserInfoStrategy { | ||
|
||
private final EveryGroupService everyGroupService; | ||
|
||
@Override | ||
public boolean supports(GroupType groupType) { | ||
return groupType == GroupType.WEEKLY; | ||
} | ||
|
||
@Override | ||
public long getGroupUserInfo(long groupId) { | ||
return everyGroupService.getEveryGroupRegisterUserId(groupId); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/ggang/be/api/group/onceGroup/strategy/OnceGroupUserInfoStrategy.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.ggang.be.api.group.onceGroup.strategy; | ||
|
||
import com.ggang.be.api.group.onceGroup.service.OnceGroupService; | ||
import com.ggang.be.api.group.registry.GroupUserInfoStrategy; | ||
import com.ggang.be.domain.constant.GroupType; | ||
import com.ggang.be.global.annotation.Strategy; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Strategy | ||
@RequiredArgsConstructor | ||
public class OnceGroupUserInfoStrategy implements GroupUserInfoStrategy { | ||
|
||
private final OnceGroupService onceGroupService; | ||
|
||
@Override | ||
public boolean supports(GroupType groupType) { | ||
return groupType == GroupType.ONCE; | ||
} | ||
|
||
@Override | ||
public long getGroupUserInfo(long groupId) { | ||
return onceGroupService.getOnceGroupRegisterUserId(groupId); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ggang/be/api/group/registry/GroupUserInfoStrategy.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,9 @@ | ||
package com.ggang.be.api.group.registry; | ||
|
||
import com.ggang.be.domain.constant.GroupType; | ||
|
||
public interface GroupUserInfoStrategy { | ||
boolean supports(GroupType groupType); | ||
|
||
long getGroupUserInfo(long groupId); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/ggang/be/api/group/registry/GroupUserInfoStrategyRegistry.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,23 @@ | ||
package com.ggang.be.api.group.registry; | ||
|
||
import com.ggang.be.api.common.ResponseError; | ||
import com.ggang.be.api.exception.GongBaekException; | ||
import com.ggang.be.domain.constant.GroupType; | ||
import com.ggang.be.global.annotation.Registry; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Registry | ||
@RequiredArgsConstructor | ||
public class GroupUserInfoStrategyRegistry { | ||
|
||
private final List<GroupUserInfoStrategy> groupUserInfoStrategies; | ||
|
||
public GroupUserInfoStrategy getGroupUserInfo(GroupType groupType) { | ||
return groupUserInfoStrategies.stream() | ||
.filter(strategy -> strategy.supports(groupType)) | ||
.findFirst() | ||
.orElseThrow(() -> new GongBaekException(ResponseError.BAD_REQUEST)); | ||
} | ||
} |