contract_api.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * @description: 合同管理 相关API
  3. * @Author: CP
  4. * @Date: 2020-10-26 15:27:04
  5. * @FilePath: \construction_management\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. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
  28. // @Router /api/section/all [get]
  29. func (c *ContractApi) GetSectionAll() {
  30. sectionData := viewmodels.TreeSectionContract{}
  31. err := c.Ctx.ReadForm(&sectionData)
  32. if err != nil {
  33. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  34. return
  35. }
  36. // if sectionData.BidsectionId == "" {
  37. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  38. // return
  39. // }
  40. // bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
  41. // if err != nil {
  42. // c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  43. // return
  44. // }
  45. // 项目ID
  46. // projectIdInt, err := utils.GetProjectId(c.Ctx)
  47. // if err != nil {
  48. // c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  49. // return
  50. // }
  51. //获得合同项目节
  52. sectionTree := c.ServiceContract.GetSecionTree()
  53. c.Ctx.JSON(iris.Map{
  54. "code": 0,
  55. "msg": "",
  56. "result": sectionTree,
  57. })
  58. }
  59. // @Summary 获得单个项目节详情
  60. // @Tags 合同管理-项目节
  61. // @Description 未设置合同项目节 返回项目节模板信息
  62. // @Accept json
  63. // @Produce json
  64. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
  65. // @Router /api/section [get]
  66. func (c *ContractApi) GetSection() {
  67. sectionData := viewmodels.TreeSectionContract{}
  68. err := c.Ctx.ReadForm(&sectionData)
  69. if err != nil {
  70. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  71. return
  72. }
  73. id, _ := utils.GetDecryptId(sectionData.Id)
  74. //获得合同项目节
  75. sectionTree := c.ServiceContract.GetSection(id)
  76. c.Ctx.JSON(iris.Map{
  77. "code": 0,
  78. "msg": "",
  79. "result": sectionTree,
  80. })
  81. }