Skip to content

Commit

Permalink
Merge branch 'develop' into feat/78
Browse files Browse the repository at this point in the history
  • Loading branch information
0-x-14 authored Aug 15, 2024
2 parents 2678325 + e8e00cf commit a4337f0
Show file tree
Hide file tree
Showing 33 changed files with 525 additions and 155 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: ttakkeun ci/cd

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name : make application.yml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
shell: bash


# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle Wrapper
run: ./gradlew build

## 웹 이미지 빌드 및 도커허브에 push
- name: Build and push Docker image
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build --platform linux/amd64 -t ${{ secrets.DOCKER_USERNAME }}/ttakkeun .
docker push ${{ secrets.DOCKER_USERNAME }}/ttakkeun
- name: Execute remote SSH commands
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }} # EC2 퍼블릭 IPv4 DNS
username: ubuntu
key: ${{ secrets.KEY }}
script: |
cd /home/ubuntu/
## .env 파일 생성
sudo touch .env
echo "${{ secrets.ENV_VARS }}" | sudo tee .env > /dev/null
## docker-compose.yml 파일 생성
sudo touch docker-compose.yml
echo "${{ secrets.DOCKER_COMPOSE }}" | sudo tee docker-compose.yml > /dev/null
## Docker 작업
sudo chmod 666 /var/run/docker.sock
sudo docker stop $(docker ps -a -q)
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ttakkeun
sudo docker run -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/ttakkeun
sudo docker image prune -f
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bin/
out/
!**/src/main/**/out/
!**/src/test/**/out/
docker-compose.yml

### NetBeans ###
/nbproject/private/
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17
ARG JAR_FILE=/build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public enum ErrorStatus implements BaseErrorCode {
MEMBER_NOT_REGISTERED(HttpStatus.BAD_REQUEST, "MEMBER4002", "등록된 사용자가 아닙니다."),
MEMBER_NOT_HAVE_PET(HttpStatus.BAD_REQUEST, "MEMBER4003", "반려동물이 없는 사용자 입니다."),

//Record 에러
RECORD_NOT_FOUND(HttpStatus.BAD_REQUEST, "RECORD4000", "해당하는 일지를 찾을 수 없습니다."),
ANSWER_NOT_FOUND(HttpStatus.BAD_REQUEST, "RECORD4001", "해당하는 답변을 찾을 수 없습니다."),

// Dignose 에러
DIAGNOSE_NOT_FOUND(HttpStatus.BAD_REQUEST, "DIAGNOSE4001", "해당하는 진단 결과를 찾을 수 없습니다."),

Expand All @@ -44,6 +48,11 @@ public enum ErrorStatus implements BaseErrorCode {
IMAGE_EMPTY(HttpStatus.BAD_REQUEST, "IMAGE4000", "이미지가 첨부되지 않았습니다."),
IMAGE_NOT_SAVE(HttpStatus.BAD_REQUEST, "IMAGE4001", "이미지 저장에 실패했습니다." ),

//S3 에러
S3_UPLOAD_FAIL(HttpStatus.BAD_REQUEST, "S34000", "이미지 업로드에 실패하였습니다."),
NO_FILE_EXTENTION(HttpStatus.BAD_REQUEST, "S34001", "해당되는 파일 확장자가 없습니다."),
INVALID_FILE_EXTENTION(HttpStatus.BAD_REQUEST, "S34002", "유효하지 않은 파일 확장자입니다."),

//Question 에러
QUESTION_NOT_FOUND(HttpStatus.BAD_REQUEST, "QUESTION4001", "유효하지 않은 Question ID입니다."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
public enum SuccessStatus implements BaseCode {

//일반적인 응답
_OK(HttpStatus.OK, "COMMON200", "성공입니다.");
_OK(HttpStatus.OK, "COMMON200", "성공입니다."),

// 이미지 관련 응답
IMAGE_SUCCESS(HttpStatus.OK, "IMAGE2000", "이미지 업로드 성공하였습니다.");

private final HttpStatus httpStatus;
private final String code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public class SecurityConfig {
public WebSecurityCustomizer webSecurityCustomizer(){
return web -> web.ignoring()
.requestMatchers("/swagger-ui/**", "/swagger/**", "/swagger-resources/**", "/swagger-ui.html", "/test",
"/configuration/ui", "/v3/api-docs/**", "/api/auth/refresh", "/api/record/**", "/api/auth/apple/**",
"/api/pet-profile/**", "/api/todos/**", "/api/diagnose/**", "/api/calendar/**",
"/api/product/**", "/test/diagnose/**");
"/configuration/ui", "/v3/api-docs/**", "/api/auth/refresh", "/api/auth/apple/**");

}

Expand All @@ -56,7 +54,7 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.authorizeHttpRequests((authorizeRequests) ->
authorizeRequests
.requestMatchers(
AntPathRequestMatcher.antMatcher("/api/auth/**")
AntPathRequestMatcher.antMatcher("/api/**")
).authenticated()
.anyRequest().authenticated()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
@RequestMapping("/api/diagnose")
public class DiagnoseController {
@Autowired
private DiagnoseService diagnoseService;
private final DiagnoseService diagnoseService;

@Autowired
private DiagnoseNaverProductService diagnoseNaverProductService;
private final DiagnoseNaverProductService diagnoseNaverProductService;

// 진단 버튼 클릭시 사용자의 포인트를 조회하는 API
@Operation(summary = "사용자 포인트 조회 API")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public class OAuthController {

private final OAuthService oAuthService;

@PostMapping("/refresh")
@PostMapping("/refreshtoken")
public ApiResponse<LoginResponseDto> regenerateAccessToken(HttpServletRequest request) {
//String accessToken = request.getHeader("Authorization");
String refreshToken = request.getHeader("Authorization");
String refreshToken = request.getHeader("RefreshToken");

//System.out.println("Access Token: " + accessToken.substring(7));
System.out.println("Refresh Token: " + refreshToken.substring(7));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static org.bouncycastle.asn1.x500.style.RFC4519Style.member;
import static ttakkeun.ttakkeun_server.apiPayLoad.code.status.ErrorStatus.IMAGE_EMPTY;
import static ttakkeun.ttakkeun_server.apiPayLoad.code.status.ErrorStatus.MEMBER_NOT_HAVE_PET;

Expand Down Expand Up @@ -60,9 +61,10 @@ public ApiResponse<PetResponseDTO.LoadResultDTO> load(
@Operation(summary = "로그인한 사용자의 모든 반려동물 조회 API")
@GetMapping("/select")
public ApiResponse<PetResponseDTO.SelectResultDTO> select(
@RequestParam("memberId") Long memberId
@AuthenticationPrincipal Member member
//@RequestParam("memberId") Long memberId
) {
List<Pet> pets = petService.getPetsByMemberId(memberId);
List<Pet> pets = petService.getPetsByMemberId(member.getMemberId());

if(pets.isEmpty())
throw new ExceptionHandler(MEMBER_NOT_HAVE_PET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import ttakkeun.ttakkeun_server.apiPayLoad.ApiResponse;
import ttakkeun.ttakkeun_server.dto.record.RecordListResponse;
import ttakkeun.ttakkeun_server.dto.record.RecordListResponseDto;
Expand All @@ -15,6 +17,8 @@

import java.util.List;

import static ttakkeun.ttakkeun_server.apiPayLoad.code.status.SuccessStatus.IMAGE_SUCCESS;

@RestController
@RequestMapping("/api/record")
@RequiredArgsConstructor
Expand Down Expand Up @@ -75,4 +79,61 @@ public ApiResponse<RecordResponseDTO.RegisterResultDTO> registerRecord(
RecordResponseDTO.RegisterResultDTO responseDTO = recordService.registerRecord(petId, requestDTO);
return ApiResponse.onSuccess(responseDTO);
}


@Operation(summary = "일지 사진 저장 API")
@PostMapping(value = "/register/{recordId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public ApiResponse uploadImages(
@PathVariable(name = "recordId") Long recordId,
@RequestPart("question_id") Long questionId,
@RequestPart("images") List<MultipartFile> images
// @RequestPart List<RecordRequestDTO.RecordImageDTO> recordImageDTO
)
{
recordService.uploadImages(recordId,questionId, images);
return ApiResponse.onSuccess(IMAGE_SUCCESS);
}



@Operation(summary = "일지 상세 내용 조회 API")
@GetMapping("/detail/{pet_id}/{record_id}")
public ApiResponse<RecordResponseDTO.DetailResultDTO> getRecordDetails(
@PathVariable("pet_id") Long petId,
@PathVariable("record_id") Long recordId
) {
RecordResponseDTO.DetailResultDTO recordDetails = recordService.getRecordDetails(petId, recordId);
return ApiResponse.onSuccess(recordDetails);
}


@Operation(summary = "일지 삭제 API")
@DeleteMapping("/{record_id}")
public ApiResponse<RecordResponseDTO.DeleteResultDTO> deleteRecord(
@PathVariable("record_id") Long record_id
) {
RecordResponseDTO.DeleteResultDTO deleteResultDTO = recordService.deleteRecord(record_id);
return ApiResponse.onSuccess(deleteResultDTO);
}


@Operation(summary = "일지 기록 검색 API")
@GetMapping("/search/{pet_id}/{category}")
public ApiResponse<RecordListResponse> getRecordListAtDate(
@PathVariable(name = "pet_id") Long petId,
@PathVariable(name = "category") Category category,
@RequestParam(name = "page", defaultValue = "0") int page,
@RequestParam(name = "size", defaultValue = "21") int size,
@RequestParam(name = "date") String date
){
// 임의의 Member 객체 생성
Member testMember = new Member();
testMember.setMemberId(1L); // 임의의 memberId 설정
System.out.println("Member ID: " + testMember.getMemberId());

List<RecordListResponseDto> records = recordService.getRecordsAtDate(testMember, petId, category, page, size, date);
RecordListResponse result = new RecordListResponse(category, records);
return ApiResponse.onSuccess(result);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
import ttakkeun.ttakkeun_server.repository.ProductRepository;
import ttakkeun.ttakkeun_server.service.LikeService;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Component
@RequiredArgsConstructor
public class ProductConverter {
Expand Down Expand Up @@ -78,4 +82,20 @@ public RecommendProductDTO JSONToDTO(JSONObject jsonObject) {
.isLike(isLike)
.build();
}

public boolean categoryFilter(RecommendProductDTO productDTO) {
List<String> validCategory3 = Arrays.asList(
"미용/목욕", "강아지 건강/관리용품", "고양이 건강/관리용품"
);
List<String> validCategory4 = Arrays.asList(
"브러시/빗", "에센스/향수/밤", "샴푸/린스/비누", "이발기", "발톱/발 관리",
"드라이기/드라이룸", "미용가위", "타월/가운", "물티슈/크리너",
"눈/귀 관리용품", "구강청결제", "칫솔", "치약", "구강티슈", "구강관리용품"
);

return validCategory3.contains(productDTO.getCategory3()) &&
validCategory4.contains(productDTO.getCategory4());
}
}


This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/ttakkeun/ttakkeun_server/dto/TempResponse.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public class LoginResponseDto {

private String accessToken;
private String refreshToken;
//private String email;
private String email;

@Builder
public LoginResponseDto(String accessToken, String refreshToken) {
public LoginResponseDto(String accessToken, String refreshToken, String email) {
this.accessToken = accessToken;
this.refreshToken = refreshToken;
//this.email = email;
this.email = email;
}
}
Loading

0 comments on commit a4337f0

Please sign in to comment.