分销商城(微商城)接口项目

fxlink_api_controller.go 1007B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package controllers
  2. import (
  3. "fmt"
  4. "wsc-go/enums"
  5. "wsc-go/service"
  6. "github.com/astaxie/beego"
  7. )
  8. type FxlinkApiController struct {
  9. BaseAuthAPIController
  10. }
  11. func FxlinkApiRegistRouters() {
  12. beego.Router("/api/getfxlink", &FxlinkApiController{}, "get:GetFxlink")
  13. }
  14. func (c *FxlinkApiController) GetFxlink() {
  15. link := c.GetString("link", "")
  16. if link != "fxlink" && link != "sylink" && link != "zxlink" {
  17. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误:link(sylink,zxlink,fxlink)")
  18. return
  19. }
  20. fxlink := beego.AppConfig.String(link)
  21. adminUserInfo := c.GetAdminUserInfo()
  22. orgId := adminUserInfo.CurrentOrgId
  23. appId := adminUserInfo.CurrentAppId
  24. thisApp := adminUserInfo.OrgApps[orgId][appId]
  25. creator := thisApp.Creator
  26. fxToken, fxTime := service.CreateFxToken(orgId, creator)
  27. fxlink = fxlink + fmt.Sprintf("&fxtoken=%s&fxorgid=%d&timestamp=%d&fxadmin=%d", fxToken, orgId, fxTime, creator)
  28. c.ServeSuccessJSON(map[string]interface{}{
  29. "fxlink": fxlink,
  30. })
  31. return
  32. }