contract_api.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. c.Ctx.JSON(iris.Map{
  55. "code": 0,
  56. "msg": "",
  57. "result": sectionTree,
  58. })
  59. }
  60. // @Summary 获得单个项目节详情
  61. // @Tags 合同管理-项目节
  62. // @Description 未设置合同项目节 返回项目节模板信息
  63. // @Accept json
  64. // @Produce json
  65. // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
  66. // @Router /api/section [get]
  67. func (c *ContractApi) GetSection() {
  68. sectionData := viewmodels.TreeSectionContract{}
  69. err := c.Ctx.ReadForm(&sectionData)
  70. if err != nil {
  71. c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
  72. return
  73. }
  74. id, _ := utils.GetDecryptId(sectionData.Id)
  75. //获得合同项目节
  76. sectionTree := c.ServiceContract.GetSection(id)
  77. c.Ctx.JSON(iris.Map{
  78. "code": 0,
  79. "msg": "",
  80. "result": sectionTree,
  81. })
  82. }