package ${packageName}.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
#foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import com.miaxis.common.utils.DateUtils;
#break
#end
#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;

/**
 * ${functionName}Service业务层处理
 *
 * @author ${author}
 * @date ${datetime}
 */
@Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service {
    @Override
    public List<${ClassName}> queryList(${ClassName} ${className}) {
        LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
    #if($column.queryType == "EQ")
        #if($javaType == 'String')
            if (StringUtils.isNotBlank(${className}.get$AttrName())){
            lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #else
            if (${className}.get$AttrName() != null){
            lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #end
    #elseif($queryType == "NE")
        #if($javaType == 'String')
            if (StringUtils.isNotBlank(${className}.get$AttrName())){
            lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #else
            if (${className}.get$AttrName() != null){
            lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #end
    #elseif($queryType == "GT")
        #if($javaType == 'String')
            if (StringUtils.isNotBlank(${className}.get$AttrName())){
            lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #else
            if (${className}.get$AttrName() != null){
            lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #end
    #elseif($queryType == "GTE")
        #if($javaType == 'String')
            if (StringUtils.isNotBlank(${className}.get$AttrName())){
            lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #else
            if (${className}.get$AttrName() != null){
            lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #end
    #elseif($queryType == "LT")
        #if($javaType == 'String')
            if (StringUtils.isNotBlank(${className}.get$AttrName())){
            lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #else
            if (${className}.get$AttrName() != null){
            lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #end
    #elseif($queryType == "LTE")
        #if($javaType == 'String')
            if (StringUtils.isNotBlank(${className}.get$AttrName())){
            lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #else
            if (${className}.get$AttrName() != null){
            lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #end
    #elseif($queryType == "LIKE")
        #if($javaType == 'String')
            if (StringUtils.isNotBlank(${className}.get$AttrName())){
            lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #else
            if (${className}.get$AttrName() != null){
            lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName());
        }
        #end
    #elseif($queryType == "BETWEEN")
        Map<String, Object> params = ${className}.getParams();
        if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) {
            lqw.between(${ClassName}::get$AttrName ,params.get("begin$AttrName"),params.get("end$AttrName"));
        }
    #end
#end
#end
        return this.list(lqw);
    }
}
