需求:根据用户输入的关键字(中英文区别,)然后根据关键字进行匹配,根据匹配度高低进行排序;
<!-- 根据搜索字符模糊查询,根据匹配度进行排序 -->
<select id="getPOIListByName" parameterType="entity.poi.Poi" resultMap="poiResultMap">
SELECT * FROM gt_poi
<if test="id != null" >AND id=#{id}</if>
<if test="cnName != null and cnName != ''">AND cn_name like CONCAT('%','${cnName}','%' ) </if>
<if test="enName != null and enName != ''">AND en_name like CONCAT('%','${enName}','%' ) </if>
<if test="online != null">AND online=#{online}</if>
<if test="approve != null">AND approve=#{approve}</if>
<if test="status != null">AND status=#{status}</if>
<if test="continentId != null">AND continent_id=#{continentId}</if>
<if test="countryId != null">AND country_id=#{countryId}</if>
<if test="provinceId != null">AND province_id=#{provinceId}</if>
<if test="cityId != null">AND city_id=#{cityId}</if>
<if test="regionId != null">AND region_id=#{regionId}</if>
<if test="type != null">AND type=#{type}</if>
ORDER BY <if test="cnName != null and cnName != ''">
REPLACE(cn_name,'${cnName}','') </if>
<if test="enName != null and enName != ''">
REPLACE(en_name,'${enName}','') </if>
<if test="startRow>=0 and pageRow>0">limit #{startRow},#{pageRow}</if>
</select>
注意:不要select* ;