Преглед изворни кода

fix:添加配置文件参数

zqbao пре 9 месеци
родитељ
комит
0318d4e558
3 измењених фајлова са 15 додато и 4 уклоњено
  1. 5 1
      controllers/report_pdf.go
  2. 3 1
      go.mod
  3. 7 2
      utils/config.go

+ 5 - 1
controllers/report_pdf.go

@@ -155,7 +155,11 @@ func (this *ReportPdfController) UploadPdf() {
 		br.Msg = "文件格式不正确"
 		br.Msg = "文件格式不正确"
 		return
 		return
 	}
 	}
-	if h.Size > 1024*1024*15 {
+	size, err := strconv.Atoi(utils.UPLOAD_PDF_SIZE)
+	if err != nil {
+		size = 15
+	}
+	if h.Size > 1024*1024*int64(size) {
 		br.Msg = "文件大小不能超过15M"
 		br.Msg = "文件大小不能超过15M"
 		return
 		return
 	}
 	}

+ 3 - 1
go.mod

@@ -5,12 +5,12 @@ go 1.21
 require (
 require (
 	github.com/aliyun/alibaba-cloud-sdk-go v1.62.789
 	github.com/aliyun/alibaba-cloud-sdk-go v1.62.789
 	github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
 	github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
-	github.com/aws/aws-sdk-go v1.54.18
 	github.com/beego/bee/v2 v2.1.0
 	github.com/beego/bee/v2 v2.1.0
 	github.com/beego/beego/v2 v2.1.0
 	github.com/beego/beego/v2 v2.1.0
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/go-redis/redis/v8 v8.11.5
 	github.com/go-redis/redis/v8 v8.11.5
 	github.com/go-sql-driver/mysql v1.7.0
 	github.com/go-sql-driver/mysql v1.7.0
+	github.com/olivere/elastic/v7 v7.0.32
 	github.com/rdlucklib/rdluck_tools v1.0.3
 	github.com/rdlucklib/rdluck_tools v1.0.3
 )
 )
 
 
@@ -21,7 +21,9 @@ require (
 	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/golang/protobuf v1.5.3 // indirect
 	github.com/hashicorp/golang-lru v0.5.4 // indirect
 	github.com/hashicorp/golang-lru v0.5.4 // indirect
 	github.com/jmespath/go-jmespath v0.4.0 // indirect
 	github.com/jmespath/go-jmespath v0.4.0 // indirect
+	github.com/josharian/intern v1.0.0 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
 	github.com/json-iterator/go v1.1.12 // indirect
+	github.com/mailru/easyjson v0.7.7 // indirect
 	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
 	github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
 	github.com/mitchellh/mapstructure v1.5.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

+ 7 - 2
utils/config.go

@@ -41,8 +41,9 @@ var (
 
 
 // 基础配置
 // 基础配置
 var (
 var (
-	STATIC_DIR   string
-	RESOURCE_DIR string
+	STATIC_DIR      string
+	RESOURCE_DIR    string
+	UPLOAD_PDF_SIZE string // 单位MB
 )
 )
 
 
 // ES配置
 // ES配置
@@ -148,6 +149,10 @@ func init() {
 	if RESOURCE_DIR == "" {
 	if RESOURCE_DIR == "" {
 		RESOURCE_DIR = "dongwu/"
 		RESOURCE_DIR = "dongwu/"
 	}
 	}
+	UPLOAD_PDF_SIZE = config["upload_pdf_size"]
+	if UPLOAD_PDF_SIZE == "" {
+		UPLOAD_PDF_SIZE = "15"
+	}
 
 
 	// 初始化缓存
 	// 初始化缓存
 	redisClient, err := initRedis(config["redis_type"], config["beego_cache"])
 	redisClient, err := initRedis(config["redis_type"], config["beego_cache"])