tencent_usersig_api_controller.go 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package kefu
  2. import (
  3. base_ctl "SCRM/controllers"
  4. "SCRM/enums"
  5. "SCRM/service/tencentim_service"
  6. "SCRM/utils"
  7. "strconv"
  8. "github.com/astaxie/beego"
  9. )
  10. type TencentUsersigApiController struct {
  11. base_ctl.BaseAuthAPIController
  12. }
  13. func TencentUsersigApiRegistRouters() {
  14. beego.Router("/api/tencent/usersig", &TencentUsersigApiController{}, "get:GetUsersig")
  15. }
  16. //GetUsersig 签名
  17. func (c *TencentUsersigApiController) GetUsersig() {
  18. adminUserInfo := c.GetAdminUserInfo()
  19. adminId := adminUserInfo.AdminUser.Id
  20. Indentifier := "Org_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  21. appIDAt3rd := Indentifier
  22. sig, err := tencentim_service.CreateUserSig(Indentifier, appIDAt3rd)
  23. if err != nil {
  24. utils.ErrorLog("usersig err : %v", err)
  25. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26. return
  27. }
  28. orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
  29. IdentifierNick := ""
  30. HeadURL := "http://jk.kuyicloud.com/static/images/ico_gjh.png"
  31. if orgInfo != nil {
  32. if len(orgInfo.OrgName) > 0 {
  33. IdentifierNick = orgInfo.OrgName
  34. }
  35. if len(orgInfo.OrgLogo) > 0 {
  36. HeadURL = orgInfo.OrgLogo
  37. }
  38. }
  39. returnData := map[string]interface{}{
  40. "sig": sig,
  41. "adminId": adminId,
  42. "Indentifier": Indentifier,
  43. "appIDAt3rd": appIDAt3rd,
  44. "IdentifierNick": IdentifierNick,
  45. "HeadURL": HeadURL,
  46. "sdkAppID": tencentim_service.ThisSDKAppId,
  47. "accountType": tencentim_service.ThisAccType,
  48. "selToAdmin": "AdminKeFu",
  49. }
  50. c.ServeSuccessJSON(returnData)
  51. return
  52. }