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

import org.apache.commons.lang3.StringUtils;

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 cn.com.ty.lift.ud.bannerImage.mapper.entity.BannerImageEntity;
import cn.com.ty.lift.ud.common.BasePageQuery;
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 BannerImageQuery extends BasePageQuery {

    /**
     * 类型 模块类型
     */
    @ApiModelProperty("类型 模块类型")
    private Integer dataTable;

    /**
     * 图片名称 图片名字
     */
    @ApiModelProperty("图片名称 图片名字")
    private String imgName;

    /**
     * 描述 图片描述
     */
    @ApiModelProperty("描述 图片描述")
    private String imgDesc;

    /**
     * 状态 0:正常1:不再前台显示
     */
    @ApiModelProperty("状态 0:正常1:不再前台显示")
    private Integer statuz;

    /**
     * 2：物业端banner图
     * 1：工具台banner
     * 3. 4.0首页banner图
     */
    @ApiModelProperty("2：物业端banner图 1：工具台banner 3. 4.0首页banner图")
    private Integer type;
    
    /**
     * 查询条件
     * 
     * @return
     */
    @Override
    public Wrapper condition() {
        LambdaQueryWrapper<BannerImageEntity> query = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(imgName)) {
            query.like(BannerImageEntity::getImgName, imgName);
        }
        if (StringUtils.isNotBlank(imgDesc)) {
            query.like(BannerImageEntity::getImgName, imgName);
        }
        if (null != type) {
            query.eq(BannerImageEntity::getType, type);
        }
        if (null != dataTable) {
            query.eq(BannerImageEntity::getDataTable, dataTable);
        }
        if (null != statuz) {
            query.eq(BannerImageEntity::getStatuz, statuz);
        }
        query.orderByDesc(BannerImageEntity::getSerialNo);
        return query;
    }

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

}
