46 lines
1.9 KiB
XML
46 lines
1.9 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="com.nlshop.mapper.AnnouncementMapper">
|
|
<resultMap id="BaseResultMap" type="com.nlshop.entity.Announcement">
|
|
<id column="id" property="id"/>
|
|
<result column="merchant_id" property="merchantId"/>
|
|
<result column="title" property="title"/>
|
|
<result column="content" property="content"/>
|
|
<result column="type" property="type"/>
|
|
<result column="status" property="status"/>
|
|
<result column="create_time" property="createTime"/>
|
|
</resultMap>
|
|
|
|
<insert id="insert" parameterType="com.nlshop.entity.Announcement" useGeneratedKeys="true" keyProperty="id">
|
|
INSERT INTO announcement (merchant_id, title, content, type, status)
|
|
VALUES (#{merchantId}, #{title}, #{content}, #{type}, #{status})
|
|
</insert>
|
|
|
|
<select id="selectByMerchantId" resultMap="BaseResultMap">
|
|
SELECT * FROM announcement WHERE merchant_id = #{merchantId} ORDER BY create_time DESC
|
|
</select>
|
|
|
|
<select id="selectPublished" resultMap="BaseResultMap">
|
|
SELECT * FROM announcement WHERE status = 1 ORDER BY create_time DESC
|
|
</select>
|
|
|
|
<select id="selectById" resultMap="BaseResultMap">
|
|
SELECT * FROM announcement WHERE id = #{id}
|
|
</select>
|
|
|
|
<update id="update" parameterType="com.nlshop.entity.Announcement">
|
|
UPDATE announcement
|
|
<set>
|
|
<if test="title != null">title = #{title},</if>
|
|
<if test="content != null">content = #{content},</if>
|
|
<if test="type != null">type = #{type},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
</set>
|
|
WHERE id = #{id}
|
|
</update>
|
|
|
|
<delete id="delete">
|
|
DELETE FROM announcement WHERE id = #{id}
|
|
</delete>
|
|
</mapper>
|