Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
26c9bc5
[Feat] 기본세팅
mjkang4416 Feb 12, 2025
d8789e7
[Feat] 인기레시피 api 구현
mjkang4416 Feb 13, 2025
e0e3912
[Feat] 오늘의 래시피
mjkang4416 Feb 13, 2025
48bd5d7
[Chore] dto 생성
mjkang4416 Feb 13, 2025
c1437f5
[Feat] S3 init #21
BEOMJIN754 Feb 13, 2025
4a16429
Merge pull request #22 from blendish-trendyton/feat/s3#21
BEOMJIN754 Feb 13, 2025
712432f
[Feat] 레시피 id 로 띄우기
mjkang4416 Feb 13, 2025
0baefe9
[Feat] Update user information #23
BEOMJIN754 Feb 13, 2025
30fc518
[Chore] Add application.yml to .gitignore #23
BEOMJIN754 Feb 13, 2025
2044357
[Fix] Fix property key #23
BEOMJIN754 Feb 13, 2025
3380aea
[Feat] 레시피 세부동작
mjkang4416 Feb 14, 2025
3250cb4
[char] 사용자 인증전
mjkang4416 Feb 14, 2025
918e6e6
[char] 병합전
mjkang4416 Feb 14, 2025
b760144
[Feat] 부모댓글 전체 띄우기
mjkang4416 Feb 14, 2025
e6c60ff
Merge pull request #25 from blendish-trendyton/feat/updateuser#23
BEOMJIN754 Feb 14, 2025
e7e8c25
[Feat] 전체 댓글 띄우기
mjkang4416 Feb 14, 2025
1233e55
[Feat] 전체 게시글 세부내용
mjkang4416 Feb 14, 2025
6801691
Merge branch 'main' of https://github.com/blendish-trendyton/blendish…
mjkang4416 Feb 14, 2025
5014e42
Merge pull request #26 from blendish-trendyton/feat/showComunity
mjkang4416 Feb 14, 2025
4fc72b6
[Feat] Find user by Id
BEOMJIN754 Feb 14, 2025
84524be
Merge pull request #28 from blendish-trendyton/feat/find#27
BEOMJIN754 Feb 14, 2025
cf1fcaa
[Refactor] s3 이미지 추가
Junyeong-An Feb 14, 2025
52e6ae5
[Refactor] s3 이미지 추가
Junyeong-An Feb 14, 2025
d4af87b
[Refactor] s3 이미지 추가
Junyeong-An Feb 14, 2025
2f16067
[Refactor] AI 관련 테이블 추가
Junyeong-An Feb 14, 2025
02f991c
Merge pull request #29 from blendish-trendyton/feat/AddRecipe
mjkang4416 Feb 14, 2025
5ed9b2c
[Feat] AI 레시피 생성기능
Junyeong-An Feb 15, 2025
373aa91
[Chore] 필요없는 속성 제거
Junyeong-An Feb 15, 2025
94373c0
Merge branch 'feat/GPT-Integration' of https://github.com/blendish-tr…
Junyeong-An Feb 15, 2025
6fd8940
[Chore] 필요없는 속성 제거
Junyeong-An Feb 15, 2025
e6f196a
Merge pull request #30 from blendish-trendyton/feat/GPT-Integration
mjkang4416 Feb 15, 2025
3b64f6d
[Feat] Ai 생성 레시피 저장 기능 추가
Junyeong-An Feb 15, 2025
3175b74
Merge branch 'main' into feat/GPT-Integration
Junyeong-An Feb 15, 2025
c81b206
Merge pull request #31 from blendish-trendyton/feat/GPT-Integration
mjkang4416 Feb 15, 2025
2aedad2
[Feat] DTO 파일 추가
Junyeong-An Feb 15, 2025
ed448b7
Merge branch 'main' into feat/GPT-Integration
Junyeong-An Feb 15, 2025
f8ff02c
Merge pull request #32 from blendish-trendyton/feat/GPT-Integration
mjkang4416 Feb 15, 2025
c1ed007
[Chore] Remove cors #33
BEOMJIN754 Feb 15, 2025
47a6506
[refactor] 필요없는 파일 삭제
Junyeong-An Feb 15, 2025
b4a5644
Merge branch 'feat/GPT-Integration' of https://github.com/blendish-tr…
Junyeong-An Feb 15, 2025
95b05f0
Merge pull request #34 from blendish-trendyton/chore/cors#33
BEOMJIN754 Feb 15, 2025
a8fd89c
[refactor] 필요없는 파일 삭제
Junyeong-An Feb 15, 2025
0f0fbd9
Merge pull request #36 from blendish-trendyton/feat/GPT-Integration
mjkang4416 Feb 15, 2025
62b79c4
[Feat] Ai RecipeStep 추가
Junyeong-An Feb 16, 2025
2b62b4e
Merge pull request #37 from blendish-trendyton/feat/GPT-Integration
mjkang4416 Feb 16, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ out/
### VS Code ###
.vscode/
application.properties
application-*.yml
application*.yml
application.yml
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ dependencies {
// AWS S3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

implementation group: 'ch.simas.qlrm', name: 'qlrm', version: '1.7.1'

implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.example.blendish.controller;

import com.example.blendish.domain.comments.dto.CommentAllDTO;
import com.example.blendish.domain.comments.dto.CommentDTO;
import com.example.blendish.domain.comments.service.CommentService;
import com.example.blendish.global.dto.ApiResponseTemplate;
import com.example.blendish.global.response.SuccessCode;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "Comment Controller", description = "댓글 API")
@RestController
@RequestMapping("/api/Comment")
@AllArgsConstructor
public class CommentController {
private final CommentService commentService;

//부모댓글 전체 띄우기
@GetMapping("/ParentsComment")
public ResponseEntity<ApiResponseTemplate<List<CommentDTO>>> getParentsComment(@RequestParam(name = "recipeId") Long recipeId) {

List<CommentDTO> commentDTOList = commentService.getParentCommnet(recipeId);
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, commentDTOList));
}

// 전체 댓글 띄우기
@GetMapping("/AllComment")
public ResponseEntity<ApiResponseTemplate<List<CommentAllDTO>>> getAllComment(@RequestParam(name = "recipeId") Long recipeId) {

List<CommentAllDTO> commentAllDTOList = commentService.getAllComment(recipeId);
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, commentAllDTOList));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.example.blendish.controller;

import com.example.blendish.domain.recipe.dto.CommunityDetailDTO;
import com.example.blendish.domain.recipe.dto.CommunityHotRecipeDTO;
import com.example.blendish.domain.recipe.dto.CommunityTodayRecipeDTO;
import com.example.blendish.domain.recipe.dto.RecipeDetailDTO;
import com.example.blendish.domain.recipe.service.CommunityService;
import com.example.blendish.global.dto.ApiResponseTemplate;
import com.example.blendish.global.response.SuccessCode;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "Community Controller", description = "커뮤니티 관련 API")
@RestController
@RequestMapping("/api/community")
@AllArgsConstructor
public class CommunityController {

private final CommunityService communityService;

//hot 레시피
@GetMapping("/HotRecipe")
public ResponseEntity<ApiResponseTemplate<List<CommunityHotRecipeDTO>>> getHot() {

List<CommunityHotRecipeDTO> hotRecipyDTOS = communityService.getTopLikedRecipes();

return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, hotRecipyDTOS));
}
//오늘의 레시피
@GetMapping("/TodayRecipe")
public ResponseEntity<ApiResponseTemplate<List<CommunityTodayRecipeDTO>>> getToday() {

List<CommunityTodayRecipeDTO> todayRecipe = communityService.getTodayRecipe();

return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, todayRecipe));
}
//레시피 디테일
@GetMapping("/DetailRecipe")
public ResponseEntity<ApiResponseTemplate<CommunityDetailDTO>> getDetail(@RequestParam(name = "recipeId") Long recipeId) {

CommunityDetailDTO detailDTOS = communityService.getDetail(recipeId);

return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, detailDTOS));
}

// 좋아요 클릭시
// @PostMapping("/updateLike")
// public ResponseEntity<ApiResponseTemplate<?>> updateLike(@RequestBody Long recipeId) {
//
// communityService.insertLike(recipeId);
//
// return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, null ));
// }
//
// // 좋아요 삭제시
// @PostMapping("/deleteLike")
// public ResponseEntity<ApiResponseTemplate<?>> deleteLike(@RequestBody Long recipeId) {
//
// communityService.removeLike(recipeId);
//
// return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, null ));
// }
//
// // 스크랩 클릭시
// @PostMapping("/updateScrap")
// public ResponseEntity<ApiResponseTemplate<?>> updatScrap(@RequestBody Long recipeId) {
//
// communityService.insertScrap(recipeId);
//
// return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, null ));
// }

//레시피 전체 디테일
@GetMapping("/AllDetailRecipe")
public ResponseEntity<ApiResponseTemplate<RecipeDetailDTO>> getAllDetail(@RequestParam(name = "recipeId") Long recipeId) {

RecipeDetailDTO recipeDetailDTO = communityService.getAllDetail(recipeId);

return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, recipeDetailDTO));
}




}
49 changes: 49 additions & 0 deletions src/main/java/com/example/blendish/controller/GPTController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.example.blendish.controller;

import com.example.blendish.domain.gpt.dto.CustomRecipeReqDTO;
import com.example.blendish.domain.gpt.service.GPTRecipeService;
import com.example.blendish.domain.gpt.service.OpenAIService;
import com.example.blendish.domain.recipe.dto.AddRecipeDTO;
import com.example.blendish.domain.recipe.service.RecipeService;
import com.example.blendish.global.dto.ApiResponseTemplate;
import com.example.blendish.global.response.SuccessCode;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;


@RestController
@RequiredArgsConstructor
@RequestMapping("/api/gpt")
public class GPTController implements GPTSwagger{

private final OpenAIService openAIService;
private final GPTRecipeService gptRecipeService;
private final RecipeService recipeService;

@GetMapping("/chat")
public ResponseEntity<ApiResponseTemplate> chatWithGpt(@RequestParam String message) {
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, openAIService.getGptResponse(message)));

}

@PostMapping("/recipe")
public ResponseEntity<ApiResponseTemplate<String>> generateCustomRecipe(
@RequestBody CustomRecipeReqDTO request,
@AuthenticationPrincipal UserDetails userDetails) {

String result = gptRecipeService.getAiGeneratedRecipe(request, userDetails);

return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.CREATED, result));
}

@PostMapping("/recipe/save")
public ResponseEntity<ApiResponseTemplate<String>> saveRecipe(AddRecipeDTO addRecipeDTO, UserDetails userDetails) {
recipeService.createAiRecipe(addRecipeDTO, userDetails.getUsername());

return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.CREATED, "레시피가 등록되었습니다."));
}

}
30 changes: 30 additions & 0 deletions src/main/java/com/example/blendish/controller/GPTSwagger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.blendish.controller;

import com.example.blendish.domain.gpt.dto.CustomRecipeReqDTO;
import com.example.blendish.domain.recipe.dto.AddRecipeDTO;
import com.example.blendish.global.dto.ApiResponseTemplate;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@Tag(name = "GPT API", description = "GPT 관련 API")
public interface GPTSwagger {

@Operation(summary = "GPT 채팅", description = "GPT에게 메시지를 보내고 응답을 받습니다.")
ResponseEntity<ApiResponseTemplate> chatWithGpt(@RequestParam String message);

@Operation(summary = "사용자 맞춤 GPT 레시피 생성", description = "사용자 입력을 기반으로 GPT가 맞춤형 레시피를 생성합니다.")
ResponseEntity<ApiResponseTemplate<String>> generateCustomRecipe(
@RequestBody CustomRecipeReqDTO request,
UserDetails userDetails
);

@Operation(summary = "AI 레시피 저장", description = "AI가 생성한 레시피를 데이터베이스에 저장합니다.")
ResponseEntity<ApiResponseTemplate<String>> saveRecipe(
@RequestBody AddRecipeDTO addRecipeDTO,
UserDetails userDetails
);
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
package com.example.blendish.controller;

import com.example.blendish.domain.recipe.dto.AddRecipeDTO;
import com.example.blendish.domain.recipe.entity.Recipe;
import com.example.blendish.domain.recipe.service.RecipeService;
import com.example.blendish.global.dto.ApiResponseTemplate;
import com.example.blendish.global.response.SuccessCode;
import com.example.blendish.global.s3.S3UploadService;
import java.io.IOException;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/recipe")
public class RecipeController implements RecipeSwagger{

private final RecipeService recipeService;
private final S3UploadService s3UploadService;

@PostMapping
@PostMapping(consumes = {"multipart/form-data"})
public ResponseEntity<ApiResponseTemplate<String>> addRecipe(@RequestBody AddRecipeDTO addRecipeDTO,
@AuthenticationPrincipal UserDetails userDetails) {
recipeService.createRecipe(addRecipeDTO, userDetails.getUsername());
@RequestPart(value = "image", required = false) MultipartFile image,
@AuthenticationPrincipal UserDetails userDetails) throws IOException {
String imageUrl = (image != null && !image.isEmpty()) ? s3UploadService.saveFile(image) : null;
recipeService.createUserRecipe(addRecipeDTO, userDetails.getUsername(), imageUrl);
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, "레시피가 등록되었습니다."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

import com.example.blendish.domain.recipe.dto.AddRecipeDTO;
import com.example.blendish.global.dto.ApiResponseTemplate;
import com.example.blendish.global.response.SuccessCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.IOException;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

public interface RecipeSwagger {

Expand All @@ -29,5 +31,6 @@ public interface RecipeSwagger {
)
@PostMapping("/api/recipe")
ResponseEntity<ApiResponseTemplate<String>> addRecipe(@RequestBody AddRecipeDTO addRecipeDTO,
@AuthenticationPrincipal UserDetails userDetails);
@RequestPart(value = "image", required = false) MultipartFile image,
@AuthenticationPrincipal UserDetails userDetails) throws IOException;
}
51 changes: 49 additions & 2 deletions src/main/java/com/example/blendish/controller/UserController.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package com.example.blendish.controller;

import com.example.blendish.domain.user.dto.UserDTO;
import com.example.blendish.domain.user.dto.check.CheckUserPwDTO;
import com.example.blendish.domain.user.service.UserService;
import com.example.blendish.global.dto.ApiResponseTemplate;
import com.example.blendish.global.response.SuccessCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@Tag(name = "User Controller", description = "사용자 관리 관련 API")
@Controller
@RequestMapping("/api/user")
Expand All @@ -32,4 +37,46 @@ public ResponseEntity<ApiResponseTemplate<List<UserDTO>>> getAllUsers() {
List<UserDTO> users = userService.getAllUsers();
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, users));
}

@Operation(
summary = "사용자 정보 업데이트",
description = "전체 사용자 정보를 전달받아 유저 정보를 업데이트 한다."
)
@PutMapping(value = "/update", consumes = {"multipart/form-data"})
public ResponseEntity<ApiResponseTemplate<UserDTO>> updateUser(
@RequestPart("user") UserDTO userDTO,
@RequestPart(value = "profilePic", required = false) MultipartFile profilePic
) throws IOException {
UserDTO updatedUser = userService.updateUser(userDTO, profilePic);
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, updatedUser));
}

@Operation(
summary = "비밀번호 확인",
description = "입력받은 비밀번호가 저장된 비밀번호와 동일한지 확인한다."
)
@PostMapping("/check")
public ResponseEntity<ApiResponseTemplate<Boolean>> checkPassword(@RequestBody CheckUserPwDTO dto) {

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String userId = authentication.getName();
System.out.println(userId);

boolean result = userService.checkPassword(userId, dto.getPassword());
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, result));
}

@Operation(
summary = "현재 로그인된 사용자 조회",
description = "토큰에 포함된 사용자 ID를 기반으로 전체 사용자 데이터를 반환한다."
)
@GetMapping("/me")
public ResponseEntity<ApiResponseTemplate<UserDTO>> getUserById() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String userId = authentication.getName();
System.out.println(userId);
UserDTO userDTO = userService.getUserById(userId);
return ResponseEntity.ok(ApiResponseTemplate.success(SuccessCode.OK, userDTO));
}

}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.blendish.domain.comments.dto;

import lombok.*;

import java.util.Date;
import java.util.List;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CommentAllDTO {
private Long commentId;
private String userId;
private String profilePic;
private String content;
private Date createdAt;
private List<CommentDTO> ReplyList;
}
Loading