修改数据库名

This commit is contained in:
2025-09-09 17:54:21 +08:00
parent 1b857e1493
commit 252e3d9143
8 changed files with 8 additions and 44 deletions

View File

@@ -97,40 +97,5 @@ public class DevicesController {
return Result.ok().data("contacts", contacts); 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();
}
} }

View File

@@ -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.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; 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.DeviceSnService;
import com.onekeycall.videotablet.service.UserService; import com.onekeycall.videotablet.service.UserService;
import com.onekeycall.videotablet.utils.JwtUtil; import com.onekeycall.videotablet.utils.JwtUtil;
import jakarta.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -19,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@RestController @RestController
@RequestMapping("/contact") @RequestMapping("/user")
public class ContactController { public class ContactController {
@Autowired @Autowired
private JwtUtil jwtUtil; private JwtUtil jwtUtil;

View File

@@ -176,7 +176,7 @@ public class UserController {
return Result.error().message("Device location not found"); 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") @GetMapping("/get_device_apk_list")

View File

@@ -8,7 +8,7 @@ import lombok.Data;
@Data @Data
@Entity @Entity
@Table(name = "device_contacts") @Table(name = "devices_contact")
public class Contact { public class Contact {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@@ -10,7 +10,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
@Data @Data
@Document(collection = "device_apks") // 指定MongoDB集合名 @Document(collection = "devices_apk_info") // 指定MongoDB集合名
public class DeviceApkInfo { public class DeviceApkInfo {
@Id @Id

View File

@@ -9,7 +9,7 @@ import java.util.Date;
@Data @Data
@Entity @Entity
@Table(name = "device_location") @Table(name = "devices_location")
public class DeviceLocation { public class DeviceLocation {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@@ -12,7 +12,7 @@ import java.util.List;
public interface DeviceLocationRepository extends JpaRepository<DeviceLocation, Long> { public interface DeviceLocationRepository extends JpaRepository<DeviceLocation, Long> {
// @Modifying // @Modifying
// @Transactional // @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}) " + // "VALUES (:#{#deviceLocation.sn}, :#{#deviceLocation.address}, :#{#deviceLocation.longitude}, :#{#deviceLocation.latitude}, :#{#deviceLocation.updateTime}, :#{#deviceLocation.createTime}) " +
// "ON DUPLICATE KEY UPDATE " + // "ON DUPLICATE KEY UPDATE " +
// "address = VALUES(address), " + // "address = VALUES(address), " +

View File

@@ -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/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配置 # Hibernate配置
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect #spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect