Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] 유사견적 추천 후 요약 데이터 제공 #390

Merged
merged 14 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Test Coverage


on:
pull_request:
branches:
branches:
- 'dev'
paths:
- '**.java'
Expand All @@ -12,6 +13,7 @@ permissions:
pull-requests: write

env:
APPLICATION: ${{ secrets.APPLICATION_TEST }}
wd: ./backend

jobs:
Expand All @@ -20,12 +22,19 @@ jobs:
steps:
- uses: actions/checkout@v3


- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Copy application.yml
working-directory: ${{ env.wd }}
run: |
touch ./src/test/resources/application.yml
echo "${{ secrets.APPLICATION_TEST }}" > ./src/test/resources/application.yml

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

Expand Down
7 changes: 5 additions & 2 deletions backend-recommend/recommend.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def recByApriori(body):
optionList = body['options']

for i in range(len(optionList)):
input.append(optionList[i]['subOptionId'])
input.append(str(optionList[i]))

input = set(input)
dataset = []
Expand Down Expand Up @@ -65,6 +65,9 @@ def recByApriori(body):
response = []
for item in top_items:
consequent = item[0]
response.append({"salesOptions": ",".join(consequent)})
subResponse = []
for option in consequent:
subResponse.append(int(option))
response.append(subResponse)

return jsonify(response)
3 changes: 2 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ out/
.vscode/

### yml files ###
src/main/resources/application.yml
src/main/resources/application.yml
src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package autoever2.cartag.controller;

import autoever2.cartag.domain.car.BoughtCarDto;
import autoever2.cartag.domain.car.CarDefaultDto;
import autoever2.cartag.domain.car.CarDto;
import autoever2.cartag.domain.share.QuoteIdList;
import autoever2.cartag.domain.share.QuoteInfoDto;
import autoever2.cartag.domain.car.CarTypeDto;
import autoever2.cartag.service.CarService;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -15,7 +12,6 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
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;
Expand Down Expand Up @@ -56,24 +52,4 @@ public List<CarDto> carTrimInfo(@Parameter(description = "선택한 car_type") @
public CarDefaultDto carDefaultDto(@Parameter(description = "선택한 car_id") @RequestParam("carid") int carId) {
return service.findCarDefaultDtoByCarId(carId);
}

@Operation(summary = "차량 구매 정보 반환 api", description = "차량 구매 정보 조회 method")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = @Content(schema = @Schema(implementation = BoughtCarDto.class))),
})
@GetMapping("bought/infos")
public List<BoughtCarDto> boughtCarDtos() {
return service.findAllBoughInfos();
}

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


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import autoever2.cartag.domain.model.ModelDetailMappedDto;
import autoever2.cartag.domain.model.ModelEfficiencyDataDto;
import autoever2.cartag.domain.model.ModelShortDataDto;
import autoever2.cartag.domain.model.PowerTrainMappedDto;
import autoever2.cartag.service.ModelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -37,7 +36,8 @@ public class ModelController {
})
@GetMapping("/list")
public List<ModelShortDataDto> getTrimModelType(@Parameter(description = "선택한 차량 트림ID") @RequestParam("carid") int carId) {
return modelTypeService.getModelTypeData(carId);
List<ModelShortDataDto> result = modelTypeService.getModelTypeData(carId);
return result;
}

@Operation(summary = "모델타입 상세 데이터 조회", description = "모델명과 설명, 이미지 반환하는 api")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package autoever2.cartag.controller;

import autoever2.cartag.domain.car.BoughtCarDto;
import autoever2.cartag.domain.quote.HistoryShortDto;
import autoever2.cartag.domain.quote.QuoteDataDto;
import autoever2.cartag.domain.quote.QuoteInfoDto;
import autoever2.cartag.service.CarService;
import autoever2.cartag.service.QuoteService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
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.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/quote")
@RequiredArgsConstructor
public class QuoteController {

private final CarService carService;
private final QuoteService quoteService;

@Operation(summary = "추천 견적 그래프 제공 API", description = "유사견적(최대 4개)와 판매횟수 제공")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = @Content(schema = @Schema(implementation = HistoryShortDto.class)))
})
@PostMapping("/list")
public List<HistoryShortDto> getRecommendedList(@RequestBody QuoteDataDto quoteDataDto) {
List<HistoryShortDto> result = quoteService.findTopHistory(quoteDataDto);
return result;
}

@Operation(summary = "차량 구매 정보 반환 api", description = "차량 구매 정보 조회 method")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "조회 성공", content = @Content(schema = @Schema(implementation = BoughtCarDto.class))),
})
@GetMapping("bought/infos")
public List<BoughtCarDto> getAllHistorySum() {
return carService.findAllBoughInfos();
}

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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package autoever2.cartag.domain.quote;

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

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@NoArgsConstructor
@Getter
public class HistorySearchDto {

private int carId;
private int powerTrainId;
private int bodyTypeId;
private int operationId;
private List<Integer> optionIds;

@Builder
public HistorySearchDto(int carId, int powerTrainId, int bodyTypeId, int operationId, List<Integer> optionIds) {
this.carId = carId;
this.powerTrainId = powerTrainId;
this.bodyTypeId = bodyTypeId;
this.operationId = operationId;
this.optionIds = new ArrayList<>();

this.optionIds.addAll(optionIds);
}

public void addAllOption(List<Integer> optionId) {
optionIds.addAll(optionId);
}

public String getOptionIds() {
if(optionIds.isEmpty()) {
return "";
}

StringBuilder stringBuilder = new StringBuilder();
for(int index = 0; index < optionIds.size() - 1; index++) {
stringBuilder.append(optionIds.get(index)).append(",");
}
stringBuilder.append(optionIds.get(optionIds.size()-1));

return stringBuilder.toString();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HistorySearchDto that = (HistorySearchDto) o;
return carId == that.carId && powerTrainId == that.powerTrainId && bodyTypeId == that.bodyTypeId && operationId == that.operationId && Objects.equals(optionIds, that.optionIds);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package autoever2.cartag.domain.quote;

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

import java.util.List;

@Schema(description = "실제 판매견적 간략 데이터")
@Getter
@Setter
@NoArgsConstructor
public class HistoryShortDto {

@Schema(description = "견적의 ID, 또는 내 견적의 ID")
private Long historyId;
@Schema(description = "견적의 판매 횟수")
private int soldCount;
@ArraySchema(schema = @Schema(implementation = HistoryShortDto.class, description = "유사견적 상위 4개 반환"))
List<HistoryShortDto> histories;

@Builder
public HistoryShortDto(Long historyId, int soldCount, List<HistoryShortDto> histories) {
this.historyId = historyId;
this.soldCount = soldCount;
this.histories = histories;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package autoever2.cartag.domain.share;
package autoever2.cartag.domain.quote;

import lombok.Builder;
import lombok.Getter;
Expand All @@ -11,7 +11,7 @@

@Getter @Setter
@NoArgsConstructor
public class QuoteIdList {
public class QuoteDataDto {
private int carId;
private int powerTrainId;
private int bodyTypeId;
Expand All @@ -21,7 +21,7 @@ public class QuoteIdList {
private List<Integer> optionIdList = new ArrayList<>();

@Builder
public QuoteIdList(int carId, int powerTrainId, int bodyTypeId, int operationId, int outerColorId, int innerColorId, List<Integer> optionIdList) {
public QuoteDataDto(int carId, int powerTrainId, int bodyTypeId, int operationId, int outerColorId, int innerColorId, List<Integer> optionIdList) {
this.carId = carId;
this.powerTrainId = powerTrainId;
this.bodyTypeId = bodyTypeId;
Expand All @@ -35,7 +35,7 @@ public QuoteIdList(int carId, int powerTrainId, int bodyTypeId, int operationId,
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
QuoteIdList that = (QuoteIdList) o;
QuoteDataDto that = (QuoteDataDto) o;
return carId == that.carId && powerTrainId == that.powerTrainId && bodyTypeId == that.bodyTypeId && operationId == that.operationId && outerColorId == that.outerColorId && innerColorId == that.innerColorId && Objects.equals(optionIdList, that.optionIdList);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package autoever2.cartag.domain.share;
package autoever2.cartag.domain.quote;

import autoever2.cartag.domain.car.TrimInfoDto;
import autoever2.cartag.domain.color.InnerColorDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
@Getter
@RequiredArgsConstructor
public enum ErrorCode {
INVALID_PARAMETER(HttpStatus.BAD_REQUEST, "Invalid parameter included"),
RESOURCE_NOT_FOUND(HttpStatus.NOT_FOUND, "Resource not exists"),
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "Unknown error");
INVALID_PARAMETER(HttpStatus.BAD_REQUEST, "잘못된 파라미터 형식입니다."),
INVALID_OPTIONS_REQUEST(HttpStatus.BAD_REQUEST, "잘못된 옵션으로 접근하였습니다."),
DATA_NOT_EXISTS(HttpStatus.NOT_FOUND, "데이터가 존재하지 않습니다."),
INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "서버오류입니다. 관리자에게 문의하세요."),
PARSE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "데이터 파싱에 실패했습니다.");

private final HttpStatus httpStatus;
private final String message;
Expand Down
Loading