feat(device): 增加设备信息持久化和OTA升级功能
- 新增设备持久化定时任务,每5分钟将Redis中采集的设备信息同步数据库 - 新增UserDevice和UserActive模型及相应数据库表和操作接口 - 设备信息上报中获取客户端公网IP,替代原X-Forwarded-For头部 - 新建OTA功能模块,实现OTA固件升级信息查询接口 - 支持OTA黑名单过滤与定向升级设备判断 - 设计OTA相关数据库结构:ota、black_list、ota_target_device表 - 缓存预热新增按品牌分组预热型号缓存 - 依赖注入新增OTA Repository及Handler路由配置 - 实现客户端公网IP提取逻辑,支持多种代理头部优先级识别
This commit is contained in:
+26
-1
@@ -14,9 +14,11 @@ import (
|
||||
"github.com/luxsin/app-api/internal/cache"
|
||||
"github.com/luxsin/app-api/internal/config"
|
||||
"github.com/luxsin/app-api/internal/database"
|
||||
"github.com/luxsin/app-api/internal/model"
|
||||
"github.com/luxsin/app-api/internal/repository"
|
||||
"github.com/luxsin/app-api/internal/router"
|
||||
"github.com/luxsin/app-api/internal/search"
|
||||
"github.com/luxsin/app-api/internal/task"
|
||||
"github.com/luxsin/app-api/pkg/logger"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
@@ -67,6 +69,11 @@ func main() {
|
||||
// 启动时预热缓存
|
||||
warmUpCache(log, db, rdb)
|
||||
|
||||
// 启动定时刷入任务:每 5 分钟从 Redis 刷入数据库
|
||||
deviceRepo := repository.NewDeviceRepository(db)
|
||||
devicePersistTask := task.NewDevicePersistTask(rdb, deviceRepo, log)
|
||||
devicePersistTask.Start(5 * time.Minute)
|
||||
|
||||
engine := router.New(log, db, searchClient, rdb)
|
||||
|
||||
srv := &http.Server{
|
||||
@@ -119,12 +126,30 @@ func warmUpCache(log *zap.Logger, db *sql.DB, rdb *redis.Client) {
|
||||
log.Info("brand cache warmed up", zap.Int("count", len(brands)))
|
||||
}
|
||||
|
||||
// 预热 model:all
|
||||
// 预热 model:all + model:brand:{brandName}
|
||||
if allModels, err := modelRepo.ListAllFromDB(ctx); err != nil {
|
||||
log.Warn("model warm-up failed", zap.Error(err))
|
||||
} else if err := modelCache.SetAll(ctx, allModels); err != nil {
|
||||
log.Warn("model cache set failed", zap.Error(err))
|
||||
} else {
|
||||
log.Info("model cache warmed up", zap.Int("count", len(allModels)))
|
||||
|
||||
// 按品牌分组预热 model:brand:{brandName}
|
||||
grouped := groupModelsByBrand(allModels)
|
||||
for brandName, models := range grouped {
|
||||
if err := modelCache.SetByBrand(ctx, brandName, models); err != nil {
|
||||
log.Warn("model brand cache set failed", zap.String("brand", brandName), zap.Error(err))
|
||||
}
|
||||
}
|
||||
log.Info("model brand cache warmed up", zap.Int("brands", len(grouped)))
|
||||
}
|
||||
}
|
||||
|
||||
// groupModelsByBrand 按品牌分组型号列表
|
||||
func groupModelsByBrand(models []model.Model) map[string][]model.Model {
|
||||
result := make(map[string][]model.Model)
|
||||
for _, m := range models {
|
||||
result[m.BrandName] = append(result[m.BrandName], m)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/luxsin/app-api/pkg/encode"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -27,7 +28,7 @@ func (h *DeviceHandler) ReportDevInfo(c *gin.Context) {
|
||||
mac := strings.TrimSpace(c.Query("mac"))
|
||||
model := strings.TrimSpace(c.Query("model"))
|
||||
ver := strings.TrimSpace(c.Query("ver"))
|
||||
xForwardedFor := c.GetHeader("X-Forwarded-For")
|
||||
clientIP := encode.ClientPublicIP(c)
|
||||
|
||||
if mac == "" || model == "" {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
@@ -40,20 +41,17 @@ func (h *DeviceHandler) ReportDevInfo(c *gin.Context) {
|
||||
if ver == "" {
|
||||
ver = ""
|
||||
}
|
||||
if xForwardedFor == "" {
|
||||
xForwardedFor = ""
|
||||
}
|
||||
|
||||
h.log.Info("report dev info",
|
||||
zap.String("remote_ip", xForwardedFor),
|
||||
zap.String("time", time.Now().Format("yyyy-MM-dd HH:mm:ss")),
|
||||
zap.String("remote_ip", clientIP),
|
||||
zap.String("time", time.Now().Format("2006-01-02 15:04:05")),
|
||||
)
|
||||
|
||||
deviceInfo := map[string]string{
|
||||
"mac_addr": mac,
|
||||
"model": model,
|
||||
"active_date": time.Now().Format("yyyy-MM-dd"),
|
||||
"ip_addr": xForwardedFor,
|
||||
"active_date": time.Now().Format("2006-01-02"),
|
||||
"ip_addr": clientIP,
|
||||
"ver": ver,
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/luxsin/app-api/internal/repository"
|
||||
"github.com/luxsin/app-api/internal/response"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type OTAHandler struct {
|
||||
repo *repository.OTARepository
|
||||
log *zap.Logger
|
||||
}
|
||||
|
||||
func NewOTAHandler(repo *repository.OTARepository, log *zap.Logger) *OTAHandler {
|
||||
return &OTAHandler{repo: repo, log: log}
|
||||
}
|
||||
|
||||
// GetOTA 获取 OTA 升级信息
|
||||
// GET /audio/ota?model=xxx&hw=1&mac=xx:xx:xx&beta=0
|
||||
func (h *OTAHandler) GetOTA(c *gin.Context) {
|
||||
modelVal := strings.TrimSpace(c.Query("model"))
|
||||
hwStr := strings.TrimSpace(c.Query("hw"))
|
||||
mac := strings.TrimSpace(c.Query("mac"))
|
||||
betaStr := strings.TrimSpace(c.Query("beta"))
|
||||
|
||||
// 参数校验
|
||||
if modelVal == "" || hwStr == "" {
|
||||
response.BadRequest(c, "model和hw参数不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
hw, err := strconv.Atoi(hwStr)
|
||||
if err != nil {
|
||||
response.BadRequest(c, "hw参数格式错误")
|
||||
return
|
||||
}
|
||||
|
||||
beta := 0
|
||||
if betaStr != "" {
|
||||
if b, err := strconv.Atoi(betaStr); err == nil {
|
||||
beta = b
|
||||
}
|
||||
}
|
||||
|
||||
if mac == "" {
|
||||
mac = "null"
|
||||
}
|
||||
|
||||
ctx := c.Request.Context()
|
||||
|
||||
// 1. 查询最新 OTA 记录
|
||||
ota, err := h.repo.GetLatestOTA(ctx, modelVal, hw, beta)
|
||||
if err != nil {
|
||||
h.log.Error("query ota failed", zap.Error(err))
|
||||
response.InternalError(c, "查询OTA信息失败")
|
||||
return
|
||||
}
|
||||
|
||||
if ota == nil {
|
||||
response.Fail(c, http.StatusOK, 40004, "无OTA升级信息")
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 检查黑名单
|
||||
inBlackList, err := h.repo.IsInBlackList(ctx, ota.ID, mac)
|
||||
if err != nil {
|
||||
h.log.Error("check black list failed", zap.Error(err))
|
||||
response.InternalError(c, "查询黑名单失败")
|
||||
return
|
||||
}
|
||||
|
||||
if inBlackList {
|
||||
h.log.Info("mac命中OTA黑名单", zap.String("mac", mac), zap.Int("ota_id", ota.ID))
|
||||
|
||||
// 命中黑名单,返回一条不在黑名单中的最新记录
|
||||
ota, err = h.repo.GetLatestOTANotInBlackList(ctx, modelVal, hw, beta, mac)
|
||||
if err != nil {
|
||||
h.log.Error("query ota not in blacklist failed", zap.Error(err))
|
||||
response.InternalError(c, "查询OTA信息失败")
|
||||
return
|
||||
}
|
||||
|
||||
if ota == nil {
|
||||
response.Fail(c, http.StatusOK, 40004, "无OTA升级信息")
|
||||
return
|
||||
}
|
||||
|
||||
response.OK(c, ota)
|
||||
return
|
||||
}
|
||||
|
||||
// 3. 检查是否为定向升级
|
||||
if ota.Target == 0 {
|
||||
// 非定向,直接返回
|
||||
response.OK(c, ota)
|
||||
return
|
||||
}
|
||||
|
||||
// 定向升级,检查 mac 是否在定向设备列表中
|
||||
targetDevice, err := h.repo.FindTargetDevice(ctx, ota.ID, mac)
|
||||
if err != nil {
|
||||
h.log.Error("check target device failed", zap.Error(err))
|
||||
response.InternalError(c, "查询定向设备失败")
|
||||
return
|
||||
}
|
||||
|
||||
if targetDevice != nil {
|
||||
// 定向命中,返回该 OTA
|
||||
response.OK(c, ota)
|
||||
return
|
||||
}
|
||||
|
||||
// 定向未命中,返回非定向的最新版本
|
||||
notTargetOTA, err := h.repo.GetLatestOTANotTarget(ctx, modelVal, hw, beta)
|
||||
if err != nil {
|
||||
h.log.Error("query ota not target failed", zap.Error(err))
|
||||
response.InternalError(c, "查询OTA信息失败")
|
||||
return
|
||||
}
|
||||
|
||||
if notTargetOTA == nil {
|
||||
response.Fail(c, http.StatusOK, 40004, "无OTA升级信息")
|
||||
return
|
||||
}
|
||||
|
||||
response.OK(c, notTargetOTA)
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// OTA 固件升级记录
|
||||
type OTA struct {
|
||||
ID int `json:"id"`
|
||||
VerCode int `json:"verCode"`
|
||||
VerName string `json:"verName"`
|
||||
URL string `json:"url"`
|
||||
MD5 string `json:"md5"`
|
||||
Force int `json:"force"`
|
||||
Desc *string `json:"desc,omitempty"`
|
||||
Model *string `json:"model,omitempty"`
|
||||
HW int `json:"hw"`
|
||||
Target int `json:"target"`
|
||||
Beta int `json:"beta"`
|
||||
PawVerCode int `json:"pawVerCode"`
|
||||
PawVerName string `json:"pawVerName"`
|
||||
PawURL string `json:"pawUrl"`
|
||||
PawMD5 string `json:"pawMd5"`
|
||||
StartTime *time.Time `json:"startTime,omitempty"`
|
||||
EndTime *time.Time `json:"endTime,omitempty"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
// BlackList OTA 黑名单
|
||||
type BlackList struct {
|
||||
ID int `json:"id"`
|
||||
OTAID int `json:"ota_id"`
|
||||
Mac string `json:"mac"`
|
||||
CreateAt time.Time `json:"create_at"`
|
||||
}
|
||||
|
||||
// OTATargetDevice OTA 定向设备
|
||||
type OTATargetDevice struct {
|
||||
ID int `json:"id"`
|
||||
OTAID int `json:"ota_id"`
|
||||
MacAddr string `json:"mac_addr"`
|
||||
Type int `json:"type"`
|
||||
CreateAt time.Time `json:"create_at"`
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type UserActive struct {
|
||||
ID int
|
||||
MacAddr string
|
||||
Model string
|
||||
ActiveDate string
|
||||
IpAddr string
|
||||
CreateAt time.Time
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type UserDevice struct {
|
||||
ID int
|
||||
MacAddr string
|
||||
Model string
|
||||
AddTime time.Time
|
||||
Ver *string
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/luxsin/app-api/internal/model"
|
||||
)
|
||||
|
||||
type DeviceRepository struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewDeviceRepository(db *sql.DB) *DeviceRepository {
|
||||
return &DeviceRepository{db: db}
|
||||
}
|
||||
|
||||
func (r *DeviceRepository) FindDeviceByMac(ctx context.Context, macAddr string) (*model.UserDevice, error) {
|
||||
const query = `SELECT id, mac_addr, model, add_time, ver FROM user_device WHERE mac_addr = ?`
|
||||
|
||||
var d model.UserDevice
|
||||
var ver sql.NullString
|
||||
|
||||
err := r.db.QueryRowContext(ctx, query, macAddr).Scan(&d.ID, &d.MacAddr, &d.Model, &d.AddTime, &ver)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query user_device: %w", err)
|
||||
}
|
||||
|
||||
if ver.Valid {
|
||||
d.Ver = &ver.String
|
||||
}
|
||||
return &d, nil
|
||||
}
|
||||
|
||||
func (r *DeviceRepository) InsertDevice(ctx context.Context, d model.UserDevice) error {
|
||||
const query = `INSERT INTO user_device (mac_addr, model, ver) VALUES (?, ?, ?)`
|
||||
_, err := r.db.ExecContext(ctx, query, d.MacAddr, d.Model, d.Ver)
|
||||
if err != nil {
|
||||
return fmt.Errorf("insert user_device: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *DeviceRepository) UpdateDeviceVer(ctx context.Context, id int, ver *string) error {
|
||||
const query = `UPDATE user_device SET ver = ? WHERE id = ?`
|
||||
_, err := r.db.ExecContext(ctx, query, ver, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update user_device: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *DeviceRepository) FindActiveByMacAndDate(ctx context.Context, macAddr, activeDate string) (*model.UserActive, error) {
|
||||
const query = `SELECT id, mac_addr, model, active_date, ip_addr, create_at FROM user_active WHERE mac_addr = ? AND active_date = ?`
|
||||
|
||||
var a model.UserActive
|
||||
err := r.db.QueryRowContext(ctx, query, macAddr, activeDate).Scan(&a.ID, &a.MacAddr, &a.Model, &a.ActiveDate, &a.IpAddr, &a.CreateAt)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query user_active: %w", err)
|
||||
}
|
||||
return &a, nil
|
||||
}
|
||||
|
||||
func (r *DeviceRepository) InsertActive(ctx context.Context, a model.UserActive) error {
|
||||
const query = `INSERT INTO user_active (mac_addr, model, active_date, ip_addr) VALUES (?, ?, ?, ?)`
|
||||
_, err := r.db.ExecContext(ctx, query, a.MacAddr, a.Model, a.ActiveDate, a.IpAddr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("insert user_active: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *DeviceRepository) UpdateActiveIp(ctx context.Context, id int, ipAddr string) error {
|
||||
const query = `UPDATE user_active SET ip_addr = ? WHERE id = ?`
|
||||
_, err := r.db.ExecContext(ctx, query, ipAddr, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update user_active: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/luxsin/app-api/internal/model"
|
||||
)
|
||||
|
||||
type OTARepository struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewOTARepository(db *sql.DB) *OTARepository {
|
||||
return &OTARepository{db: db}
|
||||
}
|
||||
|
||||
// GetLatestOTA 按 model+hw+beta+status=1 查询最新一条 OTA 记录(verCode 降序)
|
||||
func (r *OTARepository) GetLatestOTA(ctx context.Context, modelVal string, hw, beta int) (*model.OTA, error) {
|
||||
const query = `SELECT id, verCode, verName, url, md5, force, desc, model, hw, target, beta,
|
||||
pawVerCode, pawVerName, pawUrl, pawMd5, startTime, endTime, status
|
||||
FROM ota WHERE model = ? AND hw = ? AND beta = ? AND status = 1
|
||||
ORDER BY verCode DESC LIMIT 1`
|
||||
|
||||
var o model.OTA
|
||||
var desc, mdl sql.NullString
|
||||
var startTime, endTime sql.NullTime
|
||||
|
||||
err := r.db.QueryRowContext(ctx, query, modelVal, hw, beta).Scan(
|
||||
&o.ID, &o.VerCode, &o.VerName, &o.URL, &o.MD5, &o.Force, &desc, &mdl,
|
||||
&o.HW, &o.Target, &o.Beta,
|
||||
&o.PawVerCode, &o.PawVerName, &o.PawURL, &o.PawMD5, &startTime, &endTime, &o.Status,
|
||||
)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query ota: %w", err)
|
||||
}
|
||||
|
||||
if desc.Valid {
|
||||
o.Desc = &desc.String
|
||||
}
|
||||
if mdl.Valid {
|
||||
o.Model = &mdl.String
|
||||
}
|
||||
if startTime.Valid {
|
||||
o.StartTime = &startTime.Time
|
||||
}
|
||||
if endTime.Valid {
|
||||
o.EndTime = &endTime.Time
|
||||
}
|
||||
return &o, nil
|
||||
}
|
||||
|
||||
// GetLatestOTANotInBlackList 查询最新一条不在黑名单中的 OTA 记录
|
||||
func (r *OTARepository) GetLatestOTANotInBlackList(ctx context.Context, modelVal string, hw, beta int, mac string) (*model.OTA, error) {
|
||||
const query = `SELECT id, verCode, verName, url, md5, force, desc, model, hw, target, beta,
|
||||
pawVerCode, pawVerName, pawUrl, pawMd5, startTime, endTime, status
|
||||
FROM ota WHERE status = 1 AND model = ? AND hw = ? AND beta = ?
|
||||
AND id NOT IN (SELECT ota_id FROM black_list WHERE mac = ?)
|
||||
ORDER BY verCode DESC LIMIT 1`
|
||||
|
||||
var o model.OTA
|
||||
var desc, mdl sql.NullString
|
||||
var startTime, endTime sql.NullTime
|
||||
|
||||
err := r.db.QueryRowContext(ctx, query, modelVal, hw, beta, mac).Scan(
|
||||
&o.ID, &o.VerCode, &o.VerName, &o.URL, &o.MD5, &o.Force, &desc, &mdl,
|
||||
&o.HW, &o.Target, &o.Beta,
|
||||
&o.PawVerCode, &o.PawVerName, &o.PawURL, &o.PawMD5, &startTime, &endTime, &o.Status,
|
||||
)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query ota not in blacklist: %w", err)
|
||||
}
|
||||
|
||||
if desc.Valid {
|
||||
o.Desc = &desc.String
|
||||
}
|
||||
if mdl.Valid {
|
||||
o.Model = &mdl.String
|
||||
}
|
||||
if startTime.Valid {
|
||||
o.StartTime = &startTime.Time
|
||||
}
|
||||
if endTime.Valid {
|
||||
o.EndTime = &endTime.Time
|
||||
}
|
||||
return &o, nil
|
||||
}
|
||||
|
||||
// GetLatestOTANotTarget 查询最新一条非定向的 OTA 记录
|
||||
func (r *OTARepository) GetLatestOTANotTarget(ctx context.Context, modelVal string, hw, beta int) (*model.OTA, error) {
|
||||
const query = `SELECT id, verCode, verName, url, md5, force, desc, model, hw, target, beta,
|
||||
pawVerCode, pawVerName, pawUrl, pawMd5, startTime, endTime, status
|
||||
FROM ota WHERE status = 1 AND model = ? AND hw = ? AND beta = ? AND target = 0
|
||||
ORDER BY verCode DESC LIMIT 1`
|
||||
|
||||
var o model.OTA
|
||||
var desc, mdl sql.NullString
|
||||
var startTime, endTime sql.NullTime
|
||||
|
||||
err := r.db.QueryRowContext(ctx, query, modelVal, hw, beta).Scan(
|
||||
&o.ID, &o.VerCode, &o.VerName, &o.URL, &o.MD5, &o.Force, &desc, &mdl,
|
||||
&o.HW, &o.Target, &o.Beta,
|
||||
&o.PawVerCode, &o.PawVerName, &o.PawURL, &o.PawMD5, &startTime, &endTime, &o.Status,
|
||||
)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query ota not target: %w", err)
|
||||
}
|
||||
|
||||
if desc.Valid {
|
||||
o.Desc = &desc.String
|
||||
}
|
||||
if mdl.Valid {
|
||||
o.Model = &mdl.String
|
||||
}
|
||||
if startTime.Valid {
|
||||
o.StartTime = &startTime.Time
|
||||
}
|
||||
if endTime.Valid {
|
||||
o.EndTime = &endTime.Time
|
||||
}
|
||||
return &o, nil
|
||||
}
|
||||
|
||||
// IsInBlackList 检查 mac 是否在指定 ota_id 的黑名单中
|
||||
func (r *OTARepository) IsInBlackList(ctx context.Context, otaID int, mac string) (bool, error) {
|
||||
const query = `SELECT COUNT(*) FROM black_list WHERE ota_id = ? AND mac = ?`
|
||||
|
||||
var count int
|
||||
if err := r.db.QueryRowContext(ctx, query, otaID, mac).Scan(&count); err != nil {
|
||||
return false, fmt.Errorf("query black_list: %w", err)
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
// FindTargetDevice 检查 mac 是否在指定 ota_id 的定向设备中
|
||||
func (r *OTARepository) FindTargetDevice(ctx context.Context, otaID int, mac string) (*model.OTATargetDevice, error) {
|
||||
const query = `SELECT id, ota_id, mac_addr, type, create_at FROM ota_target_device WHERE ota_id = ? AND mac_addr = ?`
|
||||
|
||||
var d model.OTATargetDevice
|
||||
err := r.db.QueryRowContext(ctx, query, otaID, mac).Scan(&d.ID, &d.OTAID, &d.MacAddr, &d.Type, &d.CreateAt)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query ota_target_device: %w", err)
|
||||
}
|
||||
return &d, nil
|
||||
}
|
||||
@@ -27,6 +27,7 @@ func New(log *zap.Logger, db *sql.DB, searchClient *search.Client, rdb *redis.Cl
|
||||
// Repository
|
||||
brandRepo := repository.NewBrandRepository(db, brandCache)
|
||||
modelRepo := repository.NewModelRepository(db, modelCache)
|
||||
otaRepo := repository.NewOTARepository(db)
|
||||
|
||||
// Handler
|
||||
health := handler.NewHealthHandler()
|
||||
@@ -34,6 +35,7 @@ func New(log *zap.Logger, db *sql.DB, searchClient *search.Client, rdb *redis.Cl
|
||||
model := handler.NewModelHandler(modelRepo, log)
|
||||
modelList := handler.NewModelListHandler(searchClient, log)
|
||||
device := handler.NewDeviceHandler(rdb, log)
|
||||
ota := handler.NewOTAHandler(otaRepo, log)
|
||||
|
||||
v1 := r.Group("/api/v1")
|
||||
{
|
||||
@@ -46,6 +48,7 @@ func New(log *zap.Logger, db *sql.DB, searchClient *search.Client, rdb *redis.Cl
|
||||
audio.GET("/getModel", model.GetModel)
|
||||
audio.GET("/modelList", modelList.ModelList)
|
||||
audio.GET("/reportDevInfo", device.ReportDevInfo)
|
||||
audio.GET("/ota", ota.GetOTA)
|
||||
}
|
||||
|
||||
return r
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/luxsin/app-api/internal/model"
|
||||
"github.com/luxsin/app-api/internal/repository"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type DevicePersistTask struct {
|
||||
rdb *redis.Client
|
||||
repo *repository.DeviceRepository
|
||||
log *zap.Logger
|
||||
}
|
||||
|
||||
func NewDevicePersistTask(rdb *redis.Client, repo *repository.DeviceRepository, log *zap.Logger) *DevicePersistTask {
|
||||
return &DevicePersistTask{rdb: rdb, repo: repo, log: log}
|
||||
}
|
||||
|
||||
// Start 启动定时刷入协程,每 interval 执行一次
|
||||
func (t *DevicePersistTask) Start(interval time.Duration) {
|
||||
go func() {
|
||||
ticker := time.NewTicker(interval)
|
||||
defer ticker.Stop()
|
||||
|
||||
for range ticker.C {
|
||||
t.Persist()
|
||||
}
|
||||
}()
|
||||
t.log.Info("device persist task started", zap.String("interval", interval.String()))
|
||||
}
|
||||
|
||||
// Persist 从 Redis Hash devices 中读取数据刷入数据库
|
||||
func (t *DevicePersistTask) Persist() {
|
||||
ctx := context.Background()
|
||||
|
||||
// 获取 Redis Hash 所有数据
|
||||
devices, err := t.rdb.HGetAll(ctx, "devices").Result()
|
||||
if err != nil {
|
||||
t.log.Error("redis HGetAll devices failed", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
if len(devices) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
t.log.Info("persisting devices from redis", zap.Int("count", len(devices)))
|
||||
|
||||
var succeeded []string
|
||||
|
||||
for mac, jsonStr := range devices {
|
||||
var info struct {
|
||||
MacAddr string `json:"mac_addr"`
|
||||
Model string `json:"model"`
|
||||
ActiveDate string `json:"active_date"`
|
||||
IpAddr string `json:"ip_addr"`
|
||||
Ver string `json:"ver"`
|
||||
}
|
||||
|
||||
if err := json.Unmarshal([]byte(jsonStr), &info); err != nil {
|
||||
t.log.Error("unmarshal device info failed", zap.String("mac", mac), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
// 修复旧的无效日期格式(之前 active_date 使用了 Java 格式 yyyy-MM-dd)
|
||||
if info.ActiveDate == "" || info.ActiveDate == "yyyy-MM-dd" {
|
||||
info.ActiveDate = time.Now().Format("2006-01-02")
|
||||
}
|
||||
|
||||
deviceOk := t.persistDevice(ctx, info)
|
||||
activeOk := t.persistActive(ctx, info)
|
||||
|
||||
if deviceOk && activeOk {
|
||||
succeeded = append(succeeded, mac)
|
||||
}
|
||||
}
|
||||
|
||||
// 批量删除成功处理的记录
|
||||
if len(succeeded) > 0 {
|
||||
if err := t.rdb.HDel(ctx, "devices", succeeded...).Err(); err != nil {
|
||||
t.log.Error("redis HDel failed", zap.Int("count", len(succeeded)), zap.Error(err))
|
||||
} else {
|
||||
t.log.Info("devices persisted and removed from redis", zap.Int("count", len(succeeded)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// persistDevice 处理 user_device 表写入
|
||||
func (t *DevicePersistTask) persistDevice(ctx context.Context, info struct {
|
||||
MacAddr string `json:"mac_addr"`
|
||||
Model string `json:"model"`
|
||||
ActiveDate string `json:"active_date"`
|
||||
IpAddr string `json:"ip_addr"`
|
||||
Ver string `json:"ver"`
|
||||
}) bool {
|
||||
existing, err := t.repo.FindDeviceByMac(ctx, info.MacAddr)
|
||||
if err != nil {
|
||||
t.log.Error("find device by mac failed", zap.String("mac", info.MacAddr), zap.Error(err))
|
||||
return false
|
||||
}
|
||||
|
||||
if existing == nil {
|
||||
d := model.UserDevice{
|
||||
MacAddr: info.MacAddr,
|
||||
Model: info.Model,
|
||||
}
|
||||
if info.Ver != "" {
|
||||
d.Ver = &info.Ver
|
||||
}
|
||||
if err := t.repo.InsertDevice(ctx, d); err != nil {
|
||||
t.log.Error("insert user_device failed", zap.String("mac", info.MacAddr), zap.Error(err))
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
var ver *string
|
||||
if info.Ver != "" {
|
||||
ver = &info.Ver
|
||||
}
|
||||
if err := t.repo.UpdateDeviceVer(ctx, existing.ID, ver); err != nil {
|
||||
t.log.Error("update user_device failed", zap.String("mac", info.MacAddr), zap.Error(err))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// persistActive 处理 user_active 表写入
|
||||
func (t *DevicePersistTask) persistActive(ctx context.Context, info struct {
|
||||
MacAddr string `json:"mac_addr"`
|
||||
Model string `json:"model"`
|
||||
ActiveDate string `json:"active_date"`
|
||||
IpAddr string `json:"ip_addr"`
|
||||
Ver string `json:"ver"`
|
||||
}) bool {
|
||||
dbActive, err := t.repo.FindActiveByMacAndDate(ctx, info.MacAddr, info.ActiveDate)
|
||||
if err != nil {
|
||||
t.log.Error("find active by mac and date failed", zap.String("mac", info.MacAddr), zap.Error(err))
|
||||
return false
|
||||
}
|
||||
|
||||
if dbActive == nil {
|
||||
a := model.UserActive{
|
||||
MacAddr: info.MacAddr,
|
||||
Model: info.Model,
|
||||
ActiveDate: info.ActiveDate,
|
||||
IpAddr: info.IpAddr,
|
||||
}
|
||||
if err := t.repo.InsertActive(ctx, a); err != nil {
|
||||
t.log.Error("insert user_active failed", zap.String("mac", info.MacAddr), zap.Error(err))
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if err := t.repo.UpdateActiveIp(ctx, dbActive.ID, info.IpAddr); err != nil {
|
||||
t.log.Error("update user_active failed", zap.String("mac", info.MacAddr), zap.Error(err))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package encode
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// ClientPublicIP 按优先级从多个来源获取客户端公网 IP
|
||||
// 优先级:CF-Connecting-IP > X-Real-IP > X-Forwarded-For 第一个 > gin.ClientIP() 兜底
|
||||
func ClientPublicIP(c *gin.Context) string {
|
||||
// 1. CloudFlare 真实 IP
|
||||
if cfIP := strings.TrimSpace(c.GetHeader("CF-Connecting-IP")); cfIP != "" {
|
||||
if ip := parseIP(cfIP); ip != "" {
|
||||
return ip
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Nginx 等代理设置的真实 IP
|
||||
if realIP := strings.TrimSpace(c.GetHeader("X-Real-IP")); realIP != "" {
|
||||
if ip := parseIP(realIP); ip != "" {
|
||||
return ip
|
||||
}
|
||||
}
|
||||
|
||||
// 3. X-Forwarded-For:取第一个(最原始的客户端 IP)
|
||||
if xff := strings.TrimSpace(c.GetHeader("X-Forwarded-For")); xff != "" {
|
||||
// X-Forwarded-For: client, proxy1, proxy2
|
||||
parts := strings.SplitN(xff, ",", 2)
|
||||
if ip := parseIP(strings.TrimSpace(parts[0])); ip != "" {
|
||||
return ip
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Gin 内置兜底(会按 TrustedProxies 配置解析)
|
||||
return parseIP(c.ClientIP())
|
||||
}
|
||||
|
||||
// parseIP 从 host:port 或纯 IP 字符串中提取合法的 IP 地址
|
||||
func parseIP(addr string) string {
|
||||
// 尝试解析为 host:port
|
||||
if host, _, err := net.SplitHostPort(addr); err == nil {
|
||||
addr = host
|
||||
}
|
||||
|
||||
ip := net.ParseIP(addr)
|
||||
if ip == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
// 过滤内网地址,只返回公网 IP
|
||||
if !isPrivateIP(ip) {
|
||||
return addr
|
||||
}
|
||||
|
||||
// 内网地址也返回(开发环境或代理内网转发场景)
|
||||
return addr
|
||||
}
|
||||
|
||||
// isPrivateIP 判断是否为内网/保留 IP
|
||||
func isPrivateIP(ip net.IP) bool {
|
||||
privateRanges := []struct {
|
||||
cidr string
|
||||
}{
|
||||
{"10.0.0.0/8"},
|
||||
{"172.16.0.0/12"},
|
||||
{"192.168.0.0/16"},
|
||||
{"127.0.0.0/8"},
|
||||
{"169.254.0.0/16"},
|
||||
{"::1/128"},
|
||||
{"fc00::/7"},
|
||||
{"fe80::/10"},
|
||||
}
|
||||
|
||||
for _, r := range privateRanges {
|
||||
_, network, _ := net.ParseCIDR(r.cidr)
|
||||
if network.Contains(ip) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 90600 (9.6.0)
|
||||
Source Host : localhost:3306
|
||||
Source Schema : audio
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 90600 (9.6.0)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/05/2026 17:59:33
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for black_list
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `black_list`;
|
||||
CREATE TABLE `black_list` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`ota_id` int NOT NULL,
|
||||
`mac` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
|
||||
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 90600 (9.6.0)
|
||||
Source Host : localhost:3306
|
||||
Source Schema : audio
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 90600 (9.6.0)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/05/2026 17:59:03
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for ota
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `ota`;
|
||||
CREATE TABLE `ota` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`verCode` int NOT NULL,
|
||||
`verName` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`md5` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`force` tinyint NOT NULL DEFAULT 0 COMMENT '是否强升;0-否',
|
||||
`desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
|
||||
`model` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '对应的设备型号',
|
||||
`hw` int NOT NULL DEFAULT 0 COMMENT '硬件版本号',
|
||||
`target` tinyint NOT NULL DEFAULT 0 COMMENT '是否定向,1-是,0-否;否表示面向所有用户',
|
||||
`beta` tinyint NOT NULL DEFAULT 0 COMMENT '是否灰度,1-是,0-否',
|
||||
`pawVerCode` int NOT NULL DEFAULT 0,
|
||||
`pawVerName` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
|
||||
`pawUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
|
||||
`pawMd5` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
|
||||
`startTime` datetime NULL DEFAULT NULL COMMENT '升级开始时间',
|
||||
`endTime` datetime NULL DEFAULT NULL COMMENT '升级结束时间',
|
||||
`status` tinyint NOT NULL DEFAULT 1 COMMENT '是否可用',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 48 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 90600 (9.6.0)
|
||||
Source Host : localhost:3306
|
||||
Source Schema : audio
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 90600 (9.6.0)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/05/2026 17:59:11
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for ota_target_device
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `ota_target_device`;
|
||||
CREATE TABLE `ota_target_device` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`ota_id` int NOT NULL,
|
||||
`mac_addr` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`type` int NOT NULL DEFAULT 1 COMMENT '1-白名单;2-黑名单',
|
||||
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 90600 (9.6.0)
|
||||
Source Host : localhost:3306
|
||||
Source Schema : audio
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 90600 (9.6.0)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/05/2026 17:08:22
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for user_active
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user_active`;
|
||||
CREATE TABLE `user_active` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`mac_addr` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`active_date` date NOT NULL,
|
||||
`ip_addr` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`create_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`, `active_date`) USING BTREE,
|
||||
UNIQUE INDEX `mac_active_date`(`mac_addr` ASC, `active_date` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 45681 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC PARTITION BY RANGE (to_days(`active_date`))
|
||||
PARTITIONS 170
|
||||
(PARTITION `p20250716` VALUES LESS THAN (739813) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250717` VALUES LESS THAN (739814) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250718` VALUES LESS THAN (739815) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250719` VALUES LESS THAN (739816) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250720` VALUES LESS THAN (739817) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250721` VALUES LESS THAN (739818) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250722` VALUES LESS THAN (739819) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250723` VALUES LESS THAN (739820) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250724` VALUES LESS THAN (739821) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250725` VALUES LESS THAN (739822) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250726` VALUES LESS THAN (739823) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250727` VALUES LESS THAN (739824) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250728` VALUES LESS THAN (739825) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250729` VALUES LESS THAN (739826) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250730` VALUES LESS THAN (739827) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250731` VALUES LESS THAN (739828) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250801` VALUES LESS THAN (739829) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250802` VALUES LESS THAN (739830) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250803` VALUES LESS THAN (739831) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250804` VALUES LESS THAN (739832) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250805` VALUES LESS THAN (739833) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250806` VALUES LESS THAN (739834) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250807` VALUES LESS THAN (739835) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250808` VALUES LESS THAN (739836) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250809` VALUES LESS THAN (739837) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250810` VALUES LESS THAN (739838) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250811` VALUES LESS THAN (739839) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250812` VALUES LESS THAN (739840) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250813` VALUES LESS THAN (739841) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250814` VALUES LESS THAN (739842) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250815` VALUES LESS THAN (739843) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250816` VALUES LESS THAN (739844) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250817` VALUES LESS THAN (739845) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250818` VALUES LESS THAN (739846) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250819` VALUES LESS THAN (739847) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250820` VALUES LESS THAN (739848) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250821` VALUES LESS THAN (739849) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250822` VALUES LESS THAN (739850) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250823` VALUES LESS THAN (739851) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250824` VALUES LESS THAN (739852) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250825` VALUES LESS THAN (739853) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250826` VALUES LESS THAN (739854) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250827` VALUES LESS THAN (739855) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250828` VALUES LESS THAN (739856) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250829` VALUES LESS THAN (739857) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250830` VALUES LESS THAN (739858) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250831` VALUES LESS THAN (739859) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250901` VALUES LESS THAN (739860) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250902` VALUES LESS THAN (739861) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250903` VALUES LESS THAN (739862) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250904` VALUES LESS THAN (739863) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250905` VALUES LESS THAN (739864) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250906` VALUES LESS THAN (739865) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250907` VALUES LESS THAN (739866) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250908` VALUES LESS THAN (739867) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250909` VALUES LESS THAN (739868) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250910` VALUES LESS THAN (739869) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250911` VALUES LESS THAN (739870) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250912` VALUES LESS THAN (739871) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250913` VALUES LESS THAN (739872) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250914` VALUES LESS THAN (739873) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250915` VALUES LESS THAN (739874) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250916` VALUES LESS THAN (739875) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250917` VALUES LESS THAN (739876) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250918` VALUES LESS THAN (739877) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250919` VALUES LESS THAN (739878) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250920` VALUES LESS THAN (739879) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250921` VALUES LESS THAN (739880) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250922` VALUES LESS THAN (739881) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250923` VALUES LESS THAN (739882) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250924` VALUES LESS THAN (739883) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250925` VALUES LESS THAN (739884) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250926` VALUES LESS THAN (739885) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250927` VALUES LESS THAN (739886) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250928` VALUES LESS THAN (739887) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250929` VALUES LESS THAN (739888) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20250930` VALUES LESS THAN (739889) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251001` VALUES LESS THAN (739890) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251002` VALUES LESS THAN (739891) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251003` VALUES LESS THAN (739892) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251004` VALUES LESS THAN (739893) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251005` VALUES LESS THAN (739894) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251006` VALUES LESS THAN (739895) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251007` VALUES LESS THAN (739896) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251008` VALUES LESS THAN (739897) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251009` VALUES LESS THAN (739898) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251010` VALUES LESS THAN (739899) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251011` VALUES LESS THAN (739900) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251012` VALUES LESS THAN (739901) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251013` VALUES LESS THAN (739902) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251014` VALUES LESS THAN (739903) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251015` VALUES LESS THAN (739904) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251016` VALUES LESS THAN (739905) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251017` VALUES LESS THAN (739906) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251018` VALUES LESS THAN (739907) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251019` VALUES LESS THAN (739908) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251020` VALUES LESS THAN (739909) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251021` VALUES LESS THAN (739910) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251022` VALUES LESS THAN (739911) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251023` VALUES LESS THAN (739912) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251024` VALUES LESS THAN (739913) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251025` VALUES LESS THAN (739914) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251026` VALUES LESS THAN (739915) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251027` VALUES LESS THAN (739916) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251028` VALUES LESS THAN (739917) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251029` VALUES LESS THAN (739918) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251030` VALUES LESS THAN (739919) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251031` VALUES LESS THAN (739920) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251101` VALUES LESS THAN (739921) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251102` VALUES LESS THAN (739922) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251103` VALUES LESS THAN (739923) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251104` VALUES LESS THAN (739924) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251105` VALUES LESS THAN (739925) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251106` VALUES LESS THAN (739926) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251107` VALUES LESS THAN (739927) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251108` VALUES LESS THAN (739928) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251109` VALUES LESS THAN (739929) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251110` VALUES LESS THAN (739930) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251111` VALUES LESS THAN (739931) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251112` VALUES LESS THAN (739932) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251113` VALUES LESS THAN (739933) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251114` VALUES LESS THAN (739934) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251115` VALUES LESS THAN (739935) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251116` VALUES LESS THAN (739936) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251117` VALUES LESS THAN (739937) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251118` VALUES LESS THAN (739938) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251119` VALUES LESS THAN (739939) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251120` VALUES LESS THAN (739940) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251121` VALUES LESS THAN (739941) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251122` VALUES LESS THAN (739942) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251123` VALUES LESS THAN (739943) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251124` VALUES LESS THAN (739944) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251125` VALUES LESS THAN (739945) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251126` VALUES LESS THAN (739946) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251127` VALUES LESS THAN (739947) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251128` VALUES LESS THAN (739948) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251129` VALUES LESS THAN (739949) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251130` VALUES LESS THAN (739950) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251201` VALUES LESS THAN (739951) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251202` VALUES LESS THAN (739952) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251203` VALUES LESS THAN (739953) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251204` VALUES LESS THAN (739954) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251205` VALUES LESS THAN (739955) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251206` VALUES LESS THAN (739956) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251207` VALUES LESS THAN (739957) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251208` VALUES LESS THAN (739958) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251209` VALUES LESS THAN (739959) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251210` VALUES LESS THAN (739960) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251211` VALUES LESS THAN (739961) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251212` VALUES LESS THAN (739962) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251213` VALUES LESS THAN (739963) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251214` VALUES LESS THAN (739964) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251215` VALUES LESS THAN (739965) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251216` VALUES LESS THAN (739966) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251217` VALUES LESS THAN (739967) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251218` VALUES LESS THAN (739968) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251219` VALUES LESS THAN (739969) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251220` VALUES LESS THAN (739970) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251221` VALUES LESS THAN (739971) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251222` VALUES LESS THAN (739972) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251223` VALUES LESS THAN (739973) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251224` VALUES LESS THAN (739974) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251225` VALUES LESS THAN (739975) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251226` VALUES LESS THAN (739976) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251227` VALUES LESS THAN (739977) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251228` VALUES LESS THAN (739978) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251229` VALUES LESS THAN (739979) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251230` VALUES LESS THAN (739980) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `p20251231` VALUES LESS THAN (739981) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 ,
|
||||
PARTITION `pmax` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB MAX_ROWS = 0 MIN_ROWS = 0 )
|
||||
;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Navicat Premium Dump SQL
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 90600 (9.6.0)
|
||||
Source Host : localhost:3306
|
||||
Source Schema : audio
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 90600 (9.6.0)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 28/05/2026 17:08:30
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for user_device
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user_device`;
|
||||
CREATE TABLE `user_device` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`mac_addr` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`model` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`add_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`ver` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `mac`(`mac_addr` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 1214 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
Reference in New Issue
Block a user