package cn.com.ty.lift.ud.dataBank.controller.query;

import cn.com.ty.lift.ud.dataBank.mapper.entity.LiftBrandEntity;
import cn.com.ty.lift.ud.dataBank.mapper.entity.LiftFileEntity;

import org.apache.commons.lang3.StringUtils;

import cn.com.ty.lift.ud.common.BasePageQuery;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 电梯品牌 查询条件
 * 
 * @author Xson
 * @date 2020-04-23
 */
@Data
@ApiModel(description = "电梯品牌 查询条件")
public final class LiftBrandQuery extends BasePageQuery {

    /**
     * 名称
     */
    @ApiModelProperty("名称")
    private String name;

    /**
     * 英文名
     */
    @ApiModelProperty("英文名")
    private String ename;

    /**
     * 状态 0:上架1:下架
     */
    @ApiModelProperty("状态 0:上架1:下架")
    private Integer statuz;

    /**
     * 主页展示 0:是1:否
     */
    @ApiModelProperty("主页展示 0:是1:否")
    private Integer hotFlag;

    /**
     * 查询条件
     * 
     * @return
     */
    @Override
    public Wrapper condition() {
        LambdaQueryWrapper<LiftBrandEntity> query = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(name)) {
            query.like(LiftBrandEntity::getName, name);
        }
        if (StringUtils.isNotBlank(ename)) {
            query.like(LiftBrandEntity::getEname, ename);
        }
        if (null != hotFlag) {
            query.eq(LiftBrandEntity::getHotFlag, hotFlag);
        }
        if (null != statuz) {
            query.eq(LiftBrandEntity::getStatuz, statuz);
        }
        query.orderByDesc(LiftBrandEntity::getSort).orderByDesc(LiftBrandEntity::getCreateTime);
        // if (null == getSort()) {
        //
        // }
        // if (null != getSort()) {
        // if (getSort().getOrder().indexOf("asc") != -1 || getSort().getOrder().indexOf("ASC") != -1) {
        // query.orderByAsc(LiftBrandEntity::getSort);
        // } else {
        // query.orderByDesc(LiftBrandEntity::getSort);
        // }
        // }
        return query;
    }

    /**
     * 分页条件
     * 
     * @return
     */
    @Override
    public IPage page() {
        Page<LiftBrandEntity> page = new Page<>(getPageNum(), getPageSize());
        return page;
    }

}
