136 lines
7.4 KiB
XML
136 lines
7.4 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.bonus.material.basic.mapper.BmMessageMapper">
|
|
<resultMap type="com.bonus.material.basic.domain.BmMessage" id="BmMessageResult">
|
|
<result property="id" column="id" />
|
|
<result property="uuid" column="uuid" />
|
|
<result property="fromUser" column="from_user" />
|
|
<result property="toUser" column="to_user" />
|
|
<result property="fromCompany" column="from_company" />
|
|
<result property="fromCompanyName" column="from_company_name" />
|
|
<result property="toCompany" column="to_company" />
|
|
<result property="toCompanyName" column="to_company_name" />
|
|
<result property="messageType" column="message_type" />
|
|
<result property="messageTopic" column="message_topic" />
|
|
<result property="messageContent" column="message_content" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="isRead" column="is_read" />
|
|
</resultMap>
|
|
|
|
<sql id="selectBmMessageVo">
|
|
select bm.id, bm.uuid, bm.from_user, bm.to_user, bm.from_company, bm.to_company, bm.message_content, bm.message_topic,
|
|
bm.message_type, bm.create_time, bm.update_time, sd1.dept_name as from_company_name, sd2.dept_name as to_company_name,is_read
|
|
from bm_message bm
|
|
left join sys_dept sd1 on sd1.dept_id = bm.from_company
|
|
left join sys_dept sd2 on sd2.dept_id = bm.to_company
|
|
</sql>
|
|
|
|
<select id="selectBmMessageList" parameterType="com.bonus.material.basic.domain.BmMessage" resultMap="BmMessageResult">
|
|
<include refid="selectBmMessageVo"/>
|
|
<where>
|
|
<if test="uuid != null and uuid != ''"> and uuid = #{uuid}</if>
|
|
<if test="fromUser != null and toUser != null"> and (from_user = #{fromUser} or to_user = #{toUser})</if>
|
|
<if test="fromCompany != null and toCompany != null"> and (from_company = #{fromCompany} or to_company = #{toCompany})</if>
|
|
<if test="messageContent != null and messageContent != ''"> and message_content = #{messageContent}</if>
|
|
<if test="messageTopic != null and messageTopic != ''"> and message_topic = #{messageTopic}</if>
|
|
<if test="messageType != null and messageType != ''"> and message_type = #{messageType}</if>
|
|
</where>
|
|
order by create_time
|
|
</select>
|
|
|
|
<select id="selectBmMessageById" parameterType="Long" resultMap="BmMessageResult">
|
|
<include refid="selectBmMessageVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
<select id="selectBmMessageListOne" resultType="com.bonus.material.basic.domain.BmMessage">
|
|
<include refid="selectBmMessageVo"/>
|
|
<where>
|
|
<if test="uuid != null and uuid != ''"> and uuid = #{uuid}</if>
|
|
<if test="fromUser != null and toUser != null"> and (from_user = #{fromUser} or to_user = #{toUser})</if>
|
|
<if test="fromCompany != null and toCompany != null"> and ((from_company = #{fromCompany} and to_company = #{toCompany}) or (from_company = #{toCompany} and to_company = #{fromCompany}))</if>
|
|
<if test="messageContent != null and messageContent != ''"> and message_content = #{messageContent}</if>
|
|
<if test="messageTopic != null and messageTopic != ''"> and message_topic = #{messageTopic}</if>
|
|
<if test="messageType != null and messageType != ''"> and message_type = #{messageType}</if>
|
|
</where>
|
|
order by create_time
|
|
</select>
|
|
<select id="getdeptIds" resultType="com.bonus.material.lease.domain.DeptDto">
|
|
SELECT
|
|
sd.dept_id AS deptId,
|
|
sd1.dept_name AS companyName
|
|
FROM
|
|
sys_dept sd
|
|
JOIN (
|
|
SELECT
|
|
CASE
|
|
ancestors
|
|
WHEN ( '0' ) THEN
|
|
dept_id ELSE SUBSTRING_INDEX( SUBSTRING_INDEX( ancestors, ',', 2 ), ',', - 1 )
|
|
END AS first_ancestor,
|
|
dept_id
|
|
FROM
|
|
sys_dept GROUP BY first_ancestor
|
|
) AS subquery ON sd.dept_id = subquery.dept_id
|
|
LEFT JOIN sys_dept sd1 ON sd1.dept_id = subquery.first_ancestor
|
|
</select>
|
|
|
|
<insert id="insertBmMessage" parameterType="com.bonus.material.basic.domain.BmMessage" useGeneratedKeys="true" keyProperty="id">
|
|
insert into bm_message
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="uuid != null">uuid,</if>
|
|
<if test="fromUser != null">from_user,</if>
|
|
<if test="toUser != null">to_user,</if>
|
|
<if test="fromCompany != null">from_company,</if>
|
|
<if test="toCompany != null">to_company,</if>
|
|
<if test="messageContent != null and messageContent != ''">message_content,</if>
|
|
<if test="messageTopic != null">message_topic,</if>
|
|
<if test="messageType != null">message_type,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="uuid != null">#{uuid},</if>
|
|
<if test="fromUser != null">#{fromUser},</if>
|
|
<if test="toUser != null">#{toUser},</if>
|
|
<if test="fromCompany != null">#{fromCompany},</if>
|
|
<if test="toCompany != null">#{toCompany},</if>
|
|
<if test="messageContent != null and messageContent != ''">#{messageContent},</if>
|
|
<if test="messageTopic != null">#{messageTopic},</if>
|
|
<if test="messageType != null">#{messageType},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateBmMessage" parameterType="com.bonus.material.basic.domain.BmMessage">
|
|
update bm_message
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="uuid != null">uuid = #{uuid},</if>
|
|
<if test="fromUser != null">from_user = #{fromUser},</if>
|
|
<if test="toUser != null">to_user = #{toUser},</if>
|
|
<if test="fromCompany != null">from_company = #{fromCompany},</if>
|
|
<if test="toCompany != null">to_company = #{toCompany},</if>
|
|
<if test="messageContent != null">message_content = #{messageContent},</if>
|
|
<if test="messageTopic != null">message_topic = #{messageTopic},</if>
|
|
<if test="isRead != null">is_read = #{isRead},</if>
|
|
<if test="messageType != null">message_type = #{messageType},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
</trim>
|
|
where from_company = #{fromCompany} and to_company = #{toCompany}
|
|
</update>
|
|
|
|
<delete id="deleteBmMessageById" parameterType="Long">
|
|
delete from bm_message where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteBmMessageByIds" parameterType="String">
|
|
delete from bm_message where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
</mapper> |