完善配置中心接口
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -16,6 +16,16 @@ public class CreateParamRequest {
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
private String paramName;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 飞控型号
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,16 @@ public class UpdateParamRequest {
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
private String paramName;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 飞控型号
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,16 @@ public class AppParamsCenter implements Serializable {
|
||||
*/
|
||||
private String paramName;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 飞控型号
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
77
src/main/java/com/corewing/app/vo/AppParamsCenterVO.java
Normal file
77
src/main/java/com/corewing/app/vo/AppParamsCenterVO.java
Normal 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;
|
||||
}
|
||||
@@ -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`;
|
||||
|
||||
94
src/main/resources/mapper/AppParamsCenterMapper.xml
Normal file
94
src/main/resources/mapper/AppParamsCenterMapper.xml
Normal 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>
|
||||
Reference in New Issue
Block a user