ctr_contract_collection.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 CtrContractCollection struct{}
  11. func (c *CtrContractCollection) List(ctx context.Context, req *model.CtrContractCollectionListReq, rsp *comm_def.CommonMsg) error {
  12. g.Log().Infof("CtrContractCollection.List request %#v ", *req)
  13. s, err := service.NewCtrContractCollectionService(ctx)
  14. if err != nil {
  15. return err
  16. }
  17. total, ent, err := s.List(ctx, req)
  18. _, err, code, msg := myerrors.CheckError(err)
  19. if err != nil {
  20. return err
  21. }
  22. if ent == nil {
  23. ent = []*model.CtrContractCollection{}
  24. }
  25. rsp.Code = code
  26. rsp.Msg = msg
  27. rsp.Data = map[string]interface{}{
  28. "total": total,
  29. "list": ent,
  30. }
  31. return nil
  32. }
  33. func (c *CtrContractCollection) Add(ctx context.Context, req *model.CtrContractCollectionAddReq, rsp *comm_def.CommonMsg) error {
  34. g.Log().Infof("CtrContractCollection.Add request %#v ", *req)
  35. s, err := service.NewCtrContractCollectionService(ctx)
  36. if err != nil {
  37. return err
  38. }
  39. id, err := s.Add(ctx, req)
  40. _, err, code, msg := myerrors.CheckError(err)
  41. if err != nil {
  42. return err
  43. }
  44. rsp.Code = code
  45. rsp.Msg = msg
  46. rsp.Data = id
  47. return nil
  48. }
  49. func (c *CtrContractCollection) Update(ctx context.Context, req *model.CtrContractCollectionUpdateReq, rsp *comm_def.CommonMsg) error {
  50. g.Log().Infof("CtrContractCollection.Update request %#v ", *req)
  51. s, err := service.NewCtrContractCollectionService(ctx)
  52. if err != nil {
  53. return err
  54. }
  55. err = s.Update(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. return nil
  63. }
  64. func (c *CtrContractCollection) Delete(ctx context.Context, req *model.IdsReq, rsp *comm_def.CommonMsg) error {
  65. g.Log().Infof("CtrContractCollection.Delete request %#v ", *req)
  66. s, err := service.NewCtrContractCollectionService(ctx)
  67. if err != nil {
  68. return err
  69. }
  70. err = s.Delete(ctx, req.Id)
  71. _, err, code, msg := myerrors.CheckError(err)
  72. if err != nil {
  73. return err
  74. }
  75. rsp.Code = code
  76. rsp.Msg = msg
  77. return nil
  78. }