蛋蛋星球-客户端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

hdl_config.go 3.2 KiB

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