dynamic.go 963 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package dynamic
  2. import (
  3. "context"
  4. "go-common/app/interface/main/app-show/conf"
  5. "go-common/app/service/main/archive/api"
  6. dynarc "go-common/app/service/main/dynamic/model"
  7. dynrpc "go-common/app/service/main/dynamic/rpc/client"
  8. "go-common/library/log"
  9. )
  10. // Dao is rpc dao.
  11. type Dao struct {
  12. // dynamic rpc
  13. dynRpc *dynrpc.Service
  14. }
  15. // New new a archive dao.
  16. func New(c *conf.Config) (d *Dao) {
  17. d = &Dao{
  18. // dynamic rpc
  19. dynRpc: dynrpc.New(c.DynamicRPC),
  20. }
  21. return
  22. }
  23. // regionDynamic
  24. func (d *Dao) RegionDynamic(ctx context.Context, rid, pn, ps int) (res []*api.Arc, aids []int64, err error) {
  25. arg := &dynarc.ArgRegion3{
  26. RegionID: int32(rid),
  27. Pn: pn,
  28. Ps: ps,
  29. }
  30. var as *dynarc.DynamicArcs3
  31. if as, err = d.dynRpc.RegionArcs3(ctx, arg); err != nil {
  32. log.Error("d.dynRpc.RegionArcs(%v) error(%v)", arg, err)
  33. return
  34. }
  35. if as != nil {
  36. res = as.Archives
  37. for _, a := range res {
  38. aids = append(aids, a.Aid)
  39. }
  40. }
  41. return
  42. }