http server资源增删改查

This commit is contained in:
2025-02-20 09:04:06 +08:00
parent b800bd7f1d
commit 611648240e
15 changed files with 828 additions and 118 deletions

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 {
@@ -24,8 +22,7 @@ public class TestGroupController extends BaseController {
*/
@GetMapping("/list")
public AjaxResult list(String type) {
List<TestGroup> list = testGroupService.selectTestGroupList(type);
return success(list);
return success(testGroupService.selectTestGroupList(type));
}
/**

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.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()));
}
}

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

@@ -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

@@ -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

@@ -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,10 +28,10 @@
<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>

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>
@@ -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,35 +1,46 @@
<?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">
<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>
<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>
</where>
</select>
@@ -84,7 +95,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>
</select>
@@ -174,7 +203,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

@@ -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">

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>

View File

@@ -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}
})
}

View File

@@ -0,0 +1,225 @@
<template>
<el-container>
<el-aside style="width: 180px; padding: 0">
<div class="header">
<div>HTTP Server</div>
<div>
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd" circle/>
</div>
</div>
<div class="list" v-if="list && list.length > 0">
<div v-for="item in list" :key="item.id" :class="'item'+(selectedKey === item.id ? ' is-active' : '')" @click="handleListClick(item)">{{ item.name }}</div>
</div>
<el-empty v-else description="暂无数据" :image-size="100"/>
</el-aside>
<el-main>
<div v-if="selectedKey">
<el-form :model="form" ref="form">
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="HTTP Server名称" prop="name">
<el-input v-model="form.name" placeholder="请输入HTTP Server名称"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="协议" prop="protocol">
<el-select v-model="form.protocol">
<el-option v-for="dict in dict.type.http_protocol" :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="主机" prop="host">
<el-input v-model="form.host" placeholder="请输入主机地址"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="端口" prop="port">
<el-input v-model="form.port" placeholder="请输入端口号"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="前置路径" prop="basePath">
<el-input v-model="form.basePath" placeholder="请输入前置路径,格式为/**"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-table :data="form.header">
<el-table-column label="参数名">
<template slot-scope="scope">
<el-input placeholder="请输入参数名" v-model="form.header[scope.$index].key" @input="e => handleTableEdit(e, scope)" clearable/>
</template>
</el-table-column>
<el-table-column label="示例值">
<template slot-scope="scope">
<el-input placeholder="请输入参数名" v-model="form.header[scope.$index].value" @input="e => handleTableEdit(e, scope)" clearable/>
</template>
</el-table-column>
<el-table-column label="操作" width="60">
<template slot-scope="scope">
<el-button v-if="form.header.length > scope.$index+1" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-row>
</el-form>
<div class="footer">
<el-button type="primary" @click="save"> </el-button>
<el-button type="danger" @click="del">删除</el-button>
</div>
</div>
<el-empty v-else description="暂无数据" />
</el-main>
</el-container>
</template>
<script>
import {addHttp, delHttp, getHttp, listHttp, updateHttp} from "@/api/test/http";
export default {
name: 'Http',
dicts: ["http_protocol"],
data() {
return {
list: [],
selectedKey: "",
form: {
name: "",
protocol: "",
host: "",
port: "",
basePath: "",
header: [{
key: "",
value: "",
}],
},
}
},
created() {
this.getData();
this.$nextTick(() => {
})
},
methods: {
getData(selectedKey) {
const loading = this.setLoading();
listHttp().then(res => {
this.list = res.data;
if (selectedKey) {
this.handleListClick({id: selectedKey})
} else if (this.list && this.list.length > 0) {
this.handleListClick({id: this.list[0].id})
}
loading.close();
})
},
handleTableEdit(e, scope) {
if (e && this.form.header.length === scope.$index + 1) {
this.form.header.push({
key: "",
value: ""
})
}
},
handleDelete(scope) {
this.form.header.splice(scope.$index, 1)
},
handleListClick(item) {
const loading = this.setLoading();
this.selectedKey = item.id;
getHttp(item.id).then(res => {
this.form = res.data;
if (!this.form.header) {
this.form.header = []
} else {
this.form.header = JSON.parse(this.form.header);
}
this.form.header.push({
key: "",
value: ""
})
})
loading.close();
},
handleAdd() {
this.$prompt('请输入名称', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /^(?!\s*$).+/,
inputErrorMessage: '名称不能为空'
}).then(({ value }) => {
if (value) {
const loading = this.setLoading();
addHttp({name: value}).then(res => {
this.$message.success("添加成功")
this.getData(res.data.id);
loading.close();
})
}
});
},
save() {
this.form.header.pop();
updateHttp({
...this.form,
header: JSON.stringify(this.form.header)
}).then(res => {
this.$modal.msgSuccess("修改成功");
this.getData();
})
},
del() {
this.$modal.confirm('是否确认删除?').then(() => {
return delHttp(this.selectedKey);
}).then(() => {
this.$modal.msgSuccess("删除成功");
this.selectedKey = "";
this.getData();
})
},
setLoading() {
return this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
}
}
}
</script>
<style scoped lang="scss">
.footer {
text-align: right;
margin-top: 20px;
}
.header {
font-weight: bold;
line-height: 45px;
border-bottom: 1px solid #eee;
margin-bottom: 5px;
display: flex;
justify-content: space-between;
padding-left: 10px;
}
.list {
.item {
padding: 0 20px;
cursor: pointer;
height: 40px;
line-height: 40px;
border-right: 2px solid #eee;
}
.item.is-active {
color: var(--current-color);
border-right: 2px solid var(--current-color);
}
}
</style>

View File

@@ -1,8 +1,8 @@
<template>
<div class="app-container">
<el-tabs tab-position="left" style="height: 200px;">
<el-tabs>
<el-tab-pane label="http 服务器">
123
<http/>
</el-tab-pane>
<el-tab-pane label="数据库数据源">
<database/>
@@ -14,10 +14,11 @@
<script>
import Database from "@/views/test/resource/database.vue";
import Http from "@/views/test/resource/http.vue";
export default {
name: "Resource",
components: {Database},
components: {Http, Database},
methods: {}
}
</script>