Skip to content

Commit

Permalink
Merge pull request #86 from IDEA-CAMPUS/fix/club
Browse files Browse the repository at this point in the history
Feat: clubPost 응답 id값 추가
  • Loading branch information
jisujeong0 authored Jan 12, 2024
2 parents 45238e6 + a2fa412 commit 08a6472
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 27 deletions.
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

0 comments on commit 08a6472

Please sign in to comment.