caipin 4 years ago
parent
commit
25fbef7b15

+ 2 - 1
conf/project.go

@@ -41,7 +41,8 @@ var CookieSecret = "cm_login_account"
 // 是否需要启动全局计划任务服务
 var RunningCrontabService = false
 
-var MergeLocalRootDir = "/public/"
+// var MergeLocalRootDir = "../public/"
+var MergeLocalRootDir = "G:/project/design_quantity/web/public/"
 
 // 分页-页数
 var PageSize = 10

+ 22 - 18
web/api/upload_api.go

@@ -12,13 +12,12 @@ import (
 	"io"
 	"log"
 	"os"
+	"strings"
 	"time"
 
 	"github.com/kataras/iris/v12"
 	"go.mod/conf"
 	"go.mod/services"
-	"go.mod/web/utils"
-	"go.mod/web/viewmodels"
 )
 
 type UploadApi struct {
@@ -56,12 +55,10 @@ func (c *UploadApi) Post() {
 		return
 	}
 
-	fmt.Println(head.Header)
-
 	//  文件元信息-todo
 	// FileName := head.Filename
 	FileSize := int64(len(buf.Bytes()))
-	UploadAt := time.Now().Format("2006-01-02 15:04:05")
+	UploadAt := fmt.Sprintf("%d", time.Now().UnixNano())
 
 	Location := conf.MergeLocalRootDir + UploadAt + head.Filename // 存储地址
 	newFile, err := os.Create(Location)
@@ -79,21 +76,28 @@ func (c *UploadApi) Post() {
 		return
 	}
 
-	treeVM := &viewmodels.TreeSectionContract{}
-	err = c.Ctx.ReadForm(treeVM)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		errCode = -6
-		return
-	}
+	fmt.Println(c.Ctx.FormValue("id"))
 
-	id, err := utils.GetDecryptId(treeVM.Id)
-	if err != nil {
-		errCode = -6
-		return
-	}
+	// treeVM := &viewmodels.TreeSectionContract{}
+	// err = c.Ctx.ReadForm(treeVM)
+	// if err != nil {
+	// 	log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
+	// 	errCode = -6
+	// 	return
+	// }
+
+	// fmt.Println(treeVM)
+
+	// id, err := utils.GetDecryptId(treeVM.Id)
+	// if err != nil {
+	// 	errCode = -6
+	// 	return
+	// }
+
+	justString := strings.Join(head.Header["Content-Type"], "")
+	fmt.Println(justString)
 
-	err = c.ServiceContract.SaveUpload(Location, head.Filename, id, "pdf")
+	err = c.ServiceContract.SaveUpload(Location, head.Filename, 55, justString)
 	if err != nil {
 		errCode = -6
 		return

+ 3 - 1
web/middleware/session.go

@@ -14,6 +14,8 @@ func SessionsAuth(ctx iris.Context) {
 	if path != "/api/projectAccount" {
 		JwtAuth().Serve(ctx)
 		return
+	} else {
+		ctx.Next()
 	}
-	ctx.Next()
+
 }

+ 1 - 0
web/routes/routes.go

@@ -48,6 +48,7 @@ func Configure(b *bootstrap.Bootstrapper) {
 
 	apiUpload := mvc.New(b.Party("/api/upload"))
 	apiUpload.Register(ContractService)
+	apiUpload.Handle(new(api.UploadApi))
 
 	// oss相关
 	apiOss := mvc.New(b.Party("/api/oss"))

+ 2 - 1
web/viewmodels/tree_section_contract.go

@@ -2,7 +2,7 @@
  * @description:合同项目节-视图层
  * @Author: CP
  * @Date: 2020-11-02 15:18:59
- * @FilePath: \construction_management\web\viewmodels\tree_section_contract.go
+ * @FilePath: \design_quantity\web\viewmodels\tree_section_contract.go
  */
 package viewmodels
 
@@ -15,6 +15,7 @@ import (
 
 type TreeSectionContract struct {
 	Id string `form:"id" json:"id" `
+	// File file   `form:"File" json:"File" `
 	// TreeType     int    `form:"treeType" json:"treeType"`
 	ParentId    string `form:"parentId" json:"parentId"`
 	Name        string `form:"name" json:"name"`