ludu-cloud/promotion/promotion-service-impl/target/classes/mapper/BannerMapper.xml
2019-05-31 18:38:06 +08:00

110 lines
3.1 KiB
XML

<?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="cn.iocoder.mall.promotion.biz.dao.BannerMapper">
<sql id="FIELDS">
id, title, url, pic_url, sort,
status, memo, create_time
</sql>
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="BannerDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM banner-->
<!-- WHERE pid = #{pid}-->
<!-- AND status = #{status}-->
<!-- AND deleted = 0-->
<!-- ORDER BY sort ASC-->
<!-- </select>-->
<!-- <select id="selectList" resultType="BannerDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM banner-->
<!-- WHERE deleted = 0-->
<!-- </select>-->
<select id="selectById" parameterType="Integer" resultType="BannerDO">
SELECT
<include refid="FIELDS" />
FROM banner
WHERE id = #{id}
AND deleted = 0
</select>
<select id="selectListByStatus" parameterType="Integer" resultType="BannerDO">
SELECT
<include refid="FIELDS" />
FROM banner
<where>
<if test="status != null">
status = #{status}
</if>
AND deleted = 0
</where>
</select>
<select id="selectListByTitleLike" resultType="BannerDO">
SELECT
<include refid="FIELDS" />
FROM banner
<where>
<if test="title != null">
title LIKE "%"#{title}"%"
</if>
AND deleted = 0
</where>
LIMIT #{offset}, #{limit}
</select>
<select id="selectCountByTitleLike" resultType="Integer">
SELECT
COUNT(1)
FROM banner
<where>
<if test="title != null">
title LIKE "%"#{title}"%"
</if>
AND deleted = 0
</where>
</select>
<insert id="insert" parameterType="BannerDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO banner (
title, url, pic_url, sort, status,
memo, create_time, deleted
) VALUES (
#{title}, #{url}, #{picUrl}, #{sort}, #{status},
#{memo}, #{createTime}, #{deleted}
)
</insert>
<update id="update" parameterType="BannerDO">
UPDATE banner
<set>
<if test="title != null">
title = #{title},
</if>
<if test="url != null">
url = #{url},
</if>
<if test="picUrl != null">
pic_url = #{picUrl} ,
</if>
<if test="sort != null">
sort = #{sort},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="memo != null">
memo = #{memo},
</if>
<if test="deleted != null">
deleted = #{deleted}
</if>
</set>
WHERE id = #{id}
</update>
</mapper>