diff --git a/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java new file mode 100644 index 0000000000..2871022ffc --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/TestResourcePoolController.java @@ -0,0 +1,33 @@ +package io.metersphere.controller; + +import io.metersphere.base.domain.TestResourcePool; +import io.metersphere.service.TestResourcePoolService; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import java.util.List; + +@RequestMapping("testresourcepool") +@RestController +public class TestResourcePoolController { + + @Resource + private TestResourcePoolService testResourcePoolService; + + @PostMapping("/add") + public TestResourcePool addTestResourcePool(@RequestBody TestResourcePool testResourcePool) { + return testResourcePoolService.addTestResourcePool(testResourcePool); + } + + @GetMapping("/delete/{testResourcePoolId}") + public void deleteTestResourcePool(@PathVariable(value = "testResourcePoolId") String testResourcePoolId) { + testResourcePoolService.deleteTestResourcePool(testResourcePoolId); + } + + @PostMapping("/update") + public void updateTestResourcePool(@RequestBody TestResourcePool testResourcePool) { + testResourcePoolService.updateTestResourcePool(testResourcePool); + } + + @GetMapping("/list") + public List getTestResourcePoolList() { return testResourcePoolService.getTestResourcePoolList(); } +} diff --git a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java new file mode 100644 index 0000000000..027618e92c --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java @@ -0,0 +1,39 @@ +package io.metersphere.service; + +import io.metersphere.base.domain.TestResourcePool; +import io.metersphere.base.mapper.TestResourcePoolMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import java.util.List; +import java.util.UUID; + +@Service +@Transactional(rollbackFor = Exception.class) +public class TestResourcePoolService { + + @Resource + private TestResourcePoolMapper testResourcePoolMapper; + + public TestResourcePool addTestResourcePool(TestResourcePool testResourcePool) { + testResourcePool.setId(UUID.randomUUID().toString()); + testResourcePool.setCreateTime(System.currentTimeMillis()); + testResourcePool.setUpdateTime(System.currentTimeMillis()); + testResourcePool.setStatus("1"); + testResourcePoolMapper.insertSelective(testResourcePool); + return testResourcePool; + } + + public void deleteTestResourcePool(String testResourcePoolId) { + testResourcePoolMapper.deleteByPrimaryKey(testResourcePoolId); + } + + public void updateTestResourcePool(TestResourcePool testResourcePool) { + testResourcePool.setUpdateTime(System.currentTimeMillis()); + testResourcePoolMapper.updateByPrimaryKeySelective(testResourcePool); + } + + public List getTestResourcePoolList() { + return testResourcePoolMapper.selectByExample(null); + } +}