蛋蛋星球-客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

hdl_config.go 3.6 KiB

1週間前
1週間前
3週間前
1週間前
1週間前
3週間前
2週間前
1週間前
1週間前
1週間前
1週間前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. // Start
  92. // @Summary 打开app调用
  93. // @Tags 基本配置
  94. // @Description 打开app调用
  95. // @Accept json
  96. // @Produce json
  97. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  98. // @Success 200 {string} "具体数据"
  99. // @Failure 400 {object} md.Response "具体错误"
  100. // @Router /api/v1/openApp/start [get]
  101. func Start(c *gin.Context) {
  102. if c.GetHeader("Authorization") != "" {
  103. mw.Auth(c)
  104. user := svc.GetUser(c)
  105. if user != nil {
  106. svc.UserImeiAdd(c, user.Id)
  107. }
  108. }
  109. e.OutSuc(c, "success", nil)
  110. return
  111. }