model.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package model
  2. import (
  3. "container/ring"
  4. "context"
  5. "encoding/json"
  6. "sync"
  7. smsmdl "go-common/app/service/main/sms/model"
  8. )
  9. const (
  10. // SmsPrefix .
  11. SmsPrefix = "【哔哩哔哩】"
  12. // SmsSuffix .
  13. SmsSuffix = " 回TD退订"
  14. // SmsSuffixChuangLan .
  15. SmsSuffixChuangLan = " 退订回T"
  16. )
  17. // Provider service provider
  18. type Provider interface {
  19. // SendSms send sms
  20. GetPid() int32
  21. // SendSms send sms
  22. SendSms(context.Context, *smsmdl.ModelSend) (string, error)
  23. // SendActSms send act sms
  24. SendActSms(context.Context, *smsmdl.ModelSend) (string, error)
  25. // SendBatchActSms send batch act sms
  26. SendBatchActSms(context.Context, *smsmdl.ModelSend) (string, error)
  27. // SendInternationalSms send international sms
  28. SendInternationalSms(context.Context, *smsmdl.ModelSend) (string, error)
  29. }
  30. // Message .
  31. type Message struct {
  32. Action string `json:"action"`
  33. Table string `json:"table"`
  34. New json.RawMessage `json:"new"`
  35. Old json.RawMessage `json:"old"`
  36. }
  37. // UserMobile .
  38. type UserMobile struct {
  39. CountryCode string `json:"code"`
  40. Mobile string `json:"tel"`
  41. }
  42. // ConcurrentRing thread-safe ring
  43. type ConcurrentRing struct {
  44. *ring.Ring
  45. sync.Mutex
  46. }
  47. // NewConcurrentRing .
  48. func NewConcurrentRing(length int) *ConcurrentRing {
  49. return &ConcurrentRing{Ring: ring.New(length)}
  50. }