蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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