qcast-api/src/main/java/com/interplug/qcast/biz/object/ObjectController.java

159 lines
6.5 KiB
Java

package com.interplug.qcast.biz.object;
import com.interplug.qcast.biz.object.dto.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/api/object")
@RequiredArgsConstructor
@Tag(name = "ObjectController", description = "물건정보 관련 API")
public class ObjectController {
// @Autowired private ObjectService objectService;
private final ObjectService objectService;
@Operation(description = "물건정보 도도부현을 조회한다.")
@GetMapping("/prefecture/list")
@ResponseStatus(HttpStatus.OK)
public List<PrefResponse> selectPrefList() throws Exception {
return objectService.selectPrefList();
}
@Operation(description = "물건정보 도도부현 발전시뮬레이션 지역을 조회한다.")
@GetMapping("/prefecture/{prefId}/list")
@ResponseStatus(HttpStatus.OK)
public List<PrefResponse> selectPrefAreaList(@PathVariable String prefId) throws Exception {
return objectService.selectPrefAreaList(prefId);
}
@Operation(description = "물건정보 지역 기준풍속을 조회한다.")
@GetMapping("/windSpeed/{city}/list")
@ResponseStatus(HttpStatus.OK)
public List<WindSpeedResponse> selectWindSpeedList(@PathVariable String city) throws Exception {
return objectService.selectWindSpeedList(city);
}
@Operation(description = "1차점 판매점 목록을 조회한다.")
@GetMapping("/saleStore/{saleStoreId}/firstList")
@ResponseStatus(HttpStatus.OK)
public List<SaleStoreResponse> selectFirstSaleStoreList(
@PathVariable String saleStoreId, String userId) throws Exception {
return objectService.selectFirstSaleStoreList(saleStoreId, userId);
}
@Operation(description = "판매점 목록을 조회한다.")
@GetMapping("/saleStore/{saleStoreId}/list")
@ResponseStatus(HttpStatus.OK)
public List<SaleStoreResponse> selectSaleStoreList(
@PathVariable String saleStoreId, String firstFlg, String userId) throws Exception {
return objectService.selectSaleStoreList(saleStoreId, firstFlg, userId);
}
@Operation(description = "1차점 ID 및 판매점명을 조회한다. (saleStoreLevel > 1 인 경우)")
@GetMapping("/saleStore/{saleStoreId}/firstAgent")
@ResponseStatus(HttpStatus.OK)
public SaleStoreResponse selectFirstAgentInfo(@PathVariable String saleStoreId) throws Exception {
return objectService.selectFirstAgentInfo(saleStoreId);
}
@Operation(description = "상위 판매점 정보를 조회한다.")
@GetMapping("/saleStore/{saleStoreId}/parentInfo")
@ResponseStatus(HttpStatus.OK)
public SaleStoreResponse selectParentAgentInfo(@PathVariable String saleStoreId, String storeLvl) throws Exception {
return objectService.selectParentAgentInfo(saleStoreId, storeLvl);
}
@Operation(description = "하위 판매점 목록을 조회한다.")
@GetMapping("/saleStore/{saleStoreId}/childList")
@ResponseStatus(HttpStatus.OK)
public List<SaleStoreResponse> selectChildSaleStoreList(
@PathVariable String saleStoreId, String storeLvl, String userId) throws Exception {
return objectService.selectChildSaleStoreList(saleStoreId, storeLvl, userId);
}
@Operation(description = "물건정보 목록을 조회한다.")
@GetMapping("/list")
@ResponseStatus(HttpStatus.OK)
public List<ObjectResponse> selectObjectList(ObjectRequest objectRequest) throws Exception {
return objectService.selectObjectList(objectRequest);
}
@Operation(description = "물건정보 상세를 조회한다.")
@GetMapping("/{objectNo}/detail")
@ResponseStatus(HttpStatus.OK)
public ObjectResponse selectObjectDetail(@PathVariable String objectNo) throws Exception {
return objectService.selectObjectDetail(objectNo);
}
@Operation(description = "물건정보을 저장한다.")
@PostMapping("/save-object")
@ResponseStatus(HttpStatus.CREATED)
public ObjectResponse insertObject(@RequestBody ObjectRequest objectRequest) throws Exception {
return objectService.insertObject(objectRequest);
}
@Operation(description = "물건정보을 수정한다.")
@PutMapping("/save-object")
@ResponseStatus(HttpStatus.CREATED)
public ObjectResponse updateObject(@RequestBody ObjectRequest objectRequest) throws Exception {
return objectService.updateObject(objectRequest);
}
@Operation(description = "물건정보 갱신일을 수정한다.")
@PutMapping("/update-object-date")
@ResponseStatus(HttpStatus.CREATED)
public void updateObjectLastEditDate(@RequestBody ObjectRequest objectRequest) throws Exception {
objectService.updateObjectLastEditDate(objectRequest);
}
@Operation(description = "물건정보을 삭제한다.")
@DeleteMapping("/{objectNo}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteObject(@PathVariable String objectNo, ObjectRequest objectRequest)
throws Exception {
objectRequest.setObjectNo(objectNo);
objectService.deleteObject(objectRequest);
}
@Operation(description = "물건정보의 플랜정보를 추가한다.")
@PostMapping("/add-plan")
@ResponseStatus(HttpStatus.CREATED)
public PlanResponse insertPlan(@RequestBody PlanRequest planRequest) throws Exception {
return objectService.insertPlan(planRequest);
}
@Operation(description = "물건정보의 플랜정보를 삭제한다.")
@DeleteMapping("/plan/{objectNo}/{planNo}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deletePlan(
@PathVariable String objectNo, @PathVariable String planNo, PlanRequest planRequest)
throws Exception {
planRequest.setObjectNo(objectNo);
planRequest.setPlanNo(planNo);
objectService.deletePlan(planRequest);
}
@Operation(description = "설계의뢰 목록을 조회한다.")
@GetMapping("/planReq/list")
@ResponseStatus(HttpStatus.OK)
public PlanReqResponse selectPlanReqList(PlanReqRequest planReqRequest) throws Exception {
return objectService.selectPlanReqList(planReqRequest);
}
}