蛋蛋星球 后台端
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.
 
 
 
 

66 lines
1.8 KiB

  1. package cloud_bundle
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "applet/app/utils/cache"
  9. "applet/app/utils/logx"
  10. "code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
  11. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  12. "encoding/json"
  13. "github.com/gin-gonic/gin"
  14. )
  15. func VersionBase(c *gin.Context) {
  16. appCloudBundleData := svc.GetSysCfgStr("app_version")
  17. tmp := make([]md.CloudBundleVersion, 0)
  18. json.Unmarshal([]byte(appCloudBundleData), &tmp)
  19. data := []md.CloudBundleVersion{
  20. {Type: "station", Name: "官方渠道"},
  21. {Type: "yingyongbao", Name: "应用宝商店"},
  22. {Type: "ios", Name: "IOS商店"},
  23. {Type: "huawei", Name: "华为应用商店"},
  24. {Type: "xiaomi", Name: "小米应用商店"},
  25. {Type: "meizu", Name: "魅族应用商店"},
  26. {Type: "vivo", Name: "VIVO应用商店"},
  27. {Type: "oppo", Name: "OPPO应用商店"},
  28. }
  29. for k, v := range data {
  30. data[k].Img = "default_icon/" + v.Type + "_icon.png"
  31. data[k].ImgUrl = svc.GetOssUrl(data[k].Img)
  32. for _, v1 := range tmp {
  33. if v1.Type == v.Type {
  34. data[k].Version = v1.Version
  35. data[k].Url = v1.Url
  36. data[k].Content = v1.Content
  37. data[k].IsMust = v1.IsMust
  38. }
  39. }
  40. }
  41. res := md.CloudBundleVersionResp{Version: data}
  42. e.OutSuc(c, res, nil)
  43. return
  44. }
  45. func VersionBaseSave(c *gin.Context) {
  46. var req []md.CloudBundleVersion
  47. if err := c.ShouldBindJSON(&req); err != nil {
  48. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  49. return
  50. }
  51. conn := cache.GetPool().Get()
  52. cfgDb := implement.NewSysCfgDb(db.Db, conn)
  53. defer func(cfgDb dao.SysCfgDao) {
  54. err := cfgDb.Close()
  55. if err != nil {
  56. logx.Error("redis close err:" + err.Error()) // 记录错误信息
  57. }
  58. }(cfgDb)
  59. cfgDb.SysCfgUpdate("app_version", utils.SerializeStr(req))
  60. e.OutSuc(c, "success", nil)
  61. return
  62. }