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

import java.math.BigDecimal;

import cn.com.ty.lift.ud.common.BasePageQuery;
import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
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.recruitmentInfos.mapper.entity.RecruitmentDeliveryEntity;
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 RecruitmentDeliveryQuery extends BasePageQuery {

    /**
     * 申请人
     */
    @ApiModelProperty("申请人")
    private String applier;

    /**
     * 岗位
     */
    @ApiModelProperty("岗位")
    private String job;

    /**
     * 薪资范围
     */
    @ApiModelProperty("薪资范围")
    private BigDecimal startNum;
    @ApiModelProperty("薪资范围")
    private BigDecimal endNum;

    /**
     * 查询条件
     * 
     * @return
     */
    @Override
    public Wrapper condition() {
        QueryWrapper<RecruitmentDeliveryEntity> query = new QueryWrapper<>();
        if (StringUtils.isNotBlank(job)) {
            query.like("b.job", job);
        }
        if (StringUtils.isNotBlank(applier)) {
            query.like("c.name", applier);
        }
        if (null != startNum && null != endNum) {
            query.between("c.salary", startNum, endNum);
        }
        query.eq("1", 1);
        query.orderByDesc("c.create_time");
        return query;
    }

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

}
