You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.5 KiB

<?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.yanzhen.mapper.NoticeMapper">
<resultMap type="com.yanzhen.entity.Notice" id="Notice">
<id column="id" property="id"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
<result column="create_time" property="createTime"/>
<result column="user_id" property="userId"/>
<result column="filepath" property="filepath"/>
</resultMap>
<insert id="create" keyProperty="id" useGeneratedKeys="true" parameterType="com.yanzhen.entity.Notice">
insert into tb_notice(
title,
content,
create_time,
user_id,
filepath
)values(
#{title},
#{content},
now(),
#{userId},
#{filepath}
)
</insert>
<select id="query" resultMap="Notice">
select * from tb_notice
<include refid="NoticeFindCriteria"/>
</select>
<select id="count" resultType="int">
select count(1) from tb_notice
<include refid="NoticeFindCriteria"/>
</select>
<select id="detail" resultMap="Notice">
select * from tb_notice where id = #{id}
</select>
<delete id="delete">
delete from tb_notice where id = #{id}
</delete>
<update id="update">
update tb_notice set
title=#{title},
content=#{content},
create_time=#{createTime},
user_id=#{userId},
filepath=#{filepath}
where id = #{id}
</update>
<update id="updateSelective">
update tb_notice
<set>
<if test="title != null and title != ''"> title = #{title},</if>
<if test="content != null and content != ''"> content = #{content},</if>
<if test="createTime != null and createTime != ''"> create_time = #{createTime},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="filepath != null and filepath != ''"> filepath = #{filepath},</if>
</set>
where id = #{id}
</update>
<sql id="NoticeFindCriteria">
<where>
<if test="id != null">and id = #{id}</if>
<if test="title != null and title != ''">and title = #{title}</if>
<if test="content != null and content != ''">and content = #{content}</if>
<if test="userId != null">and user_id = #{userId}</if>
<if test="filepath != null and filepath != ''">and filepath = #{filepath}</if>
</where>
</sql>
<select id="queryByBuildingId" resultMap="Notice">
select tb_notice.* from tb_notice,tb_notice_receive where tb_notice.id = tb_notice_receive.notice_id and building_id = #{buildingId}
<include refid="NoticeFindCriteria"/>
</select>
</mapper>