Files
OneKeyCallVideoTablet/src/main/java/com/onekeycall/videotablet/service/DeviceApkInfoService.java

50 lines
1.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.onekeycall.videotablet.service;
import com.onekeycall.videotablet.entity.ApkInfo;
import com.onekeycall.videotablet.entity.DeviceApkInfo;
import com.onekeycall.videotablet.repository.DeviceApkInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Service
public class DeviceApkInfoService {
@Autowired
private DeviceApkInfoRepository deviceApkInfoRepository;
/**
* 保存或更新设备APK列表信息
* 如果该sn已存在则更新其apkList和updateTime不存在则新增
*/
public void saveOrUpdateDeviceApkInfo(String sn, List<ApkInfo> apkList) {
DeviceApkInfo deviceApkInfo;
if (deviceApkInfoRepository.existsBySn(sn)) {
// 存在则更新
deviceApkInfo = deviceApkInfoRepository.getDeviceApkInfoBySn(sn);
deviceApkInfo.setApkList(apkList);
deviceApkInfo.setUpdateTime(new Date());
} else {
// 不存在则新增
deviceApkInfo = new DeviceApkInfo();
deviceApkInfo.setSn(sn);
deviceApkInfo.setApkList(apkList);
Date now = new Date();
deviceApkInfo.setCreateTime(now);
deviceApkInfo.setUpdateTime(now);
}
deviceApkInfoRepository.save(deviceApkInfo);
}
/**
* 根据序列号sn获取设备APK列表
*/
public DeviceApkInfo getDeviceApkInfoBySn(String sn) {
return deviceApkInfoRepository.getDeviceApkInfoBySn(sn);
}
}