增加result返回列表,联系人接口增加推送
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
package com.onekeycall.videotablet.config;
|
||||||
|
|
||||||
|
public class PushIdConfig {
|
||||||
|
/*绑定设备*/
|
||||||
|
public static final String BIND_DEVICE = "1";
|
||||||
|
/*卸载应用*/
|
||||||
|
public static final String UNINSTALL_APK = "2";
|
||||||
|
/*添加联系人*/
|
||||||
|
public static final String CONTACT_ADD = "3";
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.onekeycall.videotablet.controller.sn;
|
package com.onekeycall.videotablet.controller.sn;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.onekeycall.videotablet.config.PushIdConfig;
|
||||||
import com.onekeycall.videotablet.entity.DeviceInfo;
|
import com.onekeycall.videotablet.entity.DeviceInfo;
|
||||||
import com.onekeycall.videotablet.entity.User;
|
import com.onekeycall.videotablet.entity.User;
|
||||||
import com.onekeycall.videotablet.result.Result;
|
import com.onekeycall.videotablet.result.Result;
|
||||||
@@ -80,7 +81,7 @@ public class BindSnController {
|
|||||||
params.addProperty("expire_time", System.currentTimeMillis() + 60 * 1000);
|
params.addProperty("expire_time", System.currentTimeMillis() + 60 * 1000);
|
||||||
|
|
||||||
// PushUtils.aliyunAsyncPush("1", params.toString(), sn);
|
// 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);
|
redisTemplate.opsForValue().set(sn, verifyKey, 1, TimeUnit.MINUTES);
|
||||||
return Result.ok().message("send message success");
|
return Result.ok().message("send message success");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -184,6 +185,7 @@ public class BindSnController {
|
|||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
map.put("bind_status", 1);
|
map.put("bind_status", 1);
|
||||||
map.put("device_alias", deviceInfo.getDeviceAlias());
|
map.put("device_alias", deviceInfo.getDeviceAlias());
|
||||||
|
map.put("tablet_avatar", deviceInfo.getTabletAvatar());
|
||||||
map.put("bind_phone", deviceInfo.getBindPhone());
|
map.put("bind_phone", deviceInfo.getBindPhone());
|
||||||
map.put("user_id", deviceInfo.getUserId());
|
map.put("user_id", deviceInfo.getUserId());
|
||||||
map.put("add_time", deviceInfo.getAddTime());
|
map.put("add_time", deviceInfo.getAddTime());
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class DeviceApkInfoController {
|
|||||||
public Result uploadInstallApks(@RequestBody ApkUploadRequest request) {
|
public Result uploadInstallApks(@RequestBody ApkUploadRequest request) {
|
||||||
String sn = request.getSn();
|
String sn = request.getSn();
|
||||||
List<ApkInfo> apkList = request.getApk_list();
|
List<ApkInfo> apkList = request.getApk_list();
|
||||||
if (apkList == null || apkList.size() == 0) {
|
if (apkList == null || apkList.isEmpty()) {
|
||||||
return Result.error().message("应用列表为空");
|
return Result.error().message("应用列表为空");
|
||||||
}
|
}
|
||||||
deviceApkInfoService.saveOrUpdateDeviceApkInfo(sn, apkList);
|
deviceApkInfoService.saveOrUpdateDeviceApkInfo(sn, apkList);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class DevicesController {
|
|||||||
private ContactService contactService;
|
private ContactService contactService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/update_location")
|
@PostMapping("/update_location")
|
||||||
public Result updateLocation(
|
public Result updateLocation(
|
||||||
@RequestHeader("Device-Token") String deviceToken, @RequestHeader("Device-ID") String deviceId,
|
@RequestHeader("Device-Token") String deviceToken, @RequestHeader("Device-ID") String deviceId,
|
||||||
@@ -58,6 +57,7 @@ public class DevicesController {
|
|||||||
DeviceLocation deviceLocationDB = deviceLocationService.getDeviceLocation(sn);
|
DeviceLocation deviceLocationDB = deviceLocationService.getDeviceLocation(sn);
|
||||||
deviceLocation.setId(deviceLocationDB.getId());
|
deviceLocation.setId(deviceLocationDB.getId());
|
||||||
deviceLocation.setUpdateTime(new Date(System.currentTimeMillis()));
|
deviceLocation.setUpdateTime(new Date(System.currentTimeMillis()));
|
||||||
|
deviceLocation.setCreateTime(deviceLocationDB.getCreateTime());
|
||||||
deviceLocationService.save(deviceLocation);
|
deviceLocationService.save(deviceLocation);
|
||||||
} else {
|
} else {
|
||||||
deviceLocation.setUpdateTime(new Date(System.currentTimeMillis()));
|
deviceLocation.setUpdateTime(new Date(System.currentTimeMillis()));
|
||||||
@@ -94,7 +94,7 @@ public class DevicesController {
|
|||||||
if (contacts == null || contacts.isEmpty()) {
|
if (contacts == null || contacts.isEmpty()) {
|
||||||
return Result.notFound().message("contacts not found");
|
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.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.onekeycall.videotablet.config.PushIdConfig;
|
||||||
import com.onekeycall.videotablet.entity.Contact;
|
import com.onekeycall.videotablet.entity.Contact;
|
||||||
import com.onekeycall.videotablet.entity.DeviceInfo;
|
import com.onekeycall.videotablet.entity.DeviceInfo;
|
||||||
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.ContactService;
|
import com.onekeycall.videotablet.service.ContactService;
|
||||||
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;
|
||||||
@@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
@@ -43,7 +47,7 @@ public class ContactController {
|
|||||||
@RequestParam(value = "sn") String sn,
|
@RequestParam(value = "sn") String sn,
|
||||||
@RequestPart(value = "file", required = false) MultipartFile file,
|
@RequestPart(value = "file", required = false) MultipartFile file,
|
||||||
@RequestPart("contact_json") String jsonData
|
@RequestPart("contact_json") String jsonData
|
||||||
) throws JsonProcessingException {
|
) throws Exception {
|
||||||
|
|
||||||
User user = userService.getUserByUserId(userId);
|
User user = userService.getUserByUserId(userId);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
@@ -69,6 +73,8 @@ public class ContactController {
|
|||||||
contact.setSn(sn);
|
contact.setSn(sn);
|
||||||
contactService.save(contact);
|
contactService.save(contact);
|
||||||
|
|
||||||
|
DevicePushUtils.aliyunAsyncPush(PushIdConfig.CONTACT_ADD, sn, GsonUtils.toJSONString(contactService.findAllBySn(sn)));
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +100,6 @@ public class ContactController {
|
|||||||
if (contacts == null || contacts.isEmpty()) {
|
if (contacts == null || contacts.isEmpty()) {
|
||||||
return Result.notFound().message("contacts not found");
|
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) {
|
public Result getDeviceApkList(@RequestParam String sn) {
|
||||||
|
|
||||||
DeviceApkInfo deviceApkInfo = deviceApkInfoService.getDeviceApkInfoBySn(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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import lombok.Data;
|
|||||||
public class Contact {
|
public class Contact {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id",unique = true, nullable = false)
|
@Column(name = "id", unique = true, nullable = false)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Convert(converter = AesAttributeConverter.class)
|
@Convert(converter = AesAttributeConverter.class)
|
||||||
@@ -40,11 +40,16 @@ public class Contact {
|
|||||||
@Column
|
@Column
|
||||||
private String qq;
|
private String qq;
|
||||||
|
|
||||||
|
int sort;
|
||||||
|
|
||||||
|
boolean show;
|
||||||
|
|
||||||
|
boolean emergency;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
private String sn;
|
private String sn;
|
||||||
|
|
||||||
@Column(name = "user_id")
|
@Column(name = "user_id")
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
public interface DeviceApkInfoRepository extends MongoRepository<DeviceApkInfo, String> {
|
public interface DeviceApkInfoRepository extends MongoRepository<DeviceApkInfo, String> {
|
||||||
|
|
||||||
// 根据序列号sn查找设备应用列表
|
// 根据序列号sn查找设备应用列表
|
||||||
DeviceApkInfo findDeviceApkInfoBySn(String sn);
|
DeviceApkInfo getDeviceApkInfoBySn(String sn);
|
||||||
|
|
||||||
// 判断某个序列号的记录是否存在
|
// 判断某个序列号的记录是否存在
|
||||||
boolean existsBySn(String sn);
|
boolean existsBySn(String sn);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.onekeycall.videotablet.result;
|
package com.onekeycall.videotablet.result;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -9,6 +11,7 @@ import java.util.Map;
|
|||||||
* @author 爷爷的茶七里香
|
* @author 爷爷的茶七里香
|
||||||
* @date 2022/05/30
|
* @date 2022/05/30
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
public class Result {
|
public class Result {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +32,12 @@ public class Result {
|
|||||||
/**
|
/**
|
||||||
* 放置响应的数据
|
* 放置响应的数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> data = new HashMap<>();
|
// private Map<String, Object> data = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 放置集合类型响应数据
|
||||||
|
*/
|
||||||
|
private Object data;
|
||||||
|
|
||||||
public Result() {
|
public Result() {
|
||||||
}
|
}
|
||||||
@@ -92,46 +100,19 @@ public class Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Result data(String key, Object value) {
|
public Result data(String key, Object value) {
|
||||||
this.data.put(key, value);
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
data.put(key, value);
|
||||||
|
this.setData(data);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result data(Map<String, Object> map) {
|
// public Result data(Map<String, Object> map) {
|
||||||
this.setData(map);
|
// this.setData(map);
|
||||||
|
// return this;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public Result data(Object listData) {
|
||||||
|
this.setData(listData);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 以下是get/set方法,如果项目有集成lombok可以使用@Data注解代替 */
|
|
||||||
|
|
||||||
public Boolean getSuccess() {
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuccess(Boolean success) {
|
|
||||||
this.success = success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(Map<String, Object> data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ public class ContactService {
|
|||||||
this.contactRepository = deviceSnRepository;
|
this.contactRepository = deviceSnRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Contact> findAllByUserId(String userId) {
|
||||||
|
return contactRepository.findAllByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isExistByPhoneNumber(String phoneNumber) {
|
public boolean isExistByPhoneNumber(String phoneNumber) {
|
||||||
return contactRepository.existsByPhoneNumber(phoneNumber);
|
return contactRepository.existsByPhoneNumber(phoneNumber);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class DeviceApkInfoService {
|
|||||||
DeviceApkInfo deviceApkInfo;
|
DeviceApkInfo deviceApkInfo;
|
||||||
if (deviceApkInfoRepository.existsBySn(sn)) {
|
if (deviceApkInfoRepository.existsBySn(sn)) {
|
||||||
// 存在则更新
|
// 存在则更新
|
||||||
deviceApkInfo = deviceApkInfoRepository.findDeviceApkInfoBySn(sn);
|
deviceApkInfo = deviceApkInfoRepository.getDeviceApkInfoBySn(sn);
|
||||||
deviceApkInfo.setApkList(apkList);
|
deviceApkInfo.setApkList(apkList);
|
||||||
deviceApkInfo.setUpdateTime(new Date());
|
deviceApkInfo.setUpdateTime(new Date());
|
||||||
} else {
|
} else {
|
||||||
@@ -42,7 +42,7 @@ public class DeviceApkInfoService {
|
|||||||
* 根据序列号sn获取设备APK列表
|
* 根据序列号sn获取设备APK列表
|
||||||
*/
|
*/
|
||||||
public DeviceApkInfo getDeviceApkInfoBySn(String sn) {
|
public DeviceApkInfo getDeviceApkInfoBySn(String sn) {
|
||||||
return deviceApkInfoRepository.findDeviceApkInfoBySn(sn);
|
return deviceApkInfoRepository.getDeviceApkInfoBySn(sn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class DevicePushUtils {
|
|||||||
* @throws ExecutionException
|
* @throws ExecutionException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
*/
|
*/
|
||||||
public static void aliyunAsyncPush(String title, String jsonString, String targetValue) throws ExecutionException, InterruptedException {
|
public static void aliyunAsyncPush(String title, String targetValue, String jsonString) throws ExecutionException, InterruptedException {
|
||||||
// HttpClient Configuration
|
// HttpClient Configuration
|
||||||
/*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()
|
/*HttpClient httpClient = new ApacheAsyncHttpClientBuilder()
|
||||||
.connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds
|
.connectionTimeout(Duration.ofSeconds(10)) // Set the connection timeout time, the default is 10 seconds
|
||||||
|
|||||||
@@ -56,5 +56,8 @@ logging.pattern.file=%d{yyyy-MM-dd} [%thread] %-5level %logger - %msg%n
|
|||||||
logging.logback.rollingpolicy.max-file-size=10MB
|
logging.logback.rollingpolicy.max-file-size=10MB
|
||||||
logging.logback.rollingpolicy.max-history=30
|
logging.logback.rollingpolicy.max-history=30
|
||||||
|
|
||||||
|
logging.level.com.onekeycall.videotablet.filter=DEBUG
|
||||||
|
logging.level.org.springframework.security=DEBUG
|
||||||
|
|
||||||
mybatis.type-aliases-package=com.onekeycall.videotablet.entity
|
mybatis.type-aliases-package=com.onekeycall.videotablet.entity
|
||||||
mybatis.mapperLocations=classpath:mapper/*.xml
|
mybatis.mapperLocations=classpath:mapper/*.xml
|
||||||
@@ -56,5 +56,8 @@ logging.pattern.file=%d{yyyy-MM-dd} [%thread] %-5level %logger - %msg%n
|
|||||||
logging.logback.rollingpolicy.max-file-size=10MB
|
logging.logback.rollingpolicy.max-file-size=10MB
|
||||||
logging.logback.rollingpolicy.max-history=30
|
logging.logback.rollingpolicy.max-history=30
|
||||||
|
|
||||||
|
logging.level.com.onekeycall.videotablet.filter=DEBUG
|
||||||
|
logging.level.org.springframework.security=DEBUG
|
||||||
|
|
||||||
mybatis.type-aliases-package=com.onekeycall.videotablet.entity
|
mybatis.type-aliases-package=com.onekeycall.videotablet.entity
|
||||||
mybatis.mapperLocations=classpath:mapper/*.xml
|
mybatis.mapperLocations=classpath:mapper/*.xml
|
||||||
@@ -23,7 +23,7 @@ spring.data.redis.lettuce.pool.max-wait=1ms
|
|||||||
spring.data.redis.lettuce.shutdown-timeout=100ms
|
spring.data.redis.lettuce.shutdown-timeout=100ms
|
||||||
|
|
||||||
#MongoDB
|
#MongoDB
|
||||||
spring.data.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/devices_apk_info?authSource=admin&connectTimeoutMS=5000
|
spring.data.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000
|
||||||
|
|
||||||
# Hibernate配置
|
# Hibernate配置
|
||||||
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
|
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
|
||||||
|
|||||||
Reference in New Issue
Block a user