Commit 2239aea7 by huangchengyi

Merge branch 'dev' of http://119.23.72.7/mushishixian/search_server into dev

parents da7c534f 4327d17d
......@@ -18,7 +18,7 @@ func Zyh(ctx *gin.Context){
zyhRequest[requestName] = strings.TrimSpace(requstValue[0])
}
}
fmt.Println(zyhRequest)
//fmt.Println(zyhRequest)
zyServiceImpl := service.NewZyServiceImpl()
......
......@@ -72,6 +72,11 @@ type ApiGoods struct {
type ZiyinGoodsInfo struct {
GoodsNameOrg string `json:"goods_name_org"`
SampleStatus string `json:"sample_status"`
SampleMaxNumber string `json:"sample_max_number"`
SampleClassId string `json:"sample_class_id"`
SampleClassIdName string `json:"sample_class_id_name"`
Quota int `json:"quota"`
DullGoodsData
}
......
package common
import "math"
//分页方法,根据传递过来的页数,每页数,总数,返回分页的内容 7个页数 前 1,2,3,4,5 后 的格式返回,小于5页返回具体页数
func Paginator(page, prepage int, nums int64) map[string]interface{} {
var firstpage int //前一页地址
var lastpage int //后一页地址
//根据nums总数,和prepage每页数量 生成分页总数
totalpages := int(math.Ceil(float64(nums) / float64(prepage))) //page总数
if page > totalpages {
page = totalpages
}
if page <= 0 {
page = 1
}
var pages []int
switch {
case page >= totalpages-5 && totalpages > 5: //最后5页
start := totalpages - 5 + 1
firstpage = page - 1
lastpage = int(math.Min(float64(totalpages), float64(page+1)))
pages = make([]int, 5)
for i, _ := range pages {
pages[i] = start + i
}
case page >= 3 && totalpages > 5:
start := page - 3 + 1
pages = make([]int, 5)
firstpage = page - 3
for i, _ := range pages {
pages[i] = start + i
}
firstpage = page - 1
lastpage = page + 1
default:
pages = make([]int, int(math.Min(5, float64(totalpages))))
for i, _ := range pages {
pages[i] = i + 1
}
firstpage = int(math.Max(float64(1), float64(page-1)))
lastpage = page + 1
//fmt.Println(pages)
}
paginatorMap := make(map[string]interface{})
paginatorMap["pages"] = pages
paginatorMap["totalpages"] = totalpages
paginatorMap["firstpage"] = firstpage
paginatorMap["lastpage"] = lastpage
paginatorMap["currpage"] = page
return paginatorMap
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ func InitRouter() *gin.Engine {
r.POST("/search/bom/autospu", controller.AutoSpu)
r.POST("/search/bom/recommend", controller.Recommend)
r.POST("search/ZiYing/zyh", controller.Zyh)
r.GET("search/ZiYing/zyh", controller.Zyh)
r.POST("search/mouser/GetMouserData", controller.GetMouserData)
r.GET("search/mouser/GetMouserData", controller.GetMouserData)
......
package main
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment