-
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
20 changed files
with
417 additions
and
361 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,4 @@ public void deleteComments(final List<Post> posts) { | |
} | ||
|
||
|
||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
module-domain/src/main/java/com/mile/curious/service/CuriousRemover.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,34 @@ | ||
package com.mile.curious.service; | ||
|
||
|
||
import com.mile.curious.domain.Curious; | ||
import com.mile.curious.repository.CuriousRepository; | ||
import com.mile.post.domain.Post; | ||
import com.mile.writername.domain.WriterName; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class CuriousRemover { | ||
private final CuriousRepository curiousRepository; | ||
private final CuriousRetriever curiousRetriever; | ||
|
||
public void deleteAllByWriterNameId( | ||
final WriterName writerName | ||
) { | ||
|
||
List<Curious> curiousList = curiousRetriever.findAllByWriterName(writerName); | ||
|
||
curiousList.forEach(curious -> { | ||
Post post = curious.getPost(); | ||
post.decreaseCuriousCount(); | ||
writerName.decreaseTotalCuriousCount(); | ||
}); | ||
|
||
curiousRepository.deleteAll(curiousList); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
module-domain/src/main/java/com/mile/curious/service/CuriousRetriever.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,21 @@ | ||
package com.mile.curious.service; | ||
|
||
import com.mile.curious.domain.Curious; | ||
import com.mile.curious.repository.CuriousRepository; | ||
import com.mile.writername.domain.WriterName; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class CuriousRetriever { | ||
|
||
private final CuriousRepository curiousRepository; | ||
|
||
public List<Curious> findAllByWriterName(final WriterName writerName) { | ||
return curiousRepository.findAllByWriterName(writerName); | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
module-domain/src/main/java/com/mile/moim/service/MoimCreator.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,18 @@ | ||
package com.mile.moim.service; | ||
|
||
import com.mile.moim.domain.Moim; | ||
import com.mile.moim.repository.MoimRepository; | ||
import com.mile.moim.service.dto.MoimCreateRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class MoimCreator { | ||
|
||
private final MoimRepository moimRepository; | ||
|
||
public Moim createMoim(MoimCreateRequest moimCreateRequest) { | ||
return moimRepository.save(Moim.create(moimCreateRequest)); | ||
} | ||
} |
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
Oops, something went wrong.