<?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.com.basic.panel.entity.Cp_Notice">
|
<resultMap id="BaseResultMap" type="cn.com.basic.panel.entity.Cp_Notice">
|
<id column="id" property="id" jdbcType="VARCHAR" />
|
<result column="title" property="title" jdbcType="VARCHAR" />
|
<result column="filepath" property="filepath" jdbcType="VARCHAR" />
|
<result column="userid" property="userid" jdbcType="VARCHAR" />
|
<result column="readcount" property="readcount" jdbcType="INTEGER" />
|
<result column="sendcount" property="sendcount" jdbcType="INTEGER" />
|
<result column="is_valid" property="isValid" jdbcType="TINYINT" />
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
<result column="update_user_id" property="updateUserId" jdbcType="VARCHAR" />
|
<result column="releasetime" property="releasetime" jdbcType="TIMESTAMP" />
|
<result column="filename" property="filename" jdbcType="VARCHAR" />
|
<result column="peoples" property="peoples" jdbcType="VARCHAR" />
|
</resultMap>
|
<resultMap id="ResultMapWithBLOBs" type="cn.com.basic.panel.entity.Cp_Notice"
|
extends="BaseResultMap">
|
<result column="content" property="content" jdbcType="LONGVARCHAR" />
|
</resultMap>
|
<sql id="Base_Column_List">
|
id, title, filepath, userid, readcount, sendcount,
|
is_valid, update_time,releasetime,
|
update_user_id,filename,peoples
|
</sql>
|
<sql id="Blob_Column_List">
|
content
|
</sql>
|
|
<sql id="Base_Where_Clause">
|
<where>
|
<trim prefixOverrides="and">
|
<if test="id != null"> and id = #{id}</if>
|
<if test="userid != null">
|
and userid = #{userid,jdbcType=VARCHAR}
|
</if>
|
<if test="title != null">
|
and title like CONCAT("%",#{title},"%")
|
</if>
|
<if test="isValid != null">
|
and is_valid = #{isValid,jdbcType=TINYINT} and is_valid <![CDATA[<>]]> 2
|
</if>
|
<if test="isValid == null">
|
and is_valid != 2
|
</if>
|
<if test="updateTime != null">
|
and update_time = #{updateTime,jdbcType=TIMESTAMP}
|
</if>
|
<if test="updateUserId != null">
|
and update_user_id = #{updateUserId,jdbcType=VARCHAR}
|
</if>
|
<if test="updateTime != null">
|
and releasetime = #{releasetime,jdbcType=TIMESTAMP}
|
</if>
|
|
</trim>
|
</where>
|
<if test="sorting != null">order by ${sorting}</if>
|
<if test="offset != null and limit != null">
|
limit #{offset}, #{limit}
|
</if>
|
</sql>
|
<!-- 我的通知 -->
|
<sql id="Base_MyWhere_Clause">
|
<where>
|
<trim prefixOverrides="and">
|
<if test="userid != null" >
|
u.userid = #{userid,jdbcType=VARCHAR}
|
</if>
|
<if test="title != null" >
|
and c.title like CONCAT("%",#{title},"%")
|
</if>
|
<if test="relestarttime != null and releendtime != null" >
|
and c.releasetime >= #{relestarttime} and c.releasetime <![CDATA[<=]]> #{releendtime}
|
</if>
|
<if test="isValid != null" >
|
and u.is_valid = #{isValid,jdbcType=TINYINT}
|
</if>
|
</trim>
|
</where>
|
</sql>
|
|
|
<select id="selectById" resultMap="ResultMapWithBLOBs"
|
parameterType="java.lang.String">
|
select
|
<include refid="Base_Column_List" />
|
,
|
<include refid="Blob_Column_List" />
|
from cp_notice
|
where id = #{id,jdbcType=VARCHAR}
|
</select>
|
<delete id="delete" parameterType="java.lang.String">
|
delete from cp_notice
|
where id
|
= #{id,jdbcType=VARCHAR}
|
</delete>
|
<insert id="insert" parameterType="cn.com.basic.panel.entity.Cp_Notice" useGeneratedKeys="true" keyProperty="id">
|
insert into cp_notice (id,
|
title, filepath,
|
userid, readcount, sendcount,
|
content,is_valid,update_time,update_user_id,releasetime,filename,peoples)
|
values
|
(#{id,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR},
|
#{filepath,jdbcType=VARCHAR},
|
#{userid,jdbcType=VARCHAR},
|
#{readcount,jdbcType=INTEGER}, #{sendcount,jdbcType=INTEGER},
|
#{content,jdbcType=LONGVARCHAR},#{isValid,jdbcType=TINYINT},#{updateTime,jdbcType=TIMESTAMP},
|
#{updateUserId,jdbcType=VARCHAR},#{releasetime,jdbcType=TIMESTAMP},#{filename,jdbcType=VARCHAR},#{peoples,jdbcType=VARCHAR})
|
</insert>
|
|
<update id="updateByIdSelective" parameterType="cn.com.basic.panel.entity.Cp_Notice">
|
update cp_notice
|
<set>
|
<if test="title != null">
|
title = #{title,jdbcType=VARCHAR},
|
</if>
|
<if test="filepath != null">
|
filepath = #{filepath,jdbcType=VARCHAR},
|
</if>
|
<if test="userid != null">
|
userid = #{userid,jdbcType=VARCHAR},
|
</if>
|
<if test="filename != null">
|
filename = #{filename,jdbcType=VARCHAR},
|
</if>
|
<if test="peoples != null">
|
peoples = #{peoples,jdbcType=VARCHAR},
|
</if>
|
<if test="readcount != null">
|
readcount = #{readcount,jdbcType=INTEGER},
|
</if>
|
<if test="sendcount != null">
|
sendcount = #{sendcount,jdbcType=INTEGER},
|
</if>
|
<if test="content != null">
|
content = #{content,jdbcType=LONGVARCHAR},
|
</if>
|
<if test="isValid != null">
|
is_valid = #{isValid,jdbcType=TINYINT},
|
</if>
|
<if test="updateTime != null">
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateUserId != null">
|
update_user_id = #{updateUserId,jdbcType=VARCHAR},
|
</if>
|
<if test="releasetime != null">
|
releasetime = #{releasetime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where id = #{id,jdbcType=VARCHAR}
|
</update>
|
|
<!-- 查询我创建的通知 start-->
|
<select id="selectCount" resultType="java.lang.Long"
|
parameterType="java.util.Map">
|
select count(ID)
|
from cp_notice
|
<include refid="Base_Where_Clause" />
|
</select>
|
|
<select id="select" resultMap="BaseResultMap" parameterType="java.util.Map">
|
select
|
<include refid="Base_Column_List" />
|
,
|
<include refid="Blob_Column_List" />
|
from cp_notice
|
<include refid="Base_Where_Clause" />
|
</select>
|
<!-- 查询我创建的通知 end-->
|
|
<!-- 查询我接收的通知 start-->
|
<select id="selectMyNoticeCount" resultType="java.lang.Long"
|
parameterType="java.util.Map">
|
select count(c.id)
|
from cp_notice c inner join cp_notice_user u on u.noticeid = c.id
|
<include refid="Base_MyWhere_Clause" />
|
</select>
|
|
<select id="selectMyNotice" resultMap="BaseResultMap"
|
parameterType="java.util.Map">
|
select a.id, a.title, a.filepath, a.userid, a.is_valid, a.releasetime,a.content
|
from cp_notice a inner join (select c.id from cp_notice c inner join
|
cp_notice_user u on u.noticeid=c.id
|
|
<include refid="Base_MyWhere_Clause" />
|
<if test="sorting != null">order by ${sorting}</if>
|
<if test="offset != null and limit != null">limit #{offset}, #{limit}</if>
|
) b on b.id = a.id
|
|
</select>
|
<!-- 查询我接收的通知 end-->
|
</mapper>
|