-
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.
- Loading branch information
Showing
10 changed files
with
142 additions
and
5 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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/ggang/be/api/group/everyGroup/strategy/DeleteEveryGroupStrategy.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,27 @@ | ||
package com.ggang.be.api.group.everyGroup.strategy; | ||
|
||
import com.ggang.be.api.group.dto.GroupRequest; | ||
import com.ggang.be.api.group.everyGroup.service.EveryGroupService; | ||
import com.ggang.be.api.group.registry.DeleteGroupStrategy; | ||
import com.ggang.be.domain.constant.GroupType; | ||
import com.ggang.be.domain.group.everyGroup.EveryGroupEntity; | ||
import com.ggang.be.domain.user.UserEntity; | ||
import com.ggang.be.global.annotation.Strategy; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Strategy | ||
@RequiredArgsConstructor | ||
public class DeleteEveryGroupStrategy implements DeleteGroupStrategy { | ||
private final EveryGroupService everyGroupService; | ||
|
||
@Override | ||
public boolean support(GroupType groupType) { | ||
return groupType.equals(GroupType.WEEKLY); | ||
} | ||
|
||
@Override | ||
public void deleteGroup(UserEntity userEntity, GroupRequest request) { | ||
EveryGroupEntity everyGroupEntity = everyGroupService.findEveryGroupEntityByGroupId(request.groupId()); | ||
everyGroupService.deleteEveryGroup(userEntity, everyGroupEntity); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/ggang/be/api/group/onceGroup/strategy/DeleteOnceGroupStrategy.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,27 @@ | ||
package com.ggang.be.api.group.onceGroup.strategy; | ||
|
||
import com.ggang.be.api.group.dto.GroupRequest; | ||
import com.ggang.be.api.group.onceGroup.service.OnceGroupService; | ||
import com.ggang.be.api.group.registry.DeleteGroupStrategy; | ||
import com.ggang.be.domain.constant.GroupType; | ||
import com.ggang.be.domain.group.onceGroup.OnceGroupEntity; | ||
import com.ggang.be.domain.user.UserEntity; | ||
import com.ggang.be.global.annotation.Strategy; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Strategy | ||
@RequiredArgsConstructor | ||
public class DeleteOnceGroupStrategy implements DeleteGroupStrategy { | ||
private final OnceGroupService onceGroupService; | ||
|
||
@Override | ||
public boolean support(GroupType groupType) { | ||
return groupType.equals(GroupType.ONCE); | ||
} | ||
|
||
@Override | ||
public void deleteGroup(UserEntity userEntity, GroupRequest request) { | ||
OnceGroupEntity onceGroupEntity = onceGroupService.findOnceGroupEntityByGroupId(request.groupId()); | ||
onceGroupService.deleteOnceGroup(userEntity, onceGroupEntity); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/ggang/be/api/group/registry/DeleteGroupStrategy.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,11 @@ | ||
package com.ggang.be.api.group.registry; | ||
|
||
import com.ggang.be.api.group.dto.GroupRequest; | ||
import com.ggang.be.domain.constant.GroupType; | ||
import com.ggang.be.domain.user.UserEntity; | ||
|
||
public interface DeleteGroupStrategy { | ||
boolean support(GroupType groupType); | ||
|
||
void deleteGroup(UserEntity userEntity, GroupRequest request); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/ggang/be/api/group/registry/DeleteGroupStrategyRegistry.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.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 DeleteGroupStrategyRegistry { | ||
private final List<DeleteGroupStrategy> deleteGroupStrategies; | ||
|
||
public DeleteGroupStrategy getDeleteGroupStrategy(GroupType groupType) { | ||
return deleteGroupStrategies.stream() | ||
.filter(applyGroupStrategy -> applyGroupStrategy.support(groupType)) | ||
.findFirst() | ||
.orElseThrow(() -> new GongBaekException(ResponseError.BAD_REQUEST)); | ||
} | ||
} |
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