【新增】根据类型,型号查询固件版本
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
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;
|
||||
@@ -15,6 +18,7 @@ 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;
|
||||
|
||||
@@ -27,11 +31,11 @@ import java.util.List;
|
||||
@Validated
|
||||
public class AppFirmwareController {
|
||||
|
||||
private final FirmwareService firmwareService;
|
||||
@Resource
|
||||
private FirmwareService firmwareService;
|
||||
|
||||
public AppFirmwareController(FirmwareService firmwareService) {
|
||||
this.firmwareService = firmwareService;
|
||||
}
|
||||
@Resource
|
||||
private BizDeviceCategoryService bizDeviceCategoryService;
|
||||
|
||||
/**
|
||||
* 根据ID查询固件
|
||||
@@ -96,7 +100,7 @@ public class AppFirmwareController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询固件版本
|
||||
* 根据类型查询固件版本 【兼容旧版APP】
|
||||
*
|
||||
* @param firmwareType 固件类型
|
||||
*/
|
||||
@@ -117,6 +121,35 @@ public class AppFirmwareController {
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型查询固件版本 【兼容新版APP】
|
||||
*
|
||||
* @param firmwareType 固件类型
|
||||
*/
|
||||
@CommonLog("根据类型,型号查询固件版本")
|
||||
@ApiOperation("根据类型,型号查询固件版本")
|
||||
@GetMapping("/type/{firmwareType}/{modelId}")
|
||||
public Result<List<Firmware>> listByType(@PathVariable Integer firmwareType, @PathVariable Integer modelId) {
|
||||
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.orderByDesc(Firmware::getCreateTime);
|
||||
|
||||
List<Firmware> list = firmwareService.list(wrapper);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否存在新固件
|
||||
|
||||
@@ -144,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
|
||||
|
||||
@@ -144,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