seq.go 781 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package seq
  2. import (
  3. "context"
  4. "go-common/app/job/main/app-wall/conf"
  5. seq "go-common/app/service/main/seq-server/model"
  6. seqrpc "go-common/app/service/main/seq-server/rpc/client"
  7. "go-common/library/log"
  8. )
  9. type Dao struct {
  10. c *conf.Config
  11. seqRPC *seqrpc.Service2
  12. businessID int64
  13. token string
  14. }
  15. func New(c *conf.Config) (d *Dao) {
  16. d = &Dao{
  17. c: c,
  18. seqRPC: seqrpc.New2(c.SeqRPC),
  19. businessID: c.Seq.BusinessID,
  20. token: c.Seq.Token,
  21. }
  22. return
  23. }
  24. // SeqID
  25. func (d *Dao) SeqID(ctx context.Context) (requestNo int64, err error) {
  26. arg := &seq.ArgBusiness{
  27. BusinessID: d.businessID,
  28. Token: d.token,
  29. }
  30. if requestNo, err = d.seqRPC.ID(ctx, arg); err != nil {
  31. log.Error("d.seqRPC.ID error (%v)", err)
  32. return
  33. }
  34. return
  35. }