animeic-cd 1 năm trước cách đây
mục cha
commit
bc639421e1
3 tập tin đã thay đổi với 11 bổ sung6 xóa
  1. 2 3
      src/api/upload.go
  2. 1 3
      src/api/version.go
  3. 8 0
      src/conf/app.go

+ 2 - 3
src/api/upload.go

@@ -1,6 +1,7 @@
 package api
 
 import (
+	"cr-svc/conf"
 	"cr-svc/db/model"
 	"cr-svc/db/repo"
 	"fmt"
@@ -15,8 +16,6 @@ func Upload(r *GinRouter) {
 	r.POSTJWT("/upload/pkg", UploadPkg)
 }
 
-var LocalHost = "http://192.168.110.238:8085/cr/pkg"
-
 func UploadPkg(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 
 	version := c.PostForm("version")
@@ -39,7 +38,7 @@ func UploadPkg(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		UserId:     userId,
 		UserName:   apictx.User.Name,
 		Name:       name,
-		Url:        fmt.Sprintf("%s/%s", LocalHost, file.Filename),
+		Url:        fmt.Sprintf("%s/%s", conf.AppConfig.UploadPkgUrl, file.Filename),
 		Size:       size,
 		Version:    version,
 		CreateTime: time.Now(),

+ 1 - 3
src/api/version.go

@@ -5,7 +5,6 @@ import (
 	"cr-svc/db/repo"
 	"cr-svc/log"
 	"errors"
-	"net/http"
 
 	"github.com/gin-gonic/gin"
 	"go.mongodb.org/mongo-driver/bson"
@@ -42,8 +41,7 @@ func VersionLatest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	if len(out.List) < 1 {
 		return map[string]interface{}{}, nil
 	}
-	c.JSON(http.StatusOK, out.List[0])
-	return nil, nil
+	return out.List[0], nil
 }
 
 func UpdateVersion(c *gin.Context, apictx *ApiSession) (interface{}, error) {

+ 8 - 0
src/conf/app.go

@@ -41,6 +41,8 @@ type AppConf struct {
 		UserRole  string
 	}
 
+	UploadPkgUrl string
+
 	Nats struct {
 		Url                      string
 		MaxReconnect             int
@@ -86,6 +88,12 @@ func NewAppConf(filePath string) (*AppConf, error) {
 	}
 	fmt.Println("Env NATS=>", natsHost)
 
+	uploadPkgUrl := os.Getenv("UPLOAD_PKG_URL")
+	if len(uploadPkgUrl) > 0 {
+		c.Nats.Url = uploadPkgUrl
+	}
+	fmt.Println("upload url =>", uploadPkgUrl)
+
 	AppConfig = c
 	return c, nil
 }