Merge remote-tracking branch 'origin/master'

# Conflicts:
#	test-test/src/main/java/com/test/test/service/ITestCaseService.java
#	test-test/src/main/java/com/test/test/service/impl/TestCaseServiceImpl.java
This commit is contained in:
liangdaliang
2025-02-20 15:50:02 +08:00
50 changed files with 2208 additions and 307 deletions

View File

@@ -14,12 +14,9 @@ import com.test.common.enums.BusinessType;
import com.test.test.domain.TestApi;
import com.test.test.service.ITestApiService;
import com.test.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 接口Controller
*
* @author xiaoe
*/
@RestController
@RequestMapping("/test/api")

View File

@@ -0,0 +1,79 @@
package com.test.test.controller;
import java.util.List;
import com.test.common.utils.DateUtils;
import com.test.test.domain.qo.IDQO;
import com.test.test.domain.qo.TestCaseListQO;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.test.common.annotation.Log;
import com.test.common.core.controller.BaseController;
import com.test.common.core.domain.AjaxResult;
import com.test.common.enums.BusinessType;
import com.test.test.domain.TestCase;
import com.test.test.service.ITestCaseService;
import com.test.common.core.page.TableDataInfo;
/**
* 用例Controller
*/
@RestController
@RequestMapping("/test/case")
public class TestCaseController extends BaseController {
@Resource
private ITestCaseService testCaseService;
/**
* 查询用例列表
*/
@GetMapping("/list")
public TableDataInfo list(@Validated TestCaseListQO qo) {
startPage();
List<TestCase> list = testCaseService.selectTestCaseList(qo);
return getDataTable(list);
}
/**
* 获取用例详细信息
*/
@PostMapping(value = "/detail")
public AjaxResult getInfo(@RequestBody IDQO qo) {
return success(testCaseService.selectTestCaseById(qo.getId()));
}
/**
* 新增用例
*/
@Log(title = "用例", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(@RequestBody TestCase testCase) {
testCase.setCreateBy(getLoginUser().getUsername());
testCase.setCreateTime(DateUtils.getNowDate());
testCase.setStatus(1L);
return toAjax(testCaseService.insertTestCase(testCase));
}
/**
* 修改用例
*/
@Log(title = "用例", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
public AjaxResult edit(@RequestBody TestCase testCase) {
return toAjax(testCaseService.updateTestCase(testCase));
}
/**
* 删除用例
*/
@Log(title = "用例", businessType = BusinessType.DELETE)
@PostMapping("/del")
public AjaxResult remove(@RequestBody IDQO qo) {
return toAjax(testCaseService.deleteTestCaseById(qo.getId()));
}
}

View File

@@ -0,0 +1,71 @@
package com.test.test.controller;
import java.util.List;
import com.test.test.domain.qo.IDQO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.test.common.annotation.Log;
import com.test.common.core.controller.BaseController;
import com.test.common.core.domain.AjaxResult;
import com.test.common.enums.BusinessType;
import com.test.test.domain.TestDatasource;
import com.test.test.service.ITestDatasourceService;
/**
* 数据源Controller
*/
@RestController
@RequestMapping("/test/datasource")
public class TestDatasourceController extends BaseController {
@Resource
private ITestDatasourceService testDatasourceService;
/**
* 查询数据源列表
*/
@GetMapping("/list")
public AjaxResult list() {
List<TestDatasource> list = testDatasourceService.selectTestDatasourceList();
return success(list);
}
/**
* 获取数据源详细信息
*/
@PostMapping(value = "/detail")
public AjaxResult getInfo(@RequestBody IDQO qo) {
return success(testDatasourceService.selectTestDatasourceById(qo.getId()));
}
/**
* 新增数据源
*/
@Log(title = "数据源", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(@RequestBody TestDatasource testDatasource) {
return success(testDatasourceService.insertTestDatasource(testDatasource));
}
/**
* 修改数据源
*/
@Log(title = "数据源", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
public AjaxResult edit(@RequestBody TestDatasource testDatasource) {
return toAjax(testDatasourceService.updateTestDatasource(testDatasource));
}
/**
* 删除数据源
*/
@Log(title = "数据源", businessType = BusinessType.DELETE)
@PostMapping("/del")
public AjaxResult remove(@RequestBody IDQO qo) {
return toAjax(testDatasourceService.deleteTestDatasourceById(qo.getId()));
}
}

View File

@@ -11,8 +11,6 @@ import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/test/group")
public class TestGroupController extends BaseController {
@@ -20,36 +18,35 @@ public class TestGroupController extends BaseController {
private ITestGroupService testGroupService;
/**
* 查询接口节点列表
* 查询节点列表
*/
@GetMapping("/list")
public AjaxResult list(String type) {
List<TestGroup> list = testGroupService.selectTestGroupList(type);
return success(list);
return success(testGroupService.selectTestGroupList(type));
}
/**
* 新增接口节点
* 新增节点
*/
@Log(title = "接口节点", businessType = BusinessType.INSERT)
@Log(title = "节点", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(@RequestBody TestGroup testGroup) {
return success(testGroupService.insertTestGroup(testGroup));
}
/**
* 修改接口节点
* 修改节点
*/
@Log(title = "接口节点", businessType = BusinessType.UPDATE)
@Log(title = "节点", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
public AjaxResult edit(@RequestBody TestGroup testGroup) {
return toAjax(testGroupService.updateTestGroup(testGroup));
}
/**
* 删除接口节点
* 删除节点
*/
@Log(title = "接口节点", businessType = BusinessType.DELETE)
@Log(title = "节点", businessType = BusinessType.DELETE)
@PostMapping("/del")
public AjaxResult remove(@RequestBody @Validated GroupDelectQO qo) throws Exception {
return toAjax(testGroupService.deleteTestGroupById(qo));

View File

@@ -0,0 +1,70 @@
package com.test.test.controller;
import java.util.List;
import com.test.test.domain.qo.IDQO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.test.common.annotation.Log;
import com.test.common.core.controller.BaseController;
import com.test.common.core.domain.AjaxResult;
import com.test.common.enums.BusinessType;
import com.test.test.domain.TestHttp;
import com.test.test.service.ITestHttpService;
/**
* http服务Controller
*/
@RestController
@RequestMapping("/test/http")
public class TestHttpController extends BaseController {
@Resource
private ITestHttpService testHttpService;
/**
* 查询http服务列表
*/
@GetMapping("/list")
public AjaxResult list() {
return success(testHttpService.selectTestHttpList());
}
/**
* 获取http服务详细信息
*/
@PostMapping(value = "/detail")
public AjaxResult getInfo(@RequestBody IDQO qo) {
return success(testHttpService.selectTestHttpById(qo.getId()));
}
/**
* 新增http服务
*/
@Log(title = "http服务", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult add(@RequestBody TestHttp testHttp) {
return success(testHttpService.insertTestHttp(testHttp));
}
/**
* 修改http服务
*/
@Log(title = "http服务", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
public AjaxResult edit(@RequestBody TestHttp testHttp) {
return toAjax(testHttpService.updateTestHttp(testHttp));
}
/**
* 删除http服务
*/
@Log(title = "http服务", businessType = BusinessType.DELETE)
@PostMapping("/del")
public AjaxResult remove(@RequestBody IDQO qo) {
return toAjax(testHttpService.deleteTestHttpById(qo.getId()));
}
}

View File

@@ -0,0 +1,86 @@
package com.test.test.domain;
import com.test.common.core.domain.BaseEntity;
import com.test.common.annotation.Excel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 数据源对象 test_datasource
*/
@Getter
@Setter
@ToString
public class TestDatasource extends BaseEntity {
/**
* 数据源id
*/
private Long id;
/**
* 数据源名称
*/
@Excel(name = "数据源名称")
private String name;
/**
* 数据源类型(Mysql1redis2Oracle3MongoDB4SQL Server5PostgreSQL6)
*/
@Excel(name = "数据源类型(Mysql1redis2Oracle3MongoDB4SQL Server5PostgreSQL6)")
private Long type;
/**
* 主机
*/
@Excel(name = "主机")
private String host;
/**
* 端口
*/
@Excel(name = "端口")
private String port;
/**
* 用户名
*/
@Excel(name = "用户名")
private String username;
/**
* 密码
*/
@Excel(name = "密码")
private String password;
/**
* 库名Oracle服务名
*/
@Excel(name = "库名", readConverterExp = "O=racle服务名")
private String dbName;
/**
* mongo认证库名
*/
@Excel(name = "mongo认证库名")
private String authDb;
/**
* redis集群模式
*/
@Excel(name = "redis集群模式")
private Integer cluster;
/**
* redis哨兵模式下输入MasterName
*/
@Excel(name = "redis哨兵模式下输入MasterName")
private String masterName;
/**
* 删除标志0代表存在 2代表删除
*/
private String delFlag;
}

View File

@@ -0,0 +1,58 @@
package com.test.test.domain;
import com.test.common.annotation.Excel;
import com.test.common.core.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class TestHttp extends BaseEntity {
/**
* 服务id
*/
private Long id;
/**
* 服务名
*/
@Excel(name = "服务名")
private String name;
/**
* 协议(http, https)
*/
@Excel(name = "协议(http, https)")
private String protocol;
/**
* 主机
*/
@Excel(name = "主机")
private String host;
/**
* 端口
*/
@Excel(name = "端口")
private String port;
/**
* 前置路径
*/
@Excel(name = "前置路径")
private String basePath;
/**
* 请求头
*/
@Excel(name = "请求头")
private String header;
/**
* 删除标志0代表存在 2代表删除
*/
private String delFlag;
}

View File

@@ -1,4 +0,0 @@
package com.test.test.domain.dto;
public class SwaggerInfo {
}

View File

@@ -0,0 +1,10 @@
package com.test.test.domain.qo;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class TestCaseListQO {
@NotNull(message = "父节点id不能为空")
private Long groupId;
}

View File

@@ -1,62 +1,42 @@
package com.test.test.mapper;
import com.test.test.domain.TestCase;
import com.test.test.domain.qo.TestCaseListQO;
import java.util.List;
/**
* 用例Mapper接口
*
* @author test
* @date 2025-02-18
*/
public interface TestCaseMapper
{
/**
* 查询用例
*
* @param id 用例主键
* @return 用例
*/
public TestCase selectTestCaseById(Long id);
TestCase selectTestCaseById(Long id);
/**
* 查询用例列表
*
* @param testCase 用例
* @return 用例集合
*/
public List<TestCase> selectTestCaseList(TestCase testCase);
List<TestCase> selectTestCaseList(TestCaseListQO qo);
/**
* 新增用例
*
* @param testCase 用例
* @return 结果
*/
public int insertTestCase(TestCase testCase);
int insertTestCase(TestCase testCase);
/**
* 修改用例
*
* @param testCase 用例
* @return 结果
*/
public int updateTestCase(TestCase testCase);
int updateTestCase(TestCase testCase);
/**
* 删除用例
*
* @param id 用例主键
* @return 结果
*/
public int deleteTestCaseById(Long id);
int deleteTestCaseById(Long id);
/**
* 批量删除用例
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteTestCaseByIds(Long[] ids);
int deleteTestCaseByIds(Long[] ids);
}

View File

@@ -0,0 +1,40 @@
package com.test.test.mapper;
import java.util.List;
import com.test.test.domain.TestDatasource;
/**
* 数据源Mapper接口
*/
public interface TestDatasourceMapper {
/**
* 查询数据源
*/
TestDatasource selectTestDatasourceById(Long id);
/**
* 查询数据源列表
*/
List<TestDatasource> selectTestDatasourceList();
/**
* 新增数据源
*/
int insertTestDatasource(TestDatasource testDatasource);
/**
* 修改数据源
*/
int updateTestDatasource(TestDatasource testDatasource);
/**
* 删除数据源
*/
int deleteTestDatasourceById(Long id);
/**
* 批量删除数据源
*/
int deleteTestDatasourceByIds(Long[] ids);
}

View File

@@ -33,4 +33,5 @@ public interface TestGroupMapper
*/
int deleteTestGroupByIds(List<Long> ids);
TestGroup selectGroup(String name, Long parentId, String type);
}

View File

@@ -0,0 +1,40 @@
package com.test.test.mapper;
import java.util.List;
import com.test.test.domain.TestHttp;
/**
* http服务Mapper接口
*/
public interface TestHttpMapper {
/**
* 查询http服务
*/
TestHttp selectTestHttpById(Long id);
/**
* 查询http服务列表
*/
List<TestHttp> selectTestHttpList();
/**
* 新增http服务
*/
int insertTestHttp(TestHttp testHttp);
/**
* 修改http服务
*/
int updateTestHttp(TestHttp testHttp);
/**
* 删除http服务
*/
int deleteTestHttpById(Long id);
/**
* 批量删除http服务
*/
int deleteTestHttpByIds(Long[] ids);
}

View File

@@ -1,9 +1,5 @@
package com.test.test.service;
import com.test.test.domain.TestCase;
import java.util.List;
/**
* 用例Service接口
*

View File

@@ -0,0 +1,40 @@
package com.test.test.service;
import java.util.List;
import com.test.test.domain.TestDatasource;
/**
* 数据源Service接口
*/
public interface ITestDatasourceService {
/**
* 查询数据源
*/
public TestDatasource selectTestDatasourceById(Long id);
/**
* 查询数据源列表
*/
List<TestDatasource> selectTestDatasourceList();
/**
* 新增数据源
*/
TestDatasource insertTestDatasource(TestDatasource testDatasource);
/**
* 修改数据源
*/
int updateTestDatasource(TestDatasource testDatasource);
/**
* 批量删除数据源
*/
int deleteTestDatasourceByIds(Long[] ids);
/**
* 删除数据源信息
*/
int deleteTestDatasourceById(Long id);
}

View File

@@ -1,6 +1,7 @@
package com.test.test.service;
import java.util.List;
import com.test.test.domain.TestGroup;
import com.test.test.domain.qo.GroupDelectQO;
@@ -9,8 +10,7 @@ import com.test.test.domain.qo.GroupDelectQO;
*
* @author xiaoe
*/
public interface ITestGroupService
{
public interface ITestGroupService {
/**
* 查询节点(文件夹)列表
*/
@@ -21,6 +21,11 @@ public interface ITestGroupService
*/
TestGroup insertTestGroup(TestGroup testGroup);
/**
* 查询节点(文件夹)
*/
TestGroup selectGroup(String name, Long parentId, String type);
/**
* 修改节点(文件夹)
*/

View File

@@ -0,0 +1,40 @@
package com.test.test.service;
import java.util.List;
import com.test.test.domain.TestHttp;
/**
* http服务Service接口
*/
public interface ITestHttpService {
/**
* 查询http服务
*/
TestHttp selectTestHttpById(Long id);
/**
* 查询http服务列表
*/
List<TestHttp> selectTestHttpList();
/**
* 新增http服务
*/
TestHttp insertTestHttp(TestHttp testHttp);
/**
* 修改http服务
*/
int updateTestHttp(TestHttp testHttp);
/**
* 批量删除http服务
*/
int deleteTestHttpByIds(Long[] ids);
/**
* 删除http服务信息
*/
int deleteTestHttpById(Long id);
}

View File

@@ -1,16 +1,21 @@
package com.test.test.service.impl;
import java.util.List;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.test.common.utils.DateUtils;
import com.test.common.utils.http.HttpUtils;
import com.test.test.domain.TestGroup;
import com.test.test.domain.qo.TestApiListQO;
import com.test.test.service.ITestGroupService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.test.test.mapper.TestApiMapper;
import com.test.test.domain.TestApi;
import com.test.test.service.ITestApiService;
import org.springframework.transaction.annotation.Transactional;
/**
* 接口Service业务层处理
@@ -22,6 +27,9 @@ public class TestApiServiceImpl implements ITestApiService {
@Resource
private TestApiMapper testApiMapper;
@Resource
private ITestGroupService testGroupService;
/**
* 查询接口
*
@@ -57,9 +65,172 @@ public class TestApiServiceImpl implements ITestApiService {
}
@Override
@Transactional
public int importSwaggerApi(String url) {
JSONObject json = JSONObject.parse(HttpUtils.sendGet(url));
return 0;
AtomicInteger count = new AtomicInteger();
JSONObject jsonObject = JSONObject.parseObject(HttpUtils.sendGet(url));
String title = jsonObject.getJSONObject("info").getString("title");
Date createTime = DateUtils.getNowDate();
// 设置顶级节点
Long parentId = getGroupId(title, 0L);
// 获取Schemas
JSONObject schemas = jsonObject.getJSONObject("components").getJSONObject("schemas");
// 获取所有接口
jsonObject.getJSONObject("paths").forEach((uri, pathJson) -> {
((JSONObject) pathJson).forEach((method, v) -> {
JSONObject json = (JSONObject) v;
// 获取接口名
String name = json.getString("summary");
if (name == null) name = uri;
// 获取接口分组
String groupName = title;
List<String> tags = json.getList("tags", String.class);
if (!tags.isEmpty()) {
groupName = tags.get(0);
}
// 获取body
String body = "";
String contentType = "";
if (json.getJSONObject("requestBody") != null) {
JSONObject bodyJson = json.getJSONObject("requestBody").getJSONObject("content");
if (bodyJson != null) {
Set<String> keys = bodyJson.keySet();
if (!keys.isEmpty()) {
contentType = keys.iterator().next();
JSONObject schema = bodyJson.getJSONObject(contentType).getJSONObject("schema");
body = JSONObject.toJSONString(parseSchema(schema, schemas));
}
}
}
// 获取Param
String param = "[]";
JSONObject parameters = json.getJSONObject("parameters");
if (parameters != null) {
JSONObject paramsJson = parseParams(parameters, schemas);
JSONArray array = new JSONArray();
paramsJson.forEach((key, value) -> {
JSONObject object = new JSONObject();
object.put("key", key);
object.put("value", value);
array.add(object);
});
param = array.toJSONString();
}
// 获取header
String header = "[]";
TestApi testApi = new TestApi();
testApi.setUri(uri);
testApi.setMethod(method);
testApi.setName(name);
testApi.setGroupId(getGroupId(groupName, parentId));
testApi.setBody(body);
testApi.setParam(param);
testApi.setHeader(header);
testApi.setCreateTime(createTime);
count.addAndGet(testApiMapper.insertTestApi(testApi));
});
});
return count.get();
}
private static JSONObject parseSchema(JSONObject schema, JSONObject schemas) {
JSONObject result = new JSONObject();
// 如果 schema 包含 $ref则解析引用
if (schema.containsKey("$ref")) {
String ref = schema.getString("$ref");
// 去掉 #/components/schemas/ 前缀,获取引用的 schema 名称
String schemaName = ref.replace("#/components/schemas/", "");
JSONObject referencedSchema = schemas.getJSONObject(schemaName);
// 递归解析引用的 schema
return parseSchema(referencedSchema, schemas);
}
// 如果 schema 包含 type则直接根据类型构建结果
if (schema.containsKey("type")) {
String type = schema.getString("type");
switch (type) {
case "integer":
result.put("value", 0);
break;
case "string":
result.put("value", "string");
break;
case "boolean":
result.put("value", false);
break;
default:
result.put("value", type);
}
}
// 如果 schema 有 properties则遍历 properties 并递归解析
if (schema.containsKey("properties")) {
JSONObject properties = schema.getJSONObject("properties");
for (Map.Entry<String, Object> entry : properties.entrySet()) {
String key = entry.getKey();
JSONObject propertySchema = (JSONObject) entry.getValue();
JSONObject propertyResult = parseSchema(propertySchema, schemas); // 递归解析每个字段
result.put(key, propertyResult.get("value")); // 获取解析结果的值
}
}
return result;
}
private static JSONObject parseParams(JSONObject params, JSONObject schemas) {
JSONObject result = new JSONObject();
// 遍历 params 中的每个参数
for (String key : params.keySet()) {
// 获取当前参数的 schema 定义
Object value = params.get(key);
// 获取 schema
JSONObject schema = schemas.getJSONObject(key);
// 如果 schema 是基础类型,则直接赋值
if (schema != null && schema.containsKey("type")) {
String type = schema.getString("type");
if ("string".equals(type)) {
result.put(key, value != null ? value : "string"); // 默认值为 "string"
} else if ("integer".equals(type)) {
result.put(key, value != null ? value : 0); // 默认值为 0
} else if ("boolean".equals(type)) {
result.put(key, value != null ? value : false); // 默认值为 false
}
}
// 如果 schema 是引用类型,则递归解析该引用
else if (schema != null && schema.containsKey("$ref")) {
String ref = schema.getString("$ref");
String schemaName = ref.replace("#/components/schemas/", "");
JSONObject referencedSchema = schemas.getJSONObject(schemaName);
// 如果引用的 schema 存在,递归解析该 schema
if (referencedSchema != null) {
// 递归调用,解析引用的 schema
JSONObject nestedResult = parseParams(new JSONObject(), schemas);
result.putAll(nestedResult);
}
}
}
return result;
}
private Long getGroupId(String groupName, Long parentId) {
TestGroup group = testGroupService.selectGroup(groupName, parentId, "api");
if (group == null) {
group = new TestGroup();
group.setParentId(parentId);
group.setName(groupName);
group.setType("api");
group.setCreateTime(DateUtils.getNowDate());
testGroupService.insertTestGroup(group);
}
return group.getId();
}
/**

View File

@@ -0,0 +1,73 @@
package com.test.test.service.impl;
import java.util.List;
import com.test.common.utils.DateUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.test.test.mapper.TestDatasourceMapper;
import com.test.test.domain.TestDatasource;
import com.test.test.service.ITestDatasourceService;
/**
* 数据源Service业务层处理
*/
@Service
public class TestDatasourceServiceImpl implements ITestDatasourceService {
@Resource
private TestDatasourceMapper testDatasourceMapper;
/**
* 查询数据源
*
* @param id 数据源主键
* @return 数据源
*/
@Override
public TestDatasource selectTestDatasourceById(Long id) {
return testDatasourceMapper.selectTestDatasourceById(id);
}
/**
* 查询数据源列表
*/
@Override
public List<TestDatasource> selectTestDatasourceList() {
return testDatasourceMapper.selectTestDatasourceList();
}
/**
* 新增数据源
*/
@Override
public TestDatasource insertTestDatasource(TestDatasource testDatasource) {
testDatasource.setCreateTime(DateUtils.getNowDate());
testDatasourceMapper.insertTestDatasource(testDatasource);
return testDatasource;
}
/**
* 修改数据源
*/
@Override
public int updateTestDatasource(TestDatasource testDatasource) {
testDatasource.setUpdateTime(DateUtils.getNowDate());
return testDatasourceMapper.updateTestDatasource(testDatasource);
}
/**
* 批量删除数据源
*/
@Override
public int deleteTestDatasourceByIds(Long[] ids) {
return testDatasourceMapper.deleteTestDatasourceByIds(ids);
}
/**
* 删除数据源信息
*/
@Override
public int deleteTestDatasourceById(Long id) {
return testDatasourceMapper.deleteTestDatasourceById(id);
}
}

View File

@@ -8,6 +8,7 @@ import com.test.common.utils.DateUtils;
import com.test.common.utils.StringUtils;
import com.test.test.domain.qo.GroupDelectQO;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import com.test.test.mapper.TestGroupMapper;
import com.test.test.domain.TestGroup;
@@ -26,6 +27,7 @@ public class TestGroupServiceImpl implements ITestGroupService {
private TestGroupMapper testGroupMapper;
@Resource
@Lazy
private TestApiServiceImpl testApiServiceImpl;
/**
@@ -46,6 +48,11 @@ public class TestGroupServiceImpl implements ITestGroupService {
return testGroup;
}
@Override
public TestGroup selectGroup(String name, Long parentId, String type) {
return testGroupMapper.selectGroup(name, parentId, type);
}
/**
* 修改节点(文件夹)
*/

View File

@@ -0,0 +1,70 @@
package com.test.test.service.impl;
import java.util.List;
import com.test.common.utils.DateUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.test.test.mapper.TestHttpMapper;
import com.test.test.domain.TestHttp;
import com.test.test.service.ITestHttpService;
/**
* http服务Service业务层处理
*/
@Service
public class TestHttpServiceImpl implements ITestHttpService {
@Resource
private TestHttpMapper testHttpMapper;
/**
* 查询http服务
*/
@Override
public TestHttp selectTestHttpById(Long id) {
return testHttpMapper.selectTestHttpById(id);
}
/**
* 查询http服务列表
*/
@Override
public List<TestHttp> selectTestHttpList() {
return testHttpMapper.selectTestHttpList();
}
/**
* 新增http服务
*/
@Override
public TestHttp insertTestHttp(TestHttp testHttp) {
testHttp.setCreateTime(DateUtils.getNowDate());
testHttpMapper.insertTestHttp(testHttp);
return testHttp;
}
/**
* 修改http服务
*/
@Override
public int updateTestHttp(TestHttp testHttp) {
testHttp.setUpdateTime(DateUtils.getNowDate());
return testHttpMapper.updateTestHttp(testHttp);
}
/**
* 批量删除http服务
*/
@Override
public int deleteTestHttpByIds(Long[] ids) {
return testHttpMapper.deleteTestHttpByIds(ids);
}
/**
* 删除http服务信息
*/
@Override
public int deleteTestHttpById(Long id) {
return testHttpMapper.deleteTestHttpById(id);
}
}

View File

@@ -28,11 +28,12 @@
<select id="selectTestApiList" parameterType="TestApiListQO" resultMap="TestApiResult">
<include refid="selectTestApiVo"/>
<where>
<if test="groupId != null "> and group_id = #{groupId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="method != null and method != ''"> and method = #{method}</if>
<if test="uri != null and uri != ''"> and uri like concat('%', #{uri}, '%')</if>
<if test="groupId != null ">and group_id = #{groupId}</if>
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="method != null and method != ''">and method = #{method}</if>
<if test="uri != null and uri != ''">and uri like concat('%', #{uri}, '%')</if>
</where>
order by create_time desc
</select>
<select id="selectTestApiById" parameterType="Long" resultMap="TestApiResult">

View File

@@ -1,30 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.test.test.mapper.TestCaseLogMapper">
<resultMap type="TestCaseLog" id="TestCaseLogResult">
<result property="id" column="id" />
<result property="caseId" column="case_id" />
<result property="operType" column="oper_type" />
<result property="operDetail" column="oper_detail" />
<result property="operUser" column="oper_user" />
<result property="operTime" column="oper_time" />
<result property="id" column="id"/>
<result property="caseId" column="case_id"/>
<result property="operType" column="oper_type"/>
<result property="operDetail" column="oper_detail"/>
<result property="operUser" column="oper_user"/>
<result property="operTime" column="oper_time"/>
</resultMap>
<sql id="selectTestCaseLogVo">
select id, case_id, oper_type, oper_detail, oper_user, oper_time from test_case_log
select id, case_id, oper_type, oper_detail, oper_user, oper_time
from test_case_log
</sql>
<select id="selectTestCaseLogList" parameterType="TestCaseLog" resultMap="TestCaseLogResult">
<include refid="selectTestCaseLogVo"/>
<where>
<if test="caseId != null and caseId != ''"> and case_id = #{caseId}</if>
<if test="operType != null and operType != ''"> and oper_type = #{operType}</if>
<if test="operDetail != null and operDetail != ''"> and oper_detail = #{operDetail}</if>
<if test="operUser != null "> and oper_user = #{operUser}</if>
<if test="operTime != null "> and oper_time = #{operTime}</if>
<if test="caseId != null and caseId != ''">and case_id = #{caseId}</if>
<if test="operType != null and operType != ''">and oper_type = #{operType}</if>
<if test="operDetail != null and operDetail != ''">and oper_detail = #{operDetail}</if>
<if test="operUser != null ">and oper_user = #{operUser}</if>
<if test="operTime != null ">and oper_time = #{operTime}</if>
</where>
</select>
@@ -41,14 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="operDetail != null">oper_detail,</if>
<if test="operUser != null">oper_user,</if>
<if test="operTime != null">oper_time,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="caseId != null">#{caseId},</if>
<if test="operType != null">#{operType},</if>
<if test="operDetail != null">#{operDetail},</if>
<if test="operUser != null">#{operUser},</if>
<if test="operTime != null">#{operTime},</if>
</trim>
</trim>
</insert>
<update id="updateTestCaseLog" parameterType="TestCaseLog">
@@ -64,7 +65,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteTestCaseLogById" parameterType="Long">
delete from test_case_log where id = #{id}
delete
from test_case_log
where id = #{id}
</delete>
<delete id="deleteTestCaseLogByIds" parameterType="String">

View File

@@ -1,36 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.test.test.mapper.TestCaseMapper">
<resultMap type="TestCase" id="TestCaseResult">
<result property="id" column="id" />
<result property="groupId" column="group_id" />
<result property="projectId" column="project_id" />
<result property="name" column="name" />
<result property="importance" column="importance" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="id" column="id"/>
<result property="groupId" column="group_id"/>
<result property="projectId" column="project_id"/>
<result property="name" column="name"/>
<result property="importance" column="importance"/>
<result property="status" column="status"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectTestCaseVo">
select id, group_id, project_id, name, importance, status, del_flag, create_by, create_time, update_by, update_time from test_case
select id,
group_id,
project_id,
name,
importance,
status,
del_flag,
create_by,
create_time,
update_by,
update_time
from test_case
</sql>
<select id="selectTestCaseList" parameterType="TestCase" resultMap="TestCaseResult">
<select id="selectTestCaseList" parameterType="TestCaseListQO" resultMap="TestCaseResult">
<include refid="selectTestCaseVo"/>
<where>
<if test="groupId != null "> and group_id = #{groupId}</if>
<if test="projectId != null "> and project_id = #{projectId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="importance != null "> and importance = #{importance}</if>
<if test="status != null "> and status = #{status}</if>
group_id = #{groupId}
</where>
order by create_time desc
</select>
<select id="selectTestCaseById" parameterType="Long" resultMap="TestCaseResult">
@@ -51,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="groupId != null">#{groupId},</if>
<if test="projectId != null">#{projectId},</if>
@@ -63,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</trim>
</insert>
<update id="updateTestCase" parameterType="TestCase">
@@ -84,7 +92,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteTestCaseById" parameterType="Long">
delete from test_case where id = #{id}
delete
from test_case
where id = #{id}
</delete>
<delete id="deleteTestCaseByIds" parameterType="String">

View File

@@ -1,71 +1,100 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.test.test.mapper.TestCaseStepMapper">
<resultMap type="TestCaseStep" id="TestCaseStepResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="caseId" column="case_id" />
<result property="name" column="name" />
<result property="stepNum" column="step_num" />
<result property="type" column="type" />
<result property="requestMethod" column="request_method" />
<result property="requestUrl" column="request_url" />
<result property="requestBody" column="request_body" />
<result property="requestHeader" column="request_header" />
<result property="requestParams" column="request_params" />
<result property="apiHttpId" column="api_http_id" />
<result property="apiHost" column="api_host" />
<result property="apiPort" column="api_port" />
<result property="apiProtocol" column="api_protocol" />
<result property="sqlCommand" column="sql_command" />
<result property="count" column="count" />
<result property="async" column="async" />
<result property="interval" column="interval" />
<result property="breakError" column="break_error" />
<result property="preScript" column="pre_script" />
<result property="postScript" column="post_script" />
<result property="assignment" column="assignment" />
<result property="assertion" column="assertion" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="id" column="id"/>
<result property="parentId" column="parent_id"/>
<result property="caseId" column="case_id"/>
<result property="name" column="name"/>
<result property="stepNum" column="step_num"/>
<result property="type" column="type"/>
<result property="requestMethod" column="request_method"/>
<result property="requestUrl" column="request_url"/>
<result property="requestBody" column="request_body"/>
<result property="requestHeader" column="request_header"/>
<result property="requestParams" column="request_params"/>
<result property="apiHttpId" column="api_http_id"/>
<result property="apiHost" column="api_host"/>
<result property="apiPort" column="api_port"/>
<result property="apiProtocol" column="api_protocol"/>
<result property="sqlCommand" column="sql_command"/>
<result property="count" column="count"/>
<result property="async" column="async"/>
<result property="interval" column="interval"/>
<result property="breakError" column="break_error"/>
<result property="preScript" column="pre_script"/>
<result property="postScript" column="post_script"/>
<result property="assignment" column="assignment"/>
<result property="assertion" column="assertion"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectTestCaseStepVo">
select id, parent_id, case_id, name, step_num, type, request_method, request_url, request_body, request_header, request_params, api_http_id, api_host, api_port, api_protocol, sql_command, count, async, interval, break_error, pre_script, post_script, assignment, assertion, del_flag, create_by, create_time, update_by, update_time from test_case_step
select id,
parent_id,
case_id,
name,
step_num,
type,
request_method,
request_url,
request_body,
request_header,
request_params,
api_http_id,
api_host,
api_port,
api_protocol,
sql_command,
count,
async,
interval,
break_error,
pre_script,
post_script,
assignment,
assertion,
del_flag,
create_by,
create_time,
update_by,
update_time
from test_case_step
</sql>
<select id="selectTestCaseStepList" parameterType="TestCaseStep" resultMap="TestCaseStepResult">
<include refid="selectTestCaseStepVo"/>
<where>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="caseId != null "> and case_id = #{caseId}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="stepNum != null "> and step_num = #{stepNum}</if>
<if test="type != null "> and type = #{type}</if>
<if test="requestMethod != null and requestMethod != ''"> and request_method = #{requestMethod}</if>
<if test="requestUrl != null and requestUrl != ''"> and request_url = #{requestUrl}</if>
<if test="requestBody != null and requestBody != ''"> and request_body = #{requestBody}</if>
<if test="requestHeader != null and requestHeader != ''"> and request_header = #{requestHeader}</if>
<if test="requestParams != null and requestParams != ''"> and request_params = #{requestParams}</if>
<if test="apiHttpId != null "> and api_http_id = #{apiHttpId}</if>
<if test="apiHost != null and apiHost != ''"> and api_host = #{apiHost}</if>
<if test="apiPort != null "> and api_port = #{apiPort}</if>
<if test="apiProtocol != null and apiProtocol != ''"> and api_protocol = #{apiProtocol}</if>
<if test="sqlCommand != null and sqlCommand != ''"> and sql_command = #{sqlCommand}</if>
<if test="count != null "> and count = #{count}</if>
<if test="async != null "> and async = #{async}</if>
<if test="interval != null "> and interval = #{interval}</if>
<if test="breakError != null and breakError != ''"> and break_error = #{breakError}</if>
<if test="preScript != null and preScript != ''"> and pre_script = #{preScript}</if>
<if test="postScript != null and postScript != ''"> and post_script = #{postScript}</if>
<if test="assignment != null and assignment != ''"> and assignment = #{assignment}</if>
<if test="assertion != null and assertion != ''"> and assertion = #{assertion}</if>
<if test="parentId != null ">and parent_id = #{parentId}</if>
<if test="caseId != null ">and case_id = #{caseId}</if>
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="stepNum != null ">and step_num = #{stepNum}</if>
<if test="type != null ">and type = #{type}</if>
<if test="requestMethod != null and requestMethod != ''">and request_method = #{requestMethod}</if>
<if test="requestUrl != null and requestUrl != ''">and request_url = #{requestUrl}</if>
<if test="requestBody != null and requestBody != ''">and request_body = #{requestBody}</if>
<if test="requestHeader != null and requestHeader != ''">and request_header = #{requestHeader}</if>
<if test="requestParams != null and requestParams != ''">and request_params = #{requestParams}</if>
<if test="apiHttpId != null ">and api_http_id = #{apiHttpId}</if>
<if test="apiHost != null and apiHost != ''">and api_host = #{apiHost}</if>
<if test="apiPort != null ">and api_port = #{apiPort}</if>
<if test="apiProtocol != null and apiProtocol != ''">and api_protocol = #{apiProtocol}</if>
<if test="sqlCommand != null and sqlCommand != ''">and sql_command = #{sqlCommand}</if>
<if test="count != null ">and count = #{count}</if>
<if test="async != null ">and async = #{async}</if>
<if test="interval != null ">and interval = #{interval}</if>
<if test="breakError != null and breakError != ''">and break_error = #{breakError}</if>
<if test="preScript != null and preScript != ''">and pre_script = #{preScript}</if>
<if test="postScript != null and postScript != ''">and post_script = #{postScript}</if>
<if test="assignment != null and assignment != ''">and assignment = #{assignment}</if>
<if test="assertion != null and assertion != ''">and assertion = #{assertion}</if>
</where>
ORDER BY step_num
</select>
@@ -106,7 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="caseId != null">#{caseId},</if>
@@ -136,7 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</trim>
</insert>
<update id="updateTestCaseStep" parameterType="TestCaseStep">
@@ -175,7 +204,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteTestCaseStepById" parameterType="Long">
delete from test_case_step where id = #{id}
delete
from test_case_step
where id = #{id}
</delete>
<delete id="deleteTestCaseStepByIds" parameterType="String">

View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.test.test.mapper.TestDatasourceMapper">
<resultMap type="TestDatasource" id="TestDatasourceResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="type" column="type" />
<result property="host" column="host" />
<result property="port" column="port" />
<result property="username" column="username" />
<result property="password" column="password" />
<result property="dbName" column="db_name" />
<result property="authDb" column="auth_db" />
<result property="cluster" column="cluster" />
<result property="masterName" column="master_name" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTestDatasourceVo">
select id, name, type, host, port, username, password, db_name, auth_db, cluster, master_name, del_flag, create_by, create_time, update_by, update_time from test_datasource
</sql>
<select id="selectTestDatasourceList" resultMap="TestDatasourceResult">
<include refid="selectTestDatasourceVo"/>
</select>
<select id="selectTestDatasourceById" parameterType="Long" resultMap="TestDatasourceResult">
<include refid="selectTestDatasourceVo"/>
where id = #{id}
</select>
<insert id="insertTestDatasource" parameterType="TestDatasource" useGeneratedKeys="true" keyProperty="id">
insert into test_datasource
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="type != null">type,</if>
<if test="host != null">host,</if>
<if test="port != null">port,</if>
<if test="username != null">username,</if>
<if test="password != null">password,</if>
<if test="dbName != null">db_name,</if>
<if test="authDb != null">auth_db,</if>
<if test="cluster != null">cluster,</if>
<if test="masterName != null">master_name,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="type != null">#{type},</if>
<if test="host != null">#{host},</if>
<if test="port != null">#{port},</if>
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="dbName != null">#{dbName},</if>
<if test="authDb != null">#{authDb},</if>
<if test="cluster != null">#{cluster},</if>
<if test="masterName != null">#{masterName},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTestDatasource" parameterType="TestDatasource">
update test_datasource
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="type != null">type = #{type},</if>
<if test="host != null">host = #{host},</if>
<if test="port != null">port = #{port},</if>
<if test="username != null">username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="dbName != null">db_name = #{dbName},</if>
<if test="authDb != null">auth_db = #{authDb},</if>
<if test="cluster != null">cluster = #{cluster},</if>
<if test="masterName != null">master_name = #{masterName},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTestDatasourceById" parameterType="Long">
delete from test_datasource where id = #{id}
</delete>
<delete id="deleteTestDatasourceByIds" parameterType="String">
delete from test_datasource where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -5,19 +5,28 @@
<mapper namespace="com.test.test.mapper.TestGroupMapper">
<resultMap type="TestGroup" id="TestGroupResult">
<result property="id" column="id" />
<result property="parentId" column="parent_id" />
<result property="type" column="type" />
<result property="name" column="name" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="id" column="id"/>
<result property="parentId" column="parent_id"/>
<result property="type" column="type"/>
<result property="name" column="name"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectTestGroupVo">
select id, parent_id, type, name, del_flag, create_by, create_time, update_by, update_time from test_group
select id,
parent_id,
type,
name,
del_flag,
create_by,
create_time,
update_by,
update_time
from test_group
</sql>
<select id="selectTestGroupList" parameterType="String" resultMap="TestGroupResult">
@@ -37,6 +46,13 @@
</where>
</select>
<select id="selectGroup" parameterType="String" resultMap="TestGroupResult">
<include refid="selectTestGroupVo"/>
<where>
name = #{name} and type = #{type} and parent_id = #{parentId}
</where>
</select>
<insert id="insertTestGroup" parameterType="TestGroup" useGeneratedKeys="true" keyProperty="id">
insert into test_group
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.test.test.mapper.TestHttpMapper">
<resultMap type="TestHttp" id="TestHttpResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="protocol" column="protocol"/>
<result property="host" column="host"/>
<result property="port" column="port"/>
<result property="basePath" column="basePath"/>
<result property="header" column="header"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectTestHttpVo">
select id,
name,
protocol,
host,
port,
basePath,
header,
del_flag,
create_by,
create_time,
update_by,
update_time
from test_http
</sql>
<select id="selectTestHttpList" resultMap="TestHttpResult">
<include refid="selectTestHttpVo"/>
</select>
<select id="selectTestHttpById" parameterType="Long" resultMap="TestHttpResult">
<include refid="selectTestHttpVo"/>
where id = #{id}
</select>
<insert id="insertTestHttp" parameterType="TestHttp" useGeneratedKeys="true" keyProperty="id">
insert into test_http
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="protocol != null">protocol,</if>
<if test="host != null">host,</if>
<if test="port != null">port,</if>
<if test="basePath != null">basePath,</if>
<if test="header != null">header,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="protocol != null">#{protocol},</if>
<if test="host != null">#{host},</if>
<if test="port != null">#{port},</if>
<if test="basePath != null">#{basePath},</if>
<if test="header != null">#{header},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTestHttp" parameterType="TestHttp">
update test_http
<trim prefix="SET" suffixOverrides=",">
<if test="name != null">name = #{name},</if>
<if test="protocol != null">protocol = #{protocol},</if>
<if test="host != null">host = #{host},</if>
<if test="port != null">port = #{port},</if>
<if test="basePath != null">basePath = #{basePath},</if>
<if test="header != null">header = #{header},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTestHttpById" parameterType="Long">
delete
from test_http
where id = #{id}
</delete>
<delete id="deleteTestHttpByIds" parameterType="String">
delete from test_http where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>