shjung 3 anos atrás
pai
commit
3d664f8cc7

+ 0 - 2
src/main/java/com/its/api/its/controller/cctv/TbCctvSttsHsController.java

@@ -35,7 +35,6 @@ public class TbCctvSttsHsController {
             @ApiParam(name = "id", value = "CCTV 관리번호 목록", example = "[1,2]", required = true)
             @RequestParam List<Long> id
     ) {
-        log.error("{}", id);
         return this.service.findAllByDateRange(FROM_DT, TO_DT, id);
     }
 
@@ -49,7 +48,6 @@ public class TbCctvSttsHsController {
             @ApiParam(name = "id", value = "CCTV 관리번호 목록", example = "[1,2]", required = true)
             @RequestParam List<Long> id
     ) {
-        log.error("{}", id);
         return this.service.findAllFailByDateRange(FROM_DT, TO_DT, id);
     }
 }

+ 20 - 3
src/main/java/com/its/api/its/controller/parking/ParkingLotController.java

@@ -1,9 +1,11 @@
 package com.its.api.its.controller.parking;
 
+import com.its.api.its.model.dto.common.UsageCountDto;
 import com.its.api.its.model.dto.parking.ParkingLotDto;
 import com.its.api.its.service.parking.ParkingLotService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import lombok.RequiredArgsConstructor;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -28,10 +30,20 @@ public class ParkingLotController {
 
     @ApiOperation(value = "주차장 개별조회(PARKINGLOT)", response = ParkingLotDto.class)
     @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
-    public ParkingLotDto findById(@PathVariable final String id) {
+    public ParkingLotDto findById(
+            @ApiParam(name = "id", value = "주차장 ID", example = "PAR0000001", required = true)
+            @PathVariable final String id) {
         return this.service.findById(id);
     }
 
+    @ApiOperation(value = "주차장 사용여부 조회(신규 아이디 만들때 사용)", response = UsageCountDto.class)
+    @GetMapping(value = "/usage/{id}", produces = {"application/json; charset=utf8"})
+    public UsageCountDto findUsageId(
+            @ApiParam(name = "id", value = "주차장 ID", example = "PAR0000001", required = true)
+            @PathVariable final String id) {
+        return this.service.findUsageId(id);
+    }
+
     /*@ApiOperation(value = "주차장 정보변경(PARKINGLOT)", response = ParkingLotDto.class)
     @PutMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
     public ParkingLotDto updateById(@PathVariable final String id, @RequestBody @Valid final ParkingLotDto.ParkingLotUpdReq req) {
@@ -46,13 +58,18 @@ public class ParkingLotController {
 
     @ApiOperation(value = "주차장 정보변경/생성-개별(PARKINGLOT)", response = ParkingLotDto.class)
     @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
-    public ParkingLotDto mergeInfo(@PathVariable("id") String id, @RequestBody @Valid final ParkingLotDto.ParkingLotUpdReq req) {
+    public ParkingLotDto mergeInfo(
+            @ApiParam(name = "id", value = "주차장 ID", example = "PAR0000001", required = true)
+            @PathVariable("id") String id,
+            @RequestBody @Valid final ParkingLotDto.ParkingLotUpdReq req) {
         return this.service.mergeInfo(req);
     }
 
     @ApiOperation(value = "주차장 정보삭제-개별(PARKINGLOT)", response = ParkingLotDto.class)
     @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
-    public ParkingLotDto deleteDataById(@PathVariable("id") String id) {
+    public ParkingLotDto deleteDataById(
+            @ApiParam(name = "id", value = "주차장 ID", example = "PAR0000001", required = true)
+            @PathVariable("id") String id) {
         return this.service.deleteById(id);
     }
 

+ 4 - 0
src/main/java/com/its/api/its/repository/parking/ParkingLotRepository.java

@@ -4,6 +4,7 @@ import com.its.api.its.model.entity.parking.ParkingLot;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -13,4 +14,7 @@ public interface ParkingLotRepository extends JpaRepository<ParkingLot, String>,
 
     @Query("select p from ParkingLot p")
     List<ParkingLot> findAll();
+
+    @Query("select count(p.parkingId) from ParkingLot p where p.parkingId = :id")
+    Integer findUsageId(@Param("id") String id);
 }

+ 17 - 0
src/main/java/com/its/api/its/service/parking/ParkingLotService.java

@@ -4,12 +4,14 @@ import com.its.api.its.global.CodeManager;
 import com.its.api.its.model.dto.common.FcltSttsSummaryDto;
 import com.its.api.its.model.dto.common.FcltSttsDto;
 import com.its.api.its.model.dto.common.FcltSttsListDto;
+import com.its.api.its.model.dto.common.UsageCountDto;
 import com.its.api.its.model.dto.parking.ParkingLotDto;
 import com.its.api.its.model.entity.parking.ParkingLot;
 import com.its.api.its.repository.parking.ParkingLotRepository;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -95,6 +97,7 @@ public class ParkingLotService {
      * 상태 목록
      * @param
      */
+    @Transactional(readOnly = true)
     public FcltSttsListDto findAllSttsListTotal() {
         FcltSttsListDto result = new FcltSttsListDto();
         String fcltType = "PARK";
@@ -134,4 +137,18 @@ public class ParkingLotService {
         return result;
     }
 
+    /**
+     * 주차장 ID 사용 여부 조회(신규 아이디 만들때 사용)
+     * @param id
+     * @return
+     */
+    @Transactional(readOnly = true)
+    public UsageCountDto findUsageId(String id) {
+        UsageCountDto result = UsageCountDto.builder()
+                .count(0)
+                .build();
+        Integer data = this.repo.findUsageId(id);
+        result.setCount(data);
+        return result;
+    }
 }