完善配置中心接口
Some checks failed
CI Build and Test / build (push) Has been cancelled
Deploy to Server / build-and-deploy (push) Has been cancelled

This commit is contained in:
2025-10-21 14:44:02 +08:00
parent b81db11bfc
commit 4ebef69130
9 changed files with 264 additions and 2 deletions

View File

@@ -15,10 +15,12 @@ Authorization: your-token必填
```json
{
"paramName": "默认参数配置", // 参数名称(必填)
"deviceName": "我的无人机", // 设备名称(可选)
"description": "这是一个测试参数配置", // 描述(可选)
"fcModel": "Pixhawk 4", // 飞控型号(必填)
"fcType": "PX4", // 飞控类型(必填)
"paramVersion": "1.0.0", // 参数版本(必填)
"paramDetail": "参数详细配置内容..." // 参数详情(可选)
"paramDetail": "{\"key\":\"value\"}" // 参数详情(可选可以是JSON字符串
}
```
@@ -31,6 +33,10 @@ Authorization: your-token必填
}
```
**说明:**
- paramDetail 字段可以传入任意格式的参数配置内容
- 建议使用 JSON 字符串格式存储参数配置
---
### 2. 更新参数配置
@@ -47,6 +53,8 @@ Authorization: your-token必填
{
"id": 1, // 参数ID必填
"paramName": "更新后的参数配置", // 参数名称(必填)
"deviceName": "我的无人机", // 设备名称(可选)
"description": "更新后的描述信息", // 描述(可选)
"fcModel": "Pixhawk 6X", // 飞控型号(必填)
"fcType": "PX4", // 飞控类型(必填)
"paramVersion": "1.0.1", // 参数版本(必填)
@@ -109,6 +117,8 @@ Authorization: your-token必填
"id": 1,
"userId": 1,
"paramName": "默认参数配置",
"deviceName": "我的无人机",
"description": "这是一个测试参数配置",
"fcModel": "Pixhawk 4",
"fcType": "PX4",
"paramVersion": "1.0.0",
@@ -155,6 +165,8 @@ GET /params/all/list?fcModel=Pixhawk%204
"id": 1,
"userId": 1,
"paramName": "默认参数配置",
"deviceName": "我的无人机",
"description": "这是一个测试参数配置",
"fcModel": "Pixhawk 4",
"fcType": "PX4",
"paramVersion": "1.0.0",
@@ -208,6 +220,8 @@ GET /params/all/page?current=1&size=10&fcModel=Pixhawk%204
"id": 1,
"userId": 1,
"paramName": "默认参数配置",
"deviceName": "我的无人机",
"description": "这是一个测试参数配置",
"fcModel": "Pixhawk 4",
"fcType": "PX4",
"paramVersion": "1.0.0",
@@ -263,6 +277,8 @@ GET /params/my/list?fcModel=Pixhawk%204
"id": 1,
"userId": 1,
"paramName": "默认参数配置",
"deviceName": "我的无人机",
"description": "这是一个测试参数配置",
"fcModel": "Pixhawk 4",
"fcType": "PX4",
"paramVersion": "1.0.0",
@@ -315,6 +331,8 @@ GET /params/my/page?current=1&size=10&fcModel=Pixhawk%204
"id": 1,
"userId": 1,
"paramName": "默认参数配置",
"deviceName": "我的无人机",
"description": "这是一个测试参数配置",
"fcModel": "Pixhawk 4",
"fcType": "PX4",
"paramVersion": "1.0.0",
@@ -357,6 +375,8 @@ GET /params/my/page?current=1&size=10&fcModel=Pixhawk%204
}
```
**说明:**
- 每次调用会将指定参数的下载次数 +1
---

View File

@@ -38,6 +38,8 @@ public class AppParamsCenterController {
AppParamsCenter params = new AppParamsCenter();
params.setUserId(userId);
params.setParamName(request.getParamName());
params.setDeviceName(request.getDeviceName());
params.setDescription(request.getDescription());
params.setFcModel(request.getFcModel());
params.setFcType(request.getFcType());
params.setParamVersion(request.getParamVersion());
@@ -74,6 +76,8 @@ public class AppParamsCenterController {
AppParamsCenter params = new AppParamsCenter();
params.setId(request.getId());
params.setParamName(request.getParamName());
params.setDeviceName(request.getDeviceName());
params.setDescription(request.getDescription());
params.setFcModel(request.getFcModel());
params.setFcType(request.getFcType());
params.setParamVersion(request.getParamVersion());

View File

@@ -16,6 +16,16 @@ public class CreateParamRequest {
@NotBlank(message = "参数名称不能为空")
private String paramName;
/**
* 设备名称
*/
private String deviceName;
/**
* 描述
*/
private String description;
/**
* 飞控型号
*/

View File

@@ -23,6 +23,16 @@ public class UpdateParamRequest {
@NotBlank(message = "参数名称不能为空")
private String paramName;
/**
* 设备名称
*/
private String deviceName;
/**
* 描述
*/
private String description;
/**
* 飞控型号
*/

View File

@@ -35,6 +35,16 @@ public class AppParamsCenter implements Serializable {
*/
private String paramName;
/**
* 设备名称
*/
private String deviceName;
/**
* 描述
*/
private String description;
/**
* 飞控型号
*/

View File

@@ -1,8 +1,14 @@
package com.corewing.app.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.corewing.app.entity.AppParamsCenter;
import com.corewing.app.vo.AppParamsCenterVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 参数配置中心 Mapper 接口
@@ -10,4 +16,28 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AppParamsCenterMapper extends BaseMapper<AppParamsCenter> {
/**
* 根据ID查询带用户名的VO
*/
AppParamsCenterVO selectVOById(@Param("id") Long id);
/**
* 查询所有参数列表(带用户名)
*/
List<AppParamsCenterVO> selectAllVOList(@Param("fcModel") String fcModel);
/**
* 分页查询所有参数列表(带用户名)
*/
IPage<AppParamsCenterVO> selectAllVOPage(Page<AppParamsCenterVO> page, @Param("fcModel") String fcModel);
/**
* 查询当前用户的参数列表(带用户名)
*/
List<AppParamsCenterVO> selectVOListByUserId(@Param("userId") Long userId, @Param("fcModel") String fcModel);
/**
* 分页查询当前用户的参数列表(带用户名)
*/
IPage<AppParamsCenterVO> selectVOPageByUserId(Page<AppParamsCenterVO> page, @Param("userId") Long userId, @Param("fcModel") String fcModel);
}

View File

@@ -0,0 +1,77 @@
package com.corewing.app.vo;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 参数配置中心 VO用于返回给前端
*/
@Data
public class AppParamsCenterVO {
/**
* 主键ID
*/
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 用户名
*/
private String username;
/**
* 参数名称
*/
private String paramName;
/**
* 设备名称
*/
private String deviceName;
/**
* 描述
*/
private String description;
/**
* 飞控型号
*/
private String fcModel;
/**
* 飞控类型
*/
private String fcType;
/**
* 参数版本
*/
private String paramVersion;
/**
* 参数详情
*/
private String paramDetail;
/**
* 下载次数
*/
private Integer downloadCount;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
}

View File

@@ -2,13 +2,20 @@ CREATE TABLE `app_params_center` (
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_id` BIGINT NOT NULL COMMENT '用户ID',
`param_name` VARCHAR(100) NOT NULL COMMENT '参数名称',
`device_name` VARCHAR(100) COMMENT '设备名称',
`description` VARCHAR(500) COMMENT '描述',
`fc_model` VARCHAR(50) NOT NULL COMMENT '飞控型号',
`fc_type` VARCHAR(50) NOT NULL COMMENT '飞控类型',
`param_version` VARCHAR(20) NOT NULL COMMENT '参数版本',
`param_detail` TEXT COMMENT '参数详情',
`param_detail` MEDIUMTEXT COMMENT '参数详情',
`download_count` INT NOT NULL DEFAULT 0 COMMENT '下载次数',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
INDEX `idx_user_id` (`user_id`) COMMENT '用户ID索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='参数配置中心表';
-- 如果表已经存在,执行以下 SQL 修改字段
ALTER TABLE `app_params_center` MODIFY COLUMN `param_detail` MEDIUMTEXT COMMENT '参数详情';
ALTER TABLE `app_params_center` ADD COLUMN `device_name` VARCHAR(100) COMMENT '设备名称' AFTER `param_name`;
ALTER TABLE `app_params_center` ADD COLUMN `description` VARCHAR(500) COMMENT '描述' AFTER `device_name`;

View File

@@ -0,0 +1,94 @@
<?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.corewing.app.mapper.AppParamsCenterMapper">
<!-- 结果映射 -->
<resultMap id="VOResultMap" type="com.corewing.app.vo.AppParamsCenterVO">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="username" property="username"/>
<result column="param_name" property="paramName"/>
<result column="device_name" property="deviceName"/>
<result column="description" property="description"/>
<result column="fc_model" property="fcModel"/>
<result column="fc_type" property="fcType"/>
<result column="param_version" property="paramVersion"/>
<result column="param_detail" property="paramDetail"/>
<result column="download_count" property="downloadCount"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 基础查询SQL片段 -->
<sql id="selectVOSql">
SELECT
p.id,
p.user_id,
u.username,
p.param_name,
p.device_name,
p.description,
p.fc_model,
p.fc_type,
p.param_version,
p.param_detail,
p.download_count,
p.create_time,
p.update_time
FROM app_params_center p
LEFT JOIN app_user u ON p.user_id = u.id
</sql>
<!-- 根据ID查询带用户名的VO -->
<select id="selectVOById" resultMap="VOResultMap">
<include refid="selectVOSql"/>
WHERE p.id = #{id}
</select>
<!-- 查询所有参数列表(带用户名) -->
<select id="selectAllVOList" resultMap="VOResultMap">
<include refid="selectVOSql"/>
<where>
<if test="fcModel != null and fcModel != ''">
AND p.fc_model = #{fcModel}
</if>
</where>
ORDER BY p.update_time DESC
</select>
<!-- 分页查询所有参数列表(带用户名) -->
<select id="selectAllVOPage" resultMap="VOResultMap">
<include refid="selectVOSql"/>
<where>
<if test="fcModel != null and fcModel != ''">
AND p.fc_model = #{fcModel}
</if>
</where>
ORDER BY p.update_time DESC
</select>
<!-- 查询当前用户的参数列表(带用户名) -->
<select id="selectVOListByUserId" resultMap="VOResultMap">
<include refid="selectVOSql"/>
<where>
p.user_id = #{userId}
<if test="fcModel != null and fcModel != ''">
AND p.fc_model = #{fcModel}
</if>
</where>
ORDER BY p.update_time DESC
</select>
<!-- 分页查询当前用户的参数列表(带用户名) -->
<select id="selectVOPageByUserId" resultMap="VOResultMap">
<include refid="selectVOSql"/>
<where>
p.user_id = #{userId}
<if test="fcModel != null and fcModel != ''">
AND p.fc_model = #{fcModel}
</if>
</where>
ORDER BY p.update_time DESC
</select>
</mapper>