contract_api.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * @description: 合同管理 相关API
  3. * @Author: CP
  4. * @Date: 2020-10-26 15:27:04
  5. * @FilePath: \design_quantity\web\api\contract_api.go
  6. */
  7. package api
  8. import (
  9. "github.com/kataras/iris/v12"
  10. "go.mod/services"
  11. "go.mod/web/utils"
  12. "go.mod/web/viewmodels"
  13. )
  14. type ContractApi struct {
  15. //框架-web应用上下文环境
  16. Ctx iris.Context
  17. // // 需要用的service
  18. ServiceContract services.ContractService
  19. // ServiceLogin services.LoginService
  20. // ServiceProject services.ProjectService
  21. }
  22. // @Summary 获得项目节信息
  23. // @Tags 合同管理-项目节
  24. // @Description 未设置合同项目节 返回项目节模板信息
  25. // @Accept json
  26. // @Produce json
  27. // @Param operation body string true "操作名称" 1
  28. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
  29. // @Router /api/section/all [get]
  30. func (c *ContractApi) GetSectionAll() {
  31. sectionData := viewmodels.TreeSectionContract{}
  32. err := c.Ctx.ReadForm(&sectionData)
  33. if err != nil {
  34. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  35. return
  36. }
  37. // if sectionData.BidsectionId == "" {
  38. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  39. // return
  40. // }
  41. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  42. // if err != nil {
  43. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  44. // return
  45. // }
  46. // 项目ID
  47. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  48. // if err != nil {
  49. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  50. // return
  51. // }
  52. //获得合同项目节
  53. sectionTree := c.ServiceContract.GetSecionTree(sectionData.Operation)
  54. result := make([]*viewmodels.TreeSectionContract, 0)
  55. result = append(result, sectionTree)
  56. c.Ctx.JSON(iris.Map{
  57. "code": 0,
  58. "msg": "",
  59. "result": result,
  60. })
  61. }
  62. // @Summary 获得单个项目节详情
  63. // @Tags 合同管理-项目节
  64. // @Description 未设置合同项目节 返回项目节模板信息
  65. // @Accept json
  66. // @Produce json
  67. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
  68. // @Router /api/section [get]
  69. func (c *ContractApi) GetSection() {
  70. sectionData := viewmodels.TreeSectionContract{}
  71. err := c.Ctx.ReadForm(&sectionData)
  72. if err != nil {
  73. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  74. return
  75. }
  76. id, _ := utils.GetDecryptId(sectionData.Id)
  77. //获得合同项目节
  78. name, pdfData, excelData := c.ServiceContract.GetSection(id)
  79. result := map[string]interface{}{
  80. "name": name,
  81. "pdfData": pdfData,
  82. "excelData": excelData,
  83. }
  84. c.Ctx.JSON(iris.Map{
  85. "code": 0,
  86. "msg": "",
  87. "result": result,
  88. })
  89. }