diff --git a/backend/src/main/java/io/metersphere/controller/TestResourceController.java b/backend/src/main/java/io/metersphere/controller/TestResourceController.java new file mode 100644 index 0000000000..2f2b50b9ba --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/TestResourceController.java @@ -0,0 +1,36 @@ +package io.metersphere.controller; + +import io.metersphere.base.domain.TestResource; +import io.metersphere.service.TestResourceService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RequestMapping("testresource") +@RestController +public class TestResourceController { + + @Resource + private TestResourceService testResourceService; + + @PostMapping("/add") + public TestResource addTestResource(@RequestBody TestResource testResource) { + return testResourceService.addTestResource(testResource); + } + + @GetMapping("/list/{testResourcePoolId}") + public List getTestResourceList(@PathVariable(value = "testResourcePoolId") String testResourcePoolId) { + return testResourceService.getTestResourceList(testResourcePoolId); + } + + @GetMapping("/delete/{testResourceId}") + public void deleteTestResource(@PathVariable(value = "testResourceId") String testResourceId) { + testResourceService.deleteTestResource(testResourceId); + } + + @PostMapping("/update") + public void updateTestResource(@RequestBody TestResource testResource) { + testResourceService.updateTestResource(testResource); + } +} diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index 6de2f5e69b..15b801b4be 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -1,7 +1,9 @@ package io.metersphere.controller; +import io.metersphere.base.domain.Role; import io.metersphere.base.domain.User; import io.metersphere.dto.UserDTO; +import io.metersphere.dto.UserOperateDTO; import io.metersphere.service.UserService; import org.springframework.web.bind.annotation.*; @@ -28,4 +30,9 @@ public class UserController { @PostMapping("/update") public void updateUser(@RequestBody User user) { userService.updateUser(user); } + + @GetMapping("/role/list/{userId}") + public List getUserRolesList(@PathVariable(value = "userId") String userId) { + return userService.getUserRolesList(userId); + } } diff --git a/backend/src/main/java/io/metersphere/service/TestResourceService.java b/backend/src/main/java/io/metersphere/service/TestResourceService.java new file mode 100644 index 0000000000..b74c8bfdc2 --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/TestResourceService.java @@ -0,0 +1,44 @@ +package io.metersphere.service; + +import io.metersphere.base.domain.TestResource; +import io.metersphere.base.domain.TestResourceExample; +import io.metersphere.base.mapper.TestResourceMapper; +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 TestResourceService { + + @Resource + private TestResourceMapper testResourceMapper; + + public TestResource addTestResource(TestResource testResource) { + testResource.setId(UUID.randomUUID().toString()); + testResource.setStatus("1"); + testResource.setCreateTime(System.currentTimeMillis()); + testResource.setUpdateTime(System.currentTimeMillis()); + testResourceMapper.insertSelective(testResource); + return testResource; + } + + public List getTestResourceList(String testResourcePoolId) { + TestResourceExample testResourceExample = new TestResourceExample(); + testResourceExample.createCriteria().andTestResourcePoolIdEqualTo(testResourcePoolId); + List testResources = testResourceMapper.selectByExampleWithBLOBs(testResourceExample); + return testResources; + } + + public void deleteTestResource(String testResourceId) { + testResourceMapper.deleteByPrimaryKey(testResourceId); + } + + public void updateTestResource(TestResource testResource) { + testResource.setUpdateTime(System.currentTimeMillis()); + testResourceMapper.updateByPrimaryKeySelective(testResource); + } +} diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 40dd7bbb7a..50589d6232 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -6,6 +6,7 @@ import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.UserRoleMapper; import io.metersphere.commons.exception.MSException; import io.metersphere.dto.UserDTO; +import io.metersphere.dto.UserOperateDTO; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -102,4 +103,14 @@ public class UserService { user.setUpdateTime(System.currentTimeMillis()); userMapper.updateByPrimaryKeySelective(user); } + + public List getUserRolesList(String userId) { + UserRoleExample userRoleExample = new UserRoleExample(); + userRoleExample.createCriteria().andUserIdEqualTo(userId); + List userRolesList = userRoleMapper.selectByExample(userRoleExample); + List roleIds = userRolesList.stream().map(UserRole::getRoleId).collect(Collectors.toList()); + RoleExample roleExample = new RoleExample(); + roleExample.createCriteria().andIdIn(roleIds); + return roleMapper.selectByExample(roleExample); + } } diff --git a/frontend/src/performance/components/settings/SettingMenu.vue b/frontend/src/performance/components/settings/SettingMenu.vue index 0fd7cd8bf1..c0f3bf6b0f 100644 --- a/frontend/src/performance/components/settings/SettingMenu.vue +++ b/frontend/src/performance/components/settings/SettingMenu.vue @@ -5,9 +5,9 @@