Browse Source

条件查询语句$

master
xyiege 4 years ago
parent
commit
534947c088
  1. 10
      src/main/java/cn/chjyj/szwh/mapper/GoodsMapper.java
  2. 9
      src/main/resources/mapper/szwh/GoodsMapper.xml

10
src/main/java/cn/chjyj/szwh/mapper/GoodsMapper.java

@ -46,8 +46,14 @@ public interface GoodsMapper {
/**
* 根据where 条件查询
* 排序集合等均可以
* @param con
* @param con where 条件
* @param limit 条目
* @param order 排序
* @Param orderway 正序 或倒序
* @return
*/
List<Goods> getGoodsByCondition(String con);
List<Goods> getGoodsByCondition(@Param("con") String con,
@Param("limit") int limit,
@Param("order") String order,
@Param("orderway") String orderway);
}

9
src/main/resources/mapper/szwh/GoodsMapper.xml

@ -50,7 +50,14 @@
<select id="getGoodsByCondition" resultType="cn.chjyj.szwh.bean.Goods">
select <include refid="column"/>
from <include refid="tbName"/>
where #{con};
where ${con}
<if test="order!=null">
ORDER BY ${order} ${orderway}
</if>
<if test="limit!=null">
limit #{limit}
</if>
;
</select>
<!--根据uid查询用户-->

Loading…
Cancel
Save