package ${package.ServiceImpl};

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * $!{table.comment} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
#if(${kotlin})
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
#else
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    #set($entityName = "${entity.substring(0, 1).toLowerCase()}${entity.substring(1)}")
    @Override
    public List<${entity}> queryList(${entity} $entityName) {
        return this.list(buildQueryWrapper($entityName));
    }

    private LambdaQueryWrapper<${entity}> buildQueryWrapper(${entity} bo) {
        LambdaQueryWrapper<${entity}> lqw = Wrappers.lambdaQuery();
#foreach($field in ${table.fields})
    #set($propertyNameU = "${field.propertyName.substring(0, 1).toUpperCase()}${field.propertyName.substring(1)}")
    #if($field.propertyType == 'String')
        #set($mpMethod='like')
        #set($condition='StrUtil.isNotBlank(bo.get'+$propertyNameU+'())')
    #else
        #set($mpMethod='eq')
        #set($condition='bo.get'+$propertyNameU+'() != null')
    #end
        lqw.$mpMethod($condition, ${entity}::get$propertyNameU, bo.get$propertyNameU());
#end
        return lqw;
    }
}
#end
