/* * @description: 合同管理 -项目节相关API * @Author: CP * @Date: 2020-10-26 15:27:04 * @FilePath: \construction_management\web\api\contract_section_tree_api.go */ package api import ( "fmt" "github.com/kataras/iris/v12" "go.mod/web/utils" ) // @Summary 升级降级合同项目节 // @Tags 合同管理-项目节 // @Description operation{upDepth,downDepth} // @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 operation body string true "操作名称" default(upDepth) // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}" // @Router /api/contract/section/depth [post] func (c *ContractApi) PostSectionDepth() { // 验证字段-项目节ID 操作类型 sectionData, err := c.ServiceContract.ValidRuleDepth(c.Ctx) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) return } // 项目ID // projectIdInt, err := utils.GetProjectId(c.Ctx) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) // return // } // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) // return // } // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) { // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"}) // return // } err = c.ServiceContract.MoveDepth(sectionData) 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": "操作成功", }) } // @Summary 上移下移合同项目节 // @Tags 合同管理-项目节 // @Description operation{upSerial,downSerial} // @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 operation body string true "操作名称" default(upSerial) // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}" // @Router /api/contract/section/serial [post] func (c *ContractApi) PostSectionSerial() { // 验证字段-项目节ID 操作类型 sectionData, err := c.ServiceContract.ValidRuleDepth(c.Ctx) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) return } // 项目ID // projectIdInt, err := utils.GetProjectId(c.Ctx) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) // return // } // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) // return // } // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) { // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"}) // return // } err = c.ServiceContract.MoveSerial(sectionData) 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 // @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 serial body int true "操作名称" // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}" // @Router /api/contract/section/serial/update [post] func (c *ContractApi) PostSectionSerialUpdate() { // 验证字段-项目节ID 操作类型 sectionData, err := c.ServiceContract.ValidRuleSerial(c.Ctx) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) return } // 项目ID // projectIdInt, err := utils.GetProjectId(c.Ctx) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) // return // } // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) // return // } // if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) { // c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"}) // return // } err = c.ServiceContract.UpdateSerial(sectionData) 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 设置合同项目节模板 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param templateNumber body int true "模板号" default(1) // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}" // @Router /api/contract/section/template [post] func (c *ContractApi) PostSectionTemplate() { // 获得模板号 sectionData, err := c.ServiceContract.ValidRuleTemplate(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 // } //获得合同项目节 // sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, sectionData.TreeType) err = c.ServiceContract.SetSection(sectionData.TemplateNumber) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)}) return } if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)}) } c.Ctx.JSON(iris.Map{"code": 0, "msg": "设置成功"}) // 1.未设置了项目节 // if len(sectionTree.Children) == 0 { // } else { // c.Ctx.JSON(iris.Map{"code": -1, "msg": "项目节已经设置"}) // return // } } // @Summary 新增 合同项目节 // @Tags 合同管理-项目节 // @Description 新增 合同项目节 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param id body string true "项目节ID" // @Param name body string true "项目节名称" // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}" // @Router /api/contract/section/add [post] func (c *ContractApi) PostSectionAdd() { // 获得模板号 sectionData, err := c.ServiceContract.ValidRuleSectionAdd(c.Ctx) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)}) 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.SectionAdd(sectionData) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)}) return } c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功"}) } // @Summary 修改合同项目节 名称 // @Tags 合同管理-项目节 // @Description 修改合同项目节 名称 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param id body string true "项目节ID" // @Param name body string true "项目节名称" // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}" // @Router /api/contract/section/save [post] func (c *ContractApi) PostSectionSave() { // 获得模板号 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) 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": "修改成功"}) } // @Summary 删除 合同项目节 // @Tags 合同管理-项目节 // @Description 删除 合同项目节 // @Accept json // @Produce json // @Security ApiKeyAuth // @Param id body string true "项目节ID" // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}" // @Router /api/contract/section [delete] func (c *ContractApi) DeleteSection() { // 获得模板号-=1 sectionData, err := c.ServiceContract.ValidRuleSectionDelete(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 // } // 项目节ID treeId, err := utils.GetDecryptId(sectionData.Id) 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.SectionDelete(treeId) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)}) return } c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"}) }