This commit is contained in:
2026-06-22 11:24:08 +08:00
parent 4e1b30b3cc
commit a4af179c16
14 changed files with 612 additions and 36 deletions
+1
View File
@@ -58,6 +58,7 @@ func Init(_ string) {
new(SystemSoftwareUpgrade),
new(PlatformCursorEquipment),
new(PlatformCursorActivationCode),
new(PlatformCursorEquipmentIpLog),
new(PlatformAccountPoolKiro),
new(PlatformAccountPoolWindsurf),
new(PlatformAccountPoolCursor),
@@ -0,0 +1,31 @@
package models
import "time"
// PlatformCursorEquipmentIpLog 设备 IP 登录日志 yz_platform_cursor_equipment_ip_log
// 每次客户端调用 report / activateByCode 时,若携带 ipInfo 则写入一条记录。
type PlatformCursorEquipmentIpLog struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
EquipmentID uint64 `orm:"column(equipment_id);default(0)" json:"equipmentId"`
MachineCode string `orm:"column(machine_code);size(128)" json:"machineCode"`
Source string `orm:"column(source);size(32)" json:"source"`
Status string `orm:"column(status);size(32)" json:"status"`
Country string `orm:"column(country);size(64)" json:"country"`
CountryCode string `orm:"column(country_code);size(8)" json:"countryCode"`
Region string `orm:"column(region);size(16)" json:"region"`
RegionName string `orm:"column(region_name);size(128)" json:"regionName"`
City string `orm:"column(city);size(128)" json:"city"`
Zip string `orm:"column(zip);size(32)" json:"zip"`
Lat float64 `orm:"column(lat)" json:"lat"`
Lon float64 `orm:"column(lon)" json:"lon"`
Timezone string `orm:"column(timezone);size(64)" json:"timezone"`
ISP string `orm:"column(isp);size(255)" json:"isp"`
Org string `orm:"column(org);size(255)" json:"org"`
AsInfo string `orm:"column(as_info);size(255)" json:"asInfo"`
Query string `orm:"column(query);size(64)" json:"query"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"createTime"`
}
func (m *PlatformCursorEquipmentIpLog) TableName() string {
return "yz_platform_cursor_equipment_ip_log"
}
+29
View File
@@ -0,0 +1,29 @@
package models
// GetPlatformSettingValue 从 yz_system_tenant_setting_items 表中读取平台级别(tid=0)的配置值。
// key 不存在或读取失败时返回空字符串。
func GetPlatformSettingValue(key string) string {
type row struct {
SettingValue string
}
var r row
// tid=0 表示平台全局配置,与租户无关
err := Orm.Raw(
"SELECT IFNULL(setting_value, '') AS setting_value FROM yz_system_tenant_setting_items WHERE tid = 0 AND setting_key = ? AND delete_time IS NULL LIMIT 1",
key,
).QueryRow(&r)
if err != nil {
return ""
}
return r.SettingValue
}
// SetPlatformSettingValue 写入或更新平台级别(tid=0)的配置值。
func SetPlatformSettingValue(key, value string) error {
_, err := Orm.Raw(`
INSERT INTO yz_system_tenant_setting_items (tid, setting_key, setting_value, create_time, update_time)
VALUES (0, ?, ?, NOW(), NOW())
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value), update_time = NOW(), delete_time = NULL
`, key, value).Exec()
return err
}