package com.ylcm.sys.form;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ylcm.sys.domain.AdPlatform;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * <p>
 * 媒体管理表
 * </p>
 *
 * @author admin
 * @since 2020-07-01
 */
@Data
public class AdPlatformListForm implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "栏目名称")
    private String platformName;

    @ApiModelProperty(value = "一级行业")
    private String firstInd;

    @ApiModelProperty(value = "二级行业")
    private String secondInd;

    private Integer pageSize;
    private Integer pageNo;
    
	public AdPlatformListForm page() {
		this.pageSize = this.pageSize != null && this.pageSize > 0 ? this.pageSize : 10;
		this.pageNo = this.pageNo != null && this.pageNo > 0 ? (this.pageNo - 1) * this.pageSize : 0;
		return this;
	}
    
    /**
             * 实体转换
     * @return
     */
    public LambdaQueryWrapper<AdPlatform> toAdPlatformQueryWrapper(){
    	LambdaQueryWrapper<AdPlatform> queryWrapper = new LambdaQueryWrapper<AdPlatform>();       
    	if(StringUtils.isNotBlank(platformName)){
    		queryWrapper.eq(AdPlatform::getPlatformName, platformName.trim());
    	}
    	if(StringUtils.isNotBlank(firstInd)){
    		queryWrapper.eq(AdPlatform::getFirstInd, firstInd.trim());
    	}
    	if(StringUtils.isNotBlank(secondInd)){
    		queryWrapper.eq(AdPlatform::getSecondInd, secondInd.trim());
    	}
    	queryWrapper.eq(AdPlatform::getStatus, 0);//正常
    	queryWrapper.orderByDesc(AdPlatform::getId);
    	return queryWrapper;
    }  
}
