Skip to content

Commit

Permalink
Merge pull request #89 from IDEA-CAMPUS/develop
Browse files Browse the repository at this point in the history
release 2.2.0
  • Loading branch information
jisujeong0 authored Jan 12, 2024
2 parents f01ee04 + 5488ac1 commit 366644b
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 60 deletions.
12 changes: 0 additions & 12 deletions .idea/dataSources.xml

This file was deleted.

3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import jakarta.validation.constraints.Size;
import lombok.*;

import java.util.List;


@Entity
@Builder
Expand Down
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,12 @@
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 +22,4 @@ public class ClubPostReq {

private String url2;

// 이미지 path는 추후 추가
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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
@NoArgsConstructor
@AllArgsConstructor
@Getter
Expand All @@ -25,6 +23,4 @@ public class UpdateClubPostReq {

private String url2;

// private List<ClubPostImage> clubPostImages;

}
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 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 @@ -15,6 +15,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -27,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())
.keyword(ideaPost.getKeyword())
.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 @@ -54,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 @@ -72,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
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package depth.main.ideac.domain.idea_post.application;

import depth.main.ideac.domain.idea_post.IdeaPost;
import depth.main.ideac.domain.idea_post.dto.*;
import depth.main.ideac.domain.idea_post.dto.request.*;
import depth.main.ideac.domain.idea_post.dto.response.GetAllIdeasRes;
import depth.main.ideac.domain.idea_post.dto.response.GetDetailIdeaRes;
import depth.main.ideac.domain.idea_post.repository.IdeaPostRepository;
import depth.main.ideac.domain.user.domain.Role;
import depth.main.ideac.domain.user.domain.User;
Expand All @@ -22,10 +24,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;

@Service
Expand All @@ -40,6 +39,7 @@ public class IdeaPostService {
@Transactional
public Long registerIdea(UserPrincipal userPrincipal, RegisterIdeaReq registerIdeaReq){
User user = userRepository.findById(userPrincipal.getId()).get();

IdeaPost ideapost = IdeaPost.builder()
.title(registerIdeaReq.getTitle())
.keyword(registerIdeaReq.getKeyword())
Expand All @@ -60,13 +60,18 @@ public Long registerIdea(UserPrincipal userPrincipal, RegisterIdeaReq registerId
public ResponseEntity<?> getDetailIdea(Long id) {
IdeaPost ideaPost = ideaPostRepository.findById(id).get();

String[] split = ideaPost.getKeyword().split(",");
// for (String s : split) {
// System.out.println("s = " + s);
// }
List<String> list = Arrays.asList(split);
GetDetailIdeaRes getDetailIdeaRes = GetDetailIdeaRes.builder()
.id(ideaPost.getId())
.color(ideaPost.getUser().getColor())
.nickName(ideaPost.getUser().getNickname())
.title(ideaPost.getTitle())
.simpleDescription(ideaPost.getSimpleDescription())
.keyWord(ideaPost.getKeyword())
.keyWord(list)
.detailedDescription(ideaPost.getDetailedDescription())
.url1(ideaPost.getUrl1())
.url2(ideaPost.getUrl2())
Expand All @@ -85,7 +90,11 @@ public ResponseEntity<?> getDetailIdea(Long id) {
@Transactional
public ResponseEntity<?> updateIdea(Long id, UpdateIdeaReq updateIdeaReq) {
IdeaPost ideaPost = ideaPostRepository.findById(id).get();

String[] split = updateIdeaReq.getKeyWord().split(",");
// for (String s : split) {
// System.out.println("s = " + s);
// }
List<String> list = Arrays.asList(split);
ideaPost.setTitle(updateIdeaReq.getTitle());
ideaPost.setKeyword(updateIdeaReq.getKeyWord());
ideaPost.setSimpleDescription(updateIdeaReq.getSimpleDescription());
Expand Down Expand Up @@ -128,7 +137,7 @@ public ResponseEntity<?> getAllIdea(int page, int size, String sortBy) {
.nickName(tmp.getUser().getNickname())
.title(tmp.getTitle())
.simpleDescription(tmp.getSimpleDescription())
.keyword(tmp.getKeyword())
.keyword(Arrays.asList(tmp.getKeyword().split(",")))
.hits(tmp.getHits())
.createdAt(tmp.getCreatedAt()).build())
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package depth.main.ideac.domain.idea_post.dto;
package depth.main.ideac.domain.idea_post.dto.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package depth.main.ideac.domain.idea_post.dto;
package depth.main.ideac.domain.idea_post.dto.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package depth.main.ideac.domain.idea_post.dto;
package depth.main.ideac.domain.idea_post.dto.response;

import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

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

@Getter
@Builder
Expand All @@ -15,7 +16,7 @@ public class GetAllIdeasRes {
private String title;
@NotBlank(message = "내용이 입력되지 않았습니다.")
private String simpleDescription;
private String keyword;
private List<String> keyword;
private String nickName;
private String color;
private Long hits;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package depth.main.ideac.domain.idea_post.dto;
package depth.main.ideac.domain.idea_post.dto.response;

import lombok.Builder;
import lombok.Getter;

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

@Getter
@Builder
Expand All @@ -13,7 +14,7 @@ public class GetDetailIdeaRes {
private String color;
private String nickName;
private String title;
private String keyWord;
private List<String> keyWord;
private String simpleDescription;
private String detailedDescription;
private String url1;
Expand Down
Loading

0 comments on commit 366644b

Please sign in to comment.