增加result返回列表,联系人接口增加推送
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.onekeycall.videotablet.controller.sn;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.onekeycall.videotablet.config.PushIdConfig;
|
||||
import com.onekeycall.videotablet.entity.DeviceInfo;
|
||||
import com.onekeycall.videotablet.entity.User;
|
||||
import com.onekeycall.videotablet.result.Result;
|
||||
@@ -80,7 +81,7 @@ public class BindSnController {
|
||||
params.addProperty("expire_time", System.currentTimeMillis() + 60 * 1000);
|
||||
|
||||
// PushUtils.aliyunAsyncPush("1", params.toString(), sn);
|
||||
DevicePushUtils.tpnsPush("1", params.toString(), sn);
|
||||
DevicePushUtils.aliyunAsyncPush(PushIdConfig.BIND_DEVICE, sn, params.toString());
|
||||
redisTemplate.opsForValue().set(sn, verifyKey, 1, TimeUnit.MINUTES);
|
||||
return Result.ok().message("send message success");
|
||||
} catch (Exception e) {
|
||||
@@ -184,6 +185,7 @@ public class BindSnController {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("bind_status", 1);
|
||||
map.put("device_alias", deviceInfo.getDeviceAlias());
|
||||
map.put("tablet_avatar", deviceInfo.getTabletAvatar());
|
||||
map.put("bind_phone", deviceInfo.getBindPhone());
|
||||
map.put("user_id", deviceInfo.getUserId());
|
||||
map.put("add_time", deviceInfo.getAddTime());
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DeviceApkInfoController {
|
||||
public Result uploadInstallApks(@RequestBody ApkUploadRequest request) {
|
||||
String sn = request.getSn();
|
||||
List<ApkInfo> apkList = request.getApk_list();
|
||||
if (apkList == null || apkList.size() == 0) {
|
||||
if (apkList == null || apkList.isEmpty()) {
|
||||
return Result.error().message("应用列表为空");
|
||||
}
|
||||
deviceApkInfoService.saveOrUpdateDeviceApkInfo(sn, apkList);
|
||||
|
||||
@@ -29,7 +29,6 @@ public class DevicesController {
|
||||
private ContactService contactService;
|
||||
|
||||
|
||||
|
||||
@PostMapping("/update_location")
|
||||
public Result updateLocation(
|
||||
@RequestHeader("Device-Token") String deviceToken, @RequestHeader("Device-ID") String deviceId,
|
||||
@@ -58,6 +57,7 @@ public class DevicesController {
|
||||
DeviceLocation deviceLocationDB = deviceLocationService.getDeviceLocation(sn);
|
||||
deviceLocation.setId(deviceLocationDB.getId());
|
||||
deviceLocation.setUpdateTime(new Date(System.currentTimeMillis()));
|
||||
deviceLocation.setCreateTime(deviceLocationDB.getCreateTime());
|
||||
deviceLocationService.save(deviceLocation);
|
||||
} else {
|
||||
deviceLocation.setUpdateTime(new Date(System.currentTimeMillis()));
|
||||
@@ -72,7 +72,7 @@ public class DevicesController {
|
||||
public Result getContacts(
|
||||
@RequestHeader("Device-Token") String deviceToken, @RequestHeader("Device-ID") String deviceId,
|
||||
@RequestHeader("Device-Sig") String deviceSig, @RequestParam(value = "sn") String sn
|
||||
) {
|
||||
) {
|
||||
|
||||
if (!jwtUtil.validateDeviceToken(deviceToken, deviceId, sn)) {
|
||||
return Result.error().message("Invalid token");
|
||||
@@ -94,7 +94,7 @@ public class DevicesController {
|
||||
if (contacts == null || contacts.isEmpty()) {
|
||||
return Result.notFound().message("contacts not found");
|
||||
}
|
||||
return Result.ok().data("contacts", contacts);
|
||||
return Result.ok().data(contacts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,13 +2,16 @@ package com.onekeycall.videotablet.controller.user;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.onekeycall.videotablet.config.PushIdConfig;
|
||||
import com.onekeycall.videotablet.entity.Contact;
|
||||
import com.onekeycall.videotablet.entity.DeviceInfo;
|
||||
import com.onekeycall.videotablet.entity.User;
|
||||
import com.onekeycall.videotablet.gson.GsonUtils;
|
||||
import com.onekeycall.videotablet.result.Result;
|
||||
import com.onekeycall.videotablet.service.ContactService;
|
||||
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;
|
||||
@@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
@@ -43,7 +47,7 @@ public class ContactController {
|
||||
@RequestParam(value = "sn") String sn,
|
||||
@RequestPart(value = "file", required = false) MultipartFile file,
|
||||
@RequestPart("contact_json") String jsonData
|
||||
) throws JsonProcessingException {
|
||||
) throws Exception {
|
||||
|
||||
User user = userService.getUserByUserId(userId);
|
||||
if (user == null) {
|
||||
@@ -69,6 +73,8 @@ public class ContactController {
|
||||
contact.setSn(sn);
|
||||
contactService.save(contact);
|
||||
|
||||
DevicePushUtils.aliyunAsyncPush(PushIdConfig.CONTACT_ADD, sn, GsonUtils.toJSONString(contactService.findAllBySn(sn)));
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@@ -94,6 +100,6 @@ public class ContactController {
|
||||
if (contacts == null || contacts.isEmpty()) {
|
||||
return Result.notFound().message("contacts not found");
|
||||
}
|
||||
return Result.ok().data("contacts", contacts);
|
||||
return Result.ok().data(contacts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,9 @@ public class UserController {
|
||||
public Result getDeviceApkList(@RequestParam String sn) {
|
||||
|
||||
DeviceApkInfo deviceApkInfo = deviceApkInfoService.getDeviceApkInfoBySn(sn);
|
||||
return Result.ok().data("deviceApkInfo", deviceApkInfo);
|
||||
if (deviceApkInfo == null || deviceApkInfo.getApkList() == null) {
|
||||
return Result.notFound().message("未找到设备APK信息");
|
||||
}
|
||||
return Result.ok().data(deviceApkInfo.getApkList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user