distributor_contact.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package base
  2. import (
  3. "context"
  4. model "dashoo.cn/micro/app/model/base"
  5. service "dashoo.cn/micro/app/service/base"
  6. "dashoo.cn/common_definition/comm_def"
  7. "github.com/gogf/gf/frame/g"
  8. )
  9. type BaseDistributorContact struct{}
  10. // Swagger:DistributorContact 经销商代理商联系人 查询
  11. func (c *BaseDistributorContact) List(ctx context.Context, req *model.BaseDistributorContactListReq, rsp *comm_def.CommonMsg) error {
  12. g.Log().Infof("BaseDistributorContact.List request %#v ", *req)
  13. s, err := service.NewBaseDistributorContactService(ctx)
  14. if err != nil {
  15. return err
  16. }
  17. total, ent, err := s.List(ctx, req)
  18. if err != nil {
  19. return err
  20. }
  21. if ent == nil {
  22. ent = []*model.BaseDistributorContact{}
  23. }
  24. rsp.Data = map[string]interface{}{
  25. "total": total,
  26. "list": ent,
  27. }
  28. return nil
  29. }
  30. // Swagger:DistributorContact 经销商代理商联系人 新增
  31. func (c *BaseDistributorContact) Add(ctx context.Context, req *model.BaseDistributorContactAddReq, rsp *comm_def.CommonMsg) error {
  32. g.Log().Infof("BaseDistributorContact.Add request %#v ", *req)
  33. s, err := service.NewBaseDistributorContactService(ctx)
  34. if err != nil {
  35. return err
  36. }
  37. id, err := s.Add(ctx, req)
  38. if err != nil {
  39. return err
  40. }
  41. rsp.Data = id
  42. return nil
  43. }
  44. // Swagger:DistributorContact 经销商代理商联系人 更新
  45. func (c *BaseDistributorContact) Update(ctx context.Context, req *model.BaseDistributorContactUpdateReq, rsp *comm_def.CommonMsg) error {
  46. g.Log().Infof("BaseDistributorContact.Update request %#v ", *req)
  47. s, err := service.NewBaseDistributorContactService(ctx)
  48. if err != nil {
  49. return err
  50. }
  51. err = s.Update(ctx, req)
  52. if err != nil {
  53. return err
  54. }
  55. return nil
  56. }
  57. // Swagger:DistributorContact 经销商代理商联系人 删除
  58. func (c *BaseDistributorContact) Delete(ctx context.Context, req *model.IdsReq, rsp *comm_def.CommonMsg) error {
  59. g.Log().Infof("BaseDistributorContact.Delete request %#v ", *req)
  60. s, err := service.NewBaseDistributorContactService(ctx)
  61. if err != nil {
  62. return err
  63. }
  64. err = s.Delete(ctx, req.Id)
  65. if err != nil {
  66. return err
  67. }
  68. return nil
  69. }