lanjianrong 4 年之前
父节点
当前提交
3a8f0e42aa
共有 3 个文件被更改,包括 12 次插入3 次删除
  1. 3 1
      services/contract_section_tree_service.go
  2. 3 2
      services/contract_service.go
  3. 6 0
      web/api/upload_api.go

+ 3 - 1
services/contract_section_tree_service.go

@@ -222,7 +222,7 @@ func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContrac
 		return errors.New("未找到合同项目节")
 	}
 
-	if section.Name == sectionData.Name {
+	if section.Name == sectionData.Name && section.Code2 == sectionData.Code2 {
 		return nil
 	}
 
@@ -237,6 +237,7 @@ func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContrac
 	sectionCM.Code2 = sectionData.Code2
 	sectionCM.Id = section.Id
 
+	fmt.Println("-------------------", sectionCM)
 	err = s.treeContractDao.Save(sectionCM, []string{"Name", "Code2"})
 	if err != nil {
 		return errors.New("保存失败")
@@ -435,6 +436,7 @@ func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmod
 	section.Serial = data.Serial
 	section.Attribution = data.Attribution
 	section.Code = data.Code
+	section.Code2 = data.Code2
 	section.ContractId = contractId
 	// section.Children = make([]*viewmodels.TreeSectionContract, 0)
 	section.ElderBrother = true

+ 3 - 2
services/contract_service.go

@@ -8,6 +8,7 @@ package services
 
 import (
 	"errors"
+	"fmt"
 	"html"
 	"log"
 	"strconv"
@@ -129,12 +130,11 @@ func (s *contractService) ValidRuleSectionAdd(ctx iris.Context) (*viewmodels.Tre
 // 模板规则新增项目节
 func (s *contractService) ValidRuleSectionDelete(ctx iris.Context) (*viewmodels.TreeSectionContract, error) {
 	treeSectionVaild := &viewmodels.TreeSectionContract{}
-	err := ctx.ReadForm(treeSectionVaild)
+	err := ctx.ReadJSON(treeSectionVaild)
 	if err != nil {
 		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
 		return treeSectionVaild, err
 	}
-
 	err = treeSectionVaild.ValidateSectionDelete()
 	if err != nil {
 		log.Println("参数验证错误, error=", err)
@@ -281,6 +281,7 @@ func (s *contractService) SaveUpload(Location string, Filename string, ext strin
 
 	_, err := s.uploadDao.Add(uploadCm)
 	if err != nil {
+		fmt.Println(err)
 		return "0", err
 	}
 

+ 6 - 0
web/api/upload_api.go

@@ -33,6 +33,7 @@ func (c *UploadApi) Post() {
 	id := "0"
 	defer func() {
 		if errCode < 0 {
+			fmt.Println("errCode", errCode)
 			c.Ctx.JSON(iris.Map{"code": -1, "msg": "上传失败"})
 
 		} else {
@@ -44,6 +45,7 @@ func (c *UploadApi) Post() {
 	file, head, err := c.Ctx.FormFile("file")
 	if err != nil {
 		log.Printf("Failed to get form data, err:%s\n", err.Error())
+		fmt.Println("1111")
 		errCode = -1
 		return
 	}
@@ -52,6 +54,7 @@ func (c *UploadApi) Post() {
 	buf := bytes.NewBuffer(nil)
 	if _, err := io.Copy(buf, file); err != nil {
 		log.Printf("Failed to get file data, err:%s\n", err.Error())
+		fmt.Println("2222")
 		errCode = -2
 		return
 	}
@@ -65,6 +68,7 @@ func (c *UploadApi) Post() {
 	webLocation := "/public/" + UploadAt + head.Filename
 	newFile, err := os.Create(Location)
 	if err != nil {
+		fmt.Println("33333")
 		log.Printf("Failed to create file, err:%s\n", err.Error())
 		errCode = -3
 		return
@@ -73,6 +77,7 @@ func (c *UploadApi) Post() {
 
 	nByte, err := newFile.Write(buf.Bytes())
 	if int64(nByte) != FileSize || err != nil {
+		fmt.Println("44444")
 		log.Printf("Failed to save data into file, writtenSize:%d, err:%s\n", nByte, err.Error())
 		errCode = -4
 		return
@@ -100,6 +105,7 @@ func (c *UploadApi) Post() {
 
 	id, err = c.ServiceContract.SaveUpload(webLocation, head.Filename, ext)
 	if err != nil {
+		fmt.Println("55555")
 		errCode = -6
 		return
 	}