caipin преди 4 години
родител
ревизия
46cfd39d86
променени са 5 файла, в които са добавени 91 реда и са изтрити 3 реда
  1. 1 1
      bootstrap/bootstrap.go
  2. 33 0
      services/contract_section_tree_service.go
  3. 53 1
      web/api/contract_section_tree_api.go
  4. 2 0
      web/api/login_api.go
  5. 2 1
      web/routes/routes.go

+ 1 - 1
bootstrap/bootstrap.go

@@ -181,7 +181,7 @@ func (b *Bootstrapper) Bootstrap() *Bootstrapper {
 	// 设置csrf
 	// b.SetupCsrfHandlers(CsrfKey)
 	// 设置jwt
-	b.SetupJwtHandlers(JwtKey)
+	// b.SetupJwtHandlers(JwtKey)
 	// 设置rpc
 	//b.SetupRpcClient()
 	//设置异常信息

+ 33 - 0
services/contract_section_tree_service.go

@@ -252,6 +252,39 @@ func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContrac
 	return nil
 }
 
+// 保存编号
+func (s *contractService) SectionCode(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
+	// 1.验证项目节ID
+	treeId, err := utils.GetDecryptId(sectionData.Id)
+	if err != nil {
+		return err
+	}
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	if section.Id == 0 {
+		return errors.New("未找到合同项目节")
+	}
+
+	if section.Code == sectionData.Code {
+		return nil
+	}
+
+	// 1-1 深度为>=2才能新增项目节
+	// if section.Depth < 2 {
+	// 	return errors.New("请在项目节第三层开始编辑")
+	// }
+
+	// 2.保存
+	sectionCM := &models.CmTreeContracts{}
+	sectionCM.Code = sectionData.Code
+	sectionCM.Id = section.Id
+
+	err = s.treeContractDao.Save(sectionCM, []string{"Code"})
+	if err != nil {
+		return errors.New("保存失败")
+	}
+	return nil
+}
+
 // 更新序号
 func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
 	// 1.验证项目节ID

+ 53 - 1
web/api/contract_section_tree_api.go

@@ -2,7 +2,7 @@
  * @description: 合同管理 -项目节相关API
  * @Author: CP
  * @Date: 2020-10-26 15:27:04
- * @FilePath: \construction_management\web\api\contract_section_tree_api.go
+ * @FilePath: \design_quantity\web\api\contract_section_tree_api.go
  */
 package api
 
@@ -331,6 +331,58 @@ func (c *ContractApi) PostSectionSave() {
 	c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功", "section": sectionDetail})
 }
 
+// @Summary 修改合同项目节 编号
+// @Tags 合同管理-项目节
+// @Description 修改合同项目节 编号
+// @Accept  json
+// @Produce  json
+// @Security ApiKeyAuth
+// @Param   id     body    string     true        "项目节ID"
+// @Param   bidsectionId     body    string     true        "标段ID"
+// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
+// @Param   code     body    string     true        "项目节名称"
+// @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
+// @Router /api/contract/section/code [post]
+func (c *ContractApi) PostSectionCode() {
+	// 获得模板号
+	sectionData, err := c.ServiceContract.ValidRuleSectionAdd(c.Ctx)
+	if err != nil {
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": "解析参数出错"})
+		return
+	}
+
+	// 项目ID
+	projectIdInt, err := utils.GetProjectId(c.Ctx)
+	if err != nil {
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+		return
+	}
+	// 标段ID
+	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	if err != nil {
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+		return
+	}
+
+	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+		return
+	}
+
+	err = c.ServiceContract.SectionSave(sectionData, bidsectionId, projectIdInt, sectionData.TreeType)
+	if err != nil {
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+		return
+	}
+
+	//2.请求当前项目信息
+	// 1.验证项目节ID
+	treeId, _ := utils.GetDecryptId(sectionData.Id)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
+
+	c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功", "section": sectionDetail})
+}
+
 // @Summary 删除 合同项目节
 // @Tags 合同管理-项目节
 // @Description 删除 合同项目节

+ 2 - 0
web/api/login_api.go

@@ -87,6 +87,8 @@ func (c *LoginApi) GetProjectName() {
 		})
 		return
 	} else {
+		fmt.Println("=========================")
+		fmt.Println(ProjectData)
 		// 获得项目信息
 		dataList := c.ServiceProject.GetName(ProjectData.Code)
 		c.Ctx.JSON(iris.Map{

+ 2 - 1
web/routes/routes.go

@@ -24,7 +24,7 @@ func Configure(b *bootstrap.Bootstrapper) {
 	ContractService := services.NewContractService()
 
 	//CSRF相关
-	// b.Use(middleware.SetCsrf)
+	//  b.Use(middleware.SetCsrf)
 
 	//b.Party("/", protect)
 	//protect := NewCsrf()
@@ -34,6 +34,7 @@ func Configure(b *bootstrap.Bootstrapper) {
 	// 登陆接口
 	apiLogin := mvc.New(b.Party("/api/login"))
 	apiLogin.Register(LoginService)
+	apiLogin.Register(ProjectService)
 	apiLogin.Handle(new(api.LoginApi))
 
 	// 项目账号相关接口