ctr_contract_collection.go 2.3 KB

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