蛋蛋星球-客户端
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.
 
 
 
 
 

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