package com.ssyf.common.core.domain.query;

import com.ssyf.common.core.util.StringUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 排序参数
 * @author huwei
 * @date 2023/1/26 16:21
 */
@Data
@Accessors(chain = true)
@ApiModel(value="排序参数")
public class SortQuery {
    /**
     * 排序字段名
     */
    @ApiModelProperty(value = "排序字段名")
    private String name;
    /**
     * 正序
     */
    @ApiModelProperty(value = "正序")
    private boolean desc;

    public String getNameCharLink() {
        return StringUtil.camelCaseToCharLink(this.name ,"_");
    }
    public String getNameCamelCase() {
        return StringUtil.toCamelCase(this.name, '_');
    }
    public String getSortDesc() {
        return this.desc ? "desc" : "asc";
    }
}
