Compare commits
8 Commits
306222c55e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a726b8b7d | ||
| 8f5f998c3a | |||
| 37182d7efb | |||
|
|
e472a3207f | ||
|
|
c0896c199d | ||
|
|
ccfac2a9eb | ||
|
|
84594dda48 | ||
|
|
da144b7c6a |
346
docs/API接口说明-Sirius固件版本管理.md
Normal file
346
docs/API接口说明-Sirius固件版本管理.md
Normal file
@@ -0,0 +1,346 @@
|
||||
# Sirius 固件 API 接口文档
|
||||
|
||||
## 基本信息
|
||||
|
||||
- **Base URL**: `https://api.corewing.com`
|
||||
- **接口前缀**: `/sirius_firmware`
|
||||
|
||||
## 统一响应格式
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "操作成功",
|
||||
"data": {},
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| code | Integer | 状态码(200 成功,500 失败) |
|
||||
| message | String | 提示消息 |
|
||||
| data | Object | 返回数据 |
|
||||
| success | Boolean | 是否成功 |
|
||||
|
||||
## 枚举说明
|
||||
|
||||
### 固件类型(firmwareType)
|
||||
|
||||
| 值 | 说明 |
|
||||
|----|------|
|
||||
| 1 | 高频头 |
|
||||
| 2 | 接收机 |
|
||||
| 3 | 背包 |
|
||||
|
||||
### 协议类型(protocolType)
|
||||
|
||||
| 值 | 说明 |
|
||||
|----|------|
|
||||
| 1 | ELRS |
|
||||
| 2 | CWLink |
|
||||
|
||||
## 固件对象字段说明
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
|------|------|------|
|
||||
| id | Integer | 主键ID |
|
||||
| firmwareType | Integer | 固件类型:1-高频头,2-接收机,3-背包 |
|
||||
| protocolType | Integer | 协议类型:1-ELRS,2-CWLink |
|
||||
| versionNumber | String | 版本号,如 v3.0.1 |
|
||||
| fileName | String | 文件名 |
|
||||
| filePath | String | 文件存储路径 |
|
||||
| fileSize | Long | 文件大小(字节) |
|
||||
| md5Hash | String | MD5 校验值 |
|
||||
| releaseNotes | String | 版本更新说明(可能为 null) |
|
||||
| createTime | String | 创建时间 |
|
||||
| updateTime | String | 更新时间 |
|
||||
|
||||
---
|
||||
|
||||
## 1. 查询最新固件版本
|
||||
|
||||
**接口描述:** 根据固件类型和协议类型查询最新版本,用于设备端检查更新。
|
||||
|
||||
**请求方式:** `GET`
|
||||
|
||||
**请求路径:** `/sirius_firmware/latest`
|
||||
|
||||
**请求参数:**
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| firmwareType | Integer | 是 | 固件类型:1-高频头,2-接收机,3-背包 |
|
||||
| protocolType | Integer | 是 | 协议类型:1-ELRS,2-CWLink |
|
||||
|
||||
**请求示例:**
|
||||
|
||||
```bash
|
||||
curl -X GET "http://your-server-host:8080/sirius_firmware/latest?firmwareType=1&protocolType=1"
|
||||
```
|
||||
|
||||
**成功响应示例:**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "操作成功",
|
||||
"data": {
|
||||
"id": 1,
|
||||
"firmwareType": 1,
|
||||
"protocolType": 1,
|
||||
"versionNumber": "v3.0.1",
|
||||
"fileName": "sirius_hf_elrs_v3.0.1.bin",
|
||||
"filePath": "https://oss.corewing.com/sirius_firmware/sirius_hf_elrs_v3.0.1.bin",
|
||||
"fileSize": 1048576,
|
||||
"md5Hash": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"releaseNotes": "优化信号连接稳定性",
|
||||
"createTime": "2026-03-10 10:30:00",
|
||||
"updateTime": "2026-03-10 10:30:00"
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
**失败响应示例:**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 500,
|
||||
"message": "固件不存在",
|
||||
"data": null,
|
||||
"success": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. 根据固件类型查询版本列表
|
||||
|
||||
**接口描述:** 查询指定固件类型下所有版本,按时间倒序排列。
|
||||
|
||||
**请求方式:** `GET`
|
||||
|
||||
**请求路径:** `/sirius_firmware/type/{firmwareType}`
|
||||
|
||||
**路径参数:**
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| firmwareType | Integer | 是 | 固件类型:1-高频头,2-接收机,3-背包 |
|
||||
|
||||
**请求示例:**
|
||||
|
||||
```bash
|
||||
curl -X GET "http://your-server-host:8080/sirius_firmware/type/1"
|
||||
```
|
||||
|
||||
**成功响应示例:**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "操作成功",
|
||||
"data": [
|
||||
{
|
||||
"id": 3,
|
||||
"firmwareType": 1,
|
||||
"protocolType": 2,
|
||||
"versionNumber": "v2.1.0",
|
||||
"fileName": "sirius_hf_cwlink_v2.1.0.bin",
|
||||
"filePath": "https://oss.corewing.com/sirius_firmware/sirius_hf_cwlink_v2.1.0.bin",
|
||||
"fileSize": 2097152,
|
||||
"md5Hash": "098f6bcd4621d373cade4e832627b4f6",
|
||||
"releaseNotes": "新增CWLink协议支持",
|
||||
"createTime": "2026-03-12 14:00:00",
|
||||
"updateTime": "2026-03-12 14:00:00"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"firmwareType": 1,
|
||||
"protocolType": 1,
|
||||
"versionNumber": "v3.0.1",
|
||||
"fileName": "sirius_hf_elrs_v3.0.1.bin",
|
||||
"filePath": "https://oss.corewing.com/sirius_firmware/sirius_hf_elrs_v3.0.1.bin",
|
||||
"fileSize": 1048576,
|
||||
"md5Hash": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"releaseNotes": "优化信号连接稳定性",
|
||||
"createTime": "2026-03-10 10:30:00",
|
||||
"updateTime": "2026-03-10 10:30:00"
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. 根据固件类型和协议类型查询版本列表
|
||||
|
||||
**接口描述:** 查询指定固件类型和协议类型下所有版本,按时间倒序排列。
|
||||
|
||||
**请求方式:** `GET`
|
||||
|
||||
**请求路径:** `/sirius_firmware/type/{firmwareType}/protocol/{protocolType}`
|
||||
|
||||
**路径参数:**
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| firmwareType | Integer | 是 | 固件类型:1-高频头,2-接收机,3-背包 |
|
||||
| protocolType | Integer | 是 | 协议类型:1-ELRS,2-CWLink |
|
||||
|
||||
**请求示例:**
|
||||
|
||||
```bash
|
||||
curl -X GET "http://your-server-host:8080/sirius_firmware/type/1/protocol/1"
|
||||
```
|
||||
|
||||
**成功响应示例:**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "操作成功",
|
||||
"data": [
|
||||
{
|
||||
"id": 5,
|
||||
"firmwareType": 1,
|
||||
"protocolType": 1,
|
||||
"versionNumber": "v3.0.1",
|
||||
"fileName": "sirius_hf_elrs_v3.0.1.bin",
|
||||
"filePath": "https://oss.corewing.com/sirius_firmware/sirius_hf_elrs_v3.0.1.bin",
|
||||
"fileSize": 1048576,
|
||||
"md5Hash": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"releaseNotes": "优化信号连接稳定性",
|
||||
"createTime": "2026-03-12 14:00:00",
|
||||
"updateTime": "2026-03-12 14:00:00"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"firmwareType": 1,
|
||||
"protocolType": 1,
|
||||
"versionNumber": "v3.0.0",
|
||||
"fileName": "sirius_hf_elrs_v3.0.0.bin",
|
||||
"filePath": "https://oss.corewing.com/sirius_firmware/sirius_hf_elrs_v3.0.0.bin",
|
||||
"fileSize": 1024000,
|
||||
"md5Hash": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
|
||||
"releaseNotes": null,
|
||||
"createTime": "2026-03-01 08:00:00",
|
||||
"updateTime": "2026-03-01 08:00:00"
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 查询所有固件
|
||||
|
||||
**接口描述:** 查询所有固件记录。
|
||||
|
||||
**请求方式:** `GET`
|
||||
|
||||
**请求路径:** `/sirius_firmware/list`
|
||||
|
||||
**请求示例:**
|
||||
|
||||
```bash
|
||||
curl -X GET "http://your-server-host:8080/sirius_firmware/list"
|
||||
```
|
||||
|
||||
**成功响应示例:**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "操作成功",
|
||||
"data": [
|
||||
{
|
||||
"id": 1,
|
||||
"firmwareType": 1,
|
||||
"protocolType": 1,
|
||||
"versionNumber": "v3.0.1",
|
||||
"fileName": "sirius_hf_elrs_v3.0.1.bin",
|
||||
"filePath": "https://oss.corewing.com/sirius_firmware/sirius_hf_elrs_v3.0.1.bin",
|
||||
"fileSize": 1048576,
|
||||
"md5Hash": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"releaseNotes": "优化信号连接稳定性",
|
||||
"createTime": "2026-03-10 10:30:00",
|
||||
"updateTime": "2026-03-10 10:30:00"
|
||||
}
|
||||
],
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 根据ID查询固件
|
||||
|
||||
**接口描述:** 根据固件ID查询详情。
|
||||
|
||||
**请求方式:** `GET`
|
||||
|
||||
**请求路径:** `/sirius_firmware/{id}`
|
||||
|
||||
**路径参数:**
|
||||
|
||||
| 参数名 | 类型 | 必填 | 说明 |
|
||||
|--------|------|------|------|
|
||||
| id | Integer | 是 | 固件ID |
|
||||
|
||||
**请求示例:**
|
||||
|
||||
```bash
|
||||
curl -X GET "http://your-server-host:8080/sirius_firmware/1"
|
||||
```
|
||||
|
||||
**成功响应示例:**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "操作成功",
|
||||
"data": {
|
||||
"id": 1,
|
||||
"firmwareType": 1,
|
||||
"protocolType": 1,
|
||||
"versionNumber": "v3.0.1",
|
||||
"fileName": "sirius_hf_elrs_v3.0.1.bin",
|
||||
"filePath": "https://oss.corewing.com/sirius_firmware/sirius_hf_elrs_v3.0.1.bin",
|
||||
"fileSize": 1048576,
|
||||
"md5Hash": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"releaseNotes": "优化信号连接稳定性",
|
||||
"createTime": "2026-03-10 10:30:00",
|
||||
"updateTime": "2026-03-10 10:30:00"
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
```
|
||||
|
||||
**失败响应示例:**
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 500,
|
||||
"message": "固件不存在",
|
||||
"data": null,
|
||||
"success": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 接口总览
|
||||
|
||||
| 方法 | 路径 | 说明 | 使用场景 |
|
||||
|------|------|------|----------|
|
||||
| GET | `/sirius_firmware/latest?firmwareType=&protocolType=` | 查询最新版本 | 设备端检查更新 |
|
||||
| GET | `/sirius_firmware/type/{firmwareType}` | 按固件类型查版本列表 | 查看某类固件所有版本 |
|
||||
| GET | `/sirius_firmware/type/{firmwareType}/protocol/{protocolType}` | 按类型+协议查版本列表 | 精确筛选版本列表 |
|
||||
| GET | `/sirius_firmware/list` | 查询所有固件 | 管理端展示全部数据 |
|
||||
| GET | `/sirius_firmware/{id}` | 按ID查询固件 | 查看固件详情 |
|
||||
|
||||
---
|
||||
@@ -42,6 +42,8 @@ public class SaTokenConfig implements WebMvcConfigurer {
|
||||
.excludePathPatterns("/firmware/**")
|
||||
// 排除AAT固件版本接口
|
||||
.excludePathPatterns("/aat_version/**")
|
||||
// 排除Sirius固件接口
|
||||
.excludePathPatterns("/sirius_firmware/**")
|
||||
// 排除公共固件
|
||||
.excludePathPatterns("/public_firmware/**")
|
||||
// 排除系统登录页(不需要登录)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.corewing.app.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class FirmwareVersionRequest {
|
||||
|
||||
@ApiModelProperty(value = "型号id", required = true)
|
||||
@NotNull(message = "型号不能为空")
|
||||
private Integer modelId;
|
||||
|
||||
@ApiModelProperty(value = "版本号", required = true)
|
||||
@NotNull(message = "版本号不能为空")
|
||||
private String version;
|
||||
|
||||
@ApiModelProperty(value = "固件类型", required = true)
|
||||
@NotNull(message = "固件类型不能为空")
|
||||
private Integer firmwareType;
|
||||
|
||||
}
|
||||
@@ -45,6 +45,21 @@ public class Firmware implements Serializable {
|
||||
*/
|
||||
private Integer firmwareType;
|
||||
|
||||
/**
|
||||
* 模型id
|
||||
*/
|
||||
private String modelId;
|
||||
|
||||
/**
|
||||
* 版本校验id
|
||||
*/
|
||||
private Integer versionId;
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 固件下载地址
|
||||
*/
|
||||
|
||||
79
src/main/java/com/corewing/app/entity/SiriusFirmware.java
Normal file
79
src/main/java/com/corewing/app/entity/SiriusFirmware.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package com.corewing.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Sirius固件信息实体类
|
||||
*/
|
||||
@Data
|
||||
@TableName("app_sirius_firmware")
|
||||
public class SiriusFirmware implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 固件类型:1-高频头,2-接收机,3-背包
|
||||
*/
|
||||
private Integer firmwareType;
|
||||
|
||||
/**
|
||||
* 协议类型:1-ELRS,2-CWLink
|
||||
*/
|
||||
private Integer protocolType;
|
||||
|
||||
/**
|
||||
* 版本号,如:v3.0.1
|
||||
*/
|
||||
private String versionNumber;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件存储路径
|
||||
*/
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* 文件大小(字节)
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* MD5校验值
|
||||
*/
|
||||
private String md5Hash;
|
||||
|
||||
/**
|
||||
* 版本更新说明
|
||||
*/
|
||||
private String releaseNotes;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -5,10 +5,16 @@ import com.corewing.app.common.Result;
|
||||
import com.corewing.app.util.I18nUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 全局异常处理器
|
||||
*/
|
||||
@@ -46,14 +52,39 @@ public class GlobalExceptionHandler {
|
||||
return Result.error(HttpStatus.UNAUTHORIZED.value(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 @Valid 参数校验异常(RequestBody 参数)
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<String> handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||
// 获取第一个错误信息
|
||||
String errorMessage = e.getBindingResult().getFieldErrors().stream()
|
||||
.map(FieldError::getDefaultMessage)
|
||||
.collect(Collectors.joining("; "));
|
||||
return Result.error(HttpStatus.BAD_REQUEST.value(), errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理 @Validated 参数校验异常(RequestParam/PathVariable 参数)
|
||||
*/
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public Result<String> handleConstraintViolationException(ConstraintViolationException e) {
|
||||
// 获取第一个错误信息
|
||||
String errorMessage = e.getConstraintViolations().stream()
|
||||
.map(ConstraintViolation::getMessage)
|
||||
.collect(Collectors.joining("; "));
|
||||
return Result.error(HttpStatus.BAD_REQUEST.value(), errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理其他异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
// @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public Result<String> handleException(Exception e) {
|
||||
log.error(e.getMessage());
|
||||
log.error("系统异常: ", e);
|
||||
return Result.error(HttpStatus.INTERNAL_SERVER_ERROR.value(),
|
||||
e.getMessage());
|
||||
I18nUtil.getMessage("error.system"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.corewing.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.corewing.app.entity.SiriusFirmware;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* Sirius固件信息 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SiriusFirmwareMapper extends BaseMapper<SiriusFirmware> {
|
||||
|
||||
}
|
||||
@@ -1,31 +1,41 @@
|
||||
package com.corewing.app.modules.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.common.annotation.CommonLog;
|
||||
import com.corewing.app.dto.FirmwareVersionRequest;
|
||||
import com.corewing.app.entity.BizDeviceCategory;
|
||||
import com.corewing.app.entity.Firmware;
|
||||
import com.corewing.app.service.BizDeviceCategoryService;
|
||||
import com.corewing.app.service.FirmwareService;
|
||||
import com.corewing.app.util.I18nUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 固件 Controller
|
||||
*/
|
||||
@Api(tags = "固件接口")
|
||||
@RestController
|
||||
@RequestMapping("/firmware")
|
||||
@Validated
|
||||
public class AppFirmwareController {
|
||||
|
||||
private final FirmwareService firmwareService;
|
||||
@Resource
|
||||
private FirmwareService firmwareService;
|
||||
|
||||
public AppFirmwareController(FirmwareService firmwareService) {
|
||||
this.firmwareService = firmwareService;
|
||||
}
|
||||
@Resource
|
||||
private BizDeviceCategoryService bizDeviceCategoryService;
|
||||
|
||||
/**
|
||||
* 根据ID查询固件
|
||||
@@ -84,20 +94,20 @@ public class AppFirmwareController {
|
||||
@CommonLog("查询所有固件集合")
|
||||
@ApiOperation("查询所有固件集合")
|
||||
@GetMapping("/list")
|
||||
public Result<java.util.List<Firmware>> list() {
|
||||
java.util.List<Firmware> list = firmwareService.list();
|
||||
public Result<List<Firmware>> list() {
|
||||
List<Firmware> list = firmwareService.list();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询固件版本
|
||||
* 根据类型查询固件版本 【兼容旧版APP】
|
||||
*
|
||||
* @param firmwareType 固件类型
|
||||
*/
|
||||
@CommonLog("根据类型查询固件版本")
|
||||
@ApiOperation("根据类型查询固件版本")
|
||||
@GetMapping("/type/{firmwareType}")
|
||||
public Result<java.util.List<Firmware>> listByType(@PathVariable Integer firmwareType) {
|
||||
public Result<List<Firmware>> listByType(@PathVariable Integer firmwareType) {
|
||||
if (firmwareType == null) {
|
||||
return Result.error(I18nUtil.getMessage("firmware.type.required"));
|
||||
}
|
||||
@@ -107,7 +117,49 @@ public class AppFirmwareController {
|
||||
// 按版本号或创建时间倒序排列,最新版本在前
|
||||
wrapper.orderByDesc("create_time");
|
||||
|
||||
java.util.List<Firmware> list = firmwareService.list(wrapper);
|
||||
List<Firmware> list = firmwareService.list(wrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询固件版本 【兼容新版APP】
|
||||
*
|
||||
* @param firmwareType 固件类型
|
||||
*/
|
||||
@CommonLog("根据类型,型号,当前版本查询固件版本")
|
||||
@ApiOperation("根据类型,当前版本查询固件版本")
|
||||
@GetMapping("/type/{firmwareType}/{modelId}/{softwareVersion}")
|
||||
public Result<List<Firmware>> listByType(@PathVariable Integer firmwareType, @PathVariable Integer modelId, @PathVariable Integer softwareVersion) {
|
||||
if (firmwareType == null && modelId == null) {
|
||||
return Result.error(I18nUtil.getMessage("firmware.type.or.model.required"));
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<BizDeviceCategory> categoryQueryWrapper = new LambdaQueryWrapper<>();
|
||||
categoryQueryWrapper.eq(BizDeviceCategory::getModelId, modelId);
|
||||
BizDeviceCategory bizDeviceCategory = bizDeviceCategoryService.getOne(categoryQueryWrapper);
|
||||
if(bizDeviceCategory == null) {
|
||||
return Result.error(I18nUtil.getMessage("firmware.device.not.found"));
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<Firmware> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Firmware::getFirmwareType, firmwareType);
|
||||
wrapper.eq(Firmware::getModelId, bizDeviceCategory.getId());
|
||||
wrapper.ge(Firmware::getVersionId, softwareVersion);
|
||||
// 按版本号或创建时间倒序排列,最新版本在前
|
||||
wrapper.orderByDesc(Firmware::getCreateTime);
|
||||
|
||||
List<Firmware> list = firmwareService.list(wrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否存在新固件
|
||||
* @return
|
||||
*/
|
||||
@CommonLog("校验是否存在新固件")
|
||||
@ApiOperation("校验是否存在新固件")
|
||||
@PostMapping("/checkVersion")
|
||||
public Result<Firmware> checkVersion(@RequestBody @Valid FirmwareVersionRequest firmwareVersionRequest) {
|
||||
return Result.success(firmwareService.checkVersion(firmwareVersionRequest));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.corewing.app.modules.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.common.annotation.CommonLog;
|
||||
import com.corewing.app.entity.SiriusFirmware;
|
||||
import com.corewing.app.service.SiriusFirmwareService;
|
||||
import com.corewing.app.util.I18nUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sirius固件信息 Controller
|
||||
*/
|
||||
@Api(tags = "Sirius固件信息接口")
|
||||
@RestController
|
||||
@RequestMapping("/sirius_firmware")
|
||||
public class AppSiriusFirmwareController {
|
||||
|
||||
private final SiriusFirmwareService siriusFirmwareService;
|
||||
|
||||
public AppSiriusFirmwareController(SiriusFirmwareService siriusFirmwareService) {
|
||||
this.siriusFirmwareService = siriusFirmwareService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据固件类型和协议类型查询最新版本
|
||||
*/
|
||||
@CommonLog("查询Sirius最新固件版本")
|
||||
@ApiOperation("根据固件类型和协议类型查询最新版本")
|
||||
@GetMapping("/latest")
|
||||
public Result<SiriusFirmware> getLatest(
|
||||
@RequestParam Integer firmwareType,
|
||||
@RequestParam Integer protocolType) {
|
||||
SiriusFirmware firmware = siriusFirmwareService.getLatestByTypeAndProtocol(firmwareType, protocolType);
|
||||
if (firmware != null) {
|
||||
return Result.success(firmware);
|
||||
}
|
||||
return Result.error(I18nUtil.getMessage("firmware.not.found"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据固件类型查询版本列表
|
||||
*/
|
||||
@CommonLog("根据类型查询Sirius固件版本列表")
|
||||
@ApiOperation("根据固件类型查询版本列表")
|
||||
@GetMapping("/type/{firmwareType}")
|
||||
public Result<List<SiriusFirmware>> listByType(@PathVariable Integer firmwareType) {
|
||||
QueryWrapper<SiriusFirmware> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("firmware_type", firmwareType);
|
||||
wrapper.orderByDesc("create_time");
|
||||
return Result.success(siriusFirmwareService.list(wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据固件类型和协议类型查询版本列表
|
||||
*/
|
||||
@CommonLog("根据类型和协议查询Sirius固件版本列表")
|
||||
@ApiOperation("根据固件类型和协议类型查询版本列表")
|
||||
@GetMapping("/type/{firmwareType}/protocol/{protocolType}")
|
||||
public Result<List<SiriusFirmware>> listByTypeAndProtocol(
|
||||
@PathVariable Integer firmwareType,
|
||||
@PathVariable Integer protocolType) {
|
||||
QueryWrapper<SiriusFirmware> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("firmware_type", firmwareType);
|
||||
wrapper.eq("protocol_type", protocolType);
|
||||
wrapper.orderByDesc("create_time");
|
||||
return Result.success(siriusFirmwareService.list(wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有固件
|
||||
*/
|
||||
@CommonLog("查询所有Sirius固件")
|
||||
@ApiOperation("查询所有固件")
|
||||
@GetMapping("/list")
|
||||
public Result<List<SiriusFirmware>> list() {
|
||||
return Result.success(siriusFirmwareService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查询固件
|
||||
*/
|
||||
@CommonLog("根据ID查询Sirius固件")
|
||||
@ApiOperation("根据ID查询固件")
|
||||
@GetMapping("/{id}")
|
||||
public Result<SiriusFirmware> getById(@PathVariable Integer id) {
|
||||
SiriusFirmware firmware = siriusFirmwareService.getById(id);
|
||||
if (firmware != null) {
|
||||
return Result.success(firmware);
|
||||
}
|
||||
return Result.error(I18nUtil.getMessage("firmware.not.found"));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.corewing.app.service;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.common.Result;
|
||||
import com.corewing.app.dto.FirmwareVersionRequest;
|
||||
import com.corewing.app.entity.Firmware;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -40,4 +41,11 @@ public interface FirmwareService extends IService<Firmware> {
|
||||
* @return
|
||||
*/
|
||||
boolean removeData(Long id);
|
||||
|
||||
/**
|
||||
* 校验固件是否有新固件
|
||||
* @param firmwareVersionRequest
|
||||
* @return
|
||||
*/
|
||||
Firmware checkVersion(FirmwareVersionRequest firmwareVersionRequest);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.corewing.app.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.corewing.app.entity.SiriusFirmware;
|
||||
|
||||
/**
|
||||
* Sirius固件信息 Service 接口
|
||||
*/
|
||||
public interface SiriusFirmwareService extends IService<SiriusFirmware> {
|
||||
|
||||
/**
|
||||
* 根据固件类型和协议类型查询最新版本
|
||||
*
|
||||
* @param firmwareType 固件类型
|
||||
* @param protocolType 协议类型
|
||||
* @return 最新固件版本
|
||||
*/
|
||||
SiriusFirmware getLatestByTypeAndProtocol(Integer firmwareType, Integer protocolType);
|
||||
}
|
||||
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.common.page.PageContext;
|
||||
import com.corewing.app.dto.FirmwareVersionRequest;
|
||||
import com.corewing.app.entity.BizDeviceCategory;
|
||||
import com.corewing.app.entity.Firmware;
|
||||
import com.corewing.app.mapper.FirmwareMapper;
|
||||
import com.corewing.app.service.BizDeviceCategoryService;
|
||||
import com.corewing.app.service.FirmwareService;
|
||||
import com.corewing.app.util.OSSUploadUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -13,7 +16,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 固件 Service 实现类
|
||||
@@ -21,6 +26,9 @@ import java.io.IOException;
|
||||
@Service
|
||||
public class FirmwareServiceImpl extends ServiceImpl<FirmwareMapper, Firmware> implements FirmwareService {
|
||||
|
||||
@Resource
|
||||
private BizDeviceCategoryService bizDeviceCategoryService;
|
||||
|
||||
@Override
|
||||
public Page<Firmware> page(Firmware firmware) {
|
||||
Page<Firmware> page = PageContext.getDefaultPage(Firmware.class);
|
||||
@@ -63,6 +71,30 @@ public class FirmwareServiceImpl extends ServiceImpl<FirmwareMapper, Firmware> i
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Firmware checkVersion(FirmwareVersionRequest firmwareVersionRequest) {
|
||||
|
||||
// 根据型号id搜索到设备分类id
|
||||
LambdaQueryWrapper<BizDeviceCategory> categoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
categoryLambdaQueryWrapper.eq(BizDeviceCategory::getModelId, firmwareVersionRequest.getModelId());
|
||||
BizDeviceCategory deviceCategory = bizDeviceCategoryService.getOne(categoryLambdaQueryWrapper);
|
||||
if(Objects.isNull(deviceCategory)){
|
||||
throw new RuntimeException("该设备型号不存在设备");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<Firmware> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.ge(Firmware::getVersionId, firmwareVersionRequest.getVersion());
|
||||
wrapper.eq(Firmware::getModelId, deviceCategory.getId());
|
||||
wrapper.eq(Firmware::getFirmwareType, firmwareVersionRequest.getFirmwareType());
|
||||
wrapper.orderByDesc(Firmware::getVersionId);
|
||||
wrapper.last("LIMIT 1");
|
||||
Firmware firmware = this.getOne(wrapper);
|
||||
if (firmware == null) {
|
||||
throw new RuntimeException("未找到匹配的固件版本");
|
||||
}
|
||||
return firmware;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 URL 路径的最后一节(忽略查询参数 ? 和锚点 #)
|
||||
* @param urlStr URL字符串
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.corewing.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.corewing.app.entity.SiriusFirmware;
|
||||
import com.corewing.app.mapper.SiriusFirmwareMapper;
|
||||
import com.corewing.app.service.SiriusFirmwareService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Sirius固件信息 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
public class SiriusFirmwareServiceImpl extends ServiceImpl<SiriusFirmwareMapper, SiriusFirmware> implements SiriusFirmwareService {
|
||||
|
||||
@Override
|
||||
public SiriusFirmware getLatestByTypeAndProtocol(Integer firmwareType, Integer protocolType) {
|
||||
LambdaQueryWrapper<SiriusFirmware> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SiriusFirmware::getFirmwareType, firmwareType);
|
||||
wrapper.eq(SiriusFirmware::getProtocolType, protocolType);
|
||||
wrapper.orderByDesc(SiriusFirmware::getCreateTime);
|
||||
wrapper.last("LIMIT 1");
|
||||
return getOne(wrapper);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ error.token.replaced=Account has been logged in elsewhere
|
||||
error.token.kicked.out=Account has been kicked offline
|
||||
error.not.login=Not logged in, please login first
|
||||
error.server.internal=Internal server error: {0}
|
||||
error.system=System error, please try again later
|
||||
|
||||
# ==================== Utility Classes ====================
|
||||
# Redis Utility
|
||||
@@ -143,3 +144,5 @@ firmware.update.success=Firmware updated successfully
|
||||
firmware.update.failed=Failed to update firmware
|
||||
firmware.not.found=Firmware not found
|
||||
firmware.type.required=Firmware type is required
|
||||
firmware.type.or.model.required=Firmware type or model is required
|
||||
firmware.device.not.found=Device not found
|
||||
|
||||
@@ -64,6 +64,7 @@ error.token.replaced=账号已在其他地方登录
|
||||
error.token.kicked.out=账号已被踢下线
|
||||
error.not.login=未登录,请先登录
|
||||
error.server.internal=服务器内部错误:{0}
|
||||
error.system=系统错误,请稍后重试
|
||||
|
||||
# ==================== 工具类 ====================
|
||||
# Redis工具类
|
||||
@@ -143,3 +144,5 @@ firmware.update.success=固件更新成功
|
||||
firmware.update.failed=固件更新失败
|
||||
firmware.not.found=固件不存在
|
||||
firmware.type.required=固件类型不能为空
|
||||
firmware.type.or.model.required=固件类型或型号不能为空
|
||||
firmware.device.not.found=设备不存在
|
||||
|
||||
Reference in New Issue
Block a user