Browse Source

param update add

shjung 2 years ago
parent
commit
41ae36c294

+ 19 - 5
src/main/java/com/its/op/controller/its/database/TbLinkParaStupController.java

@@ -1,6 +1,5 @@
 package com.its.op.controller.its.database;
 
-import com.its.op.dto.its.atrd.TbAtrdDto;
 import com.its.op.dto.its.common.NewIdLongDto;
 import com.its.op.dto.its.common.UsageCountDto;
 import com.its.op.dto.its.link.TbLinkParaStupDto;
@@ -57,10 +56,25 @@ public class TbLinkParaStupController {
         return this.service.findUsageId(paramId);
     }
 
-    @ApiOperation(value = "파라미터 정보삭제-개별(TB_LINK_PARA_STUP)", response = TbAtrdDto.class)
-    @DeleteMapping(value = "/{paramId}", produces = {"application/json; charset=utf8"})
-    public TbLinkParaStupDto deleteDataById(@PathVariable("paramId") Long paramId) {
-        return this.service.deleteDataById(paramId);
+//    @ApiOperation(value = "파라미터 정보삭제-개별(TB_LINK_PARA_STUP)", response = TbAtrdDto.class)
+//    @DeleteMapping(value = "/{paramId}", produces = {"application/json; charset=utf8"})
+//    public TbLinkParaStupDto deleteDataById(@PathVariable("paramId") Long paramId) {
+//        return this.service.deleteDataById(paramId);
+//    }
+
+    @ApiOperation(value = "선택구간 파라미터 적용", response = TbLinkParaStupDto.class)
+    @PostMapping(value = "/apply/select/{paramId}/{ids}", produces = {"application/json; charset=utf8"})
+    public TbLinkParaStupDto applyParamSelect(
+            @PathVariable final Long paramId,
+            @PathVariable final List<Long> ids) {
+        return this.service.applyParamSelect(paramId, ids);
+    }
+
+    @ApiOperation(value = "전체구간 파라미터 적용", response = TbLinkParaStupDto.class)
+    @PostMapping(value = "/apply/all/{paramId}", produces = {"application/json; charset=utf8"})
+    public TbLinkParaStupDto applyParamAll(
+            @PathVariable final Long paramId) {
+        return this.service.applyParamAll(paramId);
     }
 
 }

+ 7 - 0
src/main/java/com/its/op/dao/repository/its/link/TbLinkRepository.java

@@ -4,6 +4,7 @@ import com.its.op.entity.its.link.TbLink;
 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;
@@ -23,4 +24,10 @@ public interface TbLinkRepository extends JpaRepository<TbLink, Long> , JpaSpeci
     @Query("select count(p.linkId) from TbLink p where p.delYn = 'N'")
     Integer findAllCount();
 
+    @Query("update TbLink p set p.paraId = :paramId")
+    Integer updateParamAll(@Param("paramId") Long paramId);
+
+    @Query("update TbLink p set p.paraId = :paramId where p.linkId in :linkIds")
+    Integer updateParamSelect(@Param("paramId") Long paramId, @Param("ids") List<Long> linkIds);
+
 }

+ 14 - 0
src/main/java/com/its/op/service/its/link/TbLinkParaStupService.java

@@ -173,4 +173,18 @@ public class TbLinkParaStupService {
         }
         return paraObj.toDto();
     }
+
+    @Transactional
+    public TbLinkParaStupDto applyParamSelect(Long paramId, List<Long> ids) {
+        TbLinkParaStupDto result = findById(paramId);
+        this.linkRepo.updateParamSelect(paramId, ids);
+        return result;
+    }
+
+    @Transactional
+    public TbLinkParaStupDto applyParamAll(Long paramId) {
+        TbLinkParaStupDto result = findById(paramId);
+        this.linkRepo.updateParamAll(paramId);
+        return result;
+    }
 }