Browse Source

temp commit

hsun 2 years ago
parent
commit
49f9be8654
4 changed files with 99 additions and 0 deletions
  1. 45 0
      controllers/home.go
  2. 40 0
      controllers/micro_roadshow.go
  3. 9 0
      models/config.go
  4. 5 0
      routers/router.go

+ 45 - 0
controllers/home.go

@@ -1,6 +1,7 @@
 package controllers
 
 import (
+	"encoding/json"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
@@ -560,3 +561,47 @@ func (this *HomeController) ListHomeArtAndChart() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 首页/搜索头部导航接口
+// @Description 首页/搜索头部导航接口
+// @Success 200 {object} models.HomeListResp
+// @router /header_tab [get]
+func (this *HomeController) HeaderTab() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
+	key := models.HomeHeaderTabConfigCode
+	conf, e := models.GetConfigByCode(key)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error()
+		return
+	}
+	if conf.ConfigValue == "" {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值有误"
+		return
+	}
+
+	list := make([]*models.HomeHeaderTab, 0)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = list
+}

+ 40 - 0
controllers/micro_roadshow.go

@@ -0,0 +1,40 @@
+package controllers
+
+import (
+	"hongze/hongze_cygx/models"
+)
+
+// 微路演
+type MicroRoadShowController struct {
+	BaseAuthController
+}
+
+// @Title 微路演列表
+// @Description 微路演列表接口
+// @Param   PageSize		query	int		true	"每页数据条数"
+// @Param   CurrentIndex	query	int		true	"当前页页码,从1开始"
+// @Param   KeyWord			query	string	false	"搜索关键词"
+// @Success 200 {object} models.HomeListResp
+// @router /list [get]
+func (this *MicroRoadShowController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	//pageSize, _ := this.GetInt("PageSize")
+	//currentIndex, _ := this.GetInt("CurrentIndex")
+	//keywords := this.GetString("KeyWord")
+
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 9 - 0
models/config.go

@@ -5,6 +5,10 @@ import (
 	"time"
 )
 
+var (
+	HomeHeaderTabConfigCode = "home_header_tab"
+)
+
 type CygxConfig struct {
 	ConfigId    int    `json:"-" orm:"column(config_id);pk"`
 	ConfigCode  string `json:"-"`
@@ -63,3 +67,8 @@ func GetHotSearch() (permission string, err error) {
 	err = o.Raw(sql).QueryRow(&permission)
 	return
 }
+
+type HomeHeaderTab struct {
+	Id   int    `description:"导航ID"`
+	Name string `description:"导航名称"`
+}

+ 5 - 0
routers/router.go

@@ -119,6 +119,11 @@ func init() {
 				&controllers.BaseYidongController{},
 			),
 		),
+		web.NSNamespace("/micro_roadshow",
+			web.NSInclude(
+				&controllers.MicroRoadShowController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }