lanjianrong 4 lat temu
rodzic
commit
0581ff923f

+ 7 - 0
dao/tree_contract_dao.go

@@ -559,3 +559,10 @@ func (d *TreeContractDao) replaceContractAttribution(session *xorm.Session, attr
 	}
 	return nil
 }
+
+// 更新合同id
+func (d *TreeContractDao) UpdateContract(id int, contractId int) error {
+	data := &models.CmTreeContracts{Id: id, ContractId: contractId}
+	_, err := d.engine.Where("id = ?", id).Cols("contract_id").Update(data)
+	return err
+}

+ 6 - 0
services/contract_section_tree_service.go

@@ -438,3 +438,9 @@ func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmod
 	section.CreateTime = data.CreateTime.Format(conf.SysTimeform)
 	return section
 }
+
+// 更新项目节-合同id
+func (s *contractService) UpdateContractId(id int, contractId int) error {
+	err := s.treeContractDao.UpdateContract(id, contractId)
+	return err
+}

+ 19 - 0
services/contract_service.go

@@ -27,6 +27,7 @@ type ContractService interface {
 	ValidRuleSectionDelete(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
 	ValidRuleSectionNot(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
 	ValidRuleGet(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
+	ValidRuleUpdateFile(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
 	ValidRuleSerial(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
 
 	// 项目节
@@ -39,6 +40,7 @@ type ContractService interface {
 	SectionDelete(treeId int) error
 	MoveDepth(sectionData *viewmodels.TreeSectionContract) error
 	MoveSerial(sectionData *viewmodels.TreeSectionContract) error
+	UpdateContractId(id int, contractId int) error
 
 	SaveUpload(Location string, Filename string, id int, ext string) error
 }
@@ -187,6 +189,23 @@ func (s *contractService) ValidRuleSerial(ctx iris.Context) (*viewmodels.TreeSec
 	return treeSectionVaild, nil
 }
 
+// 验证更新附件相关
+func (s *contractService) ValidRuleUpdateFile(ctx iris.Context) (*viewmodels.TreeSectionContract, error) {
+	treeSectionVaild := &viewmodels.TreeSectionContract{}
+	err := ctx.ReadJSON(treeSectionVaild)
+	if err != nil {
+		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
+		return treeSectionVaild, err
+	}
+
+	err = treeSectionVaild.ValidateFile()
+	if err != nil {
+		log.Println("参数验证错误, error=", err)
+		return treeSectionVaild, err
+	}
+	return treeSectionVaild, nil
+}
+
 // 新增合同参数验证
 func (s *contractService) ValidRuleContractAdd(ctx iris.Context) (*viewmodels.Contracts, error) {
 	// 创建一个存放前端传过来参数

+ 8 - 0
web/viewmodels/tree_section_contract.go

@@ -93,6 +93,14 @@ func (l TreeSectionContract) ValidateSectionSerial() error {
 	)
 }
 
+func (l TreeSectionContract) ValidateFile() error {
+	return validation.ValidateStruct(&l,
+		validation.Field(&l.Id, validation.Required.Error("项目节ID不能为空")),
+		// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+		validation.Field(&l.ContractId, validation.Required.Error("附件不能为空")),
+	)
+}
+
 // func (l TreeSectionContract) ValidRuleGet() error {
 // 	return validation.ValidateStruct(&l,
 // 		validation.Field(&l.Id, validation.Required.Error("项目节ID不能为空")),