文件夹管理重构
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
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.TestApiGroup;
|
||||
import com.test.test.service.ITestApiGroupService;
|
||||
|
||||
/**
|
||||
* 接口节点Controller
|
||||
*
|
||||
* @author xiaoe
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test/group")
|
||||
public class TestApiGroupController extends BaseController {
|
||||
@Resource
|
||||
private ITestApiGroupService testApiGroupService;
|
||||
|
||||
/**
|
||||
* 查询接口节点列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list() {
|
||||
List<TestApiGroup> list = testApiGroupService.selectTestApiGroupList();
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增接口节点
|
||||
*/
|
||||
@Log(title = "接口节点", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody TestApiGroup testApiGroup) {
|
||||
return success(testApiGroupService.insertTestApiGroup(testApiGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改接口节点
|
||||
*/
|
||||
@Log(title = "接口节点", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody TestApiGroup testApiGroup) {
|
||||
return toAjax(testApiGroupService.updateTestApiGroup(testApiGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口节点
|
||||
*/
|
||||
@Log(title = "接口节点", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/del")
|
||||
public AjaxResult remove(@RequestBody IDQO qo) {
|
||||
return toAjax(testApiGroupService.deleteTestApiGroupById(qo.getId()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.test.test.controller;
|
||||
|
||||
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.TestGroup;
|
||||
import com.test.test.domain.qo.IDQO;
|
||||
import com.test.test.service.ITestGroupService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/test/group")
|
||||
public class TestGroupController extends BaseController {
|
||||
@Resource
|
||||
private ITestGroupService testGroupService;
|
||||
|
||||
/**
|
||||
* 查询接口节点列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(String type) {
|
||||
List<TestGroup> list = testGroupService.selectTestGroupList(type);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增接口节点
|
||||
*/
|
||||
@Log(title = "接口节点", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody TestGroup testGroup) {
|
||||
return success(testGroupService.insertTestGroup(testGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改接口节点
|
||||
*/
|
||||
@Log(title = "接口节点", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody TestGroup testGroup) {
|
||||
return toAjax(testGroupService.updateTestGroup(testGroup));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口节点
|
||||
*/
|
||||
@Log(title = "接口节点", businessType = BusinessType.DELETE)
|
||||
@PostMapping("/del")
|
||||
public AjaxResult remove(@RequestBody IDQO qo) {
|
||||
return toAjax(testGroupService.deleteTestGroupById(qo.getId()));
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,14 @@ import lombok.ToString;
|
||||
import com.test.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 接口节点对象 test_api_group
|
||||
*
|
||||
* 节点(文件夹)对象 test_group
|
||||
*
|
||||
* @author xiaoe
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
@ToString
|
||||
public class TestApiGroup extends BaseEntity
|
||||
public class TestGroup extends BaseEntity
|
||||
{
|
||||
/** 节点id */
|
||||
private Long id;
|
||||
@@ -23,10 +23,15 @@ public class TestApiGroup extends BaseEntity
|
||||
@Excel(name = "父节点id")
|
||||
private Long parentId;
|
||||
|
||||
/** 节点类型 */
|
||||
@Excel(name = "节点类型")
|
||||
private String type;
|
||||
|
||||
/** 节点名称 */
|
||||
@Excel(name = "节点名称")
|
||||
private String name;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.test.test.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.test.test.domain.TestApiGroup;
|
||||
|
||||
/**
|
||||
* 接口节点Mapper接口
|
||||
*
|
||||
* @author xiaoe
|
||||
*/
|
||||
public interface TestApiGroupMapper
|
||||
{
|
||||
/**
|
||||
* 查询接口节点列表
|
||||
*
|
||||
* @return 接口节点集合
|
||||
*/
|
||||
public List<TestApiGroup> selectTestApiGroupList();
|
||||
|
||||
/**
|
||||
* 新增接口节点
|
||||
*
|
||||
* @param testApiGroup 接口节点
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTestApiGroup(TestApiGroup testApiGroup);
|
||||
|
||||
/**
|
||||
* 修改接口节点
|
||||
*
|
||||
* @param testApiGroup 接口节点
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTestApiGroup(TestApiGroup testApiGroup);
|
||||
|
||||
/**
|
||||
* 删除接口节点
|
||||
*
|
||||
* @param id 接口节点主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestApiGroupById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.test.test.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.test.test.domain.TestGroup;
|
||||
|
||||
/**
|
||||
* 节点(文件夹)Mapper接口
|
||||
*
|
||||
* @author xiaoe
|
||||
* @date 2025-02-12
|
||||
*/
|
||||
public interface TestGroupMapper
|
||||
{
|
||||
/**
|
||||
* 查询节点(文件夹)
|
||||
*
|
||||
* @param id 节点(文件夹)主键
|
||||
* @return 节点(文件夹)
|
||||
*/
|
||||
public TestGroup selectTestGroupById(Long id);
|
||||
|
||||
/**
|
||||
* 查询节点(文件夹)列表
|
||||
*
|
||||
* @param type 节点类型
|
||||
* @return 节点(文件夹)集合
|
||||
*/
|
||||
public List<TestGroup> selectTestGroupList(String type);
|
||||
|
||||
/**
|
||||
* 新增节点(文件夹)
|
||||
*
|
||||
* @param testGroup 节点(文件夹)
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTestGroup(TestGroup testGroup);
|
||||
|
||||
/**
|
||||
* 修改节点(文件夹)
|
||||
*
|
||||
* @param testGroup 节点(文件夹)
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTestGroup(TestGroup testGroup);
|
||||
|
||||
/**
|
||||
* 删除节点(文件夹)
|
||||
*
|
||||
* @param id 节点(文件夹)主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestGroupById(Long id);
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.test.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.test.test.domain.TestApiGroup;
|
||||
|
||||
/**
|
||||
* 接口节点Service接口
|
||||
*
|
||||
* @author xiaoe
|
||||
*/
|
||||
public interface ITestApiGroupService {
|
||||
|
||||
/**
|
||||
* 查询接口节点列表
|
||||
*
|
||||
* @return 接口节点集合
|
||||
*/
|
||||
public List<TestApiGroup> selectTestApiGroupList();
|
||||
|
||||
/**
|
||||
* 新增接口节点
|
||||
*
|
||||
* @param testApiGroup 接口节点
|
||||
* @return 结果
|
||||
*/
|
||||
public TestApiGroup insertTestApiGroup(TestApiGroup testApiGroup);
|
||||
|
||||
/**
|
||||
* 修改接口节点
|
||||
*
|
||||
* @param testApiGroup 接口节点
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTestApiGroup(TestApiGroup testApiGroup);
|
||||
|
||||
/**
|
||||
* 删除接口节点信息
|
||||
*
|
||||
* @param id 接口节点主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestApiGroupById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.test.test.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.test.test.domain.TestGroup;
|
||||
|
||||
/**
|
||||
* 节点(文件夹)Service接口
|
||||
*
|
||||
* @author xiaoe
|
||||
*/
|
||||
public interface ITestGroupService
|
||||
{
|
||||
/**
|
||||
* 查询节点(文件夹)列表
|
||||
*
|
||||
* @param type 节点类型
|
||||
* @return 节点(文件夹)集合
|
||||
*/
|
||||
public List<TestGroup> selectTestGroupList(String type);
|
||||
|
||||
/**
|
||||
* 新增节点(文件夹)
|
||||
*
|
||||
* @param testGroup 节点(文件夹)
|
||||
* @return 结果
|
||||
*/
|
||||
public TestGroup insertTestGroup(TestGroup testGroup);
|
||||
|
||||
/**
|
||||
* 修改节点(文件夹)
|
||||
*
|
||||
* @param testGroup 节点(文件夹)
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTestGroup(TestGroup testGroup);
|
||||
|
||||
/**
|
||||
* 删除节点(文件夹)信息
|
||||
*
|
||||
* @param id 节点(文件夹)主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTestGroupById(Long id);
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.test.test.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.test.common.utils.DateUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.test.test.mapper.TestApiGroupMapper;
|
||||
import com.test.test.domain.TestApiGroup;
|
||||
import com.test.test.service.ITestApiGroupService;
|
||||
|
||||
/**
|
||||
* 接口节点Service业务层处理
|
||||
*
|
||||
* @author xiaoe
|
||||
*/
|
||||
@Service
|
||||
public class TestApiGroupServiceImpl implements ITestApiGroupService
|
||||
{
|
||||
@Resource
|
||||
private TestApiGroupMapper testApiGroupMapper;
|
||||
|
||||
/**
|
||||
* 查询接口节点列表
|
||||
*
|
||||
* @return 接口节点
|
||||
*/
|
||||
@Override
|
||||
public List<TestApiGroup> selectTestApiGroupList()
|
||||
{
|
||||
return testApiGroupMapper.selectTestApiGroupList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增接口节点
|
||||
*
|
||||
* @param testApiGroup 接口节点
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public TestApiGroup insertTestApiGroup(TestApiGroup testApiGroup)
|
||||
{
|
||||
testApiGroup.setCreateTime(DateUtils.getNowDate());
|
||||
testApiGroupMapper.insertTestApiGroup(testApiGroup);
|
||||
return testApiGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改接口节点
|
||||
*
|
||||
* @param testApiGroup 接口节点
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTestApiGroup(TestApiGroup testApiGroup)
|
||||
{
|
||||
testApiGroup.setUpdateTime(DateUtils.getNowDate());
|
||||
return testApiGroupMapper.updateTestApiGroup(testApiGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口节点信息
|
||||
*
|
||||
* @param id 接口节点主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTestApiGroupById(Long id)
|
||||
{
|
||||
return testApiGroupMapper.deleteTestApiGroupById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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.TestGroupMapper;
|
||||
import com.test.test.domain.TestGroup;
|
||||
import com.test.test.service.ITestGroupService;
|
||||
|
||||
/**
|
||||
* 节点(文件夹)Service业务层处理
|
||||
*
|
||||
* @author xiaoe
|
||||
*/
|
||||
@Service
|
||||
public class TestGroupServiceImpl implements ITestGroupService {
|
||||
|
||||
@Resource
|
||||
private TestGroupMapper testGroupMapper;
|
||||
|
||||
/**
|
||||
* 查询节点(文件夹)列表
|
||||
*
|
||||
* @param type 节点类型
|
||||
* @return 节点(文件夹)
|
||||
*/
|
||||
@Override
|
||||
public List<TestGroup> selectTestGroupList(String type) {
|
||||
return testGroupMapper.selectTestGroupList(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增节点(文件夹)
|
||||
*
|
||||
* @param testGroup 节点(文件夹)
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public TestGroup insertTestGroup(TestGroup testGroup) {
|
||||
testGroup.setCreateTime(DateUtils.getNowDate());
|
||||
testGroupMapper.insertTestGroup(testGroup);
|
||||
return testGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改节点(文件夹)
|
||||
*
|
||||
* @param testGroup 节点(文件夹)
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTestGroup(TestGroup testGroup) {
|
||||
testGroup.setUpdateTime(DateUtils.getNowDate());
|
||||
return testGroupMapper.updateTestGroup(testGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除节点(文件夹)信息
|
||||
*
|
||||
* @param id 节点(文件夹)主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTestGroupById(Long id) {
|
||||
return testGroupMapper.deleteTestGroupById(id);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<?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.TestApiGroupMapper">
|
||||
|
||||
<resultMap type="TestApiGroup" id="TestApiGroupResult">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<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" />
|
||||
@@ -15,18 +16,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectTestApiGroupVo">
|
||||
select id, parent_id, name, del_flag, create_by, create_time, update_by, update_time from test_api_group
|
||||
<sql id="selectTestGroupVo">
|
||||
select id, parent_id, type, name, del_flag, create_by, create_time, update_by, update_time from test_group
|
||||
</sql>
|
||||
|
||||
<select id="selectTestApiGroupList" resultMap="TestApiGroupResult">
|
||||
<include refid="selectTestApiGroupVo"/>
|
||||
<select id="selectTestGroupList" parameterType="String" resultMap="TestGroupResult">
|
||||
<include refid="selectTestGroupVo"/>
|
||||
<where>
|
||||
type = #{type}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertTestApiGroup" parameterType="TestApiGroup" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into test_api_group
|
||||
<select id="selectTestGroupById" parameterType="Long" resultMap="TestGroupResult">
|
||||
<include refid="selectTestGroupVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertTestGroup" parameterType="TestGroup" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into test_group
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
@@ -36,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
@@ -45,10 +56,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateTestApiGroup" parameterType="TestApiGroup">
|
||||
update test_api_group
|
||||
<update id="updateTestGroup" parameterType="TestGroup">
|
||||
update test_group
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
@@ -59,7 +71,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTestApiGroupById" parameterType="Long">
|
||||
delete from test_api_group where id = #{id}
|
||||
<delete id="deleteTestGroupById" parameterType="Long">
|
||||
delete from test_group where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTestGroupByIds" parameterType="String">
|
||||
delete from test_group where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user