refactor(device): 重命名硬件信息为系统信息
将 Hardware 相关类、接口、方法、API 端点统一重命名为 SystemInfo,包括实体、VO、Req、Mapper、Service 及 Controller,并更新数据库表名映射。
This commit is contained in:
@@ -7,9 +7,9 @@ import com.youlai.boot.common.enums.ActionTypeEnum;
|
||||
import com.youlai.boot.common.enums.LogModuleEnum;
|
||||
import com.youlai.boot.common.result.Result;
|
||||
import com.youlai.boot.common.util.HashUtils;
|
||||
import com.youlai.boot.device.model.entity.SnDeviceHardware;
|
||||
import com.youlai.boot.device.model.entity.SnDeviceSystemInfo;
|
||||
import com.youlai.boot.device.model.req.ApkInstallInfoReq;
|
||||
import com.youlai.boot.device.model.req.SnHardwareInfoReq;
|
||||
import com.youlai.boot.device.model.req.SnSystemInfoReq;
|
||||
import com.youlai.boot.device.model.req.SnLocationReq;
|
||||
import com.youlai.boot.device.model.entity.SnLocation;
|
||||
import com.youlai.boot.device.model.entity.SnScreenshot;
|
||||
@@ -51,7 +51,7 @@ public class MobileController {
|
||||
private final LocationService locationService;
|
||||
private final DeveloperService developerService;
|
||||
private final ApkInstallService apkInstallService;
|
||||
private final HardwareService hardwareService;
|
||||
private final SystemInfoService systemInfoService;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MobileController.class);
|
||||
|
||||
@@ -76,37 +76,37 @@ public class MobileController {
|
||||
}
|
||||
|
||||
@Operation(summary = "上传设备硬件信息")
|
||||
@PostMapping("/update_hardware_info")
|
||||
@PostMapping("/update_system_info")
|
||||
@Log(module = LogModuleEnum.MOBILE, value = ActionTypeEnum.DEVELOPER)
|
||||
public Result<Void> updateHardwareInfo(
|
||||
public Result<Void> updateSystemInfo(
|
||||
@RequestHeader(value = "X-Device-SN") String sn,
|
||||
@RequestBody SnHardwareInfoReq hardwareInfoReq
|
||||
@RequestBody SnSystemInfoReq snSystemInfoReq
|
||||
) {
|
||||
try {
|
||||
if (sn == null || sn.trim().isEmpty()) {
|
||||
return Result.failed("设备序列号不能为空");
|
||||
}
|
||||
|
||||
if (hardwareInfoReq == null) {
|
||||
if (snSystemInfoReq == null) {
|
||||
return Result.failed("硬件信息不能为空");
|
||||
}
|
||||
|
||||
SnDeviceHardware hardware = new SnDeviceHardware();
|
||||
BeanUtils.copyProperties(hardwareInfoReq, hardware);
|
||||
hardware.setSerialno(sn);
|
||||
hardware.setUpdateTime(LocalDateTime.now());
|
||||
SnDeviceSystemInfo systemInfo = new SnDeviceSystemInfo();
|
||||
BeanUtils.copyProperties(snSystemInfoReq, systemInfo);
|
||||
systemInfo.setSerialno(sn);
|
||||
systemInfo.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
SnDeviceHardware existingHardware = hardwareService.lambdaQuery()
|
||||
.eq(SnDeviceHardware::getSerialno, sn)
|
||||
SnDeviceSystemInfo existingSystemInfo = systemInfoService.lambdaQuery()
|
||||
.eq(SnDeviceSystemInfo::getSerialno, sn)
|
||||
.one();
|
||||
|
||||
boolean saved;
|
||||
if (existingHardware != null) {
|
||||
hardware.setId(existingHardware.getId());
|
||||
saved = hardwareService.updateById(hardware);
|
||||
if (existingSystemInfo != null) {
|
||||
systemInfo.setId(existingSystemInfo.getId());
|
||||
saved = systemInfoService.updateById(systemInfo);
|
||||
} else {
|
||||
hardware.setCreateTime(LocalDateTime.now());
|
||||
saved = hardwareService.save(hardware);
|
||||
systemInfo.setCreateTime(LocalDateTime.now());
|
||||
saved = systemInfoService.save(systemInfo);
|
||||
}
|
||||
|
||||
if (!saved) {
|
||||
@@ -117,7 +117,7 @@ public class MobileController {
|
||||
return Result.success();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("updateHardwareInfo error, sn: {}", sn, e);
|
||||
logger.error("updateSystemInfo error, sn: {}", sn, e);
|
||||
return Result.failed("上传硬件信息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user