mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-12 03:21:28 +08:00
客户端信息补充省、市、运营商
This commit is contained in:
@@ -13,7 +13,11 @@ export type type_monitor_client = {
|
||||
UserId?: string
|
||||
Os?: string
|
||||
Browser?: string
|
||||
Country?: string
|
||||
Province?: string
|
||||
City?: string
|
||||
Operator?: string
|
||||
Ip?: string
|
||||
Width?: number
|
||||
Height?: number
|
||||
Ua?: string
|
||||
@@ -26,14 +30,16 @@ export type type_monitor_client_query = {
|
||||
UserId?: string
|
||||
Os?: string
|
||||
Browser?: string
|
||||
Country?: string
|
||||
Province?: string
|
||||
City?: string
|
||||
Operator?: string
|
||||
Ip?: string
|
||||
Width?: number
|
||||
Height?: number
|
||||
Ua?: string
|
||||
CreateTimeStart?: string
|
||||
CreateTimeEnd?: string
|
||||
ClientTimeStart?: string
|
||||
ClientTimeEnd?: string
|
||||
}
|
||||
// 添加编辑
|
||||
export type type_monitor_client_edit = {
|
||||
@@ -43,7 +49,11 @@ export type type_monitor_client_edit = {
|
||||
UserId?: string
|
||||
Os?: string
|
||||
Browser?: string
|
||||
Country?: string
|
||||
Province?: string
|
||||
City?: string
|
||||
Operator?: string
|
||||
Ip?: string
|
||||
Width?: number
|
||||
Height?: number
|
||||
Ua?: string
|
||||
|
@@ -81,7 +81,12 @@ const formData = reactive({
|
||||
UserId: null,
|
||||
Os: null,
|
||||
Browser: null,
|
||||
Country: null,
|
||||
Province: null,
|
||||
City: null,
|
||||
Operator: null,
|
||||
Ip: null,
|
||||
|
||||
Width: null,
|
||||
Height: null,
|
||||
Ua: null,
|
||||
|
@@ -6,7 +6,7 @@
|
||||
class="mb-[-16px]"
|
||||
:model="queryParams"
|
||||
:inline="true"
|
||||
label-width="70px"
|
||||
label-width="90px"
|
||||
label-position="left"
|
||||
>
|
||||
<el-form-item label="项目" prop="ProjectKey" class="w-[280px]">
|
||||
@@ -32,9 +32,21 @@
|
||||
<el-form-item label="浏览器" prop="Browser" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Browser" />
|
||||
</el-form-item>
|
||||
<el-form-item label="国家" prop="Country" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Country" />
|
||||
</el-form-item>
|
||||
<el-form-item label="省份" prop="Province" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Province" />
|
||||
</el-form-item>
|
||||
<el-form-item label="城市" prop="City" class="w-[280px]">
|
||||
<el-input v-model="queryParams.City" />
|
||||
</el-form-item>
|
||||
<el-form-item label="电信运营商" prop="Operator" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Operator" />
|
||||
</el-form-item>
|
||||
<el-form-item label="ip" prop="Ip" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Ip" />
|
||||
</el-form-item>
|
||||
<el-form-item label="ua记录" prop="Ua" class="w-[280px]">
|
||||
<el-input v-model="queryParams.Ua" />
|
||||
</el-form-item>
|
||||
@@ -120,9 +132,15 @@
|
||||
<el-table-column label="用户id" prop="UserId" min-width="130" />
|
||||
<el-table-column label="系统" prop="Os" min-width="130" />
|
||||
<el-table-column label="浏览器" prop="Browser" min-width="130" />
|
||||
<el-table-column label="国家" prop="Country" min-width="130" />
|
||||
<el-table-column label="省份" prop="Province" min-width="130" />
|
||||
<el-table-column label="城市" prop="City" min-width="130" />
|
||||
<el-table-column label="屏幕" prop="Width" min-width="130" />
|
||||
<el-table-column label="屏幕高度" prop="Height" min-width="130" />
|
||||
<el-table-column label="电信运营商" prop="Operator" min-width="130" />
|
||||
<el-table-column label="ip" prop="Ip" min-width="130" />
|
||||
<el-table-column label="屏幕" prop="Width" min-width="130">
|
||||
<template #default="{ row }"> {{ row.Width }} * {{ row.Height }} </template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="屏幕高度" prop="Height" min-width="130" /> -->
|
||||
<el-table-column label="ua记录" prop="Ua" min-width="380" />
|
||||
<el-table-column label="创建时间" prop="CreateTime" min-width="130" />
|
||||
|
||||
@@ -182,14 +200,16 @@ const queryParams = reactive<type_monitor_client_query>({
|
||||
UserId: null,
|
||||
Os: null,
|
||||
Browser: null,
|
||||
Country: null,
|
||||
Province: null,
|
||||
City: null,
|
||||
Operator: null,
|
||||
Ip: null,
|
||||
Width: null,
|
||||
Height: null,
|
||||
Ua: null,
|
||||
CreateTimeStart: null,
|
||||
CreateTimeEnd: null,
|
||||
ClientTimeStart: null,
|
||||
ClientTimeEnd: null
|
||||
CreateTimeEnd: null
|
||||
})
|
||||
|
||||
const { pager, getLists, resetPage, resetParams } = usePaging<type_monitor_client>({
|
||||
|
@@ -10,7 +10,7 @@
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-col :span="10">
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
@@ -44,7 +44,7 @@
|
||||
<!-- <template #footer>Footer content</template> -->
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="14">
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
@@ -61,24 +61,31 @@
|
||||
>
|
||||
<template #title>
|
||||
<div class="flex-1 text-left">
|
||||
{{ user.UserId }}
|
||||
{{ user.City }}-{{ user.Browser }}:{{ user.Ip }}
|
||||
</div>
|
||||
<span class="">
|
||||
<span>
|
||||
{{ user.CreateTime }}
|
||||
</span>
|
||||
</template>
|
||||
<el-descriptions border>
|
||||
<el-descriptions-item label="城市:">{{
|
||||
user.City
|
||||
<el-descriptions-item label="省市区">
|
||||
{{ user.Country }}{{ user.Province }}{{ user.City }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="浏览器">
|
||||
{{ user.Os }}/{{ user.Browser }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="网络">{{
|
||||
user.Operator
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="IP">{{
|
||||
user.Ip
|
||||
}}</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="OS:">{{
|
||||
user.Os
|
||||
<el-descriptions-item label="业务ID">{{
|
||||
user.UserId
|
||||
}}</el-descriptions-item>
|
||||
<el-descriptions-item label="屏幕尺寸:">
|
||||
<el-tag size="small"
|
||||
>{{ user.Width }}*{{ user.Height }}</el-tag
|
||||
>
|
||||
<el-descriptions-item label="屏幕">
|
||||
{{ user.Width }}*{{ user.Height }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="userAgent">
|
||||
{{ user.Ua }}
|
||||
|
@@ -98,8 +98,7 @@ const formData = reactive({
|
||||
Path: null,
|
||||
Message: null,
|
||||
Stack: null,
|
||||
Md5: null,
|
||||
ClientTime: null
|
||||
Md5: null
|
||||
})
|
||||
|
||||
const formRules = {
|
||||
|
@@ -108,7 +108,7 @@
|
||||
<el-table-column label="错误堆栈" prop="Stack" min-width="130" />
|
||||
<el-table-column label="md5" prop="Md5" min-width="130" />
|
||||
<el-table-column label="创建时间" prop="CreateTime" min-width="130" />
|
||||
<el-table-column label="更新时间" prop="ClientTime" min-width="130" />
|
||||
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
|
@@ -17,6 +17,9 @@
|
||||
},
|
||||
{
|
||||
"path": ".workflow"
|
||||
},
|
||||
{
|
||||
"path": "x_error_sdk"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package monitor_client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -31,7 +30,11 @@ type MonitorClientHandler struct {
|
||||
// @Param UserId query string false "用户id"
|
||||
// @Param Os query string false "系统"
|
||||
// @Param Browser query string false "浏览器"
|
||||
// @Param Country query string false "国家"
|
||||
// @Param Province query string false "省份"
|
||||
// @Param City query string false "城市"
|
||||
// @Param Operator query string false "电信运营商"
|
||||
// @Param Ip query string false "ip"
|
||||
// @Param Width query number false "屏幕"
|
||||
// @Param Height query number false "屏幕高度"
|
||||
// @Param Ua query string false "ua记录"
|
||||
@@ -61,7 +64,12 @@ func (hd *MonitorClientHandler) List(c *gin.Context) {
|
||||
// @Param UserId query string false "用户id"
|
||||
// @Param Os query string false "系统"
|
||||
// @Param Browser query string false "浏览器"
|
||||
// @Param Country query string false "国家"
|
||||
// @Param Province query string false "省份"
|
||||
// @Param City query string false "城市"
|
||||
// @Param Operator query string false "电信运营商"
|
||||
// @Param Ip query string false "ip"
|
||||
// @Param Width query number
|
||||
// @Param Width query number false "屏幕"
|
||||
// @Param Height query number false "屏幕高度"
|
||||
// @Param Ua query string false "ua记录"
|
||||
@@ -116,7 +124,11 @@ func (hd *MonitorClientHandler) Detail(c *gin.Context) {
|
||||
// @Param UserId body string false "用户id"
|
||||
// @Param Os body string false "系统"
|
||||
// @Param Browser body string false "浏览器"
|
||||
// @Param City body string false "城市"
|
||||
// @Param Country query string false "国家"
|
||||
// @Param Province query string false "省份"
|
||||
// @Param City query string false "城市"
|
||||
// @Param Operator query string false "电信运营商"
|
||||
// @Param Ip query string false "ip"
|
||||
// @Param Width body number false "屏幕"
|
||||
// @Param Height body number false "屏幕高度"
|
||||
// @Param Ua body string false "ua记录"
|
||||
@@ -129,16 +141,24 @@ func (hd *MonitorClientHandler) Add(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
uaStr := c.GetHeader("user-agent")
|
||||
ip := c.ClientIP()
|
||||
|
||||
if uaStr != "" {
|
||||
ua := core.UAParser.Parse(uaStr)
|
||||
fmt.Println("ua", ua.Device.Family)
|
||||
addReq.Ua = &uaStr
|
||||
addReq.Os = &ua.Os.Family
|
||||
addReq.Browser = &ua.UserAgent.Family
|
||||
// addReq.Ip = *c.ClientIP()
|
||||
regionInfo := util.IpUtil.Parse(c.ClientIP())
|
||||
// regionInfo := util.IpUtil.Parse("118.24.157.190")
|
||||
}
|
||||
|
||||
addReq.Ip = &ip
|
||||
if ip != "" && ip != "127.0.0.1" {
|
||||
regionInfo := util.IpUtil.Parse(ip)
|
||||
// regionInfo := util.IpUtil.Parse("118.24.157.190")
|
||||
addReq.City = ®ionInfo.City
|
||||
addReq.Country = ®ionInfo.Country
|
||||
addReq.Operator = ®ionInfo.Operator
|
||||
addReq.Province = ®ionInfo.Province
|
||||
}
|
||||
|
||||
createId, e := MonitorClientService.Add(addReq)
|
||||
response.CheckAndRespWithData(c, createId, e)
|
||||
@@ -190,7 +210,11 @@ func (hd *MonitorClientHandler) DelBatch(c *gin.Context) {
|
||||
// @Param UserId query string false "用户id"
|
||||
// @Param Os query string false "系统"
|
||||
// @Param Browser query string false "浏览器"
|
||||
// @Param Country query string false "国家"
|
||||
// @Param Province query string false "省份"
|
||||
// @Param City query string false "城市"
|
||||
// @Param Operator query string false "电信运营商"
|
||||
// @Param Ip query string false "ip"
|
||||
// @Param Width query number false "屏幕"
|
||||
// @Param Height query number false "屏幕高度"
|
||||
// @Param Ua query string false "ua记录"
|
||||
|
@@ -11,7 +11,13 @@ type MonitorClientListReq struct {
|
||||
UserId *string // 用户id
|
||||
Os *string // 系统
|
||||
Browser *string // 浏览器
|
||||
|
||||
Country *string // 国家
|
||||
Province *string // 省份
|
||||
City *string // 城市
|
||||
Operator *string // 电信运营商
|
||||
Ip *string // ip
|
||||
|
||||
Width *int // 屏幕
|
||||
Height *int // 屏幕高度
|
||||
Ua *string // ua记录
|
||||
@@ -27,7 +33,11 @@ type MonitorClientAddReq struct {
|
||||
UserId *string // 用户id
|
||||
Os *string // 系统
|
||||
Browser *string // 浏览器
|
||||
Country *string // 国家
|
||||
Province *string // 省份
|
||||
City *string // 城市
|
||||
Operator *string // 电信运营商
|
||||
Ip *string // ip
|
||||
Width core.NullInt // 屏幕
|
||||
Height core.NullInt // 屏幕高度
|
||||
Ua *string // ua记录
|
||||
@@ -42,7 +52,11 @@ type MonitorClientEditReq struct {
|
||||
UserId *string // 用户id
|
||||
Os *string // 系统
|
||||
Browser *string // 浏览器
|
||||
Country *string // 国家
|
||||
Province *string // 省份
|
||||
City *string // 城市
|
||||
Operator *string // 电信运营商
|
||||
Ip *string // ip
|
||||
Width core.NullInt // 屏幕
|
||||
Height core.NullInt // 屏幕高度
|
||||
Ua *string // ua记录
|
||||
@@ -71,7 +85,11 @@ type MonitorClientResp struct {
|
||||
UserId string // 用户id
|
||||
Os string // 系统
|
||||
Browser string // 浏览器
|
||||
Country string // 国家
|
||||
Province string // 省份
|
||||
City string // 城市
|
||||
Operator string // 电信运营商
|
||||
Ip string // ip
|
||||
Width core.NullInt // 屏幕
|
||||
Height core.NullInt // 屏幕高度
|
||||
Ua string // ua记录
|
||||
|
@@ -49,9 +49,21 @@ func (service monitorClientService) GetModel(listReq MonitorClientListReq) *gorm
|
||||
if listReq.Browser != nil {
|
||||
dbModel = dbModel.Where("browser = ?", *listReq.Browser)
|
||||
}
|
||||
if listReq.Country != nil {
|
||||
dbModel = dbModel.Where("country = ?", *listReq.Country)
|
||||
}
|
||||
if listReq.Province != nil {
|
||||
dbModel = dbModel.Where("province = ?", *listReq.Province)
|
||||
}
|
||||
if listReq.City != nil {
|
||||
dbModel = dbModel.Where("city = ?", *listReq.City)
|
||||
}
|
||||
if listReq.Operator != nil {
|
||||
dbModel = dbModel.Where("operator = ?", *listReq.Operator)
|
||||
}
|
||||
if listReq.Ip != nil {
|
||||
dbModel = dbModel.Where("ip = ?", *listReq.Ip)
|
||||
}
|
||||
if listReq.Width != nil {
|
||||
dbModel = dbModel.Where("width = ?", *listReq.Width)
|
||||
}
|
||||
@@ -100,32 +112,32 @@ func (service monitorClientService) List(page request.PageReq, listReq MonitorCl
|
||||
}
|
||||
|
||||
// List 监控-客户端信息列表
|
||||
func (service monitorClientService) ListByErrorId(page request.PageReq, listReq MonitorClientListReq, errorId int) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
dbModel := service.GetModel(listReq)
|
||||
// 总数
|
||||
var count int64
|
||||
err := dbModel.Count(&count).Error
|
||||
if e = response.CheckErr(err, "失败"); e != nil {
|
||||
return
|
||||
}
|
||||
// 数据
|
||||
var modelList []model.MonitorClient
|
||||
err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []MonitorClientResp{}
|
||||
util.ConvertUtil.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
PageSize: page.PageSize,
|
||||
Count: count,
|
||||
Lists: result,
|
||||
}, nil
|
||||
}
|
||||
// func (service monitorClientService) ListByErrorId(page request.PageReq, listReq MonitorClientListReq, errorId int) (res response.PageResp, e error) {
|
||||
// // 分页信息
|
||||
// limit := page.PageSize
|
||||
// offset := page.PageSize * (page.PageNo - 1)
|
||||
// dbModel := service.GetModel(listReq)
|
||||
// // 总数
|
||||
// var count int64
|
||||
// err := dbModel.Count(&count).Error
|
||||
// if e = response.CheckErr(err, "失败"); e != nil {
|
||||
// return
|
||||
// }
|
||||
// // 数据
|
||||
// var modelList []model.MonitorClient
|
||||
// err = dbModel.Limit(limit).Offset(offset).Order("id desc").Find(&modelList).Error
|
||||
// if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
// return
|
||||
// }
|
||||
// result := []MonitorClientResp{}
|
||||
// util.ConvertUtil.Copy(&result, modelList)
|
||||
// return response.PageResp{
|
||||
// PageNo: page.PageNo,
|
||||
// PageSize: page.PageSize,
|
||||
// Count: count,
|
||||
// Lists: result,
|
||||
// }, nil
|
||||
// }
|
||||
|
||||
// ListAll 监控-客户端信息列表
|
||||
func (service monitorClientService) ListAll(listReq MonitorClientListReq) (res []MonitorClientResp, e error) {
|
||||
@@ -141,6 +153,24 @@ func (service monitorClientService) ListAll(listReq MonitorClientListReq) (res [
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (service monitorClientService) DetailByClientId(ClientId string) (res MonitorClientResp, e error) {
|
||||
var obj = model.MonitorClient{}
|
||||
err := cacheUtil.GetCache("ClientId:"+ClientId, &obj)
|
||||
if err != nil {
|
||||
err := service.db.Where("client_id = ?", ClientId).Order("id DESC").Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
if e = response.CheckErr(err, "获取详情失败"); e != nil {
|
||||
return
|
||||
}
|
||||
cacheUtil.SetCache("ClientId:"+obj.ClientId, obj)
|
||||
}
|
||||
|
||||
util.ConvertUtil.Copy(&res, obj)
|
||||
return
|
||||
}
|
||||
|
||||
// Detail 监控-客户端信息详情
|
||||
func (service monitorClientService) Detail(Id int) (res MonitorClientResp, e error) {
|
||||
var obj = model.MonitorClient{}
|
||||
@@ -163,15 +193,7 @@ func (service monitorClientService) Detail(Id int) (res MonitorClientResp, e err
|
||||
// ErrorUser 监控-客户端信息详情
|
||||
func (service monitorClientService) ErrorUsers(error_id int) (res []MonitorClientResp, e error) {
|
||||
var obj = []model.MonitorClient{}
|
||||
service.db.Raw("SELECT client.* from x_monitor_error_list as list left join x_monitor_client as client on client.client_id = list.client_id where list.error_id = ? Order by list.id DESC", error_id).Scan(&obj)
|
||||
|
||||
// if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
// return
|
||||
// }
|
||||
// if e = response.CheckErr(err, "获取失败"); e != nil {
|
||||
// return
|
||||
// }
|
||||
// cacheUtil.SetCache(obj.Id, obj)
|
||||
service.db.Raw("SELECT client.* from x_monitor_error_list as list right join x_monitor_client as client on client.id = list.client_id where list.error_id = ? Order by list.id DESC", error_id).Scan(&obj)
|
||||
|
||||
util.ConvertUtil.Copy(&res, obj)
|
||||
return
|
||||
|
@@ -2,6 +2,7 @@ package monitor_error
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"x_admin/admin/monitor_client"
|
||||
"x_admin/admin/monitor_error_list"
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
@@ -167,10 +168,15 @@ func (service monitorErrorService) Add(addReq MonitorErrorAddReq) (createId int,
|
||||
} else {
|
||||
createId = errorDetails.Id
|
||||
}
|
||||
client, err := monitor_client.MonitorClientService.DetailByClientId(addReq.ClientId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
monitor_error_list.MonitorErrorListService.Add(monitor_error_list.MonitorErrorListAddReq{
|
||||
ErrorId: strconv.Itoa(createId),
|
||||
ClientId: addReq.ClientId,
|
||||
ClientId: strconv.Itoa(client.Id),
|
||||
// ClientId: addReq.ClientId,
|
||||
ProjectKey: addReq.ProjectKey,
|
||||
})
|
||||
|
||||
|
@@ -12,7 +12,11 @@ type MonitorClient struct {
|
||||
UserId string `gorm:"comment:'用户id'"` // 用户id
|
||||
Os string `gorm:"comment:'系统'"` // 系统
|
||||
Browser string `gorm:"comment:'浏览器'"` // 浏览器
|
||||
Country string `gorm:"comment:'国家'"` // 国家
|
||||
Province string `gorm:"comment:'省份'"` // 省份
|
||||
City string `gorm:"comment:'城市'"` // 城市
|
||||
Operator string `gorm:"comment:'电信运营商'"` // 电信运营商
|
||||
Ip string `gorm:"comment:'ip'"` // ip
|
||||
Width core.NullInt `gorm:"comment:'屏幕'"` // 屏幕
|
||||
Height core.NullInt `gorm:"comment:'屏幕高度'"` // 屏幕高度
|
||||
Ua string `gorm:"comment:'ua记录'"` // ua记录
|
||||
|
@@ -41,6 +41,7 @@ func (ipUtils *ipUtil) Parse(ip string) Region {
|
||||
fmt.Println("输入ip为空")
|
||||
return Region{}
|
||||
}
|
||||
|
||||
region, err := ipUtils.Searcher.SearchByStr(ip)
|
||||
if err != nil {
|
||||
fmt.Printf("解析ip(%s)错误: %s\n", ip, err)
|
||||
|
Reference in New Issue
Block a user