-
Notifications
You must be signed in to change notification settings - Fork 27
해시태그 팔로우 구현, 검색 API 개선 #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e749af6
Feat: 해시태그 팔로우 구현
vectorch9 9865378
Merge remote-tracking branch 'origin/develop' into Feature/HashtagFollow
vectorch9 08b7683
Fix: 기존의 유저 검색 API 제거
vectorch9 ebc99b9
Feat: 유저, 해시태그 검색 API 추가
vectorch9 6f129c7
Feat: 해시태그 연관 검색어 목록 페이징 조회 API 제거
seonpilKim 8a091fa
Feat: 게시물/댓글 업로드 or 삭제 API 로직 추가
seonpilKim 3c48b31
Fix: 일치하는 검색어 처리 로직 수정
vectorch9 736b770
Fix: 테스트 후 복구시켜놓지 않은 코드 수정
vectorch9 f00455d
Fix: 검색 조회수 증가 URI 변경
vectorch9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
62 changes: 62 additions & 0 deletions
62
src/main/java/cloneproject/Instagram/controller/SearchController.java
This file contains hidden or 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,62 @@ | ||
package cloneproject.Instagram.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import cloneproject.Instagram.dto.result.ResultCode; | ||
import cloneproject.Instagram.dto.result.ResultResponse; | ||
import cloneproject.Instagram.dto.search.SearchDTO; | ||
import cloneproject.Instagram.service.SearchService; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiImplicitParam; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@Validated | ||
@Api(tags = "검색 API") | ||
@RestController | ||
@RequiredArgsConstructor | ||
public class SearchController { | ||
|
||
private final SearchService searchService; | ||
|
||
@ApiOperation(value = "검색") | ||
@ApiImplicitParam(name = "text", value = "검색내용", required = true, example = "dlwl") | ||
@GetMapping(value = "/topsearch") | ||
public ResponseEntity<ResultResponse> searchText(@RequestParam String text) { | ||
List<SearchDTO> searchDTOs = searchService.searchByText(text); | ||
|
||
ResultResponse result = ResultResponse.of(ResultCode.SEARCH_SUCCESS, searchDTOs); | ||
return new ResponseEntity<>(result, HttpStatus.valueOf(result.getStatus())); | ||
} | ||
|
||
@ApiOperation(value = "유저 검색 조회수 증가") | ||
@ApiImplicitParam(name = "username", value = "조회수 증가시킬 username", required = true, example = "dlwlrma") | ||
@PostMapping(value = "/topsearch/member/upcount") | ||
public ResponseEntity<ResultResponse> increaseSearchMemberCount(@RequestParam String username) { | ||
searchService.increaseSearchMemberCount(username); | ||
|
||
ResultResponse result = ResultResponse.of(ResultCode.INCREASE_SEARCH_COUNT_SUCCESS, null); | ||
return new ResponseEntity<>(result, HttpStatus.valueOf(result.getStatus())); | ||
} | ||
|
||
@ApiOperation(value = "해시태그 검색 조회수 증가") | ||
@ApiImplicitParam(name = "name", value = "조회수 증가시킬 hashtag", required = true, example = "만두") | ||
@PostMapping(value = "/topsearch/hashtag/upcount") | ||
public ResponseEntity<ResultResponse> increaseSearchHashtagCount(@RequestParam String name) { | ||
searchService.increaseSearchHashtagCount(name); | ||
|
||
ResultResponse result = ResultResponse.of(ResultCode.INCREASE_SEARCH_COUNT_SUCCESS, null); | ||
return new ResponseEntity<>(result, HttpStatus.valueOf(result.getStatus())); | ||
} | ||
seonpilKim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
} |
This file contains hidden or 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 hidden or 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
37 changes: 0 additions & 37 deletions
37
src/main/java/cloneproject/Instagram/dto/member/SearchedMemberDTO.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
22 changes: 22 additions & 0 deletions
22
src/main/java/cloneproject/Instagram/dto/search/SearchDTO.java
This file contains hidden or 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 cloneproject.Instagram.dto.search; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
seonpilKim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public class SearchDTO { | ||
|
||
private String dtype; | ||
|
||
@JsonIgnore | ||
private Long count; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/cloneproject/Instagram/dto/search/SearchHashtagDTO.java
This file contains hidden or 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,26 @@ | ||
package cloneproject.Instagram.dto.search; | ||
|
||
import com.querydsl.core.annotations.QueryProjection; | ||
|
||
import cloneproject.Instagram.entity.hashtag.Hashtag; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class SearchHashtagDTO extends SearchDTO{ | ||
|
||
private String name; | ||
private Integer postCount; | ||
|
||
@QueryProjection | ||
public SearchHashtagDTO(String dtype, Long count, Hashtag hashtag){ | ||
super(dtype, count); | ||
this.name = hashtag.getName(); | ||
this.postCount = hashtag.getCount(); | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/cloneproject/Instagram/dto/search/SearchMemberDTO.java
This file contains hidden or 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,37 @@ | ||
package cloneproject.Instagram.dto.search; | ||
|
||
import java.util.List; | ||
|
||
import com.querydsl.core.annotations.QueryProjection; | ||
|
||
import cloneproject.Instagram.dto.member.FollowDTO; | ||
import cloneproject.Instagram.dto.member.MemberDTO; | ||
import cloneproject.Instagram.entity.member.Member; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class SearchMemberDTO extends SearchDTO{ | ||
|
||
private MemberDTO memberDTO; | ||
private boolean isFollowing; | ||
private boolean isFollower; | ||
private List<FollowDTO> followingMemberFollow; | ||
|
||
@QueryProjection | ||
public SearchMemberDTO(String dtype, Long count, Member member, boolean isFollowing, boolean isFollower){ | ||
super(dtype, count); | ||
this.memberDTO = new MemberDTO(member); | ||
this.isFollowing = isFollowing; | ||
this.isFollower = isFollower; | ||
// this.followingMemberFollow = followingMemberFollow; | ||
} | ||
public void setFollowingMemberFollow(List<FollowDTO> followingMemberFollow) { | ||
this.followingMemberFollow = followingMemberFollow; | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/cloneproject/Instagram/entity/member/HashtagFollow.java
This file contains hidden or 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,44 @@ | ||
package cloneproject.Instagram.entity.member; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
|
||
import cloneproject.Instagram.entity.hashtag.Hashtag; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "hashtag_follows") | ||
public class HashtagFollow { | ||
|
||
@Id | ||
@Column(name = "hashtag_follow_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "hashtag_id") | ||
private Hashtag hashtag; | ||
|
||
@Builder | ||
public HashtagFollow(Member member, Hashtag hashtag) { | ||
this.member = member; | ||
this.hashtag = hashtag; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/cloneproject/Instagram/entity/search/Search.java
This file contains hidden or 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,38 @@ | ||
package cloneproject.Instagram.entity.search; | ||
|
||
import lombok.Getter; | ||
|
||
import javax.persistence.*; | ||
|
||
@Getter | ||
@Entity | ||
@Inheritance(strategy = InheritanceType.JOINED) | ||
@DiscriminatorColumn | ||
@Table(name = "searches") | ||
public class Search { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "search_id") | ||
private Long id; | ||
|
||
@Column(name = "search_count") | ||
private Long count; | ||
|
||
@Column(insertable = false, updatable = false) | ||
private String dtype; | ||
|
||
protected Search(){ | ||
this.count = 0L; | ||
} | ||
|
||
public void upCount(){ | ||
this.count++; | ||
} | ||
|
||
@Transient | ||
public void setDtype() { | ||
this.dtype = getClass().getAnnotation(DiscriminatorValue.class).value(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.