From 611648240e3472b517d9ee6239cca077127aab84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=98=B1=E6=B6=B5?= Date: Thu, 20 Feb 2025 09:04:06 +0800 Subject: [PATCH] =?UTF-8?q?http=20server=E8=B5=84=E6=BA=90=E5=A2=9E?= =?UTF-8?q?=E5=88=A0=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/controller/TestGroupController.java | 5 +- .../test/controller/TestHttpController.java | 71 ++++++ .../java/com/test/test/domain/TestHttp.java | 58 +++++ .../com/test/test/mapper/TestHttpMapper.java | 40 ++++ .../test/test/service/ITestHttpService.java | 40 ++++ .../service/impl/TestHttpServiceImpl.java | 70 ++++++ .../resources/mapper/test/TestApiMapper.xml | 8 +- .../mapper/test/TestCaseLogMapper.xml | 37 +-- .../resources/mapper/test/TestCaseMapper.xml | 57 +++-- .../mapper/test/TestCaseStepMapper.xml | 147 +++++++----- .../resources/mapper/test/TestGroupMapper.xml | 29 ++- .../resources/mapper/test/TestHttpMapper.xml | 107 +++++++++ test-ui/src/api/test/http.js | 45 ++++ test-ui/src/views/test/resource/http.vue | 225 ++++++++++++++++++ test-ui/src/views/test/resource/index.vue | 7 +- 15 files changed, 828 insertions(+), 118 deletions(-) create mode 100644 test-test/src/main/java/com/test/test/controller/TestHttpController.java create mode 100644 test-test/src/main/java/com/test/test/domain/TestHttp.java create mode 100644 test-test/src/main/java/com/test/test/mapper/TestHttpMapper.java create mode 100644 test-test/src/main/java/com/test/test/service/ITestHttpService.java create mode 100644 test-test/src/main/java/com/test/test/service/impl/TestHttpServiceImpl.java create mode 100644 test-test/src/main/resources/mapper/test/TestHttpMapper.xml create mode 100644 test-ui/src/api/test/http.js create mode 100644 test-ui/src/views/test/resource/http.vue diff --git a/test-test/src/main/java/com/test/test/controller/TestGroupController.java b/test-test/src/main/java/com/test/test/controller/TestGroupController.java index 2aa5d8d..f2f7a74 100644 --- a/test-test/src/main/java/com/test/test/controller/TestGroupController.java +++ b/test-test/src/main/java/com/test/test/controller/TestGroupController.java @@ -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 { @@ -24,8 +22,7 @@ public class TestGroupController extends BaseController { */ @GetMapping("/list") public AjaxResult list(String type) { - List list = testGroupService.selectTestGroupList(type); - return success(list); + return success(testGroupService.selectTestGroupList(type)); } /** diff --git a/test-test/src/main/java/com/test/test/controller/TestHttpController.java b/test-test/src/main/java/com/test/test/controller/TestHttpController.java new file mode 100644 index 0000000..a9eade4 --- /dev/null +++ b/test-test/src/main/java/com/test/test/controller/TestHttpController.java @@ -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.TestHttp; +import com.test.test.service.ITestHttpService; +import com.test.common.core.page.TableDataInfo; + +/** + * 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())); + } +} diff --git a/test-test/src/main/java/com/test/test/domain/TestHttp.java b/test-test/src/main/java/com/test/test/domain/TestHttp.java new file mode 100644 index 0000000..5c94026 --- /dev/null +++ b/test-test/src/main/java/com/test/test/domain/TestHttp.java @@ -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; +} diff --git a/test-test/src/main/java/com/test/test/mapper/TestHttpMapper.java b/test-test/src/main/java/com/test/test/mapper/TestHttpMapper.java new file mode 100644 index 0000000..61948ea --- /dev/null +++ b/test-test/src/main/java/com/test/test/mapper/TestHttpMapper.java @@ -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 selectTestHttpList(); + + /** + * 新增http服务 + */ + int insertTestHttp(TestHttp testHttp); + + /** + * 修改http服务 + */ + int updateTestHttp(TestHttp testHttp); + + /** + * 删除http服务 + */ + int deleteTestHttpById(Long id); + + /** + * 批量删除http服务 + */ + int deleteTestHttpByIds(Long[] ids); +} diff --git a/test-test/src/main/java/com/test/test/service/ITestHttpService.java b/test-test/src/main/java/com/test/test/service/ITestHttpService.java new file mode 100644 index 0000000..7ec24ec --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/ITestHttpService.java @@ -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 selectTestHttpList(); + + /** + * 新增http服务 + */ + TestHttp insertTestHttp(TestHttp testHttp); + + /** + * 修改http服务 + */ + int updateTestHttp(TestHttp testHttp); + + /** + * 批量删除http服务 + */ + int deleteTestHttpByIds(Long[] ids); + + /** + * 删除http服务信息 + */ + int deleteTestHttpById(Long id); +} diff --git a/test-test/src/main/java/com/test/test/service/impl/TestHttpServiceImpl.java b/test-test/src/main/java/com/test/test/service/impl/TestHttpServiceImpl.java new file mode 100644 index 0000000..c78e6d8 --- /dev/null +++ b/test-test/src/main/java/com/test/test/service/impl/TestHttpServiceImpl.java @@ -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 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); + } +} diff --git a/test-test/src/main/resources/mapper/test/TestApiMapper.xml b/test-test/src/main/resources/mapper/test/TestApiMapper.xml index 57ead91..5188abc 100644 --- a/test-test/src/main/resources/mapper/test/TestApiMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestApiMapper.xml @@ -28,10 +28,10 @@ diff --git a/test-test/src/main/resources/mapper/test/TestCaseLogMapper.xml b/test-test/src/main/resources/mapper/test/TestCaseLogMapper.xml index 2b4732f..8e39550 100644 --- a/test-test/src/main/resources/mapper/test/TestCaseLogMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestCaseLogMapper.xml @@ -1,30 +1,31 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - + + + + + + - 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 @@ -41,14 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" oper_detail, oper_user, oper_time, - + #{caseId}, #{operType}, #{operDetail}, #{operUser}, #{operTime}, - + @@ -64,7 +65,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from test_case_log where id = #{id} + delete + from test_case_log + where id = #{id} diff --git a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml index f926e89..410e0cd 100644 --- a/test-test/src/main/resources/mapper/test/TestCaseMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestCaseMapper.xml @@ -1,35 +1,46 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - + + + + + + + + + + + - 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 @@ -51,7 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time, update_by, update_time, - + #{groupId}, #{projectId}, @@ -63,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createTime}, #{updateBy}, #{updateTime}, - + @@ -84,7 +95,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from test_case where id = #{id} + delete + from test_case + where id = #{id} diff --git a/test-test/src/main/resources/mapper/test/TestCaseStepMapper.xml b/test-test/src/main/resources/mapper/test/TestCaseStepMapper.xml index 5c349b3..a5eb819 100644 --- a/test-test/src/main/resources/mapper/test/TestCaseStepMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestCaseStepMapper.xml @@ -1,71 +1,100 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - 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 @@ -105,7 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" create_time, update_by, update_time, - + #{parentId}, #{caseId}, @@ -135,7 +164,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createTime}, #{updateBy}, #{updateTime}, - + @@ -174,7 +203,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from test_case_step where id = #{id} + delete + from test_case_step + where id = #{id} diff --git a/test-test/src/main/resources/mapper/test/TestGroupMapper.xml b/test-test/src/main/resources/mapper/test/TestGroupMapper.xml index 7d684f1..f8c562c 100644 --- a/test-test/src/main/resources/mapper/test/TestGroupMapper.xml +++ b/test-test/src/main/resources/mapper/test/TestGroupMapper.xml @@ -5,19 +5,28 @@ - - - - - - - - - + + + + + + + + + - 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 + + + + + + + insert into test_http + + name, + protocol, + host, + port, + basePath, + header, + del_flag, + create_by, + create_time, + update_by, + update_time, + + + #{name}, + #{protocol}, + #{host}, + #{port}, + #{basePath}, + #{header}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update test_http + + name = #{name}, + protocol = #{protocol}, + host = #{host}, + port = #{port}, + basePath = #{basePath}, + header = #{header}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete + from test_http + where id = #{id} + + + + delete from test_http where id in + + #{id} + + + \ No newline at end of file diff --git a/test-ui/src/api/test/http.js b/test-ui/src/api/test/http.js new file mode 100644 index 0000000..7ee5269 --- /dev/null +++ b/test-ui/src/api/test/http.js @@ -0,0 +1,45 @@ +import request from '@/utils/request' + +// 查询http服务列表 +export function listHttp() { + return request({ + url: '/test/http/list', + method: 'get' + }) +} + +// 查询http服务详细 +export function getHttp(id) { + return request({ + url: '/test/http/detail', + method: 'post', + data: {id} + }) +} + +// 新增http服务 +export function addHttp(data) { + return request({ + url: '/test/http/add', + method: 'post', + data: data + }) +} + +// 修改http服务 +export function updateHttp(data) { + return request({ + url: '/test/http/edit', + method: 'post', + data: data + }) +} + +// 删除http服务 +export function delHttp(id) { + return request({ + url: '/test/http/del', + method: 'post', + data: {id} + }) +} diff --git a/test-ui/src/views/test/resource/http.vue b/test-ui/src/views/test/resource/http.vue new file mode 100644 index 0000000..db0e195 --- /dev/null +++ b/test-ui/src/views/test/resource/http.vue @@ -0,0 +1,225 @@ + + + + + diff --git a/test-ui/src/views/test/resource/index.vue b/test-ui/src/views/test/resource/index.vue index 51a1520..5b80c99 100644 --- a/test-ui/src/views/test/resource/index.vue +++ b/test-ui/src/views/test/resource/index.vue @@ -1,8 +1,8 @@