ctr_contract_collection_plan.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package contract
  2. import (
  3. "context"
  4. model "dashoo.cn/micro/app/model/contract"
  5. service "dashoo.cn/micro/app/service/contract"
  6. "dashoo.cn/common_definition/comm_def"
  7. "dashoo.cn/opms_libary/myerrors"
  8. "github.com/gogf/gf/frame/g"
  9. )
  10. type CtrContractCollectionPlan struct{}
  11. func (c *CtrContractCollectionPlan) Get(ctx context.Context, req *model.IdRequiredReq, rsp *comm_def.CommonMsg) error {
  12. g.Log().Infof("CtrContractCollectionPlan.Get request %#v ", *req)
  13. s, err := service.NewCtrContractCollectionPlanService(ctx)
  14. if err != nil {
  15. return err
  16. }
  17. ent, err := s.Get(ctx, req.Id)
  18. _, err, code, msg := myerrors.CheckError(err)
  19. if err != nil {
  20. return err
  21. }
  22. rsp.Code = code
  23. rsp.Msg = msg
  24. rsp.Data = ent
  25. return nil
  26. }
  27. func (c *CtrContractCollectionPlan) List(ctx context.Context, req *model.CtrContractCollectionPlanListReq, rsp *comm_def.CommonMsg) error {
  28. g.Log().Infof("CtrContractCollectionPlan.List request %#v ", *req)
  29. s, err := service.NewCtrContractCollectionPlanService(ctx)
  30. if err != nil {
  31. return err
  32. }
  33. total, ent, err := s.List(ctx, req)
  34. _, err, code, msg := myerrors.CheckError(err)
  35. if err != nil {
  36. return err
  37. }
  38. if ent == nil {
  39. ent = []*model.CtrContractCollectionPlan{}
  40. }
  41. rsp.Code = code
  42. rsp.Msg = msg
  43. rsp.Data = map[string]interface{}{
  44. "total": total,
  45. "list": ent,
  46. }
  47. return nil
  48. }
  49. func (c *CtrContractCollectionPlan) Add(ctx context.Context, req *model.CtrContractCollectionPlanAddReq, rsp *comm_def.CommonMsg) error {
  50. g.Log().Infof("CtrContractCollectionPlan.Add request %#v ", *req)
  51. s, err := service.NewCtrContractCollectionPlanService(ctx)
  52. if err != nil {
  53. return err
  54. }
  55. id, err := s.Add(ctx, req)
  56. _, err, code, msg := myerrors.CheckError(err)
  57. if err != nil {
  58. return err
  59. }
  60. rsp.Code = code
  61. rsp.Msg = msg
  62. rsp.Data = id
  63. return nil
  64. }
  65. func (c *CtrContractCollectionPlan) Update(ctx context.Context, req *model.CtrContractCollectionPlanUpdateReq, rsp *comm_def.CommonMsg) error {
  66. g.Log().Infof("CtrContractCollectionPlan.Update request %#v ", *req)
  67. s, err := service.NewCtrContractCollectionPlanService(ctx)
  68. if err != nil {
  69. return err
  70. }
  71. err = s.Update(ctx, req)
  72. _, err, code, msg := myerrors.CheckError(err)
  73. if err != nil {
  74. return err
  75. }
  76. rsp.Code = code
  77. rsp.Msg = msg
  78. return nil
  79. }
  80. func (c *CtrContractCollectionPlan) Delete(ctx context.Context, req *model.IdsReq, rsp *comm_def.CommonMsg) error {
  81. g.Log().Infof("CtrContractCollectionPlan.Delete request %#v ", *req)
  82. s, err := service.NewCtrContractCollectionPlanService(ctx)
  83. if err != nil {
  84. return err
  85. }
  86. err = s.Delete(ctx, req.Id)
  87. _, err, code, msg := myerrors.CheckError(err)
  88. if err != nil {
  89. return err
  90. }
  91. rsp.Code = code
  92. rsp.Msg = msg
  93. return nil
  94. }