resource.go 974 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package resource
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-resource/conf"
  5. resource "go-common/app/service/main/resource/model"
  6. resrpc "go-common/app/service/main/resource/rpc/client"
  7. "go-common/library/log"
  8. )
  9. type Dao struct {
  10. c *conf.Config
  11. // rpc
  12. resRpc *resrpc.Service
  13. }
  14. func New(c *conf.Config) (d *Dao) {
  15. d = &Dao{
  16. c: c,
  17. // rpc
  18. resRpc: resrpc.New(c.ResourceRPC),
  19. }
  20. return
  21. }
  22. // ResSideBar resource ressidebar
  23. func (d *Dao) ResSideBar(ctx context.Context) (res *resource.SideBars, err error) {
  24. if res, err = d.resRpc.SideBars(ctx); err != nil {
  25. log.Error("resource d.resRpc.SideBars error(%v)", err)
  26. return
  27. }
  28. return
  29. }
  30. // AbTest resource abtest
  31. func (d *Dao) AbTest(ctx context.Context, groups string) (res map[string]*resource.AbTest, err error) {
  32. arg := &resource.ArgAbTest{
  33. Groups: groups,
  34. }
  35. if res, err = d.resRpc.AbTest(ctx, arg); err != nil {
  36. log.Error("resource d.resRpc.AbTest error(%v)", err)
  37. return
  38. }
  39. return
  40. }