蛋蛋星球-客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

149 rader
4.6 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. res.DownViewUrl, _, res.RegisterViewUrl = svc.DownUrl(c)
  57. if res.DownViewUrl == "" {
  58. link := svc.GetSysCfgStr("kuaizhan_url")
  59. link += "?type=download"
  60. res.DownViewUrl = link
  61. }
  62. res.DownWebOpen = svc.GetSysCfgStr("down_web_open")
  63. e.OutSuc(c, res, nil)
  64. return
  65. }
  66. // Version
  67. // @Summary 版本记录
  68. // @Tags 基本配置
  69. // @Description 版本记录
  70. // @Accept json
  71. // @Produce json
  72. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  73. // @Success 200 {object} md.VersionResp "具体数据"
  74. // @Failure 400 {object} md.Response "具体错误"
  75. // @Router /api/v1/version [get]
  76. func Version(c *gin.Context) {
  77. appVersion := svc.GetSysCfgStr("app_version")
  78. version := make([]md.Version, 0)
  79. json.Unmarshal([]byte(appVersion), &version)
  80. newVersion := make([]md.Version, 0)
  81. for _, v := range version {
  82. v.Img = svc.GetOssUrl("default_icon/" + v.Type + "_icon.png")
  83. newVersion = append(newVersion, v)
  84. }
  85. res := md.VersionResp{Version: newVersion, IsAuditVersion: "0"}
  86. NewCloudBundleDb := implement.NewCloudBundleDb(db.Db)
  87. os := "1"
  88. if c.GetHeader("platform") == "iOS" {
  89. os = "2"
  90. }
  91. data, _ := NewCloudBundleDb.GetCloudBundleVersion(os, c.GetHeader("appversionname"))
  92. if data != nil {
  93. res.IsAuditVersion = utils.IntToStr(data.IsAuditing)
  94. }
  95. e.OutSuc(c, res, nil)
  96. return
  97. }
  98. func DownloadList(c *gin.Context) {
  99. appVersion := svc.GetSysCfgStr("app_version")
  100. version := make([]md.Version, 0)
  101. json.Unmarshal([]byte(appVersion), &version)
  102. newVersion := make([]md.Version, 0)
  103. for _, v := range version {
  104. if v.Url == "" {
  105. continue
  106. }
  107. v.Img = svc.GetOssUrl("default_icon/" + v.Type + "_icon.png")
  108. newVersion = append(newVersion, v)
  109. }
  110. res := md.VersionResp{Version: newVersion, IsAuditVersion: "0"}
  111. NewCloudBundleDb := implement.NewCloudBundleDb(db.Db)
  112. os := "1"
  113. if c.GetHeader("platform") == "iOS" {
  114. os = "2"
  115. }
  116. data, _ := NewCloudBundleDb.GetCloudBundleVersion(os, c.GetHeader("appversionname"))
  117. if data != nil {
  118. res.IsAuditVersion = utils.IntToStr(data.IsAuditing)
  119. }
  120. e.OutSuc(c, res, nil)
  121. return
  122. }
  123. // Start
  124. // @Summary 打开app调用
  125. // @Tags 基本配置
  126. // @Description 打开app调用
  127. // @Accept json
  128. // @Produce json
  129. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  130. // @Success 200 {string} "具体数据"
  131. // @Failure 400 {object} md.Response "具体错误"
  132. // @Router /api/v1/openApp/start [get]
  133. func Start(c *gin.Context) {
  134. if c.GetHeader("Authorization") != "" {
  135. mw.Auth(c)
  136. user := svc.GetUser(c)
  137. if user != nil {
  138. svc.UserImeiAdd(c, user.Id)
  139. }
  140. }
  141. e.OutSuc(c, "success", nil)
  142. return
  143. }