From 2bf423b42f718ebd79839ad2a59af675a8b73688 Mon Sep 17 00:00:00 2001 From: "Feng.YJ" <32027253+huiyifyj@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:59:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E7=9A=84?= =?UTF-8?q?=20context=20=E6=B3=84=E9=9C=B2=E4=BB=A5=E5=8F=8A=E9=81=97?= =?UTF-8?q?=E6=BC=8F=E7=9A=84=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=20(#1965?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复结构体 tag 字段的错误使用 --- .gitignore | 9 ++++++++- server/plugin/announcement/model/info.go | 8 ++++---- server/service/system/sys_casbin.go | 6 +++--- server/utils/upload/minio_oss.go | 5 +++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 5f7b8d3809..a25df7bb36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.idea/ /web/node_modules /web/dist @@ -33,3 +32,11 @@ server/uploads/ *.iml web/.pnpm-debug.log web/pnpm-lock.yaml + +# binary files +*.exe + +# SQLite database files +*.db +*.sqlite +*.sqlite3 diff --git a/server/plugin/announcement/model/info.go b/server/plugin/announcement/model/info.go index fcaa11f59d..42d62fe0aa 100644 --- a/server/plugin/announcement/model/info.go +++ b/server/plugin/announcement/model/info.go @@ -8,10 +8,10 @@ import ( // Info 公告 结构体 type Info struct { global.GVA_MODEL - Title string `json:"title" form:"title" gorm:"column:title;comment:公告标题;"` //标题 - Content string `json:"content" form:"content" gorm:"column:content;comment:公告内容;type:text;"` //内容 - UserID *int `json:"userID" form:"userID" gorm:"column:user_id;comment:发布者;"` //作者 - Attachments datatypes.JSON `json:"attachments" form:"attachments" gorm:"column:attachments;comment:相关附件;"swaggertype:"array,object"` //附件 + Title string `json:"title" form:"title" gorm:"column:title;comment:公告标题;"` //标题 + Content string `json:"content" form:"content" gorm:"column:content;comment:公告内容;type:text;"` //内容 + UserID *int `json:"userID" form:"userID" gorm:"column:user_id;comment:发布者;"` //作者 + Attachments datatypes.JSON `json:"attachments" form:"attachments" gorm:"column:attachments;comment:相关附件;" swaggertype:"array,object"` //附件 } // TableName 公告 Info自定义表名 gva_announcements_info diff --git a/server/service/system/sys_casbin.go b/server/service/system/sys_casbin.go index 3a315efbaa..6b54904c0e 100644 --- a/server/service/system/sys_casbin.go +++ b/server/service/system/sys_casbin.go @@ -87,12 +87,12 @@ func (casbinService *CasbinService) UpdateCasbinApi(oldPath string, newPath stri "v1": newPath, "v2": newMethod, }).Error - e := casbinService.Casbin() - err = e.LoadPolicy() if err != nil { return err } - return err + + e := casbinService.Casbin() + return e.LoadPolicy() } //@author: [piexlmax](https://github.com/piexlmax) diff --git a/server/utils/upload/minio_oss.go b/server/utils/upload/minio_oss.go index 3a6af72ce1..7ad5008cea 100644 --- a/server/utils/upload/minio_oss.go +++ b/server/utils/upload/minio_oss.go @@ -67,7 +67,6 @@ func (m *Minio) UploadFile(file *multipart.FileHeader) (filePathres, key string, } f.Close() // 创建文件 defer 关闭 - // 对文件名进行加密存储 ext := filepath.Ext(file.Filename) filename := utils.MD5V([]byte(strings.TrimSuffix(file.Filename, ext))) + ext @@ -91,8 +90,10 @@ func (m *Minio) UploadFile(file *multipart.FileHeader) (filePathres, key string, } func (m *Minio) DeleteFile(key string) error { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + // Delete the object from MinIO - ctx, _ := context.WithTimeout(context.Background(), time.Second*5) err := m.Client.RemoveObject(ctx, m.bucket, key, minio.RemoveObjectOptions{}) return err }