http server资源增删改查
This commit is contained in:
@@ -11,8 +11,6 @@ import jakarta.annotation.Resource;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/test/group")
|
@RequestMapping("/test/group")
|
||||||
public class TestGroupController extends BaseController {
|
public class TestGroupController extends BaseController {
|
||||||
@@ -24,8 +22,7 @@ public class TestGroupController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(String type) {
|
public AjaxResult list(String type) {
|
||||||
List<TestGroup> list = testGroupService.selectTestGroupList(type);
|
return success(testGroupService.selectTestGroupList(type));
|
||||||
return success(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
58
test-test/src/main/java/com/test/test/domain/TestHttp.java
Normal file
58
test-test/src/main/java/com/test/test/domain/TestHttp.java
Normal 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;
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectTestCaseLogVo">
|
<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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTestCaseLogList" parameterType="TestCaseLog" resultMap="TestCaseLogResult">
|
<select id="selectTestCaseLogList" parameterType="TestCaseLog" resultMap="TestCaseLogResult">
|
||||||
@@ -64,7 +65,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteTestCaseLogById" parameterType="Long">
|
<delete id="deleteTestCaseLogById" parameterType="Long">
|
||||||
delete from test_case_log where id = #{id}
|
delete
|
||||||
|
from test_case_log
|
||||||
|
where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteTestCaseLogByIds" parameterType="String">
|
<delete id="deleteTestCaseLogByIds" parameterType="String">
|
||||||
|
|||||||
@@ -19,7 +19,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectTestCaseVo">
|
<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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTestCaseList" parameterType="TestCase" resultMap="TestCaseResult">
|
<select id="selectTestCaseList" parameterType="TestCase" resultMap="TestCaseResult">
|
||||||
@@ -84,7 +95,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteTestCaseById" parameterType="Long">
|
<delete id="deleteTestCaseById" parameterType="Long">
|
||||||
delete from test_case where id = #{id}
|
delete
|
||||||
|
from test_case
|
||||||
|
where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteTestCaseByIds" parameterType="String">
|
<delete id="deleteTestCaseByIds" parameterType="String">
|
||||||
|
|||||||
@@ -37,7 +37,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectTestCaseStepVo">
|
<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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTestCaseStepList" parameterType="TestCaseStep" resultMap="TestCaseStepResult">
|
<select id="selectTestCaseStepList" parameterType="TestCaseStep" resultMap="TestCaseStepResult">
|
||||||
@@ -174,7 +203,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteTestCaseStepById" parameterType="Long">
|
<delete id="deleteTestCaseStepById" parameterType="Long">
|
||||||
delete from test_case_step where id = #{id}
|
delete
|
||||||
|
from test_case_step
|
||||||
|
where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteTestCaseStepByIds" parameterType="String">
|
<delete id="deleteTestCaseStepByIds" parameterType="String">
|
||||||
|
|||||||
@@ -17,7 +17,16 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectTestGroupVo">
|
<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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTestGroupList" parameterType="String" resultMap="TestGroupResult">
|
<select id="selectTestGroupList" parameterType="String" resultMap="TestGroupResult">
|
||||||
|
|||||||
107
test-test/src/main/resources/mapper/test/TestHttpMapper.xml
Normal file
107
test-test/src/main/resources/mapper/test/TestHttpMapper.xml
Normal 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>
|
||||||
45
test-ui/src/api/test/http.js
Normal file
45
test-ui/src/api/test/http.js
Normal 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}
|
||||||
|
})
|
||||||
|
}
|
||||||
225
test-ui/src/views/test/resource/http.vue
Normal file
225
test-ui/src/views/test/resource/http.vue
Normal 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>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-tabs tab-position="left" style="height: 200px;">
|
<el-tabs>
|
||||||
<el-tab-pane label="http 服务器">
|
<el-tab-pane label="http 服务器">
|
||||||
123
|
<http/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="数据库数据源">
|
<el-tab-pane label="数据库数据源">
|
||||||
<database/>
|
<database/>
|
||||||
@@ -14,10 +14,11 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
import Database from "@/views/test/resource/database.vue";
|
import Database from "@/views/test/resource/database.vue";
|
||||||
|
import Http from "@/views/test/resource/http.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Resource",
|
name: "Resource",
|
||||||
components: {Database},
|
components: {Http, Database},
|
||||||
methods: {}
|
methods: {}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user