package ${packageName}.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
    #foreach ($column in $columns)
        #if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
        import com.ruoyi.common.utils.DateUtils;
            #break
        #end
    #end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils;
    #if($table.sub)
    import java.util.ArrayList;

    import org.springframework.transaction.annotation.Transactional;
    import ${packageName}.domain.${subClassName};
    #end
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 {

    /**
     * 查询${functionName}列表
     *
     * @param ${className} ${functionName}
     * @return ${functionName}集合
     * @date ${datetime}
     */
    @Override
    public List<${ClassName}> queryList(${ClassName} ${className}) {
        QueryWrapper<${ClassName}> queryWrapper = Wrappers.query();
        #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 (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.eq("$columnName", ${className}.get${AttrName}());
                }
                #elseif($queryType == "NE")
                if (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.ne("$columnName", ${className}.get${AttrName}());
                }
                #elseif($queryType == "GT")
                if (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.gt("$columnName", ${className}.get${AttrName}());
                }
                #elseif($queryType == "GTE")
                if (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.ge("$columnName", ${className}.get${AttrName}());
                }
                #elseif($queryType == "LT")
                if (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.lt("$columnName", ${className}.get${AttrName}());
                }
                #elseif($queryType == "LTE")
                if (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.le("$columnName", ${className}.get${AttrName}());
                }
                #elseif($queryType == "LIKE")
                if (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.like("$columnName", ${className}.get${AttrName}());
                }
                #elseif($queryType == "BETWEEN")
                if (#if($javaType =='String') StringUtils.isNotEmpty(${className}.get${AttrName}())#end  #if($javaType != 'String')StringUtils.isNotNull(${className}.get${AttrName}())#end){
                    queryWrapper.between("$columnName", ${className}.get${AttrName}());
                }
                #end
            #end
        #end
        queryWrapper.orderByDesc("id");
        return this.list(queryWrapper);
    }
}
