整理代码

This commit is contained in:
2025-02-10 11:11:42 +08:00
parent 21efe997ef
commit 13872d9f29
16 changed files with 90 additions and 314 deletions

View File

@@ -17,13 +17,6 @@
<dependencies>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- spring-doc -->
<dependency>
<groupId>org.springdoc</groupId>

View File

@@ -22,6 +22,11 @@
<groupId>com.test</groupId>
<artifactId>test-common</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@@ -2,8 +2,10 @@ package com.test.test.controller;
import java.util.List;
import com.test.test.domain.qo.TestApiListQO;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
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.PathVariable;
@@ -23,7 +25,6 @@ import com.test.common.core.page.TableDataInfo;
* 接口Controller
*
* @author xiaoe
* @date 2025-02-08
*/
@RestController
@RequestMapping("/test/api")
@@ -35,7 +36,7 @@ public class TestApiController extends BaseController {
* 查询接口列表
*/
@GetMapping("/list")
public TableDataInfo list(TestApi testApi) {
public TableDataInfo list(@Validated TestApiListQO testApi) {
startPage();
List<TestApi> list = testApiService.selectTestApiList(testApi);
return getDataTable(list);
@@ -46,7 +47,7 @@ public class TestApiController extends BaseController {
*/
@Log(title = "接口", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TestApi testApi) {
public void export(HttpServletResponse response, TestApiListQO testApi) {
List<TestApi> list = testApiService.selectTestApiList(testApi);
ExcelUtil<TestApi> util = new ExcelUtil<TestApi>(TestApi.class);
util.exportExcel(response, list, "接口数据");

View File

@@ -3,13 +3,8 @@ package com.test.test.controller;
import java.util.List;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -20,14 +15,11 @@ import com.test.common.core.domain.AjaxResult;
import com.test.common.enums.BusinessType;
import com.test.test.domain.TestApiGroup;
import com.test.test.service.ITestApiGroupService;
import com.test.common.utils.poi.ExcelUtil;
import com.test.common.core.page.TableDataInfo;
/**
* 接口节点Controller
*
* @author xiaoe
* @date 2025-02-10
*/
@RestController
@RequestMapping("/test/group")
@@ -39,29 +31,9 @@ public class TestApiGroupController extends BaseController {
* 查询接口节点列表
*/
@GetMapping("/list")
public TableDataInfo list(TestApiGroup testApiGroup) {
startPage();
List<TestApiGroup> list = testApiGroupService.selectTestApiGroupList(testApiGroup);
return getDataTable(list);
}
/**
* 导出接口节点列表
*/
@Log(title = "接口节点", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TestApiGroup testApiGroup) {
List<TestApiGroup> list = testApiGroupService.selectTestApiGroupList(testApiGroup);
ExcelUtil<TestApiGroup> util = new ExcelUtil<TestApiGroup>(TestApiGroup.class);
util.exportExcel(response, list, "接口节点数据");
}
/**
* 获取接口节点详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(testApiGroupService.selectTestApiGroupById(id));
public AjaxResult list() {
List<TestApiGroup> list = testApiGroupService.selectTestApiGroupList();
return success(list);
}
/**
@@ -77,7 +49,7 @@ public class TestApiGroupController extends BaseController {
* 修改接口节点
*/
@Log(title = "接口节点", businessType = BusinessType.UPDATE)
@PutMapping("/edit")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody TestApiGroup testApiGroup) {
return toAjax(testApiGroupService.updateTestApiGroup(testApiGroup));
}
@@ -86,8 +58,8 @@ public class TestApiGroupController extends BaseController {
* 删除接口节点
*/
@Log(title = "接口节点", businessType = BusinessType.DELETE)
@DeleteMapping("/del/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(testApiGroupService.deleteTestApiGroupByIds(ids));
@PostMapping("/del/{id}")
public AjaxResult remove(@PathVariable Long id) {
return toAjax(testApiGroupService.deleteTestApiGroupById(id));
}
}

View File

@@ -1,24 +1,30 @@
package com.test.test.domain;
import com.test.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import com.test.common.annotation.Excel;
/**
* 接口对象 test_api
*
* @author xiaoe
* @date 2025-02-08
*/
@Setter
@Getter
@ToString
public class TestApi extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 接口id
*/
private Long id;
/** 节点id */
@Excel(name = "节点id")
private Long groupId;
/**
* 接口名称
*/
@@ -60,85 +66,4 @@ public class TestApi extends BaseEntity {
*/
private String delFlag;
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setMethod(String method) {
this.method = method;
}
public String getMethod() {
return method;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getUri() {
return uri;
}
public void setHeader(String header) {
this.header = header;
}
public String getHeader() {
return header;
}
public void setParam(String param) {
this.param = param;
}
public String getParam() {
return param;
}
public void setBody(String body) {
this.body = body;
}
public String getBody() {
return body;
}
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
public String getDelFlag() {
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("method", getMethod())
.append("uri", getUri())
.append("header", getHeader())
.append("param", getParam())
.append("body", getBody())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@@ -1,20 +1,21 @@
package com.test.test.domain;
import com.test.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import com.test.common.annotation.Excel;
/**
* 接口节点对象 test_api_group
*
* @author xiaoe
* @date 2025-02-10
*/
@Setter
@Getter
@ToString
public class TestApiGroup extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 节点id */
private Long id;
@@ -24,45 +25,4 @@ public class TestApiGroup extends BaseEntity
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

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

View File

@@ -7,25 +7,15 @@ import com.test.test.domain.TestApiGroup;
* 接口节点Mapper接口
*
* @author xiaoe
* @date 2025-02-10
*/
public interface TestApiGroupMapper
{
/**
* 查询接口节点
*
* @param id 接口节点主键
* @return 接口节点
*/
public TestApiGroup selectTestApiGroupById(Long id);
/**
* 查询接口节点列表
*
* @param testApiGroup 接口节点
* @return 接口节点集合
*/
public List<TestApiGroup> selectTestApiGroupList(TestApiGroup testApiGroup);
public List<TestApiGroup> selectTestApiGroupList();
/**
* 新增接口节点
@@ -50,12 +40,4 @@ public interface TestApiGroupMapper
* @return 结果
*/
public int deleteTestApiGroupById(Long id);
/**
* 批量删除接口节点
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteTestApiGroupByIds(Long[] ids);
}

View File

@@ -3,12 +3,12 @@ package com.test.test.mapper;
import java.util.List;
import com.test.test.domain.TestApi;
import com.test.test.domain.qo.TestApiListQO;
/**
* 接口Mapper接口
*
* @author xiaoe
* @date 2025-02-08
*/
public interface TestApiMapper {
/**
@@ -25,7 +25,7 @@ public interface TestApiMapper {
* @param testApi 接口
* @return 接口集合
*/
public List<TestApi> selectTestApiList(TestApi testApi);
public List<TestApi> selectTestApiList(TestApiListQO testApi);
/**
* 新增接口

View File

@@ -1,31 +1,22 @@
package com.test.test.service;
import java.util.List;
import com.test.test.domain.TestApiGroup;
/**
* 接口节点Service接口
*
* @author xiaoe
* @date 2025-02-10
*/
public interface ITestApiGroupService
{
/**
* 查询接口节点
*
* @param id 接口节点主键
* @return 接口节点
*/
public TestApiGroup selectTestApiGroupById(Long id);
public interface ITestApiGroupService {
/**
* 查询接口节点列表
*
* @param testApiGroup 接口节点
* @return 接口节点集合
*/
public List<TestApiGroup> selectTestApiGroupList(TestApiGroup testApiGroup);
public List<TestApiGroup> selectTestApiGroupList();
/**
* 新增接口节点
@@ -43,14 +34,6 @@ public interface ITestApiGroupService
*/
public int updateTestApiGroup(TestApiGroup testApiGroup);
/**
* 批量删除接口节点
*
* @param ids 需要删除的接口节点主键集合
* @return 结果
*/
public int deleteTestApiGroupByIds(Long[] ids);
/**
* 删除接口节点信息
*

View File

@@ -3,12 +3,12 @@ package com.test.test.service;
import java.util.List;
import com.test.test.domain.TestApi;
import com.test.test.domain.qo.TestApiListQO;
/**
* 接口Service接口
*
* @author xiaoe
* @date 2025-02-08
*/
public interface ITestApiService {
/**
@@ -25,7 +25,7 @@ public interface ITestApiService {
* @param testApi 接口
* @return 接口集合
*/
public List<TestApi> selectTestApiList(TestApi testApi);
public List<TestApi> selectTestApiList(TestApiListQO testApi);
/**
* 新增接口

View File

@@ -13,7 +13,6 @@ import com.test.test.service.ITestApiGroupService;
* 接口节点Service业务层处理
*
* @author xiaoe
* @date 2025-02-10
*/
@Service
public class TestApiGroupServiceImpl implements ITestApiGroupService
@@ -21,28 +20,15 @@ public class TestApiGroupServiceImpl implements ITestApiGroupService
@Resource
private TestApiGroupMapper testApiGroupMapper;
/**
* 查询接口节点
*
* @param id 接口节点主键
* @return 接口节点
*/
@Override
public TestApiGroup selectTestApiGroupById(Long id)
{
return testApiGroupMapper.selectTestApiGroupById(id);
}
/**
* 查询接口节点列表
*
* @param testApiGroup 接口节点
* @return 接口节点
*/
@Override
public List<TestApiGroup> selectTestApiGroupList(TestApiGroup testApiGroup)
public List<TestApiGroup> selectTestApiGroupList()
{
return testApiGroupMapper.selectTestApiGroupList(testApiGroup);
return testApiGroupMapper.selectTestApiGroupList();
}
/**
@@ -71,18 +57,6 @@ public class TestApiGroupServiceImpl implements ITestApiGroupService
return testApiGroupMapper.updateTestApiGroup(testApiGroup);
}
/**
* 批量删除接口节点
*
* @param ids 需要删除的接口节点主键
* @return 结果
*/
@Override
public int deleteTestApiGroupByIds(Long[] ids)
{
return testApiGroupMapper.deleteTestApiGroupByIds(ids);
}
/**
* 删除接口节点信息
*

View File

@@ -3,6 +3,7 @@ package com.test.test.service.impl;
import java.util.List;
import com.test.common.utils.DateUtils;
import com.test.test.domain.qo.TestApiListQO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.test.test.mapper.TestApiMapper;
@@ -13,7 +14,6 @@ import com.test.test.service.ITestApiService;
* 接口Service业务层处理
*
* @author xiaoe
* @date 2025-02-08
*/
@Service
public class TestApiServiceImpl implements ITestApiService {
@@ -38,7 +38,7 @@ public class TestApiServiceImpl implements ITestApiService {
* @return 接口
*/
@Override
public List<TestApi> selectTestApiList(TestApi testApi) {
public List<TestApi> selectTestApiList(TestApiListQO testApi) {
return testApiMapper.selectTestApiList(testApi);
}

View File

@@ -18,16 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, name, del_flag, create_by, create_time, update_by, update_time from test_api_group
</sql>
<select id="selectTestApiGroupList" parameterType="TestApiGroup" resultMap="TestApiGroupResult">
<select id="selectTestApiGroupList" resultMap="TestApiGroupResult">
<include refid="selectTestApiGroupVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
</where>
</select>
<select id="selectTestApiGroupById" parameterType="Long" resultMap="TestApiGroupResult">
<include refid="selectTestApiGroupVo"/>
where id = #{id}
</select>
<insert id="insertTestApiGroup" parameterType="TestApiGroup" useGeneratedKeys="true" keyProperty="id">
@@ -66,11 +58,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<delete id="deleteTestApiGroupById" parameterType="Long">
delete from test_api_group where id = #{id}
</delete>
<delete id="deleteTestApiGroupByIds" parameterType="String">
delete from test_api_group where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@@ -5,45 +5,35 @@
<mapper namespace="com.test.test.mapper.TestApiMapper">
<resultMap type="TestApi" id="TestApiResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="method" column="method"/>
<result property="uri" column="uri"/>
<result property="header" column="header"/>
<result property="param" column="param"/>
<result property="body" column="body"/>
<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="name" column="name" />
<result property="method" column="method" />
<result property="uri" column="uri" />
<result property="header" column="header" />
<result property="param" column="param" />
<result property="body" column="body" />
<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="selectTestApiVo">
select id,
name,
method,
uri,
header,
param,
body,
del_flag,
create_by,
create_time,
update_by,
update_time
from test_api
select id, group_id, name, method, uri, header, param, body, del_flag, create_by, create_time, update_by, update_time from test_api
</sql>
<select id="selectTestApiList" parameterType="TestApi" resultMap="TestApiResult">
<include refid="selectTestApiVo"/>
<where>
<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="header != null and header != ''">and header = #{header}</if>
<if test="param != null and param != ''">and param = #{param}</if>
<if test="body != null and body != ''">and body = #{body}</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>
<if test="header != null and header != ''"> and header = #{header}</if>
<if test="param != null and param != ''"> and param = #{param}</if>
<if test="body != null and body != ''"> and body = #{body}</if>
</where>
</select>
@@ -55,6 +45,7 @@
<insert id="insertTestApi" parameterType="TestApi" useGeneratedKeys="true" keyProperty="id">
insert into test_api
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="groupId != null">group_id,</if>
<if test="name != null">name,</if>
<if test="method != null">method,</if>
<if test="uri != null">uri,</if>
@@ -68,6 +59,7 @@
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="groupId != null">#{groupId},</if>
<if test="name != null">#{name},</if>
<if test="method != null">#{method},</if>
<if test="uri != null">#{uri},</if>
@@ -85,6 +77,7 @@
<update id="updateTestApi" parameterType="TestApi">
update test_api
<trim prefix="SET" suffixOverrides=",">
<if test="groupId != null">group_id = #{groupId},</if>
<if test="name != null">name = #{name},</if>
<if test="method != null">method = #{method},</if>
<if test="uri != null">uri = #{uri},</if>
@@ -101,9 +94,7 @@
</update>
<delete id="deleteTestApiById" parameterType="Long">
delete
from test_api
where id = #{id}
delete from test_api where id = #{id}
</delete>
<delete id="deleteTestApiByIds" parameterType="String">

View File

@@ -45,18 +45,9 @@ export function delApi(id) {
// 查询接口节点列表
export function listGroup(query) {
export function listGroup() {
return request({
url: '/test/group/list',
method: 'get',
params: query
})
}
// 查询接口节点详细
export function getGroup(id) {
return request({
url: '/test/group/' + id,
method: 'get'
})
}