Skip to content
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

Feat: clubPost 응답 id값 추가 #86

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import depth.main.ideac.domain.club_post.ClubPost;
import depth.main.ideac.domain.club_post.ClubPostImage;
import depth.main.ideac.domain.club_post.dto.ClubPostReq;
import depth.main.ideac.domain.club_post.dto.ClubPostRes;
import depth.main.ideac.domain.club_post.dto.request.ClubPostReq;
import depth.main.ideac.domain.club_post.dto.response.ClubPostRes;
import depth.main.ideac.domain.club_post.repository.ClubPostImageRepository;
import depth.main.ideac.domain.club_post.repository.ClubPostRepository;
import depth.main.ideac.domain.club_post.dto.ClubPostDetailRes;
import depth.main.ideac.domain.club_post.dto.UpdateClubPostReq;
import depth.main.ideac.domain.club_post.dto.response.ClubPostDetailRes;
import depth.main.ideac.domain.club_post.dto.request.UpdateClubPostReq;
import depth.main.ideac.domain.user.domain.Role;
import depth.main.ideac.domain.user.domain.User;
import depth.main.ideac.global.error.DefaultException;
Expand Down Expand Up @@ -42,6 +42,7 @@ public Page<ClubPostRes> getAllClubPosts(Pageable pageable) {

List<ClubPostRes> clubPostResList = posts.getContent().stream()
.map(clubPost -> ClubPostRes.builder()
.id(clubPost.getId())
.title(clubPost.getTitle())
.description(clubPost.getDetailedDescription())
.createdAt(clubPost.getCreatedAt())
Expand Down Expand Up @@ -72,6 +73,7 @@ public ClubPostDetailRes getDetailClubPosts(Long clubId) {
.toList();

return ClubPostDetailRes.builder()
.id(clubPost.getId())
.title(clubPost.getTitle())
.description(clubPost.getDetailedDescription())
.url1(clubPost.getUrl1())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package depth.main.ideac.domain.club_post.dto;
package depth.main.ideac.domain.club_post.dto.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Data
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class ClubPostReq {
Expand All @@ -22,5 +23,4 @@ public class ClubPostReq {

private String url2;

// 이미지 path는 추후 추가
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package depth.main.ideac.domain.club_post.dto;
package depth.main.ideac.domain.club_post.dto.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
Expand All @@ -8,7 +8,6 @@
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@AllArgsConstructor
@Getter
Expand All @@ -25,6 +24,4 @@ public class UpdateClubPostReq {

private String url2;

// private List<ClubPostImage> clubPostImages;

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package depth.main.ideac.domain.club_post.dto;
package depth.main.ideac.domain.club_post.dto.response;

import lombok.Builder;
import lombok.Data;
import lombok.Getter;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Getter
@Builder
public class ClubPostDetailRes {

private Long id;

private String title;

private String description;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package depth.main.ideac.domain.club_post.dto;
package depth.main.ideac.domain.club_post.dto.response;

import depth.main.ideac.domain.club_post.ClubPost;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;


import java.time.LocalDateTime;

@Data
@Getter
@Builder
public class ClubPostRes {

private Long id;

private String title;

private String description;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package depth.main.ideac.domain.club_post.presentation;

import depth.main.ideac.domain.club_post.application.ClubPostService;
import depth.main.ideac.domain.club_post.dto.ClubPostDetailRes;
import depth.main.ideac.domain.club_post.dto.ClubPostReq;
import depth.main.ideac.domain.club_post.dto.ClubPostRes;
import depth.main.ideac.domain.club_post.dto.UpdateClubPostReq;
import depth.main.ideac.domain.club_post.dto.response.ClubPostDetailRes;
import depth.main.ideac.domain.club_post.dto.request.ClubPostReq;
import depth.main.ideac.domain.club_post.dto.response.ClubPostRes;
import depth.main.ideac.domain.club_post.dto.request.UpdateClubPostReq;
import depth.main.ideac.global.config.security.token.CurrentUser;
import depth.main.ideac.global.config.security.token.UserPrincipal;
import depth.main.ideac.global.payload.ApiResponse;
Expand Down Expand Up @@ -38,7 +38,7 @@ public class ClubPostController {
@Operation(summary = "글 전체 조회", description = "동아리/학회 페이지의 글을 전체 조회하는 API입니다.")
@GetMapping
public ResponseEntity<?> getAllClubPosts(@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size) {
@RequestParam(defaultValue = "10") int size) {
Pageable pageable = PageRequest.of(page, size, Sort.by("createdAt").descending());
Page<ClubPostRes> posts = clubPostService.getAllClubPosts(pageable);

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

import depth.main.ideac.domain.club_post.ClubPost;
import depth.main.ideac.domain.club_post.ClubPostImage;
import depth.main.ideac.domain.club_post.dto.ClubPostRes;
import depth.main.ideac.domain.club_post.dto.response.ClubPostRes;
import depth.main.ideac.domain.club_post.repository.ClubPostRepository;
import depth.main.ideac.domain.idea_post.IdeaPost;
import depth.main.ideac.domain.idea_post.dto.GetAllIdeasRes;
import depth.main.ideac.domain.idea_post.dto.response.GetAllIdeasRes;
import depth.main.ideac.domain.idea_post.repository.IdeaPostRepository;
import depth.main.ideac.domain.project_post.ProjectPost;
import depth.main.ideac.domain.project_post.ProjectPostImage;
Expand All @@ -28,17 +28,19 @@ public class HomeService {
private final IdeaPostRepository ideaPostRepository;
private final ProjectPostRepository projectPostRepository;

// 아이디어
public List<GetAllIdeasRes> getIdeas() {
List<IdeaPost> ideaPosts = ideaPostRepository.findTop3ByOrderByCreatedAtDesc();

return ideaPosts.stream()
.map(ideaPost -> GetAllIdeasRes.builder()
.id(ideaPost.getId())
.title(ideaPost.getTitle())
.simpleDescription(ideaPost.getSimpleDescription())
.hits(ideaPost.getHits())
.keyword(Arrays.asList(ideaPost.getKeyword().split(",")))
.color(ideaPost.getUser().getColor())
.nickName(ideaPost.getUser().getNickname())
.createdAt(ideaPost.getCreatedAt())
.build())
.collect(Collectors.toList());
}
Expand All @@ -55,12 +57,15 @@ public List<ProjectRes> getProjects() {
.map(ProjectPostImage::getImagePath)
.orElse(null);
return ProjectRes.builder()
.id(projectPost.getId())
.booleanWeb(projectPost.isBooleanWeb())
.booleanApp(projectPost.isBooleanApp())
.booleanAi(projectPost.isBooleanAi())
.team(projectPost.getTeam())
.title(projectPost.getTitle())
.simpleDescription(projectPost.getSimpleDescription())
.hits(projectPost.getHits())
.createdAt(projectPost.getCreatedAt())
.thumbnail(thumbnail)
.build();
})
Expand All @@ -73,6 +78,7 @@ public List<ClubPostRes> getClubs() {

return clubPosts.stream()
.map(clubPost -> ClubPostRes.builder()
.id(clubPost.getId())
.title(clubPost.getTitle())
.description(clubPost.getDetailedDescription())
.thumbnail(clubPost.getClubPostImages().stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package depth.main.ideac.domain.home.presentation;

import depth.main.ideac.domain.club_post.dto.ClubPostRes;
import depth.main.ideac.domain.club_post.dto.response.ClubPostRes;
import depth.main.ideac.domain.home.application.HomeService;
import depth.main.ideac.domain.idea_post.dto.GetAllIdeasRes;
import depth.main.ideac.domain.idea_post.dto.response.GetAllIdeasRes;
import depth.main.ideac.domain.project_post.dto.response.ProjectRes;
import depth.main.ideac.global.payload.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand Down
Loading