From 30feaae7e782051eb72cde5a3b6ce4eb2865a594 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 18:59:58 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix=F0=9F=90=9B=20=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=87=BD=E6=95=B0=20(#382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/apis/public/file.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/app/admin/apis/public/file.go b/app/admin/apis/public/file.go index af899de..c69241c 100644 --- a/app/admin/apis/public/file.go +++ b/app/admin/apis/public/file.go @@ -24,6 +24,8 @@ type FileResponse struct { Type string `json:"type"` } +const path = "static/uploadfile/" + type File struct { apis.Api } @@ -72,7 +74,11 @@ func (e *File) baseImg(c *gin.Context, fileResponse FileResponse, urlPerfix stri ddd, _ := base64.StdEncoding.DecodeString(file2list[1]) guid := uuid.New().String() fileName := guid + ".jpg" - base64File := "static/uploadfile/" + fileName + err := utils.IsNotExistMkDir(path) + if err != nil { + e.Error(c, 500, errors.New(""), "初始化文件路径失败") + } + base64File := path + fileName _ = ioutil.WriteFile(base64File, ddd, 0666) typeStr := strings.Replace(strings.Replace(file2list[0], "data:", "", -1), ";base64", "", -1) fileResponse = FileResponse{ @@ -83,7 +89,7 @@ func (e *File) baseImg(c *gin.Context, fileResponse FileResponse, urlPerfix stri Type: typeStr, } source, _ := c.GetPostForm("source") - err := thirdUpload(source, fileName, base64File) + err = thirdUpload(source, fileName, base64File) if err != nil { e.Error(c, 200, errors.New(""), "上传第三方失败") return fileResponse @@ -102,7 +108,12 @@ func (e *File) multipleFile(c *gin.Context, urlPerfix string) []FileResponse { for _, f := range files { guid := uuid.New().String() fileName := guid + utils.GetExt(f.Filename) - multipartFileName := "static/uploadfile/" + fileName + + err := utils.IsNotExistMkDir(path) + if err != nil { + e.Error(c, 500, errors.New(""), "初始化文件路径失败") + } + multipartFileName := path + fileName err1 := c.SaveUploadedFile(f, multipartFileName) fileType, _ := utils.GetType(multipartFileName) if err1 == nil { @@ -139,7 +150,12 @@ func (e *File) singleFile(c *gin.Context, fileResponse FileResponse, urlPerfix s guid := uuid.New().String() fileName := guid + utils.GetExt(files.Filename) - singleFile := "static/uploadfile/" + fileName + + err = utils.IsNotExistMkDir(path) + if err != nil { + e.Error(c, 500, errors.New(""), "初始化文件路径失败") + } + singleFile := path + fileName _ = c.SaveUploadedFile(files, singleFile) fileType, _ := utils.GetType(singleFile) fileResponse = FileResponse{ @@ -178,4 +194,4 @@ func ossUpload(name string, path string) error { func qiniuUpload(name string, path string) error { oss := file_store.ALiYunOSS{} return oss.UpLoad(name, path) -} +} \ No newline at end of file From aefdb47c32a6845232013e71be3a0b00d6cd2e6b Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 19:06:25 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat=20=E2=9C=A8=EF=BC=9A=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E6=89=A9=E5=B1=95=E9=A1=B9=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/api/server.go | 6 ++++-- config/extent.go | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 config/extent.go diff --git a/cmd/api/server.go b/cmd/api/server.go index 0b998e4..dde9044 100644 --- a/cmd/api/server.go +++ b/cmd/api/server.go @@ -22,6 +22,7 @@ import ( "go-admin/app/jobs" "go-admin/common/database" "go-admin/common/global" + ext "go-admin/config" ) var ( @@ -50,7 +51,8 @@ func init() { } func setup() { - + // 注入配置扩展项 + config.ExtendConfig = &ext.ExtConfig //1. 读取配置 config.Setup(file.NewSource, file.WithPath(configYml)) go config.Watch() @@ -148,4 +150,4 @@ func run() error { func tip() { usageStr := `欢迎使用 ` + pkg.Green(`go-admin `+global.Version) + ` 可以使用 ` + pkg.Red(`-h`) + ` 查看命令` fmt.Printf("%s \n\n", usageStr) -} +} \ No newline at end of file diff --git a/config/extent.go b/config/extent.go new file mode 100644 index 0000000..e477fbf --- /dev/null +++ b/config/extent.go @@ -0,0 +1,16 @@ +package config + +var ExtConfig Extand + +// 扩展配置 +// extend: +// demo: +// name: demo-name +// 使用方法: config.ExtConfig......即可!! +type Extand struct { + // Demo Demo // 这里配置对应配置文件的结构即可 +} + +type Demo struct { + Name string +} \ No newline at end of file From 376727475514ee65449b7e643c007363942e0c2e Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 19:09:47 +0800 Subject: [PATCH 3/6] =?UTF-8?q?config=F0=9F=94=A7=20=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/settings.full.yml | 6 ++++++ config/settings.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/config/settings.full.yml b/config/settings.full.yml index 96b2aab..dfe7269 100644 --- a/config/settings.full.yml +++ b/config/settings.full.yml @@ -42,8 +42,14 @@ settings: source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms # source: sqlite3.db # source: host=myhost port=myport user=gorm dbname=gorm password=mypassword + registers: + - sources: + - user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms gen: # 代码生成读取的数据库名称 dbname: dbname # 代码生成是使用前端代码存放位置,需要指定到src文件夹,相对路径 frontpath: ../go-admin-ui/src + extend: # 扩展项使用说明 + demo: + name: data \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index 878ec6a..c9fc749 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -31,8 +31,14 @@ settings: driver: mysql # 数据库连接字符串 mysql 缺省信息 charset=utf8&parseTime=True&loc=Local&timeout=1000ms source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms + registers: + - sources: + - user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms gen: # 代码生成读取的数据库名称 dbname: dbname # 代码生成是使用前端代码存放位置,需要指定到src文件夹,相对路径 frontpath: ../go-admin-ui/src + extend: # 扩展项使用说明 + demo: + name: data \ No newline at end of file From 2a27c91656320248a9d65b1c3de21a5421489840 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 19:44:08 +0800 Subject: [PATCH 4/6] =?UTF-8?q?config=F0=9F=94=A7=20=EF=BC=9Acore=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c7552bc..0e1c3a9 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 github.com/casbin/casbin/v2 v2.25.1 github.com/gin-gonic/gin v1.6.3 - github.com/go-admin-team/go-admin-core v1.3.2-rc.0 + github.com/go-admin-team/go-admin-core v1.3.3 github.com/google/uuid v1.2.0 github.com/mojocn/base64Captcha v1.3.1 github.com/mssola/user_agent v0.5.2 @@ -28,4 +28,4 @@ require ( gorm.io/driver/postgres v1.0.6-0.20201208020313-1ed927cfab53 gorm.io/driver/sqlite v1.1.5-0.20201206014648-c84401fbe3ba gorm.io/gorm v1.21.3 -) +) \ No newline at end of file From 510bdd94f9ef87034eb78a9b4aa0d4fc5d445ed4 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Wed, 31 Mar 2021 19:45:07 +0800 Subject: [PATCH 5/6] =?UTF-8?q?docs=F0=9F=93=9D=20=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/global/adm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/global/adm.go b/common/global/adm.go index 64267b8..8757d13 100644 --- a/common/global/adm.go +++ b/common/global/adm.go @@ -2,7 +2,7 @@ package global const ( // go-admin Version Info - Version = "1.3.2" + Version = "1.3.3" ) var ( From 24370899ab509d2c097f0aaf98d7376f2b2cc713 Mon Sep 17 00:00:00 2001 From: linwenxiang <991154416@qq.com> Date: Wed, 31 Mar 2021 21:02:12 +0800 Subject: [PATCH 6/6] =?UTF-8?q?perf=20=F0=9F=91=8C=EF=BC=9A=20=E5=8D=87?= =?UTF-8?q?=E7=BA=A7go-admin-core=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c7552bc..0814150 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5 github.com/casbin/casbin/v2 v2.25.1 github.com/gin-gonic/gin v1.6.3 - github.com/go-admin-team/go-admin-core v1.3.2-rc.0 + github.com/go-admin-team/go-admin-core v1.3.4-0.20210331124757-4c4d0bf6c336 github.com/google/uuid v1.2.0 github.com/mojocn/base64Captcha v1.3.1 github.com/mssola/user_agent v0.5.2