abiao 1 vuosi sitten
vanhempi
commit
8743fddc60

+ 3 - 1
go/gopath/src/fohow.com/apps/controllers/category_controller/navigate_icon_config_controller.go

@@ -5,7 +5,9 @@ import "fohow.com/apps/models/category_model"
 func (self *CategoryController) GetNavigateIcons() {
 
 	cache, _ := self.GetBool("cache", true)
-	icons := category_model.GetNavigateIconsByState(1, cache)
+	source := self.GetString("source")
+
+	icons := category_model.GetNavigateIconsByState(cache, source)
 
 	self.Data["json"] = icons
 	self.ServeJSON()

+ 16 - 7
go/gopath/src/fohow.com/apps/models/category_model/navigate_icon_config.go

@@ -2,14 +2,15 @@ package category_model
 
 import (
 	"fmt"
+	"fohow.com/cache"
 	"github.com/astaxie/beego"
 	"github.com/astaxie/beego/orm"
-	"fohow.com/cache"
 	"time"
 )
 
 const (
 	navigate_icon_configs_tablename = "navigate_icon_configs"
+	navigate_source                 = "app"
 )
 
 type NavigateIconConfig struct {
@@ -19,8 +20,9 @@ type NavigateIconConfig struct {
 	Url             string `orm:"column(url)"        json:"url"`      // varchar(4096)
 	UrlType         int64  `orm:"column(url_type)"   json:"url_type"` //tinyint(4)
 	Cover           string `orm:"column(cover)" json:"cover"`
-	State           int64  `orm:"column(state)"      json:"state"` // tinyint(1)
-	Remark          string `orm:"column(remark)"     json:"-"`     // varchar(225)
+	State           int64  `orm:"column(state)"      json:"state"`         // tinyint(1)
+	AppState        int64  `orm:"column(app_state)"      json:"app_state"` // tinyint(1)
+	Remark          string `orm:"column(remark)"     json:"-"`             // varchar(225)
 	ProductCatIndex int64  `orm:"column(product_cat_index)"  json:"product_cat_index"`
 }
 
@@ -28,18 +30,25 @@ func (self *NavigateIconConfig) TableName() string {
 	return navigate_icon_configs_tablename
 }
 
-func GetNavigateIconsByState(state int64, useCache bool) (cats []*NavigateIconConfig) {
-	k := fmt.Sprintf("category_model.GetNavigateIconsByState(%d)", state)
+func GetNavigateIconsByState(useCache bool, source string) (cats []*NavigateIconConfig) {
+	k := fmt.Sprintf("category_model.GetNavigateIconsByState(%s)", source)
 	if useCache {
 		if ret, ok := cache.Cache.Get(k).([]*NavigateIconConfig); ok {
 			return ret
 		}
 	}
-
 	cat := new(NavigateIconConfig)
-	if _, err := orm.NewOrm().QueryTable(cat).Filter("state", state).OrderBy("-sort").All(&cats); err != nil {
+	qs := orm.NewOrm().QueryTable(cat)
+	if source == navigate_source {
+		qs = qs.Filter("state", true)
+	} else {
+		qs = qs.Filter("app_state", true)
+	}
+
+	if _, err := qs.OrderBy("-sort").All(&cats); err != nil {
 		beego.BeeLogger.Error("GetCatsByPlatform[%s] err=[%s]", err)
 	}
+
 	for _, item := range cats {
 		item.Cover = GetFullImgUrl(item.Cover)
 	}