完善配置中心接口
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

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