diff --git a/src/main/java/com/onekeycall/videotablet/controller/sn/DevicesController.java b/src/main/java/com/onekeycall/videotablet/controller/sn/DevicesController.java index 7993fd7..2f9d73b 100644 --- a/src/main/java/com/onekeycall/videotablet/controller/sn/DevicesController.java +++ b/src/main/java/com/onekeycall/videotablet/controller/sn/DevicesController.java @@ -97,40 +97,5 @@ public class DevicesController { return Result.ok().data("contacts", contacts); } - @PostMapping("/upload_install_apk") - public Result uploadInstallApk( - @RequestHeader("Device-Token") String deviceToken, @RequestHeader("Device-ID") String deviceId, - @RequestHeader("Device-Sig") String deviceSig, - @Valid @RequestBody DeviceLocation deviceLocation - ) { - String sn = deviceLocation.getSn(); - if (!jwtUtil.validateDeviceToken(deviceToken, deviceId, sn)) { - return Result.error().message("Invalid token"); - } - - DeviceInfo deviceInfo = deviceSnService.findBySn(sn); - if (deviceInfo == null) { - return Result.notFound().message("sn not found"); - } - - if (!deviceInfo.getBindSig().equals(deviceSig)) { - return Result.error().message("device sig not match"); - } - - if (TextUtils.isEmpty(deviceInfo.getBindPhone())) { - return Result.error().message("sn not bind"); - } - if (deviceLocationService.isExist(sn)) { - DeviceLocation deviceLocationDB = deviceLocationService.getDeviceLocation(sn); - deviceLocation.setId(deviceLocationDB.getId()); - deviceLocation.setUpdateTime(new Date(System.currentTimeMillis())); - deviceLocationService.save(deviceLocation); - } else { - deviceLocation.setUpdateTime(new Date(System.currentTimeMillis())); - deviceLocation.setCreateTime(new Date(System.currentTimeMillis())); - deviceLocationService.save(deviceLocation); - } - return Result.ok(); - } } diff --git a/src/main/java/com/onekeycall/videotablet/controller/ContactController.java b/src/main/java/com/onekeycall/videotablet/controller/user/ContactController.java similarity index 96% rename from src/main/java/com/onekeycall/videotablet/controller/ContactController.java rename to src/main/java/com/onekeycall/videotablet/controller/user/ContactController.java index eb33796..dd1c334 100644 --- a/src/main/java/com/onekeycall/videotablet/controller/ContactController.java +++ b/src/main/java/com/onekeycall/videotablet/controller/user/ContactController.java @@ -1,4 +1,4 @@ -package com.onekeycall.videotablet.controller; +package com.onekeycall.videotablet.controller.user; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -10,7 +10,6 @@ import com.onekeycall.videotablet.service.ContactService; import com.onekeycall.videotablet.service.DeviceSnService; import com.onekeycall.videotablet.service.UserService; import com.onekeycall.videotablet.utils.JwtUtil; -import jakarta.validation.Valid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -19,7 +18,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @RestController -@RequestMapping("/contact") +@RequestMapping("/user") public class ContactController { @Autowired private JwtUtil jwtUtil; diff --git a/src/main/java/com/onekeycall/videotablet/controller/user/UserController.java b/src/main/java/com/onekeycall/videotablet/controller/user/UserController.java index 3e01841..83dd5b8 100644 --- a/src/main/java/com/onekeycall/videotablet/controller/user/UserController.java +++ b/src/main/java/com/onekeycall/videotablet/controller/user/UserController.java @@ -176,7 +176,7 @@ public class UserController { return Result.error().message("Device location not found"); } - return Result.ok().data("device_location", deviceLocation); + return Result.ok().data("devices_location", deviceLocation); } @GetMapping("/get_device_apk_list") diff --git a/src/main/java/com/onekeycall/videotablet/entity/Contact.java b/src/main/java/com/onekeycall/videotablet/entity/Contact.java index 24f1379..2020484 100644 --- a/src/main/java/com/onekeycall/videotablet/entity/Contact.java +++ b/src/main/java/com/onekeycall/videotablet/entity/Contact.java @@ -8,7 +8,7 @@ import lombok.Data; @Data @Entity -@Table(name = "device_contacts") +@Table(name = "devices_contact") public class Contact { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/onekeycall/videotablet/entity/DeviceApkInfo.java b/src/main/java/com/onekeycall/videotablet/entity/DeviceApkInfo.java index 152cced..c861868 100644 --- a/src/main/java/com/onekeycall/videotablet/entity/DeviceApkInfo.java +++ b/src/main/java/com/onekeycall/videotablet/entity/DeviceApkInfo.java @@ -10,7 +10,7 @@ import java.util.Date; import java.util.List; @Data -@Document(collection = "device_apks") // 指定MongoDB集合名 +@Document(collection = "devices_apk_info") // 指定MongoDB集合名 public class DeviceApkInfo { @Id diff --git a/src/main/java/com/onekeycall/videotablet/entity/DeviceLocation.java b/src/main/java/com/onekeycall/videotablet/entity/DeviceLocation.java index f12e90c..ecd509c 100644 --- a/src/main/java/com/onekeycall/videotablet/entity/DeviceLocation.java +++ b/src/main/java/com/onekeycall/videotablet/entity/DeviceLocation.java @@ -9,7 +9,7 @@ import java.util.Date; @Data @Entity -@Table(name = "device_location") +@Table(name = "devices_location") public class DeviceLocation { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/onekeycall/videotablet/repository/DeviceLocationRepository.java b/src/main/java/com/onekeycall/videotablet/repository/DeviceLocationRepository.java index c21bad8..5562470 100644 --- a/src/main/java/com/onekeycall/videotablet/repository/DeviceLocationRepository.java +++ b/src/main/java/com/onekeycall/videotablet/repository/DeviceLocationRepository.java @@ -12,7 +12,7 @@ import java.util.List; public interface DeviceLocationRepository extends JpaRepository { // @Modifying // @Transactional -// @Query(value = "INSERT INTO device_location (sn, address, longitude, latitude, update_time, create_time) " + +// @Query(value = "INSERT INTO devices_location (sn, address, longitude, latitude, update_time, create_time) " + // "VALUES (:#{#deviceLocation.sn}, :#{#deviceLocation.address}, :#{#deviceLocation.longitude}, :#{#deviceLocation.latitude}, :#{#deviceLocation.updateTime}, :#{#deviceLocation.createTime}) " + // "ON DUPLICATE KEY UPDATE " + // "address = VALUES(address), " + diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties index 81956e5..653f6ac 100644 --- a/src/main/resources/application-test.properties +++ b/src/main/resources/application-test.properties @@ -23,7 +23,7 @@ spring.data.redis.lettuce.pool.max-wait=1ms spring.data.redis.lettuce.shutdown-timeout=100ms #MongoDB -spring.data.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/device_apks?authSource=admin&connectTimeoutMS=5000 +spring.data.mongodb.uri=mongodb://fht:fanhuitong@139.199.77.221:27027/devices_apk_info?authSource=admin&connectTimeoutMS=5000 # Hibernate配置 #spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect