|
@@ -27,6 +27,8 @@ type TagManagementController struct {
|
|
// @Param CurrentIndex query int true "当前页码"
|
|
// @Param CurrentIndex query int true "当前页码"
|
|
// @Param PageSize query int true "每页数据数"
|
|
// @Param PageSize query int true "每页数据数"
|
|
// @Param Status query string false "发布状态,1,上线,0下线"
|
|
// @Param Status query string false "发布状态,1,上线,0下线"
|
|
|
|
+// @Param SortParam query string false "排序字段参数,用来排序的字段, 枚举值: 'pv':总Pv/Uv "
|
|
|
|
+// @Param SortType query string true "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
|
|
// @Success 200 {object} cygx.ChartPermissionResp
|
|
// @Success 200 {object} cygx.ChartPermissionResp
|
|
// @router /tag/list [get]
|
|
// @router /tag/list [get]
|
|
func (this *TagManagementController) TagList() {
|
|
func (this *TagManagementController) TagList() {
|
|
@@ -46,6 +48,9 @@ func (this *TagManagementController) TagList() {
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
status, _ := this.GetInt("Status", 1)
|
|
status, _ := this.GetInt("Status", 1)
|
|
|
|
+ //排序参数
|
|
|
|
+ sortParam := this.GetString("SortParam")
|
|
|
|
+ sortType := this.GetString("SortType")
|
|
|
|
|
|
var condition string
|
|
var condition string
|
|
var startSize int
|
|
var startSize int
|
|
@@ -58,9 +63,9 @@ func (this *TagManagementController) TagList() {
|
|
startSize = utils.StartIndex(currentIndex, pageSize)
|
|
startSize = utils.StartIndex(currentIndex, pageSize)
|
|
|
|
|
|
if status == 1 {
|
|
if status == 1 {
|
|
- condition += ` AND status=1 ORDER BY online_time DESC `
|
|
|
|
|
|
+ condition += ` AND status=1 `
|
|
} else {
|
|
} else {
|
|
- condition += ` AND status=0 ORDER BY online_time DESC `
|
|
|
|
|
|
+ condition += ` AND status=0 `
|
|
}
|
|
}
|
|
|
|
|
|
total, err := cygx.GetCygxTagListCount(condition)
|
|
total, err := cygx.GetCygxTagListCount(condition)
|
|
@@ -71,6 +76,20 @@ func (this *TagManagementController) TagList() {
|
|
}
|
|
}
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
|
|
|
|
|
+ //排序字段以及排序方式处理
|
|
|
|
+ var sortStr string
|
|
|
|
+ if sortParam != "" && sortType != "" {
|
|
|
|
+ if sortParam == "pv" {
|
|
|
|
+ if sortType == "asc" {
|
|
|
|
+ sortStr = " ORDER BY pv ASC, online_time DESC "
|
|
|
|
+ } else {
|
|
|
|
+ sortStr = " ORDER BY pv DESC, online_time DESC "
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ sortStr = " ORDER BY online_time DESC "
|
|
|
|
+ }
|
|
|
|
+ condition += sortStr
|
|
list, err := cygx.GetCygxTagListPage(condition, startSize, pageSize)
|
|
list, err := cygx.GetCygxTagListPage(condition, startSize, pageSize)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "获取标签失败"
|
|
br.Msg = "获取标签失败"
|