err_msg.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package cms
  2. import "go-common/app/interface/main/tv/model"
  3. const (
  4. // auth failure cases
  5. _pgcOffline = "pgc_offline"
  6. _cmsInvalid = "cms_invalid"
  7. _licenseReject = "license_reject"
  8. // auth correct values in DB
  9. _contentOnline = 0
  10. _snPass = 1
  11. _epPass = 3
  12. _cmsValid = 1
  13. )
  14. // AuthMsg returns the error message in the config according to the error condition
  15. func (d *Dao) authMsg(cond string) (msg string) {
  16. msgCfg := d.conf.Cfg.AuthMsg
  17. if cond == _licenseReject {
  18. return msgCfg.LicenseReject
  19. }
  20. if cond == _cmsInvalid {
  21. return msgCfg.CMSInvalid
  22. }
  23. if cond == _pgcOffline {
  24. return msgCfg.PGCOffline
  25. }
  26. return "err msg config load error"
  27. }
  28. // SnErrMsg returns the season auth result and the error message in case of auth failure
  29. func (d *Dao) SnErrMsg(season *model.SnAuth) (bool, string) {
  30. if season.IsDeleted == _contentOnline && season.Check == _snPass && season.Valid == _cmsValid {
  31. return true, ""
  32. }
  33. if season.Check != _snPass {
  34. return false, d.authMsg(_licenseReject)
  35. }
  36. if season.IsDeleted != _contentOnline {
  37. return false, d.authMsg(_pgcOffline)
  38. }
  39. return false, d.authMsg(_cmsInvalid) // must be cms valid logically
  40. }
  41. // UgcErrMsg returns the arc auth result and the error message in case of auth failure
  42. func (d *Dao) UgcErrMsg(deleted int, result int, valid int) (bool, string) {
  43. if deleted == _contentOnline && result == _snPass && valid == _cmsValid {
  44. return true, ""
  45. }
  46. if result != _snPass {
  47. return false, d.authMsg(_licenseReject)
  48. }
  49. if deleted != _contentOnline {
  50. return false, d.authMsg(_pgcOffline)
  51. }
  52. return false, d.authMsg(_cmsInvalid) // must be cms valid logically
  53. }
  54. // AuditingMsg returns the msg for the archive whose all videos are being audited
  55. func (d *Dao) AuditingMsg() (bool, string) {
  56. return false, d.authMsg(_licenseReject) // must be cms valid logically
  57. }
  58. // EpErrMsg returns the ep auth result and the error message in case of auth failure
  59. func (d *Dao) EpErrMsg(ep *model.EpAuth) (bool, string) {
  60. if ep.IsDeleted == _contentOnline && ep.State == _epPass && ep.Valid == _cmsValid {
  61. return true, ""
  62. }
  63. if ep.State != _epPass {
  64. return false, d.authMsg(_licenseReject)
  65. }
  66. if ep.IsDeleted != _contentOnline {
  67. return false, d.authMsg(_pgcOffline)
  68. }
  69. return false, d.authMsg(_cmsInvalid) // must be cms valid logically
  70. }