package cn.com.ty.lift.ud.applyExpert.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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import cn.com.ty.lift.ud.applyExpert.mapper.entity.ApplyExpert;
import cn.com.ty.lift.ud.common.BasePageQuery;
import cn.com.ty.lift.ud.recruitmentInfos.mapper.entity.RecruitmentInfoEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 专家申请表查询条件
 * 
 * @author Xson
 * @date 2020-05-16
 */
@Data
@ApiModel(description = "专家申请表查询条件")
public final class ApplyExpertQuery extends BasePageQuery {

    /**
     * 用户id
     */
    @ApiModelProperty("用户id")
    private Long userId;

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

    /**
     * 姓名
     */
    @ApiModelProperty("真实姓名")
    private String realName;
    
    /**
     * 性别
     */
    @ApiModelProperty("性别")
    private Integer gender;

    /**
     * 专家审核 1通过 0驳回2待审核
     */
    @ApiModelProperty("专家审核 1通过 0驳回2待审核")
    private Integer checkFlag;

    /**
     * 联系电话
     */
    @ApiModelProperty("联系电话")
    private String mobile;

    /**
     * 查询条件
     * 
     * @return
     */
    @Override
    public Wrapper condition() {
        
        QueryWrapper<ApplyExpert> query = new QueryWrapper<>();
        if (StringUtils.isNotBlank(name)) {
            query.like("b.name", name);
        }
        if (StringUtils.isNotBlank(mobile)) {
            query.like("b.mobile", mobile);
        }
        if (StringUtils.isNotBlank(realName)) {
            query.like("a.name", realName);
        }
        if (null != checkFlag) {
            query.eq("a.hot_flag", checkFlag);
        }
        query.eq("1", 1);
        query.orderByDesc("a.create_time");
        return query;
    }

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

}
