商品分页

This commit is contained in:
YunaiV
2019-03-05 22:52:29 +08:00
parent 83fdf181b8
commit 15a9425396
13 changed files with 376 additions and 6 deletions

View File

@@ -2,11 +2,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.product.dao.ProductSpuMapper">
<sql id="FIELDS">
id, name, sell_point, description, cid,
pic_urls, visible, sort, create_time
</sql>
<select id="selectById" parameterType="Integer" resultType="ProductSpuDO">
SELECT
id
<include refid="FIELDS" />
FROM product_spu
WHERE id = #{id}
AND deleted = 0
</select>
<insert id="insert" parameterType="ProductSpuDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
@@ -50,4 +56,30 @@
WHERE id = #{id}
</update>
<select id="selectListByNameLikeOrderBySortAsc" resultType="ProductSpuDO">
SELECT
<include refid="FIELDS" />
FROM product_spu
<where>
<if test="name != null">
name LIKE "%"#{name}"%"
</if>
AND deleted = 0
</where>
ORDER BY sort ASC
LIMIT #{offset}, #{limit}
</select>
<select id="selectCountByNameLike" resultType="Integer">
SELECT
COUNT(1)
FROM product_spu
<where>
<if test="name != null">
name LIKE "%"#{name}"%"
</if>
AND deleted = 0
</where>
</select>
</mapper>