caipin 4 gadi atpakaļ
vecāks
revīzija
590bc21b7a
2 mainītis faili ar 24 papildinājumiem un 24 dzēšanām
  1. 15 15
      services/contract_section_tree_service.go
  2. 9 9
      services/contract_service.go

+ 15 - 15
services/contract_section_tree_service.go

@@ -17,7 +17,7 @@ import (
 
 // 获得合同项目节
 func (s *contractService) GetSecionTree(bidsectionId int, projectId int) *viewmodels.TreeSectionContract {
-	dataList := s.treeContractDao.GetAll(bidsectionId, projectId)
+	dataList := s.treeContractDao.GetAll(bidsectionId, projectId, 0)
 	sectionList := s.makeSectionTreeView(dataList)
 
 	// Node := sectionRoot //父节点
@@ -28,7 +28,7 @@ func (s *contractService) GetSecionTree(bidsectionId int, projectId int) *viewmo
 
 // 获得项目节树和孩子们下的合同数据
 func (s *contractService) GetSectionTreeContract(attribution string, bidsectionId int, projectId int) []*viewmodels.Contracts {
-	s.treeContractDao.GetAttribution(attribution, bidsectionId, projectId)
+	s.treeContractDao.GetAttribution(attribution, bidsectionId, projectId, 0)
 	return nil
 }
 
@@ -81,7 +81,7 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 	if err != nil {
 		return err
 	}
-	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if sectionFather.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -96,7 +96,7 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 
 	// 2 获得最大序号
 	// 2-1 孩子节点
-	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId)
+	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId, 0)
 	// 2-1 最大序号
 	serial := 1
 	if len(childrenList) != 0 {
@@ -134,7 +134,7 @@ func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContrac
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -163,7 +163,7 @@ func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContra
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -173,7 +173,7 @@ func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContra
 	// 	return errors.New("请在项目节第三层开始编辑")
 	// }
 
-	err = s.treeContractDao.UpdateSerial(section, sectionData.Serial)
+	err = s.treeContractDao.UpdateSerial(section, sectionData.Serial, 0)
 	if err != nil {
 		return errors.New("更新失败")
 	}
@@ -183,7 +183,7 @@ func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContra
 // 项目节删除
 func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId int) error {
 	// 1.验证项目节ID
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -212,7 +212,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -230,7 +230,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 	elderBrother := &models.CmTreeContracts{}
 	if sectionData.Operation == "downDepth" {
 		// 获得前一个兄弟节点
-		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId)
+		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 		if len(elderBrotherList) == 0 {
 			return errors.New("项目节不能降级")
 		}
@@ -249,7 +249,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 	}
 
 	// 4.执行升降级
-	err = s.treeContractDao.MoveDepth(section, elderBrother, sectionData.Operation, bidsectionId, projectId)
+	err = s.treeContractDao.MoveDepth(section, elderBrother, sectionData.Operation, bidsectionId, projectId, 0)
 	if err != nil {
 		return err
 	}
@@ -264,7 +264,7 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -282,14 +282,14 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 	brother := &models.CmTreeContracts{}
 	if sectionData.Operation == "downSerial" {
 		// 获得下一个兄弟
-		youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId)
+		youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 		if len(youngerBrotherList) == 0 {
 			return errors.New("项目节不能下移")
 		}
 		brother = &youngerBrotherList[0]
 	} else if sectionData.Operation == "upSerial" {
 		// 获得上一个兄弟
-		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId)
+		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 		if len(elderBrotherList) == 0 {
 			return errors.New("项目节不能上移")
 		}
@@ -299,7 +299,7 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 	}
 
 	// 4.执行升降级
-	err = s.treeContractDao.MoveSerial(section, brother, sectionData.Operation, bidsectionId, projectId)
+	err = s.treeContractDao.MoveSerial(section, brother, sectionData.Operation, bidsectionId, projectId, 0)
 	if err != nil {
 		return err
 	}

+ 9 - 9
services/contract_service.go

@@ -262,16 +262,16 @@ func (s *contractService) ValidRuleContractDel(ctx iris.Context) (*viewmodels.Co
 // 获得项目节
 func (s *contractService) Get(treeId int, bidsectionId int, projectId int) *viewmodels.TreeSectionContract {
 	// 1.获得项目节
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	// 2.构造数据
 	sectionVM := s.makeSectionView(section)
 	// 3.更新 上移和下一的限制
-	youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId)
+	youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 	if len(youngerBrotherList) == 0 {
 		sectionVM.IsEnd = true
 	}
 	sectionVM.ElderBrother = true
-	elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId)
+	elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 	if len(elderBrotherList) == 0 {
 		sectionVM.ElderBrother = false
 	}
@@ -315,7 +315,7 @@ func (s *contractService) GetContract(contractId int) *viewmodels.Contracts {
 // 新增合同
 func (s *contractService) Add(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error {
 	// 1. 项目节存在
-	contracts := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	contracts := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if contracts.Id == 0 {
 		return errors.New("未找到项目节")
 	}
@@ -359,7 +359,7 @@ func (s *contractService) Add(contractData *viewmodels.Contracts, projectId int,
 // 更新合同
 func (s *contractService) Update(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error {
 	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if contractsTree.Id == 0 {
 		return errors.New("未找到项目节")
 	}
@@ -404,7 +404,7 @@ func (s *contractService) Update(contractData *viewmodels.Contracts, projectId i
 // 删除合同
 func (s *contractService) Delete(projectId int, bidsectionId int, treeId int, id int) error {
 	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if contractsTree.Id == 0 {
 		return errors.New("未找到项目节")
 	}
@@ -438,7 +438,7 @@ func (s *contractService) Delete(projectId int, bidsectionId int, treeId int, id
 // 关闭合同
 func (s *contractService) Close(projectId int, bidsectionId int, treeId int, id int) error {
 	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if contractsTree.Id == 0 {
 		return errors.New("未找到项目节")
 	}
@@ -459,7 +459,7 @@ func (s *contractService) Close(projectId int, bidsectionId int, treeId int, id
 // 解锁合同
 func (s *contractService) Unlock(projectId int, bidsectionId int, treeId int, id int) error {
 	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId)
+	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 	if contractsTree.Id == 0 {
 		return errors.New("未找到项目节")
 	}
@@ -479,7 +479,7 @@ func (s *contractService) Unlock(projectId int, bidsectionId int, treeId int, id
 
 // 获得合同总数量和总金额
 func (s *contractService) getContractTotalAndPrice(bidsectionId int, projectId int) (contractTotal int, priceTotal float64) {
-	contractList := s.treeContractDao.GetContract(bidsectionId, projectId)
+	contractList := s.treeContractDao.GetContract(bidsectionId, projectId, 0)
 	priceTotal = 0.00
 	for _, item := range contractList {
 		contractPrice, _ := strconv.ParseFloat(item.ContractPrice, 64)