Skip to content

Commit

Permalink
Merge pull request #479 from team-yello/develop
Browse files Browse the repository at this point in the history
[feat] 댓글 게시글 추가
  • Loading branch information
euije authored Mar 12, 2024
2 parents 82a88fa + e9f18d8 commit 7af29d2
Show file tree
Hide file tree
Showing 34 changed files with 564 additions and 288 deletions.
5 changes: 0 additions & 5 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@

* link:purchase-check.html[구독 상태 및 열람권 개수 조회하기]

=== Pay API

- @Deprecated at 2024.03
* link:pay.html[결제 전환율 체크]

=== Notice API

* 🆕 link:find-notice.html[공지 조회, 2024-01-29]
Expand Down
10 changes: 0 additions & 10 deletions src/docs/asciidoc/pay.adoc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ protected void doFilterInternal(
|| requestPath.startsWith("/v2/google/notifications")
|| requestPath.startsWith("/api/v1/admob/verify")
|| requestPath.startsWith("/api/v1/statistics")
|| (requestPath.startsWith("/api/v1/auth")
&& !requestPath.startsWith("/api/v1/auth/token/issue"))) {
|| (requestPath.startsWith("/api/v1/auth") && !requestPath.startsWith("/api/v1/auth/token/issue"))) {
filterChain.doFilter(request, response);
return;
}
Expand All @@ -68,6 +67,22 @@ protected void doFilterInternal(
throw new CustomAuthenticationException(AUTHENTICATION_ERROR);
}

val token = accessHeader.substring(BEARER.length());
Long userId = tokenProvider.getUserId(token);
request.setAttribute("userId", userId);
} else if (requestPath.equals("/api/v1/user/post/comment")) {
val accessHeader = request.getHeader(AUTHORIZATION);
log.info("Authorization : {}", accessHeader);

if (accessHeader == null) {
filterChain.doFilter(request, response);
return;
}

if (!accessHeader.startsWith(BEARER)) {
throw new CustomAuthenticationException(AUTHENTICATION_ERROR);
}

val token = accessHeader.substring(BEARER.length());
Long userId = tokenProvider.getUserId(token);
request.setAttribute("userId", userId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.yello.server.domain.authorization.filter;

import static org.springframework.http.HttpHeaders.AUTHORIZATION;

import com.yello.server.domain.user.entity.User;
import com.yello.server.domain.user.repository.UserRepository;
import jakarta.servlet.FilterChain;
Expand Down Expand Up @@ -48,6 +50,11 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
return;
}

if (requestPath.equals("/api/v1/user/post/comment") && request.getHeader(AUTHORIZATION) == null) {
filterChain.doFilter(request, response);
return;
}

final Long userId = (Long) request.getAttribute("userId");
log.info("Current user's id: {}", userId);

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions src/main/java/com/yello/server/domain/pay/service/PayService.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.yello.server.domain.user.controller;

import static com.yello.server.global.common.SuccessCode.DELETE_USER_SUCCESS;
import static com.yello.server.global.common.SuccessCode.GET_USER_POST_COMMENT_SUCCESS;
import static com.yello.server.global.common.SuccessCode.POST_USER_POST_COMMENT_SUCCESS;
import static com.yello.server.global.common.SuccessCode.READ_USER_DATA_SUCCESS;
import static com.yello.server.global.common.SuccessCode.READ_USER_SUBSCRIBE_SUCCESS;
import static com.yello.server.global.common.SuccessCode.READ_USER_SUCCESS;
Expand All @@ -11,10 +13,12 @@
import com.yello.server.domain.user.dto.request.UserDataUpdateRequest;
import com.yello.server.domain.user.dto.request.UserDeleteReasonRequest;
import com.yello.server.domain.user.dto.request.UserDeviceTokenRequest;
import com.yello.server.domain.user.dto.request.UserPostCommentUpdateRequest;
import com.yello.server.domain.user.dto.request.UserUpdateRequest;
import com.yello.server.domain.user.dto.response.UserDataResponse;
import com.yello.server.domain.user.dto.response.UserDetailResponse;
import com.yello.server.domain.user.dto.response.UserDetailV2Response;
import com.yello.server.domain.user.dto.response.UserPostCommentResponse;
import com.yello.server.domain.user.dto.response.UserResponse;
import com.yello.server.domain.user.dto.response.UserSubscribeDetailResponse;
import com.yello.server.domain.user.entity.User;
Expand All @@ -23,15 +27,18 @@
import com.yello.server.global.common.annotation.AccessTokenUser;
import com.yello.server.global.common.dto.BaseResponse;
import com.yello.server.global.common.dto.EmptyObject;
import jakarta.annotation.Nullable;
import lombok.RequiredArgsConstructor;
import lombok.val;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
Expand Down Expand Up @@ -105,4 +112,19 @@ public BaseResponse updateUserData(@AccessTokenUser User user, @PathVariable("ta
userService.updateUserData(user.getId(), UserDataType.fromCode(tag), request);
return BaseResponse.success(UPDATE_USER_DATA_SUCCESS);
}

@GetMapping("/v1/user/post/comment")
public BaseResponse<UserPostCommentResponse> getUserPostComment(@Nullable @AccessTokenUser User user,
@RequestParam(value = "postId") Long postId, Pageable pageable) {
System.out.println("user = " + user);
val data = userService.getUserPostComment(user == null ? null : user.getId(), postId, pageable);
return BaseResponse.success(GET_USER_POST_COMMENT_SUCCESS, data);
}

@PostMapping("/v1/user/post/comment")
public BaseResponse postUserPostComment(@Nullable @AccessTokenUser User user,
@RequestBody UserPostCommentUpdateRequest request) {
userService.updatePostComment(user == null ? null : user.getId(), request);
return BaseResponse.success(POST_USER_POST_COMMENT_SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.yello.server.domain.user.dto.request;

import jakarta.annotation.Nullable;

public record UserPostCommentUpdateRequest(
@Nullable Long id,
Long postId,
String userName,
String yelloId,
String status,
String title,
String subtitle,
String content
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.yello.server.domain.user.dto.response;

import java.util.List;
import lombok.Builder;

@Builder
public record UserPostCommentResponse(
Long pageCount,
Long totalCount,
List<UserPostCommentVO> postCommentList
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.yello.server.domain.user.dto.response;

import com.yello.server.domain.user.entity.User;
import com.yello.server.domain.user.entity.UserPost;
import com.yello.server.domain.user.entity.UserPostComment;
import lombok.Builder;

@Builder
public record UserPostCommentVO(
Long id,
Long userPostId,
Long userId,
String status,
String userName,
String yelloId,
String title,
String subtitle,
String content,
String createdAt,
String updatedAt
) {

public static UserPostCommentVO of(UserPostComment userPostComment) {
UserPost userPost = userPostComment.getUserPost();
User user = userPostComment.getUser();
return UserPostCommentVO.builder()
.id(userPostComment.getId())
.userPostId(userPost == null ? null : userPost.getId())
.userId(user == null ? null : user.getId())
.status(userPostComment.getStatus().getInitial())
.userName(userPostComment.getUserName())
.yelloId(userPostComment.getYelloId())
.title(userPostComment.getTitle())
.subtitle(userPostComment.getSubtitle())
.content(userPostComment.getContent())
.createdAt(String.valueOf(userPostComment.getCreatedAt()))
.updatedAt(String.valueOf(userPostComment.getUpdatedAt()))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.yello.server.domain.pay.entity;
package com.yello.server.domain.user.entity;

import com.yello.server.domain.user.entity.User;
import com.yello.server.global.common.dto.AuditingTimeEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand All @@ -16,32 +18,39 @@
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Getter
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Pay {
public class UserPost extends AuditingTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private Integer optionIndex;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "userId")
@OnDelete(action = OnDeleteAction.CASCADE)
@OnDelete(action = OnDeleteAction.SET_NULL)
@JoinColumn(name = "userId", nullable = true)
private User user;

public static Pay of(Integer optionIndex, User user) {
return Pay.builder()
.optionIndex(optionIndex)
.user(user)
.build();
}

public static Pay createPay(Integer optionIndex, User user) {
return Pay.of(optionIndex, user);
}
}
@Column(nullable = false)
@Convert(converter = UserPostStatusConverter.class)
private UserPostStatus status;

@Column
private String userName;

@Column
private String yelloId;

@Column
private String title;

@Column
private String subtitle;

@Column(columnDefinition = "MEDIUMTEXT")
private String content;

}
Loading

0 comments on commit 7af29d2

Please sign in to comment.