获取周报列表时增加ids
parent
3af73b9dbc
commit
e659a60e6e
|
@ -6,6 +6,7 @@ import (
|
||||||
"goweb-gin-demo/global"
|
"goweb-gin-demo/global"
|
||||||
"goweb-gin-demo/model/common/request"
|
"goweb-gin-demo/model/common/request"
|
||||||
"goweb-gin-demo/model/common/response"
|
"goweb-gin-demo/model/common/response"
|
||||||
|
"goweb-gin-demo/model/wt"
|
||||||
wtReq "goweb-gin-demo/model/wt/request"
|
wtReq "goweb-gin-demo/model/wt/request"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
@ -108,12 +109,13 @@ func (wtReportsApi *WtReportsApi) GetWtReportsList(c *gin.Context) {
|
||||||
var searchInfo wtReq.WtReportsSearch
|
var searchInfo wtReq.WtReportsSearch
|
||||||
_ = c.ShouldBindQuery(&searchInfo)
|
_ = c.ShouldBindQuery(&searchInfo)
|
||||||
|
|
||||||
if err, list, total := wtReportsService.GetWtReportsInfoList(searchInfo); err != nil {
|
if err, list, total, ids := wtReportsService.GetWtReportsInfoList(searchInfo); err != nil {
|
||||||
global.GLOBAL_LOG.Error("获取失败!", zap.Any("err", err))
|
global.GLOBAL_LOG.Error("获取失败!", zap.Any("err", err))
|
||||||
response.FailWithMessage("获取失败", c)
|
response.FailWithMessage("获取失败", c)
|
||||||
} else {
|
} else {
|
||||||
response.OkWithDetailed(response.PageResult{
|
response.OkWithDetailed(wt.PageResult{
|
||||||
List: list,
|
List: list,
|
||||||
|
Ids: ids,
|
||||||
Total: total,
|
Total: total,
|
||||||
Page: searchInfo.Page,
|
Page: searchInfo.Page,
|
||||||
PageSize: searchInfo.PageSize,
|
PageSize: searchInfo.PageSize,
|
||||||
|
|
|
@ -30,3 +30,11 @@ type UploadFileJson struct {
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PageResult struct {
|
||||||
|
List interface{} `json:"list"`
|
||||||
|
Ids []int `json:"ids"`
|
||||||
|
Total int64 `json:"total"`
|
||||||
|
Page int `json:"page"`
|
||||||
|
PageSize int `json:"pageSize"`
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
wtRes "goweb-gin-demo/model/wt/response"
|
wtRes "goweb-gin-demo/model/wt/response"
|
||||||
"goweb-gin-demo/service/system"
|
"goweb-gin-demo/service/system"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WtReportsService struct {
|
type WtReportsService struct {
|
||||||
|
@ -45,7 +46,7 @@ func (wtReportsService *WtReportsService) GetWtReports(id uint) (err error, repo
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWtReportsInfoList 分页获取周报
|
// GetWtReportsInfoList 分页获取周报
|
||||||
func (wtReportsService *WtReportsService) GetWtReportsInfoList(info wtReq.WtReportsSearch) (err error, list []wtRes.WtReportsSearchResult, total int64) {
|
func (wtReportsService *WtReportsService) GetWtReportsInfoList(info wtReq.WtReportsSearch) (err error, list []wtRes.WtReportsSearchResult, total int64, ids []int) {
|
||||||
limit := info.PageSize
|
limit := info.PageSize
|
||||||
offset := info.PageSize * (info.Page - 1)
|
offset := info.PageSize * (info.Page - 1)
|
||||||
|
|
||||||
|
@ -92,9 +93,15 @@ func (wtReportsService *WtReportsService) GetWtReportsInfoList(info wtReq.WtRepo
|
||||||
|
|
||||||
err = global.GLOBAL_DB.Raw(querySql, limit, offset).Scan(&reportsSearchBOList).Error
|
err = global.GLOBAL_DB.Raw(querySql, limit, offset).Scan(&reportsSearchBOList).Error
|
||||||
|
|
||||||
|
// 获取所有周报内容的id列表
|
||||||
|
idsSplit := strings.Split(querySql, "FROM wt_reports")
|
||||||
|
idsSql := "SELECT id FROM wt_reports " + idsSplit[1]
|
||||||
|
|
||||||
|
err = global.GLOBAL_DB.Select("id").Raw(idsSql, int(total), 0).Scan(&ids).Error
|
||||||
|
|
||||||
reportsSearchResultList := reportsToSearchResult(reportsSearchBOList)
|
reportsSearchResultList := reportsToSearchResult(reportsSearchBOList)
|
||||||
|
|
||||||
return err, reportsSearchResultList, total
|
return err, reportsSearchResultList, total, ids
|
||||||
}
|
}
|
||||||
|
|
||||||
//数据转换一下, 需要把json数据转换为字符串
|
//数据转换一下, 需要把json数据转换为字符串
|
||||||
|
|
Loading…
Reference in New Issue