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

106 rader
3.3 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.ArticleByTypeId("1")
  30. if article != nil {
  31. res.Title = article.Title
  32. res.Content = article.Content
  33. }
  34. userArticle, _ := NewArticleDb.ArticleByTypeId("2")
  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.ArticleByTypeId("3")
  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(userArticle.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. e.OutSuc(c, res, nil)
  52. return
  53. }
  54. // Version
  55. // @Summary 版本记录
  56. // @Tags 基本配置
  57. // @Description 版本记录
  58. // @Accept json
  59. // @Produce json
  60. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  61. // @Success 200 {object} md.VersionResp "具体数据"
  62. // @Failure 400 {object} md.Response "具体错误"
  63. // @Router /api/v1/version [get]
  64. func Version(c *gin.Context) {
  65. appVersion := svc.GetSysCfgStr("app_version")
  66. version := make([]md.Version, 0)
  67. json.Unmarshal([]byte(appVersion), &version)
  68. res := md.VersionResp{Version: version, IsAuditVersion: "0"}
  69. NewCloudBundleDb := implement.NewCloudBundleDb(db.Db)
  70. os := "1"
  71. if c.GetHeader("platform") == "iOS" {
  72. os = "2"
  73. }
  74. data, _ := NewCloudBundleDb.GetCloudBundleVersion(os, c.GetHeader("appversionname"))
  75. if data != nil {
  76. res.IsAuditVersion = utils.IntToStr(data.IsAuditing)
  77. }
  78. e.OutSuc(c, res, nil)
  79. return
  80. }
  81. // Start
  82. // @Summary 打开app调用
  83. // @Tags 基本配置
  84. // @Description 打开app调用
  85. // @Accept json
  86. // @Produce json
  87. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  88. // @Success 200 {string} "具体数据"
  89. // @Failure 400 {object} md.Response "具体错误"
  90. // @Router /api/v1/openApp/start [get]
  91. func Start(c *gin.Context) {
  92. if c.GetHeader("Authorization") != "" {
  93. mw.Auth(c)
  94. user := svc.GetUser(c)
  95. if user != nil {
  96. svc.UserImeiAdd(c, user.Id)
  97. }
  98. }
  99. e.OutSuc(c, "success", nil)
  100. return
  101. }