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

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

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.sensitivewords.mapper.entity.SensitiveWords;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 敏感词汇 查询条件
 * 
 * @author Xson
 * @date 2020-04-24
 */
@Data
@ApiModel(description = "敏感词汇 查询条件")
public final class SensitiveWordsQuery extends BasePageQuery {

    /**
     * 关键字 敏感词
     */
    @ApiModelProperty("关键字 敏感词")
    private String keyword;

    /**
     * 状态 0正常1停用
     */
    @ApiModelProperty("状态 0正常1停用")
    private Integer status;

    /**
     * 查询条件
     * 
     * @return
     */
    @Override
    public Wrapper condition() {
        LambdaQueryWrapper<SensitiveWords> query = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(keyword)) {
            query.like(SensitiveWords::getKeyword, keyword);
        }
        if (null != status) {
            query.eq(SensitiveWords::getStatus, status);
        }
        query.orderByDesc(SensitiveWords::getCreateTime);
        return query;
    }

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

}
