|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- package hdl
-
- import (
- "applet/app/db"
- "applet/app/e"
- "applet/app/md"
- "applet/app/mw"
- "applet/app/svc"
- "applet/app/utils"
- "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
- "encoding/json"
- "fmt"
- "github.com/gin-gonic/gin"
- "github.com/tidwall/gjson"
- )
-
- // Config
- // @Summary 基本配置
- // @Tags 基本配置
- // @Description 基本配置
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Success 200 {object} md.ConfigResp "具体数据"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/v1/config [get]
- func Config(c *gin.Context) {
- res := md.ConfigResp{}
- eg := db.Db
- NewArticleDb := implement.NewArticleDb(eg)
- article, _ := NewArticleDb.GetArticle("112")
- if article != nil {
- res.Title = article.Title
- res.Content = article.Content
- }
- userArticle, _ := NewArticleDb.GetArticle("113")
- if userArticle != nil {
- res.UserTitle = userArticle.Title
- 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))
- }
- privacyArticle, _ := NewArticleDb.GetArticle("114")
- if privacyArticle != nil {
- res.PrivacyTitle = privacyArticle.Title
- 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))
- }
- res.OssUrl = svc.GetOssDomain()
- appCloudBundleData := svc.GetSysCfgStr("app_cloud_bundle_data")
- guideStr := gjson.Get(appCloudBundleData, "guide").String()
- Guide := make([]md.Guide, 0)
- json.Unmarshal([]byte(guideStr), &Guide)
- res.Guide = Guide
- res.DownUrl = svc.GetSysCfgStr("kuaizhan_url")
- res.Seo = md.Seo{
- SeoTitle: svc.GetSysCfgStr("seo_title"),
- SeoLogo: svc.GetOssUrl(svc.GetSysCfgStr("seo_logo")),
- WebLogo: svc.GetOssUrl(svc.GetSysCfgStr("web_logo")),
- }
- e.OutSuc(c, res, nil)
- return
- }
-
- // Version
- // @Summary 版本记录
- // @Tags 基本配置
- // @Description 版本记录
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Success 200 {object} md.VersionResp "具体数据"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/v1/version [get]
- func Version(c *gin.Context) {
- appVersion := svc.GetSysCfgStr("app_version")
- version := make([]md.Version, 0)
- json.Unmarshal([]byte(appVersion), &version)
- for k, v := range version {
- version[k].Img = svc.GetOssUrl("default_icon/" + v.Type + "_icon.png")
- }
- res := md.VersionResp{Version: version, IsAuditVersion: "0"}
- NewCloudBundleDb := implement.NewCloudBundleDb(db.Db)
- os := "1"
- if c.GetHeader("platform") == "iOS" {
- os = "2"
- }
- data, _ := NewCloudBundleDb.GetCloudBundleVersion(os, c.GetHeader("appversionname"))
- if data != nil {
- res.IsAuditVersion = utils.IntToStr(data.IsAuditing)
- }
- e.OutSuc(c, res, nil)
- return
- }
-
- // Start
- // @Summary 打开app调用
- // @Tags 基本配置
- // @Description 打开app调用
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Success 200 {string} "具体数据"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/v1/openApp/start [get]
- func Start(c *gin.Context) {
- if c.GetHeader("Authorization") != "" {
- mw.Auth(c)
- user := svc.GetUser(c)
- if user != nil {
- svc.UserImeiAdd(c, user.Id)
- }
- }
- e.OutSuc(c, "success", nil)
- return
- }
|