Browse Source

修改like查询逻辑。查询模式由参数决定。删除$START,$END条件,使用$LIKE替代

周浩 9 years ago
parent
commit
bc730e347d

+ 2 - 8
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/basic/BasicMapper.xml

@@ -14,16 +14,10 @@
                 AND `${$tableName}`.`${item}`!=#{term.${item+'$NOT'}}
             </if>
             <if test="#this['term.'+item+'$LIKE']!=null">
-                AND INSTR(`${$tableName}`.`${item}`,#{term.${item+'$LIKE'}})>0
+                AND ${$tableName}.${item} like #{term.${item+'$LIKE'}}
             </if>
             <if test="#this['term.'+item+'$NOTLIKE']!=null">
-                AND INSTR(`${$tableName}`.`${item}`,#{term.${item+'$NOTLIKE'}})&lt;=0
-            </if>
-            <if test="#this['term.'+item+'$START']!=null">
-                AND `${$tableName}`.`${item}` LIKE CONCAT(#{term.${item+'$START'}},'%')
-            </if>
-            <if test="#this['term.'+item+'$END']!=null">
-                AND `${$tableName}`.`${item}` LIKE CONCAT('%',#{term.${item+'$END'})
+                AND  ${$tableName}.${item} not like #{term.${item+'$LIKE'}}
             </if>
             <if test="#this['term.'+item+'$IN']!=null">
                 AND `${$tableName}`.`${item}` IN

+ 6 - 11
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/oracle/basic/BasicMapper.xml

@@ -24,16 +24,10 @@
                 </choose>
             </if>
             <if test="#this['term.'+item+'$LIKE']!=null">
-                AND INSTR(${$tableName}.${item},#{term.${item+'$LIKE'}})>0
+                AND ${$tableName}.${item} like #{term.${item+'$LIKE'}}
             </if>
             <if test="#this['term.'+item+'$NOTLIKE']!=null">
-                AND INSTR(${$tableName}.${item},#{term.${item+'$NOTLIKE'}})&lt;=0
-            </if>
-            <if test="#this['term.'+item+'$START']!=null">
-                AND ${$tableName}.${item} LIKE #{term.${item+'$START'}}||'%'
-            </if>
-            <if test="#this['term.'+item+'$END']!=null">
-                AND ${$tableName}.${item} LIKE '%'||#{term.${item+'$END'}}
+                AND ${$tableName}.${item} not like #{term.${item+'$LIKE'}}
             </if>
             <if test="#this['term.'+item+'$IN']!=null">
                 AND ${$tableName}.${item} IN
@@ -100,7 +94,8 @@
                     </if>
                 </foreach>
             </when>
-            <otherwise><bind name="fieldHasLen" value="true"/>*</otherwise>
+            <otherwise><bind name="fieldHasLen" value="true"/>*
+            </otherwise>
         </choose>
         <if test="!fieldHasLen">*</if>
     </sql>
@@ -189,11 +184,11 @@
             <when test="sortField!=null and sortField.size()>0">
                 <foreach item="item" index="index" collection="sortField" open="" separator="," close="">
                     <if test="item in $fields">
-                        <if test="!fieldHasLen"> order by </if>${item}
+                        <if test="!fieldHasLen">order by</if>${item}
                         <bind name="fieldHasLen" value="true"/>
                     </if>
                 </foreach>
-                <if test="fieldHasLen"> ${sortOrder}</if>
+                <if test="fieldHasLen">${sortOrder}</if>
             </when>
         </choose>
     </sql>