增加sn推送控制
This commit is contained in:
@@ -55,7 +55,7 @@ public class ManageSnController {
|
||||
// 3. 校验 sn 是否存在
|
||||
DeviceInfo oldDeviceInfo = deviceSnService.findBySn(sn);
|
||||
if (oldDeviceInfo != null) {
|
||||
return Result.error().message("sn already exists");
|
||||
return Result.exists().message("sn already exists");
|
||||
}
|
||||
|
||||
// 4. 新增 sn
|
||||
|
||||
@@ -117,7 +117,6 @@ public class DevicesController {
|
||||
@RequestParam(value = "version_code") Long versionCode,
|
||||
@RequestParam(value = "md5") String md5
|
||||
) throws Exception {
|
||||
|
||||
String iconPath = FilePath.getApkIconPath();
|
||||
logger.info("uploadApkIcon, iconPath: {}", iconPath);
|
||||
File fileDir = new File(iconPath);
|
||||
@@ -125,22 +124,23 @@ public class DevicesController {
|
||||
fileDir.mkdirs();
|
||||
}
|
||||
|
||||
String fileMd5 = HashUtils.calculateMultipartFileMd5(file);
|
||||
|
||||
if (!fileMd5.equals(md5)) {
|
||||
return Result.error().message("file md5 not match");
|
||||
}
|
||||
|
||||
logger.info("uploadApkIcon, fileMd5: {}", fileMd5);
|
||||
if (apkIconService.existsByPackageNameAndMd5(packageName, md5)) {
|
||||
return Result.error().message("apk icon already exists");
|
||||
}
|
||||
|
||||
String originName = file.getOriginalFilename();
|
||||
String fileExtension = FilenameUtils.getExtension(originName);
|
||||
if (TextUtils.isEmpty(fileExtension)) {
|
||||
return Result.error().message("file extension is empty");
|
||||
}
|
||||
|
||||
String fileMd5 = HashUtils.calculateMultipartFileMd5(file);
|
||||
|
||||
if (!fileMd5.equalsIgnoreCase(md5)) {
|
||||
return Result.error().message("file md5 not match");
|
||||
}
|
||||
|
||||
logger.info("uploadApkIcon, fileMd5: {}", fileMd5);
|
||||
if (apkIconService.existsByPackageNameAndMd5(packageName, md5)) {
|
||||
return Result.exists().message("apk icon already exists");
|
||||
}
|
||||
|
||||
String fileName = packageName + "_" + md5 + "." + fileExtension;
|
||||
File destFile = new File(fileDir, fileName);
|
||||
file.transferTo(destFile);
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.onekeycall.videotablet.controller.user;
|
||||
|
||||
import com.onekeycall.videotablet.config.PushIdConfig;
|
||||
import com.onekeycall.videotablet.controller.pub.LoginController;
|
||||
import com.onekeycall.videotablet.dto.TokenPair;
|
||||
import com.onekeycall.videotablet.entity.DeviceApkInfo;
|
||||
import com.onekeycall.videotablet.entity.DeviceInfo;
|
||||
import com.onekeycall.videotablet.entity.DeviceLocation;
|
||||
import com.onekeycall.videotablet.entity.User;
|
||||
import com.onekeycall.videotablet.gson.GsonUtils;
|
||||
import com.onekeycall.videotablet.result.Result;
|
||||
import com.onekeycall.videotablet.service.DeviceApkInfoService;
|
||||
import com.onekeycall.videotablet.service.DeviceLocationService;
|
||||
import com.onekeycall.videotablet.service.DeviceSnService;
|
||||
import com.onekeycall.videotablet.service.UserService;
|
||||
import com.onekeycall.videotablet.utils.DevicePushUtils;
|
||||
import com.onekeycall.videotablet.utils.JwtUtil;
|
||||
import com.onekeycall.videotablet.utils.TextUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@@ -188,4 +192,30 @@ public class UserController {
|
||||
}
|
||||
return Result.ok().data(deviceApkInfo.getApkList());
|
||||
}
|
||||
|
||||
@PostMapping("/control_app")
|
||||
public Result controlApp(@RequestParam String sn,
|
||||
@RequestParam(value = "package_name") String packageName,
|
||||
@RequestParam String action
|
||||
) throws ExecutionException, InterruptedException {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("package_name", packageName);
|
||||
switch (action){
|
||||
case "open":
|
||||
DevicePushUtils.aliyunAsyncPush(PushIdConfig.OPEN_APP, sn, GsonUtils.toJSONString(params));
|
||||
break;
|
||||
case "kill":
|
||||
DevicePushUtils.aliyunAsyncPush(PushIdConfig.KILL_APP, sn, GsonUtils.toJSONString(params));
|
||||
break;
|
||||
case "clear":
|
||||
DevicePushUtils.aliyunAsyncPush(PushIdConfig.CLEAR_APP, sn, GsonUtils.toJSONString(params));
|
||||
break;
|
||||
case "uninstall":
|
||||
DevicePushUtils.aliyunAsyncPush(PushIdConfig.UNINSTALL_APP, sn, GsonUtils.toJSONString(params));
|
||||
break;
|
||||
default:
|
||||
return Result.error().message("action is empty");
|
||||
}
|
||||
return Result.ok().message("success");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user