|
@@ -3,7 +3,6 @@ package controllers
|
|
import (
|
|
import (
|
|
"eta/eta_mobile/models"
|
|
"eta/eta_mobile/models"
|
|
"eta/eta_mobile/utils"
|
|
"eta/eta_mobile/utils"
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
// 分类
|
|
// 分类
|
|
@@ -26,28 +25,22 @@ func (this *ClassifyController) ListClassify() {
|
|
this.Data["json"] = br
|
|
this.Data["json"] = br
|
|
this.ServeJSON()
|
|
this.ServeJSON()
|
|
}()
|
|
}()
|
|
- pageSize, _ := this.GetInt("PageSize")
|
|
|
|
- currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
|
|
|
+
|
|
keyWord := this.GetString("KeyWord")
|
|
keyWord := this.GetString("KeyWord")
|
|
companyType := this.GetString("CompanyType")
|
|
companyType := this.GetString("CompanyType")
|
|
hideDayWeek, _ := this.GetInt("HideDayWeek")
|
|
hideDayWeek, _ := this.GetInt("HideDayWeek")
|
|
|
|
|
|
- var startSize int
|
|
|
|
- if pageSize <= 0 {
|
|
|
|
- pageSize = utils.PageSize20
|
|
|
|
|
|
+ reqEnabled, _ := this.GetInt("Enabled", -1)
|
|
|
|
+ // 商家不隐藏晨周报
|
|
|
|
+ if utils.BusinessCode != utils.BusinessCodeRelease {
|
|
|
|
+ hideDayWeek = 0
|
|
}
|
|
}
|
|
- if currentIndex <= 0 {
|
|
|
|
- currentIndex = 1
|
|
|
|
|
|
+ enabled := -1
|
|
|
|
+ if reqEnabled == 1 {
|
|
|
|
+ enabled = reqEnabled
|
|
}
|
|
}
|
|
|
|
|
|
- startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
|
- list, err := models.GetClassifyList(startSize, pageSize, keyWord, companyType, hideDayWeek)
|
|
|
|
- if err != nil {
|
|
|
|
- br.Msg = "获取失败"
|
|
|
|
- br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- total, err := models.GetClassifyListCount(keyWord, companyType, hideDayWeek)
|
|
|
|
|
|
+ list, err := models.GetClassifyList(keyWord, companyType, hideDayWeek, enabled)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
br.ErrMsg = "获取失败,Err:" + err.Error()
|
|
@@ -61,8 +54,7 @@ func (this *ClassifyController) ListClassify() {
|
|
parentIdLen := len(parentIds)
|
|
parentIdLen := len(parentIds)
|
|
if parentIdLen == 0 {
|
|
if parentIdLen == 0 {
|
|
resp := &models.ClassifyListResp{
|
|
resp := &models.ClassifyListResp{
|
|
- List: list,
|
|
|
|
- Paging: paging.GetPaging(currentIndex, pageSize, 0),
|
|
|
|
|
|
+ List: list,
|
|
}
|
|
}
|
|
br.Data = resp
|
|
br.Data = resp
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
@@ -91,7 +83,7 @@ func (this *ClassifyController) ListClassify() {
|
|
}
|
|
}
|
|
|
|
|
|
// 获取子分类
|
|
// 获取子分类
|
|
- children, e := models.GetClassifyChildByParentIds(parentIds, keyWord)
|
|
|
|
|
|
+ children, e := models.GetClassifyChildByParentIds(parentIds, keyWord, enabled)
|
|
if e != nil {
|
|
if e != nil {
|
|
br.Msg = "获取失败"
|
|
br.Msg = "获取失败"
|
|
br.ErrMsg = "获取子分类失败"
|
|
br.ErrMsg = "获取子分类失败"
|
|
@@ -124,13 +116,15 @@ func (this *ClassifyController) ListClassify() {
|
|
// 二级分类
|
|
// 二级分类
|
|
childrenMap := make(map[int][]*models.ClassifyItem, 0)
|
|
childrenMap := make(map[int][]*models.ClassifyItem, 0)
|
|
for i := range children {
|
|
for i := range children {
|
|
|
|
+
|
|
if childrenMap[children[i].ParentId] == nil {
|
|
if childrenMap[children[i].ParentId] == nil {
|
|
childrenMap[children[i].ParentId] = make([]*models.ClassifyItem, 0)
|
|
childrenMap[children[i].ParentId] = make([]*models.ClassifyItem, 0)
|
|
}
|
|
}
|
|
- childrenMap[children[i].ParentId] = append(childrenMap[children[i].ParentId], &models.ClassifyItem{
|
|
|
|
|
|
+ tmp := &models.ClassifyItem{
|
|
Classify: *children[i],
|
|
Classify: *children[i],
|
|
ClassifyMenuId: relateMap[children[i].Id],
|
|
ClassifyMenuId: relateMap[children[i].Id],
|
|
- })
|
|
|
|
|
|
+ }
|
|
|
|
+ childrenMap[children[i].ParentId] = append(childrenMap[children[i].ParentId], tmp)
|
|
}
|
|
}
|
|
|
|
|
|
// 一级分类
|
|
// 一级分类
|
|
@@ -139,10 +133,8 @@ func (this *ClassifyController) ListClassify() {
|
|
list[i].Child = childrenMap[list[i].Id]
|
|
list[i].Child = childrenMap[list[i].Id]
|
|
}
|
|
}
|
|
|
|
|
|
- page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
|
resp := new(models.ClassifyListResp)
|
|
resp := new(models.ClassifyListResp)
|
|
resp.List = list
|
|
resp.List = list
|
|
- resp.Paging = page
|
|
|
|
br.Data = resp
|
|
br.Data = resp
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|