<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}.mapper.${classUppercaseName}Mapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="${classUppercaseName}">
        #foreach($field in ${columnInfoList})
            <id column="${field.columnName}" property="${field.lowercaseName}"/>
        #end
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ${baseColumnList}
    </sql>

    <!-- 分页查询${comment}内容 -->
    <select id="selectListByPage" resultType="${voClassType}">
        select
        base.*,
        create_user.username as create_username,
        update_user.username as update_username
        from $tableName base
        left join sys_user create_user on create_user.id = base.create_user
        left join sys_user update_user on update_user.id = base.update_user
        <where>
            base.is_deleted = 0
            #foreach($field in $columnInfoList)
                <if test="dto.${field.lowercaseName} != null and dto.${field.lowercaseName} != ''">
                    and base.${field.columnName} like CONCAT('%',#{dto.${field.lowercaseName}},'%')
                </if>
            #end
        </where>
    </select>

</mapper>
