TestResourcePool CURD

This commit is contained in:
shiziyuan9527 2020-02-13 13:24:11 +08:00
parent fec574d869
commit 89fd3c1f6b
2 changed files with 72 additions and 0 deletions

View File

@ -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<TestResourcePool> getTestResourcePoolList() { return testResourcePoolService.getTestResourcePoolList(); }
}

View File

@ -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<TestResourcePool> getTestResourcePoolList() {
return testResourcePoolMapper.selectByExample(null);
}
}