/* * @description: 合同管理 相关API * @Author: CP * @Date: 2020-10-26 15:27:04 * @FilePath: \design_quantity\web\api\contract_api.go */ package api import ( "github.com/kataras/iris/v12" "go.mod/services" "go.mod/web/utils" "go.mod/web/viewmodels" ) type ContractApi struct { //框架-web应用上下文环境 Ctx iris.Context // // 需要用的service ServiceContract services.ContractService // ServiceLogin services.LoginService // ServiceProject services.ProjectService } // @Summary 获得项目节信息 // @Tags 合同管理-项目节 // @Description 未设置合同项目节 返回项目节模板信息 // @Accept json // @Produce json // @Param operation body string true "操作名称" 1 // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}" // @Router /api/section/all [get] func (c *ContractApi) GetSectionAll() { sectionData := viewmodels.TreeSectionContract{} err := c.Ctx.ReadForm(§ionData) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"}) return } // if sectionData.BidsectionId == "" { // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"}) // return // } // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"}) // return // } // 项目ID // projectIdInt, err := utils.GetProjectId(c.Ctx) // if err != nil { // c.Ctx.JSON(iris.Map{"code": -1, "msg": err}) // return // } //获得合同项目节 sectionTree := c.ServiceContract.GetSecionTree(sectionData.Operation) result := make([]*viewmodels.TreeSectionContract, 0) result = append(result, sectionTree) c.Ctx.JSON(iris.Map{ "code": 0, "msg": "", "result": result, }) } // @Summary 获得单个项目节详情 // @Tags 合同管理-项目节 // @Description 未设置合同项目节 返回项目节模板信息 // @Accept json // @Produce json // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}" // @Router /api/section [get] func (c *ContractApi) GetSection() { sectionData := viewmodels.TreeSectionContract{} err := c.Ctx.ReadForm(§ionData) if err != nil { c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"}) return } id, _ := utils.GetDecryptId(sectionData.Id) //获得合同项目节 name, pdfData, excelData := c.ServiceContract.GetSection(id) result := map[string]interface{}{ "name": name, "pdfData": pdfData, "excelData": excelData, } c.Ctx.JSON(iris.Map{ "code": 0, "msg": "", "result": result, }) }