eta_forum_hub.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package eta_forum
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. )
  6. type GetForumAdminAuthCodeResp struct {
  7. Ret int
  8. Msg string
  9. ErrMsg string
  10. ErrCode string
  11. Data *LoginAuthCode
  12. Success bool `description:"true 执行成功,false 执行失败"`
  13. IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
  14. IsAddLog bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
  15. }
  16. type LoginAuthCode struct {
  17. AuthCode string `json:"auth_code" description:"登录凭证"`
  18. }
  19. // GetLoginAuthCodeReq 获取登录编码请求体
  20. type GetLoginAuthCodeReq struct {
  21. AdminName string `description:"用户名"`
  22. Source int `description:"来源: 1-CRM; 2-ETA"`
  23. }
  24. // GetForumAdminAuthCode 获取登录凭证
  25. func GetForumAdminAuthCode(adminName string) (authCode string, err error) {
  26. // 查询图表信息
  27. param := GetLoginAuthCodeReq{
  28. Source: 1,
  29. AdminName: adminName,
  30. }
  31. reqJson, e := json.Marshal(param)
  32. if e != nil {
  33. err = fmt.Errorf("data json marshal err: %s", e.Error())
  34. return
  35. }
  36. respItem, err := GetForumAdminAuthCodeLib(string(reqJson))
  37. if err != nil {
  38. err = fmt.Errorf("获取登录凭证,Err:" + err.Error())
  39. return
  40. }
  41. if respItem.Ret != 200 {
  42. err = fmt.Errorf("获取登录凭证,Err:" + respItem.ErrMsg)
  43. return
  44. }
  45. if respItem.Data != nil {
  46. authCode = respItem.Data.AuthCode
  47. }
  48. return
  49. }