蛋蛋星球-客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

118 řádky
3.7 KiB

  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/mw"
  7. "applet/app/svc"
  8. "applet/app/utils"
  9. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  10. "encoding/json"
  11. "fmt"
  12. "github.com/gin-gonic/gin"
  13. "github.com/tidwall/gjson"
  14. )
  15. // Config
  16. // @Summary 基本配置
  17. // @Tags 基本配置
  18. // @Description 基本配置
  19. // @Accept json
  20. // @Produce json
  21. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  22. // @Success 200 {object} md.ConfigResp "具体数据"
  23. // @Failure 400 {object} md.Response "具体错误"
  24. // @Router /api/v1/config [get]
  25. func Config(c *gin.Context) {
  26. res := md.ConfigResp{}
  27. eg := db.Db
  28. NewArticleDb := implement.NewArticleDb(eg)
  29. article, _ := NewArticleDb.GetArticle("112")
  30. if article != nil {
  31. res.Title = article.Title
  32. res.Content = article.Content
  33. }
  34. userArticle, _ := NewArticleDb.GetArticle("113")
  35. if userArticle != nil {
  36. res.UserTitle = userArticle.Title
  37. res.UserUrl = fmt.Sprintf("%s%s?id=%s&is_hide=1", svc.GetSysCfgStr("wap_host"), "/#/pages/course-detail-page/course-detail-page", utils.AnyToString(userArticle.Id))
  38. }
  39. privacyArticle, _ := NewArticleDb.GetArticle("114")
  40. if privacyArticle != nil {
  41. res.PrivacyTitle = privacyArticle.Title
  42. res.PrivacyUrl = fmt.Sprintf("%s%s?id=%s&is_hide=1", svc.GetSysCfgStr("wap_host"), "/#/pages/course-detail-page/course-detail-page", utils.AnyToString(privacyArticle.Id))
  43. }
  44. res.OssUrl = svc.GetOssDomain()
  45. appCloudBundleData := svc.GetSysCfgStr("app_cloud_bundle_data")
  46. guideStr := gjson.Get(appCloudBundleData, "guide").String()
  47. Guide := make([]md.Guide, 0)
  48. json.Unmarshal([]byte(guideStr), &Guide)
  49. res.Guide = Guide
  50. res.DownUrl = svc.GetSysCfgStr("kuaizhan_url")
  51. res.Seo = md.Seo{
  52. SeoTitle: svc.GetSysCfgStr("seo_title"),
  53. SeoLogo: svc.GetOssUrl(svc.GetSysCfgStr("seo_logo")),
  54. WebLogo: svc.GetOssUrl(svc.GetSysCfgStr("web_logo")),
  55. }
  56. e.OutSuc(c, res, nil)
  57. return
  58. }
  59. // Version
  60. // @Summary 版本记录
  61. // @Tags 基本配置
  62. // @Description 版本记录
  63. // @Accept json
  64. // @Produce json
  65. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  66. // @Success 200 {object} md.VersionResp "具体数据"
  67. // @Failure 400 {object} md.Response "具体错误"
  68. // @Router /api/v1/version [get]
  69. func Version(c *gin.Context) {
  70. appVersion := svc.GetSysCfgStr("app_version")
  71. version := make([]md.Version, 0)
  72. json.Unmarshal([]byte(appVersion), &version)
  73. newVersion := make([]md.Version, 0)
  74. for _, v := range version {
  75. v.Img = svc.GetOssUrl("default_icon/" + v.Type + "_icon.png")
  76. if v.Type != "360" {
  77. newVersion = append(newVersion, v)
  78. }
  79. }
  80. res := md.VersionResp{Version: newVersion, IsAuditVersion: "0"}
  81. NewCloudBundleDb := implement.NewCloudBundleDb(db.Db)
  82. os := "1"
  83. if c.GetHeader("platform") == "iOS" {
  84. os = "2"
  85. }
  86. data, _ := NewCloudBundleDb.GetCloudBundleVersion(os, c.GetHeader("appversionname"))
  87. if data != nil {
  88. res.IsAuditVersion = utils.IntToStr(data.IsAuditing)
  89. }
  90. e.OutSuc(c, res, nil)
  91. return
  92. }
  93. // Start
  94. // @Summary 打开app调用
  95. // @Tags 基本配置
  96. // @Description 打开app调用
  97. // @Accept json
  98. // @Produce json
  99. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  100. // @Success 200 {string} "具体数据"
  101. // @Failure 400 {object} md.Response "具体错误"
  102. // @Router /api/v1/openApp/start [get]
  103. func Start(c *gin.Context) {
  104. if c.GetHeader("Authorization") != "" {
  105. mw.Auth(c)
  106. user := svc.GetUser(c)
  107. if user != nil {
  108. svc.UserImeiAdd(c, user.Id)
  109. }
  110. }
  111. e.OutSuc(c, "success", nil)
  112. return
  113. }