Skip to content

Commit

Permalink
fix: fix for non-members to see
Browse files Browse the repository at this point in the history
  • Loading branch information
minaamim committed Jan 15, 2024
1 parent 51eccf6 commit 0fa9486
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ public PostResponse publish(JwtUser user, Long postId, CreatePostReq dto) {
}

public PostResponse getPost(JwtUser user, Long postId) {
String userId;
//비회원
if(user.getRole().equals(Role.NON_MEMBER.getValue())) userId = postId + NON_MEMBER + LocalDateTime.now();
else userId = user.getId().toString();
String userId = NON_MEMBER + LocalDateTime.now();

if(!user.getRole().equals(Role.NON_MEMBER.getValue())) {
userId = user.getId().toString();
}

String key = String.format(POLL_DEFAULT + "%s", postId);

Expand Down Expand Up @@ -162,18 +163,19 @@ public String endPoll(JwtUser user, Long postId) {

//전체 공개 포스트만
public List<PostResponse> getPage(JwtUser user, final int page, final int count) {
String userId;
//비회원
if(user.getRole().equals(Role.NON_MEMBER.getValue())) userId = NON_MEMBER + LocalDateTime.now();
else userId = user.getId().toString();
String userId = NON_MEMBER + LocalDateTime.now();

if(!user.getRole().equals(Role.NON_MEMBER.getValue())) {
userId = user.getId().toString();
}

List<PostResponse> responseList = postRepository.findPageByIsPublishedAndPublicStatusOrderByIdDesc(true, PublicStatus.PUBLIC, PageRequest.of(page, count))
.stream()
.map(Post::newPostResponse)
.collect(Collectors.toList());

responseList = addItemSelectedByUser(userId, responseList);
responseList = addArchiveStatusByUser(user.getId().toString(), responseList);
responseList = addArchiveStatusByUser(userId, responseList);
return responseList;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.nexters.buyornot.module.user.api.dto;

import com.nexters.buyornot.module.model.Role;
import io.jsonwebtoken.Claims;
import lombok.*;

Expand All @@ -15,7 +16,7 @@ public class JwtUser implements Serializable {
private UUID id;
private String nickname;
private String profile;
private String role;
private String role = Role.NON_MEMBER.getValue();

public static JwtUser newJwtUser(Claims claims) {
return builder()
Expand Down

0 comments on commit 0fa9486

Please sign in to comment.