增加sn推送控制
This commit is contained in:
@@ -3,8 +3,13 @@ package com.onekeycall.videotablet.config;
|
|||||||
public class PushIdConfig {
|
public class PushIdConfig {
|
||||||
/*绑定设备*/
|
/*绑定设备*/
|
||||||
public static final String BIND_DEVICE = "1";
|
public static final String BIND_DEVICE = "1";
|
||||||
/*卸载应用*/
|
|
||||||
public static final String UNINSTALL_APK = "2";
|
|
||||||
/*添加联系人*/
|
/*添加联系人*/
|
||||||
public static final String CONTACT_ADD = "3";
|
public static final String CONTACT_ADD = "3";
|
||||||
|
|
||||||
|
public static final String OPEN_APP = "10";
|
||||||
|
public static final String KILL_APP = "11";
|
||||||
|
public static final String CLEAR_APP = "12";
|
||||||
|
/*卸载应用*/
|
||||||
|
public static final String UNINSTALL_APP = "13";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class ManageSnController {
|
|||||||
// 3. 校验 sn 是否存在
|
// 3. 校验 sn 是否存在
|
||||||
DeviceInfo oldDeviceInfo = deviceSnService.findBySn(sn);
|
DeviceInfo oldDeviceInfo = deviceSnService.findBySn(sn);
|
||||||
if (oldDeviceInfo != null) {
|
if (oldDeviceInfo != null) {
|
||||||
return Result.error().message("sn already exists");
|
return Result.exists().message("sn already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 新增 sn
|
// 4. 新增 sn
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ public class DevicesController {
|
|||||||
@RequestParam(value = "version_code") Long versionCode,
|
@RequestParam(value = "version_code") Long versionCode,
|
||||||
@RequestParam(value = "md5") String md5
|
@RequestParam(value = "md5") String md5
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
|
|
||||||
String iconPath = FilePath.getApkIconPath();
|
String iconPath = FilePath.getApkIconPath();
|
||||||
logger.info("uploadApkIcon, iconPath: {}", iconPath);
|
logger.info("uploadApkIcon, iconPath: {}", iconPath);
|
||||||
File fileDir = new File(iconPath);
|
File fileDir = new File(iconPath);
|
||||||
@@ -125,22 +124,23 @@ public class DevicesController {
|
|||||||
fileDir.mkdirs();
|
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 originName = file.getOriginalFilename();
|
||||||
String fileExtension = FilenameUtils.getExtension(originName);
|
String fileExtension = FilenameUtils.getExtension(originName);
|
||||||
if (TextUtils.isEmpty(fileExtension)) {
|
if (TextUtils.isEmpty(fileExtension)) {
|
||||||
return Result.error().message("file extension is empty");
|
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;
|
String fileName = packageName + "_" + md5 + "." + fileExtension;
|
||||||
File destFile = new File(fileDir, fileName);
|
File destFile = new File(fileDir, fileName);
|
||||||
file.transferTo(destFile);
|
file.transferTo(destFile);
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
package com.onekeycall.videotablet.controller.user;
|
package com.onekeycall.videotablet.controller.user;
|
||||||
|
|
||||||
|
import com.onekeycall.videotablet.config.PushIdConfig;
|
||||||
import com.onekeycall.videotablet.controller.pub.LoginController;
|
import com.onekeycall.videotablet.controller.pub.LoginController;
|
||||||
import com.onekeycall.videotablet.dto.TokenPair;
|
import com.onekeycall.videotablet.dto.TokenPair;
|
||||||
import com.onekeycall.videotablet.entity.DeviceApkInfo;
|
import com.onekeycall.videotablet.entity.DeviceApkInfo;
|
||||||
import com.onekeycall.videotablet.entity.DeviceInfo;
|
import com.onekeycall.videotablet.entity.DeviceInfo;
|
||||||
import com.onekeycall.videotablet.entity.DeviceLocation;
|
import com.onekeycall.videotablet.entity.DeviceLocation;
|
||||||
import com.onekeycall.videotablet.entity.User;
|
import com.onekeycall.videotablet.entity.User;
|
||||||
|
import com.onekeycall.videotablet.gson.GsonUtils;
|
||||||
import com.onekeycall.videotablet.result.Result;
|
import com.onekeycall.videotablet.result.Result;
|
||||||
import com.onekeycall.videotablet.service.DeviceApkInfoService;
|
import com.onekeycall.videotablet.service.DeviceApkInfoService;
|
||||||
import com.onekeycall.videotablet.service.DeviceLocationService;
|
import com.onekeycall.videotablet.service.DeviceLocationService;
|
||||||
import com.onekeycall.videotablet.service.DeviceSnService;
|
import com.onekeycall.videotablet.service.DeviceSnService;
|
||||||
import com.onekeycall.videotablet.service.UserService;
|
import com.onekeycall.videotablet.service.UserService;
|
||||||
|
import com.onekeycall.videotablet.utils.DevicePushUtils;
|
||||||
import com.onekeycall.videotablet.utils.JwtUtil;
|
import com.onekeycall.videotablet.utils.JwtUtil;
|
||||||
import com.onekeycall.videotablet.utils.TextUtils;
|
import com.onekeycall.videotablet.utils.TextUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -23,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
@@ -188,4 +192,30 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
return Result.ok().data(deviceApkInfo.getApkList());
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ public class Result {
|
|||||||
|
|
||||||
public static Result error() {
|
public static Result error() {
|
||||||
Result r = new Result();
|
Result r = new Result();
|
||||||
r.setSuccess(ResultCodeEnum.UNKNOWN_REASON.getSuccess());
|
r.setSuccess(ResultCodeEnum.FAIL.getSuccess());
|
||||||
r.setCode(ResultCodeEnum.UNKNOWN_REASON.getCode());
|
r.setCode(ResultCodeEnum.FAIL.getCode());
|
||||||
r.setMessage(ResultCodeEnum.UNKNOWN_REASON.getMessage());
|
r.setMessage(ResultCodeEnum.FAIL.getMessage());
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +76,14 @@ public class Result {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Result exists() {
|
||||||
|
Result r = new Result();
|
||||||
|
r.setSuccess(ResultCodeEnum.EXISTS.getSuccess());
|
||||||
|
r.setCode(ResultCodeEnum.EXISTS.getCode());
|
||||||
|
r.setMessage(ResultCodeEnum.EXISTS.getMessage());
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
public static Result setResult(ResultCodeEnum resultCodeEnum) {
|
public static Result setResult(ResultCodeEnum resultCodeEnum) {
|
||||||
Result r = new Result();
|
Result r = new Result();
|
||||||
r.setSuccess(resultCodeEnum.getSuccess());
|
r.setSuccess(resultCodeEnum.getSuccess());
|
||||||
|
|||||||
@@ -11,11 +11,25 @@ public enum ResultCodeEnum {
|
|||||||
SUCCESS(true, 20000, "成功"),
|
SUCCESS(true, 20000, "成功"),
|
||||||
|
|
||||||
UNKNOWN_REASON(false, 20001, "未知错误"),
|
UNKNOWN_REASON(false, 20001, "未知错误"),
|
||||||
NOT_FOUND(true, 20004, "没有数据"),
|
/**
|
||||||
|
* 失败
|
||||||
|
*/
|
||||||
|
FAIL(false, 20002, "失败"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 未登录
|
* 未登录
|
||||||
*/
|
*/
|
||||||
UNAUTHORIZED(false, 20003, "未登录");
|
UNAUTHORIZED(false, 20003, "未登录"),
|
||||||
|
/**
|
||||||
|
* 没有数据
|
||||||
|
*/
|
||||||
|
NOT_FOUND(false, 20004, "没有数据"),
|
||||||
|
/**
|
||||||
|
* 已存在
|
||||||
|
*/
|
||||||
|
EXISTS(false, 20005, "已存在"),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
private final Boolean success;
|
private final Boolean success;
|
||||||
|
|||||||
Reference in New Issue
Block a user