Skip to content

Commit

Permalink
Merge pull request #372 from softeerbootcamp-2nd/dev
Browse files Browse the repository at this point in the history
Main Merge
  • Loading branch information
tank3a authored Aug 21, 2023
2 parents b18f5ca + ab006b9 commit 0e19cd3
Show file tree
Hide file tree
Showing 51 changed files with 1,159 additions and 468 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,16 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Run Coverage
- name: Test with Gradle
working-directory: ${{ env.wd }}
run: |
chmod +x gradlew
./gradlew testCoverage
run: ./gradlew test

- name: Add coverage to PR
id: jacoco
uses: madrapps/jacoco-report@v1.6.1
uses: madrapps/jacoco-report@v1.2
with:
paths: ${{ github.workspace }}/backend/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
title: 📊 테스트 커버리지 결과
min-coverage-overall: 50
min-coverage-changed-files: 50
update-comment: true
continue-on-error: true
min-coverage-overall: 80
min-coverage-changed-files: 80
30 changes: 22 additions & 8 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,36 @@ jacoco {
toolVersion = '0.8.9'
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
csv.required = false
}
finalizedBy 'jacocoTestCoverageVerification'
}

tasks.register('testCoverage', Test) {
group 'verification'
description 'Runs the tests with covarage (Create JaCoCo report)'

dependsOn test, jacocoTestReport
tasks['jacocoTestReport'].mustRunAfter(tasks['test'])
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.8
}
limit {
counter = 'METHOD'
value = 'COVEREDRATIO'
minimum = 0.8
}
}
}
}

jar {
enabled = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import autoever2.cartag.domain.car.BoughtCarDto;
import autoever2.cartag.domain.car.CarDefaultDto;
import autoever2.cartag.domain.car.CarDto;
<<<<<<< HEAD:backend/src/main/java/autoever2/cartag/controller/TrimController.java
import autoever2.cartag.domain.share.QuoteIdList;
import autoever2.cartag.domain.share.QuoteInfoDto;
=======
import autoever2.cartag.domain.car.CarTypeDto;
>>>>>>> 57c527d6b6e527b4e91eff53de6936fa62b8d654:backend/src/main/java/autoever2/cartag/controller/CarController.java
import autoever2.cartag.service.CarService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -12,22 +18,34 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
<<<<<<< HEAD:backend/src/main/java/autoever2/cartag/controller/TrimController.java
import org.springframework.web.bind.annotation.*;
=======
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;
>>>>>>> 57c527d6b6e527b4e91eff53de6936fa62b8d654:backend/src/main/java/autoever2/cartag/controller/CarController.java

import java.util.List;

@RestController
@RequestMapping("api/cars")
@RequiredArgsConstructor
@Tag(name = "TrimController", description = "트림 반환 api")
public class TrimController {
@Tag(name = "CarController", description = "트림 반환 api")
public class CarController {

private final CarService service;

@Operation(summary = "차종 리스트 조회", description = "차종명 + 이미지 리스트 조회")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공", content = @Content(schema = @Schema(implementation = CarTypeDto.class)))
})
@GetMapping("/list")
public List<CarTypeDto> getCarTypeList() {
return service.getAllCarTypes();
}

@Operation(summary = "trim 조회", description = "trim 조회 method")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = @Content(schema = @Schema(implementation = CarDto.class))),
Expand Down Expand Up @@ -55,4 +73,14 @@ public List<BoughtCarDto> boughtCarDtos() {
return service.findAllBoughInfos();
}

@Operation(summary = "차량 공유하기를 위한 api", description = "차량 공유를 위한 정보 반환")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = @Content(schema = @Schema(implementation = QuoteInfoDto.class))),
})
@GetMapping("/infos/shares")
public QuoteInfoDto boughtCarDtos(@Parameter(description = "선택한 id 리스트") @RequestBody QuoteIdList idList) {
return service.findShareInfoDto(idList);
}


}
28 changes: 28 additions & 0 deletions backend/src/main/java/autoever2/cartag/domain/car/CarTypeDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package autoever2.cartag.domain.car;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@Schema(description = "차종 ID와 이름, 이미지를 반환하는 dto")
public class CarTypeDto {

@Schema(description = "차종 ID, 차량(트림) ID와 다름", example = "1")
private int carTypeId;
@Schema(description = "차종 이미지", example = "/cartype/palisade/palisade-thumbnail.png")
private String carTypeImage;
@Schema(description = "차종 명", example = "팰리세이드")
private String carTypeName;

@Builder
public CarTypeDto(int carTypeId, String carTypeImage, String carTypeName) {
this.carTypeId = carTypeId;
this.carTypeImage = carTypeImage;
this.carTypeName = carTypeName;
}
}
20 changes: 20 additions & 0 deletions backend/src/main/java/autoever2/cartag/domain/car/TrimInfoDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package autoever2.cartag.domain.car;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter @Setter
@NoArgsConstructor
public class TrimInfoDto {
private int carId;
private String trim;
private int carDefaultPrice;
@Builder
public TrimInfoDto(int carId, String trim, int carDefaultPrice) {
this.carId = carId;
this.trim = trim;
this.carDefaultPrice = carDefaultPrice;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ public class ModelDefaultDto {
private String modelName;
private Long modelPrice;
private String modelImage;
private String modelTitle;

@Builder
public ModelDefaultDto(int modelId, String modelName, Long modelPrice, String modelImage) {
public ModelDefaultDto(int modelId, String modelName, Long modelPrice, String modelImage, String modelTitle) {
this.modelId = modelId;
this.modelName = modelName;
this.modelPrice = modelPrice;
this.modelImage = modelImage;
this.modelTitle = modelTitle;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package autoever2.cartag.domain.option;

import lombok.Getter;
import lombok.Setter;

@Getter @Setter
public class QuoteSubOptionDto {
private int optionId;
private String optionName;
private Long optionPrice;
private String optionTitle;
private String optionImage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package autoever2.cartag.domain.share;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
@Getter @Setter
public class QuoteIdList {
private int carId;
private int powerTrainId;
private int bodyTypeId;
private int operationId;
private int outerColorId;
private int innerColorId;
private List<Integer> optionIdList = new ArrayList<>();
}
121 changes: 121 additions & 0 deletions backend/src/main/java/autoever2/cartag/domain/share/QuoteInfoDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package autoever2.cartag.domain.share;

import autoever2.cartag.domain.car.TrimInfoDto;
import autoever2.cartag.domain.color.InnerColorDto;
import autoever2.cartag.domain.color.OuterColorDto;
import autoever2.cartag.domain.model.ModelDefaultDto;
import autoever2.cartag.domain.option.QuoteSubOptionDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;

import java.util.List;

@Getter
@Builder
public class QuoteInfoDto {
@Schema(description = "car의 id")
private int carId;
@Schema(description = "차량의 trim명")
private String trim;
@Schema(description = "차량 기본 가격")
private int carDefaultPrice;
@Schema(description = "powerTrain의 id")
private int powerTrainId;
private String powerTrainTitle;
@Schema(description = "기본 powerTrain의 이름", example = "디젤 2.2")
private String powerTrainName;
@Schema(description = "기본 powerTrain의 이미지 url")
private String powerTrainImage;
@Schema(description = "기본 powerTrain의 가격")
private Long powerTrainPrice;

@Schema(description = "bodyType의 id")
private int bodyTypeId;
@Schema(description = "bodyType 명")
private String bodyTypeTitle;
@Schema(description = "기본 bodyType의 이름", example = "7인승")
private String bodyTypeName;
@Schema(description = "기본 bodyType의 이미지 url")
private String bodyTypeImage;
@Schema(description = "기본 bodyType의 가격")
private Long bodyTypePrice;

@Schema(description = "operation의 id")
private int operationId;
@Schema(description = "operation 명")
private String operationTitle;
@Schema(description = "기본 operation의 이름", example = "2WD")
private String operationName;
@Schema(description = "기본 operation의 이미지 url")
private String operationImage;
@Schema(description = "기본 operation의 가격")
private Long operationPrice;

@Schema(description = "외장색상의 id")
private int colorOuterId;
@Schema(description = "기본 외장색상 이미지 url")
private String colorOuterImage;
@Schema(description = "기본 외장색상이 적용된 차량 url")
private String colorCarOuterImage;
@Schema(description = "기본 외장색상 가격")
private Long colorOuterPrice;
@Schema(description = "기본 외장색상 이름")
private String colorOuterImageName;
@Schema(description = "외장색상 명")
private String colorOuterTitle;


@Schema(description = "내장색상의 id")
private int colorInnerId;
@Schema(description = "기본 내장색상 이미지 url")
private String colorInnerImage;
@Schema(description = "기본 내장색상이 적용된 차량 url")
private String colorCarInnerImage;
@Schema(description = "기본 내장색상 가격")
private Long colorInnerPrice;
@Schema(description = "기본 내장색상 이름")
private String colorInnerImageName;
@Schema(description = "내장색상 명")
private String colorInnerTitle;
@Schema(description = "option들의 리스트")
List<QuoteSubOptionDto> optionList;

public static QuoteInfoDto toInfoDto(TrimInfoDto trimInfoDto, OuterColorDto outerColorDto, InnerColorDto innerColorDto,
List<ModelDefaultDto> modelDefaultDto, List<QuoteSubOptionDto> optionInfos, String colorCarOuterImage) {
return QuoteInfoDto.builder()
.carId(trimInfoDto.getCarId())
.trim(trimInfoDto.getTrim())
.carDefaultPrice(trimInfoDto.getCarDefaultPrice())
.powerTrainId(modelDefaultDto.get(0).getModelId())
.powerTrainName(modelDefaultDto.get(0).getModelName())
.powerTrainImage(modelDefaultDto.get(0).getModelImage())
.powerTrainPrice(modelDefaultDto.get(0).getModelPrice())
.powerTrainTitle(modelDefaultDto.get(0).getModelTitle())
.operationId(modelDefaultDto.get(1).getModelId())
.operationName(modelDefaultDto.get(1).getModelName())
.operationImage(modelDefaultDto.get(1).getModelImage())
.operationPrice(modelDefaultDto.get(1).getModelPrice())
.operationTitle(modelDefaultDto.get(1).getModelTitle())
.bodyTypeId(modelDefaultDto.get(2).getModelId())
.bodyTypeName(modelDefaultDto.get(2).getModelName())
.bodyTypeImage(modelDefaultDto.get(2).getModelImage())
.bodyTypePrice(modelDefaultDto.get(2).getModelPrice())
.bodyTypeTitle(modelDefaultDto.get(2).getModelTitle())
.colorOuterId(outerColorDto.getColorId())
.colorOuterImage(outerColorDto.getColorImage())
.colorCarOuterImage(colorCarOuterImage)
.colorOuterPrice(outerColorDto.getColorPrice())
.colorOuterImageName(outerColorDto.getColorName())
.colorOuterTitle("외장 색상")
.colorInnerTitle("내장 색상")
.colorInnerId(innerColorDto.getColorId())
.colorInnerImage(innerColorDto.getColorImage())
.colorCarInnerImage(innerColorDto.getColorCarImage())
.colorInnerPrice(innerColorDto.getColorPrice())
.colorInnerImageName(innerColorDto.getColorName())
.optionList(optionInfos)
.build();

}
}
Loading

0 comments on commit 0e19cd3

Please sign in to comment.