-
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.
Merge pull request #96 from potenday-project/develop
Develop
- Loading branch information
Showing
33 changed files
with
917 additions
and
214 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
ALTER TABLE alcohol_type | ||
ADD `display_order` bigint DEFAULT NULL | ||
ADD `display_order` int DEFAULT NULL |
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
28 changes: 0 additions & 28 deletions
28
server/src/main/java/com/bside/bside_311/component/PostManager.java
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
server/src/main/java/com/bside/bside_311/component/PostService.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,72 @@ | ||
package com.bside.bside_311.component; | ||
|
||
import com.bside.bside_311.dto.GetPostsToOneMvo; | ||
import com.bside.bside_311.dto.PostSearchCondition; | ||
import com.bside.bside_311.entity.Post; | ||
import com.bside.bside_311.entity.YesOrNo; | ||
import com.bside.bside_311.repository.PostMybatisRepository; | ||
import com.bside.bside_311.repository.PostRepository; | ||
import com.bside.bside_311.util.AuthUtil; | ||
import com.bside.bside_311.util.MessageUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class PostService { | ||
private final PostRepository postRepository; | ||
private final PostMybatisRepository postMybatisRepository; | ||
|
||
public void savePost(Post post) { | ||
postRepository.save(post); | ||
} | ||
|
||
public Post findPost(Long postNo) { | ||
return postRepository.findByIdAndDelYnIs(postNo, YesOrNo.N).orElseThrow( | ||
() -> new IllegalArgumentException(MessageUtil.POST_NOT_FOUND_MSG)); | ||
} | ||
|
||
public void deletePost(Post post) { | ||
post.setDelYn(YesOrNo.Y); | ||
postRepository.save(post); | ||
} | ||
|
||
public Page<Post> getPostListCommon(Pageable pageable, String searchKeyword, | ||
List<Long> searchUserNoList, | ||
Boolean isLikedByMe, Boolean isCommentedByMe, | ||
List<Long> searchAlcoholNoList) { | ||
return postRepository.searchPageSimple( | ||
PostSearchCondition.builder().searchKeyword(searchKeyword) | ||
.searchUserNoList(searchUserNoList) | ||
.isLikedByMe(isLikedByMe) | ||
.isCommentedByMe(isCommentedByMe) | ||
.myUserNo( | ||
AuthUtil.getUserNoFromAuthentication()) | ||
.searchAlcoholNoList(searchAlcoholNoList) | ||
.build(), pageable); | ||
} | ||
|
||
public Page<Post> getPostListPopular(Long page, Long size) { | ||
return postRepository.searchPagePopular(page, size); | ||
} | ||
|
||
public Map<Long, GetPostsToOneMvo> getGetPostsToOneMvoMap(List<Long> postNos) { | ||
List<GetPostsToOneMvo> postsToOneList = | ||
CollectionUtils.isNotEmpty(postNos) ? postMybatisRepository.getPostsToOne(postNos) : | ||
List.of(); | ||
Map<Long, GetPostsToOneMvo> postsToOneMap = new HashMap<>(); | ||
for (GetPostsToOneMvo getPostsToOneMvo : postsToOneList) { | ||
postsToOneMap.put(getPostsToOneMvo.getPostNo(), getPostsToOneMvo); | ||
} | ||
return postsToOneMap; | ||
} | ||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
server/src/main/java/com/bside/bside_311/component/UserManager.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,25 @@ | ||
package com.bside.bside_311.component; | ||
|
||
import com.bside.bside_311.entity.User; | ||
import com.bside.bside_311.entity.YesOrNo; | ||
import com.bside.bside_311.repository.UserRepository; | ||
import com.bside.bside_311.util.MessageUtil; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.ObjectUtils; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class UserManager { | ||
private final UserRepository userRepository; | ||
|
||
public User getUser(Long userNo) { | ||
if (ObjectUtils.isEmpty(userNo)) { | ||
return null; | ||
} | ||
return userRepository.findByIdAndDelYnIs(userNo, YesOrNo.N).orElseThrow( | ||
() -> new IllegalArgumentException(MessageUtil.USER_NOT_FOUND_MSG)); | ||
} | ||
} |
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.