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 brandName;
    
    @ApiModelProperty(value = "一级行业")
    private String firstInd;

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

    private Integer pageSize = 10;
    private Integer pageNo =1 ;
    
    
    public AdPlatformListForm page(){
        this.pageSize = this.pageSize != null && this.pageSize > 0 ? this.pageSize:20;
        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.like(AdPlatform::getPlatformName, platformName.trim());
    	}
     	if(StringUtils.isNotBlank(brandName)){
    		queryWrapper.like(AdPlatform::getBrandName, brandName.trim());
    	}
    	if(StringUtils.isNotBlank(firstInd)){
    		queryWrapper.eq(AdPlatform::getFirstInd, firstInd.trim());
    	}
    	if(StringUtils.isNotBlank(secondInd)){
    		queryWrapper.eq(AdPlatform::getSecondInd, secondInd.trim());
    	}
    	queryWrapper.orderByDesc(AdPlatform::getId);
    	return queryWrapper;
    }  
    
    
	/**
	 * 实体转换
	 * 
	 * @return
	 */
	public LambdaQueryWrapper<AdPlatform> toAdPlatformQueryBrandNameWrapper() {
		LambdaQueryWrapper<AdPlatform> queryWrapper = new LambdaQueryWrapper<AdPlatform>();
		queryWrapper.eq(AdPlatform::getPlatformName, platformName.trim());
		if (StringUtils.isNotBlank(brandName)) {
			queryWrapper.like(AdPlatform::getBrandName, brandName.trim());
		}
		queryWrapper.orderByAsc(AdPlatform::getBrandName);
		return queryWrapper;
	}
}
