package com.jg.common.utils;

import com.alibaba.fastjson2.JSON;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * description
 *
 * @author lxp
 * @version V1.0
 * @date 2021/12/22  14:23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "分页参数", description = "分页查询model")
public class QueryPage {

    private static final long serialVersionUID = 1L;

    /**
     * 降序
     */
    public static final String DESC = "descend";
    /**
     * 升序
     */
    public static final String ASC = "ascend";

    @ApiModelProperty(value = "页号")
    private Integer pageNum = 0;

    @ApiModelProperty(value = "页面大小")
    private Integer pageSize = 10;

    @ApiModelProperty("过滤")
    protected Map<String, String> filter;

    @ApiModelProperty("排序")
    protected Map<String, String> sorter;

    @SuppressWarnings("unchecked")
    public void setFilter(String filter) {
        this.filter = JSON.parseObject(filter, Map.class);
    }

    @SuppressWarnings("unchecked")
    public void setSorter(String sorter) {
        this.sorter = JSON.parseObject(sorter, Map.class);
    }
}
