From 5f98ed56510a1001163ef33dfc99eee23b4de7cf Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Fri, 3 Jan 2025 16:10:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=8F=8A=E6=9B=B4=E6=96=B0=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=A2=9E=E5=88=A0=E6=94=B9?= =?UTF-8?q?=E6=9F=A5=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8A=9F=E8=83=BD.=E6=B7=BB=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/file.go | 2 +- proto/file_req.go | 4 ++++ service/fileService.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/handler/file.go b/handler/file.go index f5ac3db..3885dbd 100644 --- a/handler/file.go +++ b/handler/file.go @@ -22,7 +22,7 @@ func SetUpFileGroup(router *gin.Engine) { func AddConfigFile(c *gin.Context) { id, _ := c.Get("id") user_id := int(id.(float64)) - var req proto.ConfigFileReq + var req proto.AddConfigFileReq if err := c.ShouldBind(&req); err == nil { err2 := service.CreateConfigFile(&req, user_id) if err2 != nil { diff --git a/proto/file_req.go b/proto/file_req.go index 58fd716..a0bbae3 100644 --- a/proto/file_req.go +++ b/proto/file_req.go @@ -18,6 +18,10 @@ type ConfigFileReq struct { Content string `json:"content" form:"content"` } +type AddConfigFileReq struct { + FileName string `json:"file_name" form:"file_name" required:"true"` + FilePath string `json:"file_path" form:"file_path" required:"true"` +} type SearchOneConfigFileResp struct { ID uint `json:"id" form:"id"` CreatedAt time.Time `json:"created_at" form:"created_at"` diff --git a/service/fileService.go b/service/fileService.go index 3e8615a..78a5351 100644 --- a/service/fileService.go +++ b/service/fileService.go @@ -75,7 +75,7 @@ func CheckUploadRequestParameters(req *proto.FileUploadReq) error { return err } -func CreateConfigFile(req *proto.ConfigFileReq, userId int) error { +func CreateConfigFile(req *proto.AddConfigFileReq, userId int) error { var err error user := GetUserByIDWithCache(userId) if user.ID == 0 || user.Role != "admin" {