distributor.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package base
  2. import (
  3. "context"
  4. "dashoo.cn/common_definition/comm_def"
  5. "dashoo.cn/opms_libary/myerrors"
  6. "github.com/gogf/gf/frame/g"
  7. "github.com/gogf/gf/util/gvalid"
  8. model "dashoo.cn/micro/app/model/base"
  9. server "dashoo.cn/micro/app/service/base"
  10. )
  11. type DistributorHandler struct{}
  12. // GetList 获取列表
  13. func (p *DistributorHandler) GetList(ctx context.Context, req *model.BaseDistributorSearchReq, rsp *comm_def.CommonMsg) error {
  14. distributorServer, err := server.NewDistributorService(ctx)
  15. if err != nil {
  16. g.Log().Error(err)
  17. return err
  18. }
  19. total, list, err := distributorServer.GetList(req)
  20. _, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
  21. if err != nil {
  22. g.Log().Error(err)
  23. return err
  24. }
  25. rsp.Data = g.Map{"list": list, "total": total}
  26. return nil
  27. }
  28. // 创建
  29. func (p *DistributorHandler) Create(ctx context.Context, req *model.AddDistributor, rsp *comm_def.CommonMsg) error {
  30. if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
  31. return err
  32. }
  33. distributorServer, err := server.NewDistributorService(ctx)
  34. if err != nil {
  35. g.Log().Error(err)
  36. return err
  37. }
  38. distributorServer.Create(req)
  39. return nil
  40. }
  41. // 编辑
  42. //删掉