Skip to content

Commit

Permalink
Merge pull request #126 from inje-megabrain/modi/anonymouseSearch
Browse files Browse the repository at this point in the history
익명사용자에 대한 검색기능 예외처리
  • Loading branch information
mjh000526 authored Mar 7, 2024
2 parents 53b6a7d + b924290 commit 1cf222c
Show file tree
Hide file tree
Showing 18 changed files with 146 additions and 31 deletions.
Binary file modified .gradle/7.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions src/main/generated/com/example/just/Dao/QHashTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class QHashTag extends EntityPathBase<HashTag> {

public static final QHashTag hashTag = new QHashTag("hashTag");

public final ListPath<HashTagMap, QHashTagMap> hashTagMaps = this.<HashTagMap, QHashTagMap>createList("hashTagMaps", HashTagMap.class, QHashTagMap.class, PathInits.DIRECT2);

public final NumberPath<Long> id = createNumber("id", Long.class);

public final StringPath name = createString("name");

public final ListPath<Post, QPost> posts = this.<Post, QPost>createList("posts", Post.class, QPost.class, PathInits.DIRECT2);

public final NumberPath<Long> tagCount = createNumber("tagCount", Long.class);

public QHashTag(String variable) {
Expand Down
54 changes: 54 additions & 0 deletions src/main/generated/com/example/just/Dao/QHashTagMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.example.just.Dao;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.PathInits;


/**
* QHashTagMap is a Querydsl query type for HashTagMap
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QHashTagMap extends EntityPathBase<HashTagMap> {

private static final long serialVersionUID = -1800252931L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QHashTagMap hashTagMap = new QHashTagMap("hashTagMap");

public final QHashTag hashTag;

public final NumberPath<Long> id = createNumber("id", Long.class);

public final QPost post;

public QHashTagMap(String variable) {
this(HashTagMap.class, forVariable(variable), INITS);
}

public QHashTagMap(Path<? extends HashTagMap> path) {
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
}

public QHashTagMap(PathMetadata metadata) {
this(metadata, PathInits.getFor(metadata, INITS));
}

public QHashTagMap(PathMetadata metadata, PathInits inits) {
this(HashTagMap.class, metadata, inits);
}

public QHashTagMap(Class<? extends HashTagMap> type, PathMetadata metadata, PathInits inits) {
super(type, metadata, inits);
this.hashTag = inits.isInitialized("hashTag") ? new QHashTag(forProperty("hashTag")) : null;
this.post = inits.isInitialized("post") ? new QPost(forProperty("post"), inits.get("post")) : null;
}

}

2 changes: 1 addition & 1 deletion src/main/generated/com/example/just/Dao/QPost.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class QPost extends EntityPathBase<Post> {

public final StringPath emoticon = createString("emoticon");

public final ListPath<HashTag, QHashTag> hashTags = this.<HashTag, QHashTag>createList("hashTags", HashTag.class, QHashTag.class, PathInits.DIRECT2);
public final ListPath<HashTagMap, QHashTagMap> hashTagMaps = this.<HashTagMap, QHashTagMap>createList("hashTagMaps", HashTagMap.class, QHashTagMap.class, PathInits.DIRECT2);

public final ListPath<Member, QMember> likedMembers = this.<Member, QMember>createList("likedMembers", Member.class, QMember.class, PathInits.DIRECT2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-03-06T15:49:26+0900",
date = "2024-03-07T17:11:37+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
)
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-03-06T15:49:26+0900",
date = "2024-03-07T17:11:38+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
)
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class CommentController {
+ " \"child\": []\n"
+ " \"message\": \"입력 완료\"\n"
+ "}"),
@ApiResponse(responseCode = "404", description = "{\n"
@ApiResponse(responseCode = "400", description = "{\n"
+ " \"comment_id\": \"\",\n"
+ " \"comment_create_time\": 0\n"
+ " \"comment_create_time\": \"\",\n"
Expand Down Expand Up @@ -109,7 +109,7 @@ public ResponseEntity<String> deleteComment(@PathVariable Long post_id, @PathVar
@ApiOperation(value = "댓글 수정")
@ApiResponses(value = {
@ApiResponse(responseCode = "200",description = "댓글 내용"),
@ApiResponse(responseCode = "404",description = "댓글이 존재하지 않습니다.\n게시물이 존재하지 않습니다.")
@ApiResponse(responseCode = "400",description = "댓글이 존재하지 않습니다.\n게시물이 존재하지 않습니다.")
})
@PutMapping("/put/comment/{post_id}/{comment_id}")
public ResponseEntity<String> putComment(@PathVariable Long post_id, @PathVariable Long comment_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public class SearchController {

@GetMapping("/get/search/post")
@Operation(summary = "게시글 내용 검색", description = "해당 keyword를 content에 포함하는 게시글 검색\n태그검색구현시 추후 변경 가능")
@ApiResponses(value = {
@ApiResponse(responseCode = "400", description = "{\n"
+ " \"message\": \"로그인 후 검색가능합니다.\"\n"
+ "}")
})
public ResponseEntity getPosts(@RequestParam String keyword,@RequestParam int page, HttpServletRequest request) {
return searchService.searchPostContent(request,keyword,page-1);
}
Expand Down
27 changes: 18 additions & 9 deletions src/main/java/com/example/just/Dao/HashTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
Expand All @@ -12,8 +13,12 @@
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
Expand All @@ -31,14 +36,18 @@ public class HashTag {
@Column(name = "tag_count")
private Long tagCount;

@ManyToMany()
@JoinTable(
name = "hash_tag_map",
joinColumns = @JoinColumn(name = "hash_tag_id"),
inverseJoinColumns = @JoinColumn(name = "post_id")
)
@JsonIgnore
@Builder.Default
private List<Post> posts = new ArrayList<>();
@OneToMany(mappedBy = "hashTag", cascade = CascadeType.REMOVE)
private List<HashTagMap> hashTagMaps = new ArrayList<>();


public HashTag() {
}

public HashTag(String name) {
this.name = name;
}

public void addHashTagMap(HashTagMap hashTagMap) {
this.hashTagMaps.add(hashTagMap);
}
}
36 changes: 36 additions & 0 deletions src/main/java/com/example/just/Dao/HashTagMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.example.just.Dao;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Getter
@Setter
@NoArgsConstructor
public class HashTagMap {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id", nullable = false)
private Long id;

@ManyToOne
@JoinColumn(name = "post_id")
private Post post;

@ManyToOne
@JoinColumn(name = "hash_tag_id")
private HashTag hashTag;

public HashTagMap(HashTag newHashTag, Post p) {
this.hashTag = newHashTag;
this.post = p;
}
}
23 changes: 8 additions & 15 deletions src/main/java/com/example/just/Dao/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ public class Post {
@Builder.Default
private List<Member> likedMembers = new ArrayList<>();

@Builder.Default
@ManyToMany(mappedBy = "posts")
private List<HashTag> hashTags = new ArrayList<>();
@OneToMany(mappedBy = "post", cascade = CascadeType.REMOVE)
private List<HashTagMap> hashTagMaps = new ArrayList<>();

@ManyToOne()
@JoinColumn(name = "member_id") //글을쓴 Member_id
@JsonIgnore
private Member member;

@OneToMany(mappedBy = "post", cascade = CascadeType.REMOVE)
@OneToMany(mappedBy = "post", orphanRemoval = true)
private List<Comment> comments = new ArrayList<>();
@Column(name = "blamed_count")
private Long blamedCount;
Expand Down Expand Up @@ -123,24 +122,13 @@ public boolean getSecret() {
}

public void changePost(PutPostDto postDto, Member member, Post post) {
/*
this.post_id = post.getPost_id();
this.member = member;
this.setPost_create_time(new Date(System.currentTimeMillis()));
this.setPost_like(post.getPost_like());
this.post_picture = postDto.getPost_picture();
this.secret = postDto.getSecret();
this.postContent = postDto.getPost_content();
this.hash_tag = null;
if (postDto.getHash_tage() != null) {
for (int i = 0; i < postDto.getHash_tage().size(); i++) {
String hashTag_name = postDto.getHash_tage().get(i);
HashTag hashTag = new HashTag(hashTag_name);
addHashTag(hashTag);
}
}
*/
}

public List<HashTag> getHashTag() {
Expand All @@ -155,4 +143,9 @@ public List<HashTag> getHashTag() {
*/
return array;
}


public void addHashTagMaps(HashTagMap hashTagMap) {
this.hashTagMaps.add(hashTagMap);
}
}
13 changes: 13 additions & 0 deletions src/main/java/com/example/just/Response/ResponseMessage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.just.Response;

import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class ResponseMessage {
private String message;
public ResponseMessage(String m){
message = m;
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/example/just/Service/SearchService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.example.just.Repository.MemberRepository;
import com.example.just.Repository.PostContentESRespository;
import com.example.just.Repository.PostRepository;
import com.example.just.Response.ResponseMessage;
import com.example.just.Response.ResponseSearchDto;
import com.example.just.jwt.JwtProvider;
import java.util.Comparator;
Expand All @@ -16,6 +17,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

Expand All @@ -39,6 +41,9 @@ public class SearchService {

public ResponseEntity searchPostContent(HttpServletRequest request,String keyword,int page){
String token = jwtProvider.getAccessToken(request);
if(token == null){
return new ResponseEntity(new ResponseMessage("로그인 후 검색가능합니다."),null, HttpStatus.BAD_REQUEST);
}
Long id = Long.valueOf(jwtProvider.getIdFromToken(token)); //토큰
List<Blame> blames = blameRepository.findByBlameMemberId(id);
//유저가 신고한 게시글 id들
Expand Down

0 comments on commit 1cf222c

Please sign in to comment.