gengxin
This commit is contained in:
parent
4e1b30b3cc
commit
a4af179c16
@ -16,44 +16,91 @@ type ApiCursorEquipmentController struct {
|
|||||||
beego.Controller
|
beego.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cursorIpInfo 对应 ip-api.com 返回的 JSON 结构
|
||||||
|
type cursorIpInfo struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
Country string `json:"country"`
|
||||||
|
CountryCode string `json:"countryCode"`
|
||||||
|
Region string `json:"region"`
|
||||||
|
RegionName string `json:"regionName"`
|
||||||
|
City string `json:"city"`
|
||||||
|
Zip string `json:"zip"`
|
||||||
|
Lat float64 `json:"lat"`
|
||||||
|
Lon float64 `json:"lon"`
|
||||||
|
Timezone string `json:"timezone"`
|
||||||
|
ISP string `json:"isp"`
|
||||||
|
Org string `json:"org"`
|
||||||
|
As string `json:"as"`
|
||||||
|
Query string `json:"query"`
|
||||||
|
}
|
||||||
|
|
||||||
type cursorEquipmentReportPayload struct {
|
type cursorEquipmentReportPayload struct {
|
||||||
DeviceInfo string `json:"deviceInfo"`
|
DeviceInfo string `json:"deviceInfo"`
|
||||||
DeviceInfoSnake string `json:"device_info"`
|
DeviceInfoSnake string `json:"device_info"`
|
||||||
MachineCode string `json:"machineCode"`
|
MachineCode string `json:"machineCode"`
|
||||||
MachineCodeSnake string `json:"machine_code"`
|
MachineCodeSnake string `json:"machine_code"`
|
||||||
Status *int8 `json:"status"`
|
Status *int8 `json:"status"`
|
||||||
System string `json:"system"`
|
System string `json:"system"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
BindAccount string `json:"bindAccount"`
|
BindAccount string `json:"bindAccount"`
|
||||||
BindAccountSnake string `json:"bind_account"`
|
BindAccountSnake string `json:"bind_account"`
|
||||||
OwnerUserID *uint64 `json:"ownerUserId"`
|
OwnerUserID *uint64 `json:"ownerUserId"`
|
||||||
OwnerUserIDSnake *uint64 `json:"owner_user_id"`
|
OwnerUserIDSnake *uint64 `json:"owner_user_id"`
|
||||||
OwnerUserName string `json:"ownerUserName"`
|
OwnerUserName string `json:"ownerUserName"`
|
||||||
OwnerUserNameSnake string `json:"owner_user_name"`
|
OwnerUserNameSnake string `json:"owner_user_name"`
|
||||||
ActivationTime string `json:"activationTime"`
|
ActivationTime string `json:"activationTime"`
|
||||||
ActivationTimeSnake string `json:"activation_time"`
|
ActivationTimeSnake string `json:"activation_time"`
|
||||||
ExpireTime string `json:"expireTime"`
|
ExpireTime string `json:"expireTime"`
|
||||||
ExpireTimeSnake string `json:"expire_time"`
|
ExpireTimeSnake string `json:"expire_time"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
|
IpInfo *cursorIpInfo `json:"ipInfo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type cursorEquipmentActivatePayload struct {
|
type cursorEquipmentActivatePayload struct {
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
ActivationCode string `json:"activationCode"`
|
ActivationCode string `json:"activationCode"`
|
||||||
ActivationCodeSnake string `json:"activation_code"`
|
ActivationCodeSnake string `json:"activation_code"`
|
||||||
DeviceInfo string `json:"deviceInfo"`
|
DeviceInfo string `json:"deviceInfo"`
|
||||||
DeviceInfoSnake string `json:"device_info"`
|
DeviceInfoSnake string `json:"device_info"`
|
||||||
MachineCode string `json:"machineCode"`
|
MachineCode string `json:"machineCode"`
|
||||||
MachineCodeSnake string `json:"machine_code"`
|
MachineCodeSnake string `json:"machine_code"`
|
||||||
System string `json:"system"`
|
System string `json:"system"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
BindAccount string `json:"bindAccount"`
|
BindAccount string `json:"bindAccount"`
|
||||||
BindAccountSnake string `json:"bind_account"`
|
BindAccountSnake string `json:"bind_account"`
|
||||||
OwnerUserID *uint64 `json:"ownerUserId"`
|
OwnerUserID *uint64 `json:"ownerUserId"`
|
||||||
OwnerUserIDSnake *uint64 `json:"owner_user_id"`
|
OwnerUserIDSnake *uint64 `json:"owner_user_id"`
|
||||||
OwnerUserName string `json:"ownerUserName"`
|
OwnerUserName string `json:"ownerUserName"`
|
||||||
OwnerUserNameSnake string `json:"owner_user_name"`
|
OwnerUserNameSnake string `json:"owner_user_name"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
|
IpInfo *cursorIpInfo `json:"ipInfo"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// cursorSaveIpLog 将 ipInfo 写入设备 IP 日志表(异步,失败不影响主流程)
|
||||||
|
func cursorSaveIpLog(equipmentID uint64, machineCode, source string, ip *cursorIpInfo) {
|
||||||
|
if ip == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log := &models.PlatformCursorEquipmentIpLog{
|
||||||
|
EquipmentID: equipmentID,
|
||||||
|
MachineCode: machineCode,
|
||||||
|
Source: source,
|
||||||
|
Status: ip.Status,
|
||||||
|
Country: ip.Country,
|
||||||
|
CountryCode: ip.CountryCode,
|
||||||
|
Region: ip.Region,
|
||||||
|
RegionName: ip.RegionName,
|
||||||
|
City: ip.City,
|
||||||
|
Zip: ip.Zip,
|
||||||
|
Lat: ip.Lat,
|
||||||
|
Lon: ip.Lon,
|
||||||
|
Timezone: ip.Timezone,
|
||||||
|
ISP: ip.ISP,
|
||||||
|
Org: ip.Org,
|
||||||
|
AsInfo: ip.As,
|
||||||
|
Query: ip.Query,
|
||||||
|
}
|
||||||
|
_, _ = models.Orm.Insert(log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cursorFirstNonEmpty(values ...string) string {
|
func cursorFirstNonEmpty(values ...string) string {
|
||||||
@ -293,6 +340,9 @@ func (c *ApiCursorEquipmentController) Report() {
|
|||||||
row.UpdateTime = &now
|
row.UpdateTime = &now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录 IP 日志
|
||||||
|
cursorSaveIpLog(row.ID, machineCode, "report", p.IpInfo)
|
||||||
|
|
||||||
// 查询该设备最新激活码,补全激活时间和到期时间
|
// 查询该设备最新激活码,补全激活时间和到期时间
|
||||||
var retActivationTime interface{} = row.ActivationTime
|
var retActivationTime interface{} = row.ActivationTime
|
||||||
var retExpireTime interface{} = row.ExpireTime
|
var retExpireTime interface{} = row.ExpireTime
|
||||||
@ -569,6 +619,9 @@ func (c *ApiCursorEquipmentController) ActivateByCode() {
|
|||||||
}
|
}
|
||||||
rollback = false
|
rollback = false
|
||||||
|
|
||||||
|
// 记录 IP 日志
|
||||||
|
cursorSaveIpLog(device.ID, machineCode, "activateByCode", p.IpInfo)
|
||||||
|
|
||||||
c.jsonResult(200, "success", map[string]interface{}{
|
c.jsonResult(200, "success", map[string]interface{}{
|
||||||
"activated": true,
|
"activated": true,
|
||||||
"reused": false,
|
"reused": false,
|
||||||
|
|||||||
@ -143,6 +143,40 @@ func (c *PlatformCursorEquipmentController) rowToMap(row *models.PlatformCursorE
|
|||||||
lastExtractedAt = latestExtract.ExtractedTime
|
lastExtractedAt = latestExtract.ExtractedTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询该设备最近一条 IP 日志
|
||||||
|
var lastLoginIp interface{}
|
||||||
|
var lastLoginIpInfo interface{}
|
||||||
|
var latestIpLog models.PlatformCursorEquipmentIpLog
|
||||||
|
ipCond := orm.NewCondition().
|
||||||
|
AndCond(orm.NewCondition().
|
||||||
|
Or("equipment_id", row.ID).
|
||||||
|
Or("machine_code", row.MachineCode))
|
||||||
|
if err := models.Orm.QueryTable(new(models.PlatformCursorEquipmentIpLog)).
|
||||||
|
SetCond(ipCond).
|
||||||
|
OrderBy("-id").
|
||||||
|
One(&latestIpLog); err == nil {
|
||||||
|
lastLoginIp = latestIpLog.Query
|
||||||
|
lastLoginIpInfo = map[string]interface{}{
|
||||||
|
"id": latestIpLog.ID,
|
||||||
|
"source": latestIpLog.Source,
|
||||||
|
"status": latestIpLog.Status,
|
||||||
|
"country": latestIpLog.Country,
|
||||||
|
"countryCode": latestIpLog.CountryCode,
|
||||||
|
"region": latestIpLog.Region,
|
||||||
|
"regionName": latestIpLog.RegionName,
|
||||||
|
"city": latestIpLog.City,
|
||||||
|
"zip": latestIpLog.Zip,
|
||||||
|
"lat": latestIpLog.Lat,
|
||||||
|
"lon": latestIpLog.Lon,
|
||||||
|
"timezone": latestIpLog.Timezone,
|
||||||
|
"isp": latestIpLog.ISP,
|
||||||
|
"org": latestIpLog.Org,
|
||||||
|
"asInfo": latestIpLog.AsInfo,
|
||||||
|
"query": latestIpLog.Query,
|
||||||
|
"createTime": latestIpLog.CreateTime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"id": row.ID,
|
"id": row.ID,
|
||||||
"deviceInfo": row.DeviceInfo,
|
"deviceInfo": row.DeviceInfo,
|
||||||
@ -164,6 +198,8 @@ func (c *PlatformCursorEquipmentController) rowToMap(row *models.PlatformCursorE
|
|||||||
"activationCount": activationCount,
|
"activationCount": activationCount,
|
||||||
"extractCount": extractCount,
|
"extractCount": extractCount,
|
||||||
"lastExtractedAt": lastExtractedAt,
|
"lastExtractedAt": lastExtractedAt,
|
||||||
|
"lastLoginIp": lastLoginIp,
|
||||||
|
"lastLoginIpInfo": lastLoginIpInfo,
|
||||||
"remark": row.Remark,
|
"remark": row.Remark,
|
||||||
"createTime": row.CreateTime,
|
"createTime": row.CreateTime,
|
||||||
"updateTime": row.UpdateTime,
|
"updateTime": row.UpdateTime,
|
||||||
@ -679,3 +715,85 @@ func (c *PlatformCursorEquipmentController) ExtractRecords() {
|
|||||||
"pageSize": pageSize,
|
"pageSize": pageSize,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IpLogs GET /platform/cursor/equipment/ipLogs?equipmentId=1
|
||||||
|
func (c *PlatformCursorEquipmentController) IpLogs() {
|
||||||
|
if _, err := c.platformClaims(); err != nil {
|
||||||
|
c.jsonErr(401, 401, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
equipmentID, _ := c.GetUint64("equipmentId")
|
||||||
|
if equipmentID == 0 {
|
||||||
|
equipmentID, _ = c.GetUint64("id")
|
||||||
|
}
|
||||||
|
if equipmentID == 0 {
|
||||||
|
c.jsonErr(400, 400, "缺少设备ID")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var equipment models.PlatformCursorEquipment
|
||||||
|
if err := models.Orm.QueryTable(new(models.PlatformCursorEquipment)).
|
||||||
|
Filter("id", equipmentID).
|
||||||
|
Filter("delete_time__isnull", true).
|
||||||
|
One(&equipment); err != nil {
|
||||||
|
c.jsonErr(404, 404, "设备不存在")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
page, _ := c.GetInt("page", 1)
|
||||||
|
pageSize, _ := c.GetInt("pageSize", 20)
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
if pageSize < 1 {
|
||||||
|
pageSize = 20
|
||||||
|
}
|
||||||
|
if pageSize > 200 {
|
||||||
|
pageSize = 200
|
||||||
|
}
|
||||||
|
|
||||||
|
ipCond := orm.NewCondition().
|
||||||
|
AndCond(orm.NewCondition().
|
||||||
|
Or("equipment_id", equipment.ID).
|
||||||
|
Or("machine_code", equipment.MachineCode))
|
||||||
|
|
||||||
|
qs := models.Orm.QueryTable(new(models.PlatformCursorEquipmentIpLog)).SetCond(ipCond)
|
||||||
|
total, _ := qs.Count()
|
||||||
|
|
||||||
|
var rows []models.PlatformCursorEquipmentIpLog
|
||||||
|
if _, err := qs.OrderBy("-id").Limit(pageSize, (page-1)*pageSize).All(&rows); err != nil {
|
||||||
|
c.jsonErr(500, 500, "获取 IP 日志失败: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
list := make([]map[string]interface{}, 0, len(rows))
|
||||||
|
for _, row := range rows {
|
||||||
|
list = append(list, map[string]interface{}{
|
||||||
|
"id": row.ID,
|
||||||
|
"source": row.Source,
|
||||||
|
"status": row.Status,
|
||||||
|
"country": row.Country,
|
||||||
|
"countryCode": row.CountryCode,
|
||||||
|
"region": row.Region,
|
||||||
|
"regionName": row.RegionName,
|
||||||
|
"city": row.City,
|
||||||
|
"zip": row.Zip,
|
||||||
|
"lat": row.Lat,
|
||||||
|
"lon": row.Lon,
|
||||||
|
"timezone": row.Timezone,
|
||||||
|
"isp": row.ISP,
|
||||||
|
"org": row.Org,
|
||||||
|
"asInfo": row.AsInfo,
|
||||||
|
"query": row.Query,
|
||||||
|
"createTime": row.CreateTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
c.ok(map[string]interface{}{
|
||||||
|
"list": list,
|
||||||
|
"total": total,
|
||||||
|
"page": page,
|
||||||
|
"pageSize": pageSize,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ func Init(_ string) {
|
|||||||
new(SystemSoftwareUpgrade),
|
new(SystemSoftwareUpgrade),
|
||||||
new(PlatformCursorEquipment),
|
new(PlatformCursorEquipment),
|
||||||
new(PlatformCursorActivationCode),
|
new(PlatformCursorActivationCode),
|
||||||
|
new(PlatformCursorEquipmentIpLog),
|
||||||
new(PlatformAccountPoolKiro),
|
new(PlatformAccountPoolKiro),
|
||||||
new(PlatformAccountPoolWindsurf),
|
new(PlatformAccountPoolWindsurf),
|
||||||
new(PlatformAccountPoolCursor),
|
new(PlatformAccountPoolCursor),
|
||||||
|
|||||||
31
go/models/platform_cursor_equipment_ip_log.go
Normal file
31
go/models/platform_cursor_equipment_ip_log.go
Normal file
@ -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
go/models/platform_setting.go
Normal file
29
go/models/platform_setting.go
Normal 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
|
||||||
|
}
|
||||||
@ -171,6 +171,7 @@ func Register() {
|
|||||||
beego.Router("/platform/cursor/equipment/activate", &controllers.PlatformCursorEquipmentController{}, "post:Activate")
|
beego.Router("/platform/cursor/equipment/activate", &controllers.PlatformCursorEquipmentController{}, "post:Activate")
|
||||||
beego.Router("/platform/cursor/equipment/activationRecords", &controllers.PlatformCursorEquipmentController{}, "get:ActivationRecords")
|
beego.Router("/platform/cursor/equipment/activationRecords", &controllers.PlatformCursorEquipmentController{}, "get:ActivationRecords")
|
||||||
beego.Router("/platform/cursor/equipment/extractRecords", &controllers.PlatformCursorEquipmentController{}, "get:ExtractRecords")
|
beego.Router("/platform/cursor/equipment/extractRecords", &controllers.PlatformCursorEquipmentController{}, "get:ExtractRecords")
|
||||||
|
beego.Router("/platform/cursor/equipment/ipLogs", &controllers.PlatformCursorEquipmentController{}, "get:IpLogs")
|
||||||
|
|
||||||
// Cursor 激活码管理(yz_platform_cursor_activation_code)
|
// Cursor 激活码管理(yz_platform_cursor_activation_code)
|
||||||
beego.Router("/platform/cursor/activationcode/list", &controllers.PlatformCursorActivationCodeController{}, "get:List")
|
beego.Router("/platform/cursor/activationcode/list", &controllers.PlatformCursorActivationCodeController{}, "get:List")
|
||||||
|
|||||||
2
platform/components.d.ts
vendored
2
platform/components.d.ts
vendored
@ -18,7 +18,6 @@ declare module 'vue' {
|
|||||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||||
ElBacktop: typeof import('element-plus/es')['ElBacktop']
|
ElBacktop: typeof import('element-plus/es')['ElBacktop']
|
||||||
ElButton: typeof import('element-plus/es')['ElButton']
|
ElButton: typeof import('element-plus/es')['ElButton']
|
||||||
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
|
|
||||||
ElCard: typeof import('element-plus/es')['ElCard']
|
ElCard: typeof import('element-plus/es')['ElCard']
|
||||||
ElCascader: typeof import('element-plus/es')['ElCascader']
|
ElCascader: typeof import('element-plus/es')['ElCascader']
|
||||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||||
@ -40,7 +39,6 @@ declare module 'vue' {
|
|||||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||||
ElIcon: typeof import('element-plus/es')['ElIcon']
|
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||||
ElImage: typeof import('element-plus/es')['ElImage']
|
|
||||||
ElInput: typeof import('element-plus/es')['ElInput']
|
ElInput: typeof import('element-plus/es')['ElInput']
|
||||||
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
||||||
ElLink: typeof import('element-plus/es')['ElLink']
|
ElLink: typeof import('element-plus/es')['ElLink']
|
||||||
|
|||||||
@ -63,3 +63,11 @@ export function getCursorEquipmentExtractRecords(params) {
|
|||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCursorEquipmentIpLogs(params) {
|
||||||
|
return request({
|
||||||
|
url: `${baseUrl}/ipLogs`,
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -88,3 +88,11 @@ export function getCursorEquipmentExtractRecords(params: Record<string, any>) {
|
|||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCursorEquipmentIpLogs(params: Record<string, any>) {
|
||||||
|
return request({
|
||||||
|
url: `${baseUrl}/ipLogs`,
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -42,6 +42,12 @@ function copyText(text: unknown, label = '内容') {
|
|||||||
ElMessage.success(`${label}已复制`);
|
ElMessage.success(`${label}已复制`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sourceLabel(source: string) {
|
||||||
|
if (source === 'report') return '心跳上报';
|
||||||
|
if (source === 'activateByCode') return '激活码激活';
|
||||||
|
return source || '-';
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -111,6 +117,59 @@ function copyText(text: unknown, label = '内容') {
|
|||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
|
|
||||||
|
<!-- IP 信息区块 -->
|
||||||
|
<template v-if="row.raw?.lastLoginIpInfo || row.lastLoginIpInfo">
|
||||||
|
<el-divider content-position="left">最后登录 IP 详情</el-divider>
|
||||||
|
<el-descriptions :column="2" border size="small">
|
||||||
|
<el-descriptions-item label="出口 IP">
|
||||||
|
<span class="ip-text">{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.query) }}</span>
|
||||||
|
<el-button
|
||||||
|
v-if="(row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.query"
|
||||||
|
link type="primary"
|
||||||
|
@click="copyText((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.query, 'IP 地址')"
|
||||||
|
>复制</el-button>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="来源">
|
||||||
|
{{ sourceLabel((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.source) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="国家">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.country) }}
|
||||||
|
<span v-if="(row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.countryCode" class="country-code">
|
||||||
|
({{ (row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.countryCode }})
|
||||||
|
</span>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="省/州">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.regionName) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="城市">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.city) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="时区">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.timezone) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="ISP 运营商" :span="2">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.isp) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="组织" :span="2">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.org) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="AS 信息" :span="2">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.asInfo) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="经纬度">
|
||||||
|
{{ (row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.lat }},
|
||||||
|
{{ (row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.lon }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="上报时间">
|
||||||
|
{{ display((row.raw?.lastLoginIpInfo || row.lastLoginIpInfo)?.createTime) }}
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<el-divider content-position="left">最后登录 IP 详情</el-divider>
|
||||||
|
<div class="no-ip-tip">暂无 IP 记录(客户端未上报 ipInfo)</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="emit('update:modelValue', false)">关闭</el-button>
|
<el-button @click="emit('update:modelValue', false)">关闭</el-button>
|
||||||
</template>
|
</template>
|
||||||
@ -132,6 +191,24 @@ function copyText(text: unknown, label = '内容') {
|
|||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ip-text {
|
||||||
|
font-family: monospace;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.country-code {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-ip-tip {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 12px 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
:deep(.equipment-detail-dialog) {
|
:deep(.equipment-detail-dialog) {
|
||||||
max-width: calc(100vw - 24px);
|
max-width: calc(100vw - 24px);
|
||||||
}
|
}
|
||||||
|
|||||||
151
platform/src/views/cursor/equipment/components/ipLogs.vue
Normal file
151
platform/src/views/cursor/equipment/components/ipLogs.vue
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: { type: Boolean, default: false },
|
||||||
|
row: { type: Object, default: null },
|
||||||
|
loading: { type: Boolean, default: false },
|
||||||
|
records: { type: Array as () => Record<string, any>[], default: () => [] },
|
||||||
|
total: { type: Number, default: 0 },
|
||||||
|
page: { type: Number, default: 1 },
|
||||||
|
pageSize: { type: Number, default: 20 },
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits([
|
||||||
|
'update:modelValue',
|
||||||
|
'update:page',
|
||||||
|
'update:page-size',
|
||||||
|
'refresh',
|
||||||
|
]);
|
||||||
|
|
||||||
|
function handleOpen() {
|
||||||
|
emit('refresh');
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime(value: any) {
|
||||||
|
if (!value) return '-';
|
||||||
|
const d = new Date(value);
|
||||||
|
if (Number.isNaN(d.getTime())) return String(value);
|
||||||
|
const p = (v: number) => String(v).padStart(2, '0');
|
||||||
|
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sourceLabel(source: string) {
|
||||||
|
if (source === 'report') return '心跳上报';
|
||||||
|
if (source === 'activateByCode') return '激活码激活';
|
||||||
|
return source || '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyText(text: unknown, label = '内容') {
|
||||||
|
const value = String(text || '').trim();
|
||||||
|
if (!value) {
|
||||||
|
ElMessage.warning(`暂无${label}可复制`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
navigator.clipboard.writeText(value).then(() => {
|
||||||
|
ElMessage.success(`${label}已复制`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
class="ip-logs-dialog"
|
||||||
|
:model-value="modelValue"
|
||||||
|
title="IP 登录日志"
|
||||||
|
width="900px"
|
||||||
|
@update:model-value="(v: boolean) => emit('update:modelValue', v)"
|
||||||
|
@open="handleOpen"
|
||||||
|
>
|
||||||
|
<div class="dialog-desc" v-if="row">
|
||||||
|
<span>设备:{{ row.machineCode || row.id || '-' }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="records" border stripe size="small" style="width: 100%">
|
||||||
|
<el-table-column label="IP 地址" width="140" prop="query">
|
||||||
|
<template #default="{ row: r }">
|
||||||
|
<span class="ip-text">{{ r.query || '-' }}</span>
|
||||||
|
<el-button v-if="r.query" link size="small" type="primary" @click="copyText(r.query, 'IP')">复制</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="来源" width="110" align="center">
|
||||||
|
<template #default="{ row: r }">
|
||||||
|
<el-tag size="small" :type="r.source === 'activateByCode' ? 'warning' : 'info'">
|
||||||
|
{{ sourceLabel(r.source) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="国家 / 地区" min-width="140">
|
||||||
|
<template #default="{ row: r }">
|
||||||
|
<span>{{ r.country || '-' }}</span>
|
||||||
|
<span v-if="r.countryCode" class="country-code">({{ r.countryCode }})</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="城市" width="110" prop="city">
|
||||||
|
<template #default="{ row: r }">{{ r.city || '-' }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="ISP 运营商" min-width="200" show-overflow-tooltip prop="isp">
|
||||||
|
<template #default="{ row: r }">{{ r.isp || '-' }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="时区" width="140" show-overflow-tooltip prop="timezone">
|
||||||
|
<template #default="{ row: r }">{{ r.timezone || '-' }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="上报时间" width="170">
|
||||||
|
<template #default="{ row: r }">{{ formatTime(r.createTime) }}</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
class="pager"
|
||||||
|
:current-page="page"
|
||||||
|
:page-size="pageSize"
|
||||||
|
background
|
||||||
|
layout="total, sizes, prev, pager, next"
|
||||||
|
:page-sizes="[20, 50, 100]"
|
||||||
|
:total="total"
|
||||||
|
@current-change="(v: number) => emit('update:page', v)"
|
||||||
|
@size-change="(v: number) => emit('update:page-size', v)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="emit('update:modelValue', false)">关闭</el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="emit('refresh')">刷新</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.dialog-desc {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
color: #606266;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ip-text {
|
||||||
|
font-family: monospace;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.country-code {
|
||||||
|
color: #909399;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pager {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ip-logs-dialog) {
|
||||||
|
max-width: calc(100vw - 24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
:deep(.ip-logs-dialog) {
|
||||||
|
width: calc(100vw - 24px) !important;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -6,6 +6,7 @@ import EditDialog from './components/edit.vue';
|
|||||||
import DeleteDialog from './components/delete.vue';
|
import DeleteDialog from './components/delete.vue';
|
||||||
import ActivationRecords from './components/activationRecords.vue';
|
import ActivationRecords from './components/activationRecords.vue';
|
||||||
import ExtractRecords from './components/extractRecords.vue';
|
import ExtractRecords from './components/extractRecords.vue';
|
||||||
|
import IpLogs from './components/ipLogs.vue';
|
||||||
import {
|
import {
|
||||||
activateCursorEquipment,
|
activateCursorEquipment,
|
||||||
addCursorEquipment,
|
addCursorEquipment,
|
||||||
@ -13,6 +14,7 @@ import {
|
|||||||
getCursorEquipmentActivationRecords,
|
getCursorEquipmentActivationRecords,
|
||||||
getCursorEquipmentDetail,
|
getCursorEquipmentDetail,
|
||||||
getCursorEquipmentExtractRecords,
|
getCursorEquipmentExtractRecords,
|
||||||
|
getCursorEquipmentIpLogs,
|
||||||
getCursorEquipmentList,
|
getCursorEquipmentList,
|
||||||
updateCursorEquipment,
|
updateCursorEquipment,
|
||||||
} from '../../../api/cursorEquipment';
|
} from '../../../api/cursorEquipment';
|
||||||
@ -59,6 +61,16 @@ const extractState = reactive({
|
|||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ipLogsState = reactive({
|
||||||
|
loading: false,
|
||||||
|
records: [] as EquipmentRow[],
|
||||||
|
total: 0,
|
||||||
|
page: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
});
|
||||||
|
|
||||||
|
const ipLogsVisible = ref(false);
|
||||||
|
|
||||||
const statusOptions = [
|
const statusOptions = [
|
||||||
{ label: '未激活', value: 0 },
|
{ label: '未激活', value: 0 },
|
||||||
{ label: '已激活', value: 1 },
|
{ label: '已激活', value: 1 },
|
||||||
@ -122,6 +134,13 @@ watch(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [ipLogsState.page, ipLogsState.pageSize],
|
||||||
|
() => {
|
||||||
|
if (ipLogsVisible.value) fetchIpLogs();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
function pick(raw: any, ...keys: string[]) {
|
function pick(raw: any, ...keys: string[]) {
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (raw?.[key] !== undefined && raw?.[key] !== null) return raw[key];
|
if (raw?.[key] !== undefined && raw?.[key] !== null) return raw[key];
|
||||||
@ -167,6 +186,8 @@ function normalizeRow(raw: any): EquipmentRow {
|
|||||||
lastExtractedAt: formatTime(pick(raw, 'last_extracted_at', 'lastExtractedAt', 'extracted_at')),
|
lastExtractedAt: formatTime(pick(raw, 'last_extracted_at', 'lastExtractedAt', 'extracted_at')),
|
||||||
expiredAt: formatTime(pick(raw, 'expiredAt', 'expired_at', 'expireTime', 'expire_time')),
|
expiredAt: formatTime(pick(raw, 'expiredAt', 'expired_at', 'expireTime', 'expire_time')),
|
||||||
createdAt: formatTime(pick(raw, 'create_time', 'created_at', 'createdAt', 'CreatedAt')),
|
createdAt: formatTime(pick(raw, 'create_time', 'created_at', 'createdAt', 'CreatedAt')),
|
||||||
|
lastLoginIp: pick(raw, 'lastLoginIp', 'last_login_ip') || '',
|
||||||
|
lastLoginIpInfo: raw?.lastLoginIpInfo ?? null,
|
||||||
remark: pick(raw, 'remark', 'Remark'),
|
remark: pick(raw, 'remark', 'Remark'),
|
||||||
raw,
|
raw,
|
||||||
};
|
};
|
||||||
@ -343,6 +364,14 @@ function openExtractRecords(row: EquipmentRow) {
|
|||||||
extractVisible.value = true;
|
extractVisible.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openIpLogs(row: EquipmentRow) {
|
||||||
|
currentRow.value = row;
|
||||||
|
ipLogsState.page = 1;
|
||||||
|
ipLogsState.records = [];
|
||||||
|
ipLogsState.total = 0;
|
||||||
|
ipLogsVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchActivationRecords() {
|
async function fetchActivationRecords() {
|
||||||
if (!currentRow.value?.id) return;
|
if (!currentRow.value?.id) return;
|
||||||
activationState.loading = true;
|
activationState.loading = true;
|
||||||
@ -385,6 +414,27 @@ async function fetchExtractRecords() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchIpLogs() {
|
||||||
|
if (!currentRow.value?.id) return;
|
||||||
|
ipLogsState.loading = true;
|
||||||
|
try {
|
||||||
|
const res = await getCursorEquipmentIpLogs({
|
||||||
|
equipmentId: currentRow.value.id,
|
||||||
|
page: ipLogsState.page,
|
||||||
|
pageSize: ipLogsState.pageSize,
|
||||||
|
});
|
||||||
|
if (res?.code !== 200) {
|
||||||
|
ElMessage.error(res?.msg || '获取 IP 日志失败');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const list = Array.isArray(res?.data?.list) ? res.data.list : Array.isArray(res?.data) ? res.data : [];
|
||||||
|
ipLogsState.records = list;
|
||||||
|
ipLogsState.total = Number(res?.data?.total || list.length || 0);
|
||||||
|
} finally {
|
||||||
|
ipLogsState.loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateDeviceType() {
|
function updateDeviceType() {
|
||||||
isMobile.value = window.innerWidth <= 768;
|
isMobile.value = window.innerWidth <= 768;
|
||||||
}
|
}
|
||||||
@ -483,6 +533,11 @@ onUnmounted(() => {
|
|||||||
<el-table-column prop="lastActivatedAt" label="最后激活" width="180">
|
<el-table-column prop="lastActivatedAt" label="最后激活" width="180">
|
||||||
<template #default="{ row }">{{ row.lastActivatedAt || '-' }}</template>
|
<template #default="{ row }">{{ row.lastActivatedAt || '-' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="最后登录 IP" width="140" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="ip-col-text">{{ row.lastLoginIp || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="expiredAt" label="过期时间" width="180">
|
<el-table-column prop="expiredAt" label="过期时间" width="180">
|
||||||
<template #default="{ row }">{{ row.expiredAt || '-' }}</template>
|
<template #default="{ row }">{{ row.expiredAt || '-' }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -494,6 +549,7 @@ onUnmounted(() => {
|
|||||||
<el-button v-if="row.status !== 'active'" link type="success" @click="handleActivate(row)">激活</el-button>
|
<el-button v-if="row.status !== 'active'" link type="success" @click="handleActivate(row)">激活</el-button>
|
||||||
<el-button link type="info" @click="openActivationRecords(row)">激活记录</el-button>
|
<el-button link type="info" @click="openActivationRecords(row)">激活记录</el-button>
|
||||||
<el-button link type="info" @click="openExtractRecords(row)">提取记录</el-button>
|
<el-button link type="info" @click="openExtractRecords(row)">提取记录</el-button>
|
||||||
|
<el-button link type="primary" @click="openIpLogs(row)">IP日志</el-button>
|
||||||
<el-button link type="danger" @click="openDelete(row)">删除</el-button>
|
<el-button link type="danger" @click="openDelete(row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -549,6 +605,17 @@ onUnmounted(() => {
|
|||||||
:total="extractState.total"
|
:total="extractState.total"
|
||||||
@refresh="fetchExtractRecords"
|
@refresh="fetchExtractRecords"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<IpLogs
|
||||||
|
v-model="ipLogsVisible"
|
||||||
|
v-model:page="ipLogsState.page"
|
||||||
|
v-model:page-size="ipLogsState.pageSize"
|
||||||
|
:row="currentRow || undefined"
|
||||||
|
:loading="ipLogsState.loading"
|
||||||
|
:records="ipLogsState.records"
|
||||||
|
:total="ipLogsState.total"
|
||||||
|
@refresh="fetchIpLogs"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -657,6 +724,12 @@ onUnmounted(() => {
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ip-col-text {
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
.pager {
|
.pager {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|||||||
28
sql/yz_platform_cursor_equipment_ip_log.sql
Normal file
28
sql/yz_platform_cursor_equipment_ip_log.sql
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
-- 设备 IP 登录日志表
|
||||||
|
-- 每次客户端调用 report / activateByCode 接口时,若携带 ipInfo,则向本表插入一条记录
|
||||||
|
CREATE TABLE IF NOT EXISTS `yz_platform_cursor_equipment_ip_log` (
|
||||||
|
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`equipment_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联 yz_platform_cursor_equipment.id,0 表示设备尚未创建时的记录',
|
||||||
|
`machine_code` VARCHAR(128) NOT NULL DEFAULT '' COMMENT '机器码(冗余,便于无 equipment_id 时查询)',
|
||||||
|
`source` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '来源:report / activateByCode',
|
||||||
|
-- ip-api.com 返回的原始字段
|
||||||
|
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'ip-api status',
|
||||||
|
`country` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '国家',
|
||||||
|
`country_code` VARCHAR(8) NOT NULL DEFAULT '' COMMENT '国家代码',
|
||||||
|
`region` VARCHAR(16) NOT NULL DEFAULT '' COMMENT '省/州代码',
|
||||||
|
`region_name` VARCHAR(128) NOT NULL DEFAULT '' COMMENT '省/州名称',
|
||||||
|
`city` VARCHAR(128) NOT NULL DEFAULT '' COMMENT '城市',
|
||||||
|
`zip` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '邮编',
|
||||||
|
`lat` DOUBLE NOT NULL DEFAULT 0 COMMENT '纬度',
|
||||||
|
`lon` DOUBLE NOT NULL DEFAULT 0 COMMENT '经度',
|
||||||
|
`timezone` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '时区',
|
||||||
|
`isp` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'ISP 运营商',
|
||||||
|
`org` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '组织',
|
||||||
|
`as_info` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'AS 信息',
|
||||||
|
`query` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '出口 IP 地址',
|
||||||
|
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_equipment_id` (`equipment_id`),
|
||||||
|
KEY `idx_machine_code` (`machine_code`),
|
||||||
|
KEY `idx_create_time` (`create_time`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备 IP 登录日志';
|
||||||
Loading…
Reference in New Issue
Block a user