dao.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package account
  2. import (
  3. "context"
  4. "go-common/app/job/main/up/conf"
  5. "go-common/app/service/main/account/model"
  6. account "go-common/app/service/main/account/rpc/client"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. )
  10. // Dao dao is account dao.
  11. type Dao struct {
  12. // config
  13. c *conf.Config
  14. // rpc
  15. acc *account.Service3
  16. }
  17. // New new a account dao.
  18. func New(c *conf.Config) (d *Dao) {
  19. d = &Dao{
  20. // config
  21. c: c,
  22. // rpc
  23. acc: account.New3(c.AccountRPC),
  24. }
  25. return
  26. }
  27. // Close close resource.
  28. func (d *Dao) Close() {
  29. }
  30. // Ping ping success.
  31. func (d *Dao) Ping(c context.Context) (err error) {
  32. return
  33. }
  34. // IdentifyInfo 获取用户实名认证状态
  35. func (d *Dao) IdentifyInfo(c context.Context, ak, ck, ip string, mid int64) (err error) {
  36. var mf *model.Profile
  37. if mf, err = d.Profile(c, mid, ip); err != nil {
  38. log.Error("d.Profile mid(%d),ip(%s),error(%v)", mid, ip, err)
  39. err = ecode.CreativeAccServiceErr
  40. return
  41. }
  42. if mf.Identification == 1 {
  43. return
  44. }
  45. //switch for FrontEnd return json format, return OldPhone, and newError
  46. if err = d.switchIDInfoRet(mf.TelStatus); err != nil {
  47. log.Error("switchIDInfoRet url(%s) res(%v)", mf.TelStatus)
  48. return
  49. }
  50. return
  51. }
  52. func (d *Dao) switchIDInfoRet(phoneRet int32) (err error) {
  53. switch phoneRet {
  54. case 0:
  55. err = ecode.UserCheckNoPhone
  56. case 1:
  57. err = nil
  58. case 2:
  59. err = ecode.UserCheckInvalidPhone
  60. }
  61. return
  62. }