distributor_target.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 BaseDistributorTarget struct{}
  10. // Swagger:DistributorTarget 经销商代理商指标 查询
  11. func (c *BaseDistributorTarget) List(ctx context.Context, req *model.BaseDistributorTargetListReq, rsp *comm_def.CommonMsg) error {
  12. g.Log().Infof("BaseDistributorTarget.List request %#v ", *req)
  13. s, err := service.NewBaseDistributorTargetService(ctx)
  14. if err != nil {
  15. return err
  16. }
  17. total, ent, err := s.List(ctx, req)
  18. if ent == nil {
  19. ent = []*model.BaseDistributorTargetListRsp{}
  20. }
  21. rsp.Data = map[string]interface{}{
  22. "total": total,
  23. "list": ent,
  24. }
  25. return nil
  26. }
  27. // Swagger:DistributorTarget 经销商代理商指标 添加
  28. func (c *BaseDistributorTarget) Add(ctx context.Context, req *model.BaseDistributorTargetAddReq, rsp *comm_def.CommonMsg) error {
  29. g.Log().Infof("BaseDistributorTarget.Add request %#v ", *req)
  30. s, err := service.NewBaseDistributorTargetService(ctx)
  31. if err != nil {
  32. return err
  33. }
  34. id, err := s.Add(ctx, req)
  35. if err != nil {
  36. return err
  37. }
  38. rsp.Data = id
  39. return nil
  40. }
  41. // Swagger:DistributorTarget 经销商代理商指标 更新
  42. func (c *BaseDistributorTarget) Update(ctx context.Context, req *model.BaseDistributorTargetUpdateReq, rsp *comm_def.CommonMsg) error {
  43. g.Log().Infof("BaseDistributorTarget.Update request %#v ", *req)
  44. s, err := service.NewBaseDistributorTargetService(ctx)
  45. if err != nil {
  46. return err
  47. }
  48. err = s.Update(ctx, req)
  49. if err != nil {
  50. return err
  51. }
  52. return nil
  53. }
  54. // Swagger:DistributorTarget 经销商代理商指标 删除
  55. func (c *BaseDistributorTarget) Delete(ctx context.Context, req *model.IdsReq, rsp *comm_def.CommonMsg) error {
  56. g.Log().Infof("BaseDistributorTarget.Delete request %#v ", *req)
  57. s, err := service.NewBaseDistributorTargetService(ctx)
  58. if err != nil {
  59. return err
  60. }
  61. err = s.Delete(ctx, req.Id)
  62. if err != nil {
  63. return err
  64. }
  65. return nil
  66. }