Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	go.mod
This commit is contained in:
linwenxiang committed 2021-03-31 21:02:59 +08:00
commit 225970c005
6 files changed
+54 -8

No files matched your search

+21 -5
View File
@@ -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)
}
}
+4 -2
View File
@@ -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)
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ package global
const (
// go-admin Version Info
Version = "1.3.2"
Version = "1.3.3"
)
var (
+16
View File
@@ -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
}
+6
View File
@@ -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
+6
View File
@@ -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