This commit is contained in:
xh
2025-06-24 11:51:03 +08:00
parent 58f387aef3
commit c0c45a72a6
12 changed files with 53 additions and 61 deletions

View File

@@ -9,7 +9,7 @@
"preview": "vite preview --port 4173", "preview": "vite preview --port 4173",
"build": "node ./scripts/build.mjs", "build": "node ./scripts/build.mjs",
"type-check": "vue-tsc --noEmit --checkJs true --skipLibCheck", "type-check": "vue-tsc --noEmit --checkJs true --skipLibCheck",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint": "eslint src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts src --fix --ignore-path .gitignore",
"preinstall": "npx only-allow pnpm", "preinstall": "npx only-allow pnpm",
"outdated": "pnpm outdated" "outdated": "pnpm outdated"
}, },

View File

@@ -22,5 +22,4 @@ import LayoutHeader from './components/header/index.vue'
defineOptions({ defineOptions({
name: 'LayoutDefault' name: 'LayoutDefault'
}) })
</script> </script>

View File

@@ -208,13 +208,11 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, shallowRef, reactive, nextTick } from 'vue' import { ref, shallowRef, reactive } from 'vue'
import { import {
monitor_client_delete, monitor_client_delete,
monitor_client_delete_batch, monitor_client_delete_batch,
monitor_client_list, monitor_client_list
monitor_client_import_file,
monitor_client_export_file
} from '@/api/monitor/client' } from '@/api/monitor/client'
import type { type_monitor_client, type_monitor_client_query } from '@/api/monitor/client' import type { type_monitor_client, type_monitor_client_query } from '@/api/monitor/client'
@@ -256,11 +254,6 @@ const { listAllData } = useListAllData<{
}>({ }>({
monitor_project_listAll: '/monitor_project/listAll' monitor_project_listAll: '/monitor_project/listAll'
}) })
const handleAdd = async () => {
showEdit.value = true
await nextTick()
editRef.value?.open('add')
}
const multipleSelection = ref<type_monitor_client[]>([]) const multipleSelection = ref<type_monitor_client[]>([])
const handleSelectionChange = (val: type_monitor_client[]) => { const handleSelectionChange = (val: type_monitor_client[]) => {
@@ -291,12 +284,5 @@ const deleteBatch = async () => {
getLists() getLists()
} catch (error) {} } catch (error) {}
} }
const exportFile = async () => {
try {
await feedback.confirm('确定要导出?')
await monitor_client_export_file(queryParams)
} catch (error) {}
}
getLists() getLists()
</script> </script>

View File

@@ -41,7 +41,7 @@ export default ({ mode }) => {
}, },
{ {
name: 'vue-router', name: 'vue-router',
test:/node_modules\/vue-router/ test: /node_modules\/vue-router/
}, },
{ {
name: 'element-plus', name: 'element-plus',
@@ -84,9 +84,8 @@ export default ({ mode }) => {
{ {
name: '@wangeditor/editor', name: '@wangeditor/editor',
test: /node_modules\/@wangeditor/ test: /node_modules\/@wangeditor/
}, }
]
],
// vue: ['vue'], // vue: ['vue'],
// 'vue-router': ['vue-router'], // 'vue-router': ['vue-router'],
// pinia: ['pinia'], // pinia: ['pinia'],

View File

@@ -21,6 +21,7 @@
"mediumtext", "mediumtext",
"nvarchar", "nvarchar",
"oneof", "oneof",
"primarykey",
"qrtz", "qrtz",
"rmvb", "rmvb",
"singleflight", "singleflight",

View File

@@ -164,7 +164,6 @@ func (service monitorClientService) Detail(Id int) (res MonitorClientResp, e err
cacheUtil.SetCache(obj.Id, obj) cacheUtil.SetCache(obj.Id, obj)
cacheUtil.SetCache("ClientId:"+obj.ClientId, obj) cacheUtil.SetCache("ClientId:"+obj.ClientId, obj)
} }
convert_util.Copy(&res, obj) convert_util.Copy(&res, obj)
return return
} }

View File

@@ -17,22 +17,25 @@ import (
) )
var MonitorErrorService = NewMonitorErrorService() var MonitorErrorService = NewMonitorErrorService()
var cacheUtil = util.CacheUtil{
Name: MonitorErrorService.Name, // var cacheUtil = util.CacheUtil{
} // Name: MonitorErrorService.Name,
// }
// NewMonitorErrorService 初始化 // NewMonitorErrorService 初始化
func NewMonitorErrorService() *monitorErrorService { func NewMonitorErrorService() *monitorErrorService {
return &monitorErrorService{ return &monitorErrorService{
db: core.GetDB(), db: core.GetDB(),
CacheUtil: util.CacheUtil{
Name: "monitorError", Name: "monitorError",
},
} }
} }
// monitorErrorService 监控-错误列服务实现类 // monitorErrorService 监控-错误列服务实现类
type monitorErrorService struct { type monitorErrorService struct {
db *gorm.DB db *gorm.DB
Name string CacheUtil util.CacheUtil
} }
// List 监控-错误列列表 // List 监控-错误列列表
@@ -112,7 +115,7 @@ func (service monitorErrorService) ListAll(listReq MonitorErrorListReq) (res []M
// Detail 监控-错误列详情 // Detail 监控-错误列详情
func (service monitorErrorService) Detail(Id int) (res MonitorErrorResp, e error) { func (service monitorErrorService) Detail(Id int) (res MonitorErrorResp, e error) {
var obj = model.MonitorError{} var obj = model.MonitorError{}
err := cacheUtil.GetCache(Id, &obj) err := service.CacheUtil.GetCache(Id, &obj)
if err != nil { if err != nil {
err := service.db.Where("id = ?", Id).Limit(1).First(&obj).Error err := service.db.Where("id = ?", Id).Limit(1).First(&obj).Error
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
@@ -121,7 +124,7 @@ func (service monitorErrorService) Detail(Id int) (res MonitorErrorResp, e error
if e = response.CheckErr(err, "获取详情失败"); e != nil { if e = response.CheckErr(err, "获取详情失败"); e != nil {
return return
} }
cacheUtil.SetCache(obj.Id, obj) service.CacheUtil.SetCache(obj.Id, obj)
} }
convert_util.Copy(&res, obj) convert_util.Copy(&res, obj)
@@ -131,7 +134,7 @@ func (service monitorErrorService) Detail(Id int) (res MonitorErrorResp, e error
// DetailByMD5 监控-错误列详情 // DetailByMD5 监控-错误列详情
func (service monitorErrorService) DetailByMD5(md5 string) (res MonitorErrorResp, e error) { func (service monitorErrorService) DetailByMD5(md5 string) (res MonitorErrorResp, e error) {
var obj = model.MonitorError{} var obj = model.MonitorError{}
err := cacheUtil.GetCache("md5:"+md5, &obj) err := service.CacheUtil.GetCache("md5:"+md5, &obj)
if err != nil { if err != nil {
err := service.db.Where("md5 = ?", md5).Order("id DESC").Limit(1).First(&obj).Error err := service.db.Where("md5 = ?", md5).Order("id DESC").Limit(1).First(&obj).Error
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil { if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
@@ -140,7 +143,7 @@ func (service monitorErrorService) DetailByMD5(md5 string) (res MonitorErrorResp
if e = response.CheckErr(err, "获取详情失败"); e != nil { if e = response.CheckErr(err, "获取详情失败"); e != nil {
return return
} }
cacheUtil.SetCache("md5:"+md5, obj) service.CacheUtil.SetCache("md5:"+md5, obj)
} }
convert_util.Copy(&res, obj) convert_util.Copy(&res, obj)
@@ -166,8 +169,8 @@ func (service monitorErrorService) Add(addReq MonitorErrorAddReq) (createId int,
return 0, err return 0, err
} }
createId = obj.Id createId = obj.Id
cacheUtil.SetCache(createId, obj) service.CacheUtil.SetCache(createId, obj)
cacheUtil.SetCache("md5:"+Md5, obj) service.CacheUtil.SetCache("md5:"+Md5, obj)
} else { } else {
createId = errorDetails.Id createId = errorDetails.Id
} }
@@ -200,8 +203,8 @@ func (service monitorErrorService) Del(Id int) (e error) {
// 删除 // 删除
err = service.db.Delete(&obj).Error err = service.db.Delete(&obj).Error
e = response.CheckErr(err, "删除失败") e = response.CheckErr(err, "删除失败")
cacheUtil.RemoveCache(obj.Id) service.CacheUtil.RemoveCache(obj.Id)
cacheUtil.RemoveCache("md5:" + obj.Md5) service.CacheUtil.RemoveCache("md5:" + obj.Md5)
return return
} }
@@ -226,8 +229,8 @@ func (service monitorErrorService) DelBatch(Ids []string) (e error) {
md5s = append(md5s, "md5:"+v.Md5) md5s = append(md5s, "md5:"+v.Md5)
} }
// 删除缓存 // 删除缓存
cacheUtil.RemoveCache(Ids) service.CacheUtil.RemoveCache(Ids)
cacheUtil.RemoveCache(md5s) service.CacheUtil.RemoveCache(md5s)
return nil return nil
} }

View File

@@ -1,8 +1,6 @@
module x_admin module x_admin
go 1.21.4 go 1.24.2
toolchain go1.22.4
require ( require (
github.com/fatih/structs v1.1.0 github.com/fatih/structs v1.1.0
@@ -30,7 +28,9 @@ require (
) )
require ( require (
github.com/guregu/null/v5 v5.0.0 github.com/duke-git/lancet/v2 v2.3.2
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20240510055607-89e20ab7b6c6
github.com/mitchellh/mapstructure v1.5.0
github.com/redis/go-redis/v9 v9.5.2 github.com/redis/go-redis/v9 v9.5.2
go.uber.org/ratelimit v0.3.1 go.uber.org/ratelimit v0.3.1
golang.org/x/sync v0.7.0 golang.org/x/sync v0.7.0
@@ -47,7 +47,6 @@ require (
github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect github.com/cloudwego/iasm v0.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/duke-git/lancet/v2 v2.3.2 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect
@@ -65,12 +64,9 @@ require (
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20240510055607-89e20ab7b6c6 // indirect
github.com/magiconair/properties v1.8.7 // indirect github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect

View File

@@ -81,8 +81,6 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/guregu/null/v5 v5.0.0 h1:PRxjqyOekS11W+w/7Vfz6jgJE/BCwELWtgvOJzddimw=
github.com/guregu/null/v5 v5.0.0/go.mod h1:SjupzNy+sCPtwQTKWhUCqjhVCO69hpsl2QsZrWHjlwU=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
@@ -127,8 +125,6 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.3 h1:j7a/xn1U6TKA/PHHxqZuzh64CdtRc7rU9M+AvkOl5bA= github.com/mattn/go-sqlite3 v1.14.3 h1:j7a/xn1U6TKA/PHHxqZuzh64CdtRc7rU9M+AvkOl5bA=
github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -209,6 +205,8 @@ github.com/xuri/nfp v0.0.0-20230919160717-d98342af3f05/go.mod h1:WwHg+CVyzlv/TX9
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw=
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=

View File

@@ -1,10 +1,12 @@
package model package model
import ( import (
"x_admin/core" "x_admin/core"
"gorm.io/plugin/soft_delete" "gorm.io/plugin/soft_delete"
) )
//UserProtocol 用户协议实体 // UserProtocol 用户协议实体
type UserProtocol struct { type UserProtocol struct {
Id int `gorm:"primarykey;comment:''"` // Id int `gorm:"primarykey;comment:''"` //
Title string `gorm:"comment:'标题'"` // 标题 Title string `gorm:"comment:'标题'"` // 标题

View File

@@ -35,6 +35,8 @@ func (c CacheUtil) GetCache(key interface{}, obj interface{}) error {
switch k := key.(type) { switch k := key.(type) {
case int: case int:
cacheKey = strconv.Itoa(k) cacheKey = strconv.Itoa(k)
case int64:
cacheKey = strconv.FormatInt(k, 10)
case string: case string:
cacheKey = k cacheKey = k
default: default:

View File

@@ -11,6 +11,13 @@ import (
"github.com/xuri/excelize/v2" "github.com/xuri/excelize/v2"
) )
/**
* @Description: 获取导入数据
* @param file 上传的文件
* @param dst 导入目标对象【传指针】
* @param cols 列信息
* @return err
*/
func GetExcelData(file multipart.File, dst interface{}, cols []Col) (err error) { func GetExcelData(file multipart.File, dst interface{}, cols []Col) (err error) {
// 创建缓冲区 // 创建缓冲区
buf := new(bytes.Buffer) buf := new(bytes.Buffer)