|
@@ -2,6 +2,7 @@ package router
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"demo/data/dao"
|
|
"demo/data/dao"
|
|
|
|
|
+ "demo/data/dao/manage"
|
|
|
"demo/data/domain"
|
|
"demo/data/domain"
|
|
|
"demo/share"
|
|
"demo/share"
|
|
|
"demo/util/templatefunc"
|
|
"demo/util/templatefunc"
|
|
@@ -26,6 +27,9 @@ func TestRouth(engine *gin.RouterGroup) {
|
|
|
PushRouter(user, "GET", "/detail", Detail)
|
|
PushRouter(user, "GET", "/detail", Detail)
|
|
|
PushRouter(user, "GET", "/search", SearchPage)
|
|
PushRouter(user, "GET", "/search", SearchPage)
|
|
|
PushRouter(user, "GET", "/info/:infoName", InfoPage)
|
|
PushRouter(user, "GET", "/info/:infoName", InfoPage)
|
|
|
|
|
+
|
|
|
|
|
+ PushRouter(user, "GET", "/category/:category", CategoryPage)
|
|
|
|
|
+ PushRouter(user, "GET", "/category", CategoryPage)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -84,6 +88,7 @@ func Home(c *gin.Context) {
|
|
|
c.JSON(200, CreateResultError(401, err.Error()))
|
|
c.JSON(200, CreateResultError(401, err.Error()))
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ m["footerType"] = "home"
|
|
|
json.Unmarshal(d2m, &m)
|
|
json.Unmarshal(d2m, &m)
|
|
|
|
|
|
|
|
c.HTML(http.StatusOK, "index.html", m)
|
|
c.HTML(http.StatusOK, "index.html", m)
|
|
@@ -184,7 +189,6 @@ func SearchPage(c *gin.Context) {
|
|
|
m["key"] = key
|
|
m["key"] = key
|
|
|
c.HTML(http.StatusOK, "search.html", m)
|
|
c.HTML(http.StatusOK, "search.html", m)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
func GetUserId(c *gin.Context) int64 {
|
|
func GetUserId(c *gin.Context) int64 {
|
|
|
header := c.GetHeader("auth-sign")
|
|
header := c.GetHeader("auth-sign")
|
|
|
if header == "" {
|
|
if header == "" {
|
|
@@ -197,3 +201,31 @@ func GetUserId(c *gin.Context) int64 {
|
|
|
i, err := strconv.ParseInt(claims["iss"].(string), 10, 32)
|
|
i, err := strconv.ParseInt(claims["iss"].(string), 10, 32)
|
|
|
return i
|
|
return i
|
|
|
}
|
|
}
|
|
|
|
|
+func CategoryPage(c *gin.Context) {
|
|
|
|
|
+ data := share.GetJsonAnyParam(c)
|
|
|
|
|
+ categoryPath := c.Param("category")
|
|
|
|
|
+ category, _ := data("category")
|
|
|
|
|
+ if categoryPath != "" {
|
|
|
|
|
+ category = categoryPath
|
|
|
|
|
+ }
|
|
|
|
|
+ pageNum, _ := data("pageNum")
|
|
|
|
|
+ pageSize, _ := data("pageSize")
|
|
|
|
|
+ m := make(map[string]interface{})
|
|
|
|
|
+ m["category"] = category
|
|
|
|
|
+ m["pageNum"] = pageNum
|
|
|
|
|
+ m["pageSize"] = pageSize
|
|
|
|
|
+ m["pageSize"] = pageSize
|
|
|
|
|
+ list, err := manage.GetGoodsTypeList(domain.GoodsType{}, 1, 99999)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ c.JSON(200, CreateResultError(401, "未查询到结果"))
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ m["footerType"] = "category"
|
|
|
|
|
+ m["menus"] = list.List
|
|
|
|
|
+
|
|
|
|
|
+ d, err := json.Marshal(m)
|
|
|
|
|
+ var dm = make(map[string]interface{})
|
|
|
|
|
+ json.Unmarshal(d, &dm)
|
|
|
|
|
+
|
|
|
|
|
+ c.HTML(http.StatusOK, "category.html", dm)
|
|
|
|
|
+}
|