Browse Source

no message

xingzai 2 năm trước cách đây
mục cha
commit
ffb7fa1659
3 tập tin đã thay đổi với 20 bổ sung11 xóa
  1. 2 2
      controllers/chart.go
  2. 14 6
      models/chart.go
  3. 4 3
      services/chart.go

+ 2 - 2
controllers/chart.go

@@ -68,13 +68,13 @@ func (this *ChartController) Collection() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	list, err := services.GetChartCollectionByApi(mobile)
+	list, err, total := services.GetChartCollectionByApi(mobile)
 	if err != nil {
 		br.Msg = "获取图表分类失败!"
 		br.ErrMsg = "获取图表分类失败"
 		return
 	}
-	page := paging.GetPaging(currentIndex, pageSize, len(list))
+	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(models.HomeChartListItem)
 	resp.List = list
 	resp.Paging = page

+ 14 - 6
models/chart.go

@@ -13,9 +13,17 @@ type ChartResultApi struct {
 }
 
 type ChartFavoritesResultApi struct {
-	Data []ChartInfo `json:"data"`
-	Code int         `json:"code"`
-	Msg  string      `json:"msg"`
+	Data       []ChartInfo `json:"data"`
+	Code       int         `json:"code"`
+	Msg        string      `json:"msg"`
+	Pagination Pagination  `json:"pagination"`
+}
+
+type Pagination struct {
+	Total     int `json:"total"`
+	Page      int `json:"id"`
+	PageSize  int `json:"page_size"`
+	PageTotal int `json:"page_total"`
 }
 
 type ChartInfo struct {
@@ -95,9 +103,9 @@ type ChartPtagResultApidate struct {
 }
 
 type ChartPtagResp struct {
-	ChartPermissionId   int         `description:"分类ID"`
-	ChartPermissionName string      `description:"分类名称"`
-	List                []*CtagResp `description:"子分类"`
+	ChartPermissionId int         `description:"分类ID"`
+	PermissionName    string      `description:"分类名称"`
+	List              []*CtagResp `description:"子分类"`
 }
 
 type CtagResp struct {

+ 4 - 3
services/chart.go

@@ -134,7 +134,7 @@ func GetChartPtagByApi() (items []*models.ChartPtagResp, err error) {
 	}
 	for _, v := range chartResult.Data {
 		item := new(models.ChartPtagResp)
-		item.ChartPermissionName = v.ChartPermissionName
+		item.PermissionName = v.ChartPermissionName
 		item.ChartPermissionId = v.ChartPermissionId
 		if len(v.Ctag) > 0 {
 			for _, v2 := range v.Ctag {
@@ -189,8 +189,8 @@ func GetUserTokenByMobile(mobile string) (token string, err error) {
 	return
 }
 
-//获取图表分类
-func GetChartCollectionByApi(mobile string) (items []*models.HomeChartListResp, err error) {
+//获取图表收藏
+func GetChartCollectionByApi(mobile string) (items []*models.HomeChartListResp, err error, total int) {
 	defer func() {
 		if err != nil {
 			fmt.Println("GetChartPtagByApi Err:" + err.Error())
@@ -229,5 +229,6 @@ func GetChartCollectionByApi(mobile string) (items []*models.HomeChartListResp,
 		item.IsNeedJump = true
 		items = append(items, item)
 	}
+	total = chartResult.Pagination.Total
 	return
 }