project_inventory.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package opsdev
  2. import (
  3. "context"
  4. "dashoo.cn/common_definition/comm_def"
  5. "dashoo.cn/opms_libary/myerrors"
  6. "dashoo.cn/opms_parent/app/model/opsdev"
  7. opssrv "dashoo.cn/opms_parent/app/service/opsdev"
  8. "github.com/gogf/gf/frame/g"
  9. "github.com/gogf/gf/util/gvalid"
  10. )
  11. type ProjectInventoryHandler struct{}
  12. func (h *ProjectInventoryHandler) GetList(ctx context.Context, req *opsdev.ProjectInventorySearchReq, rsp *comm_def.CommonMsg) error {
  13. srv, err := opssrv.NewProjectInventoryService(ctx)
  14. if err != nil {
  15. return err
  16. }
  17. total, list, err := srv.GetList(req)
  18. if err != nil {
  19. return err
  20. }
  21. rsp.Data = g.Map{"list": list, "total": total}
  22. return nil
  23. }
  24. func (h *ProjectInventoryHandler) GetProjectManagers(ctx context.Context, req *opsdev.ProjectManagerReq, rsp *comm_def.CommonMsg) error {
  25. srv, err := opssrv.NewProjectInventoryService(ctx)
  26. if err != nil {
  27. return err
  28. }
  29. records, err := srv.GetProjectManagers(req.RoleType)
  30. if err != nil {
  31. return err
  32. }
  33. rsp.Data = records
  34. return nil
  35. }
  36. func (h *ProjectInventoryHandler) GetContractProducts(ctx context.Context, req *opsdev.ContractProductReq, rsp *comm_def.CommonMsg) error {
  37. if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
  38. return myerrors.ValidError(err.Error())
  39. }
  40. srv, err := opssrv.NewProjectInventoryService(ctx)
  41. if err != nil {
  42. return err
  43. }
  44. records, err := srv.GetContractProducts(req.ContractId)
  45. if err != nil {
  46. return err
  47. }
  48. rsp.Data = records
  49. return nil
  50. }
  51. func (h *ProjectInventoryHandler) GetProductLines(ctx context.Context, req *struct{}, rsp *comm_def.CommonMsg) error {
  52. srv, err := opssrv.NewProjectInventoryService(ctx)
  53. if err != nil {
  54. return err
  55. }
  56. rsp.Data = srv.GetProductLines()
  57. return nil
  58. }
  59. func (h *ProjectInventoryHandler) GetProjectStatusList(ctx context.Context, req *struct{}, rsp *comm_def.CommonMsg) error {
  60. srv, err := opssrv.NewProjectInventoryService(ctx)
  61. if err != nil {
  62. return err
  63. }
  64. rsp.Data = srv.GetProjectStatusList()
  65. return nil
  66. }
  67. func (h *ProjectInventoryHandler) GetDeliveryNodes(ctx context.Context, req *struct{}, rsp *comm_def.CommonMsg) error {
  68. srv, err := opssrv.NewProjectInventoryService(ctx)
  69. if err != nil {
  70. return err
  71. }
  72. rsp.Data = srv.GetDeliveryNodes()
  73. return nil
  74. }
  75. func (h *ProjectInventoryHandler) Export(ctx context.Context, req *opsdev.ProjectInventoryExportReq, rsp *comm_def.CommonMsg) error {
  76. srv, err := opssrv.NewProjectInventoryService(ctx)
  77. if err != nil {
  78. return err
  79. }
  80. content, err := srv.Export(ctx, req)
  81. if err != nil {
  82. return err
  83. }
  84. rsp.Data = content
  85. return nil
  86. }