project_inventory.go 2.4 KB

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