diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index 222857b..0000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - mysql.8 - true - com.mysql.cj.jdbc.Driver - jdbc:mysql://ideacdb.ce84mlt0kgjd.ap-northeast-2.rds.amazonaws.com:3306 - $ProjectFileDir$ - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 6197270..5cac8eb 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -10,6 +10,9 @@ + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..fda1536 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,5 +2,7 @@ + + \ No newline at end of file diff --git a/ideac-core/src/main/java/depth/main/ideac/domain/idea_post/IdeaPost.java b/ideac-core/src/main/java/depth/main/ideac/domain/idea_post/IdeaPost.java index 7798fe3..1d69f10 100644 --- a/ideac-core/src/main/java/depth/main/ideac/domain/idea_post/IdeaPost.java +++ b/ideac-core/src/main/java/depth/main/ideac/domain/idea_post/IdeaPost.java @@ -7,6 +7,8 @@ import jakarta.validation.constraints.Size; import lombok.*; +import java.util.List; + @Entity @Builder diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java index 8768498..5bff447 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/application/ClubPostService.java @@ -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; @@ -42,6 +42,7 @@ public Page getAllClubPosts(Pageable pageable) { List clubPostResList = posts.getContent().stream() .map(clubPost -> ClubPostRes.builder() + .id(clubPost.getId()) .title(clubPost.getTitle()) .description(clubPost.getDetailedDescription()) .createdAt(clubPost.getCreatedAt()) @@ -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()) diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostReq.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/ClubPostReq.java similarity index 83% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostReq.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/ClubPostReq.java index 38bfea6..c17d760 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostReq.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/ClubPostReq.java @@ -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 { @@ -22,5 +22,4 @@ public class ClubPostReq { private String url2; - // 이미지 path는 추후 추가 } diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/UpdateClubPostReq.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/UpdateClubPostReq.java similarity index 82% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/UpdateClubPostReq.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/UpdateClubPostReq.java index 6d4f190..8416908 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/UpdateClubPostReq.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/request/UpdateClubPostReq.java @@ -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 @@ -25,6 +23,4 @@ public class UpdateClubPostReq { private String url2; - // private List clubPostImages; - } diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostDetailRes.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostDetailRes.java similarity index 77% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostDetailRes.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostDetailRes.java index 919d443..9578a57 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostDetailRes.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostDetailRes.java @@ -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; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostRes.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostRes.java similarity index 67% rename from ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostRes.java rename to ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostRes.java index 2f0af4c..729df3f 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/ClubPostRes.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/dto/response/ClubPostRes.java @@ -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; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java index 44035dd..7efa967 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/club_post/presentation/ClubPostController.java @@ -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; @@ -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 posts = clubPostService.getAllClubPosts(pageable); diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java b/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java index 0cf9bf6..d7c9fe0 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/home/application/HomeService.java @@ -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; @@ -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; @@ -27,17 +28,19 @@ public class HomeService { private final IdeaPostRepository ideaPostRepository; private final ProjectPostRepository projectPostRepository; - // 아이디어 public List getIdeas() { List 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()); } @@ -54,12 +57,15 @@ public List 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(); }) @@ -72,6 +78,7 @@ public List getClubs() { return clubPosts.stream() .map(clubPost -> ClubPostRes.builder() + .id(clubPost.getId()) .title(clubPost.getTitle()) .description(clubPost.getDetailedDescription()) .thumbnail(clubPost.getClubPostImages().stream() diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java b/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java index dd27c7e..50e1e89 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/home/presentation/HomeController.java @@ -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; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/application/IdeaPostService.java b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/application/IdeaPostService.java index 8e5bba0..169c642 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/application/IdeaPostService.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/application/IdeaPostService.java @@ -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; @@ -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 @@ -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()) @@ -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 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()) @@ -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 list = Arrays.asList(split); ideaPost.setTitle(updateIdeaReq.getTitle()); ideaPost.setKeyword(updateIdeaReq.getKeyWord()); ideaPost.setSimpleDescription(updateIdeaReq.getSimpleDescription()); @@ -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()); diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/RegisterIdeaReq.java b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/request/RegisterIdeaReq.java similarity index 92% rename from ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/RegisterIdeaReq.java rename to ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/request/RegisterIdeaReq.java index d37beab..738ee46 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/RegisterIdeaReq.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/request/RegisterIdeaReq.java @@ -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; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/UpdateIdeaReq.java b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/request/UpdateIdeaReq.java similarity index 92% rename from ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/UpdateIdeaReq.java rename to ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/request/UpdateIdeaReq.java index 5bbfa4a..fe02dfd 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/UpdateIdeaReq.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/request/UpdateIdeaReq.java @@ -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; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/GetAllIdeasRes.java b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/response/GetAllIdeasRes.java similarity index 81% rename from ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/GetAllIdeasRes.java rename to ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/response/GetAllIdeasRes.java index 31b8af6..b6260ce 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/GetAllIdeasRes.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/response/GetAllIdeasRes.java @@ -1,4 +1,4 @@ -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; @@ -6,6 +6,7 @@ import lombok.Getter; import java.time.LocalDateTime; +import java.util.List; @Getter @Builder @@ -15,7 +16,7 @@ public class GetAllIdeasRes { private String title; @NotBlank(message = "내용이 입력되지 않았습니다.") private String simpleDescription; - private String keyword; + private List keyword; private String nickName; private String color; private Long hits; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/GetDetailIdeaRes.java b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/response/GetDetailIdeaRes.java similarity index 78% rename from ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/GetDetailIdeaRes.java rename to ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/response/GetDetailIdeaRes.java index f379d19..66dbd5d 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/GetDetailIdeaRes.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/dto/response/GetDetailIdeaRes.java @@ -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 @@ -13,7 +14,7 @@ public class GetDetailIdeaRes { private String color; private String nickName; private String title; - private String keyWord; + private List keyWord; private String simpleDescription; private String detailedDescription; private String url1; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/presentation/IdeaPostController.java b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/presentation/IdeaPostController.java index b6b77b4..e48f72c 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/presentation/IdeaPostController.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/idea_post/presentation/IdeaPostController.java @@ -1,8 +1,8 @@ package depth.main.ideac.domain.idea_post.presentation; import depth.main.ideac.domain.idea_post.application.IdeaPostService; -import depth.main.ideac.domain.idea_post.dto.RegisterIdeaReq; -import depth.main.ideac.domain.idea_post.dto.UpdateIdeaReq; +import depth.main.ideac.domain.idea_post.dto.request.RegisterIdeaReq; +import depth.main.ideac.domain.idea_post.dto.request.UpdateIdeaReq; import depth.main.ideac.global.config.security.token.CurrentUser; import depth.main.ideac.global.config.security.token.UserPrincipal; import depth.main.ideac.global.payload.ErrorResponse; diff --git a/ideac-user/src/main/java/depth/main/ideac/domain/user/presentation/UserController.java b/ideac-user/src/main/java/depth/main/ideac/domain/user/presentation/UserController.java index a28d668..3064e65 100644 --- a/ideac-user/src/main/java/depth/main/ideac/domain/user/presentation/UserController.java +++ b/ideac-user/src/main/java/depth/main/ideac/domain/user/presentation/UserController.java @@ -22,7 +22,7 @@ @RequiredArgsConstructor @RestController @RequestMapping("/api/user") -public class UserController { +public class UserController { private final UserService userService; @Operation(summary = "비밀번호 바꾸기", description = "비밀번호를 바꾼다.") @ApiResponses(value = {