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.
 
 

93 lines
2.8 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.ccsens.tall.persist.dao.SysRingMsgDao">
<resultMap id="ring_message" type="com.ccsens.tall.bean.vo.RingVo$RingInfo">
<id column="messageId" property="messageId" />
<result column="value" property="value" />
<result column="mine" property="mine" />
<result column="unread" property="unread" />
<result column="time" property="time" />
<collection property="roleList" ofType="com.ccsens.tall.bean.vo.RingVo$MsgReceiveRole">
<id column="roleId" property="id"/>
<result column="roleName" property="name"/>
<result column="readStatus" property="readStatus"/>
</collection>
<collection property="sender" ofType="com.ccsens.tall.bean.vo.RingVo$MsgSender">
<id column="senderId" property="id"/>
<result column="senderName" property="name"/>
</collection>
</resultMap>
<select id="selectRingInfoByProject" parameterType="java.util.Map" resultMap="ring_message">
SELECT
m.id as messageId,
m.`value` as `value`,
m.`value_text` as `valueText`,
m.`time` as time,
if(m.sender_id = #{userId},1,0) as mine,
r.id as roleId,
r.name as roleName,
s.read_status as readStatus,
m.sender_id as senderId,
(
SELECT
IF( u.nickname = '', a.identifier, u.nickname ) AS userName
FROM
t_sys_user u
LEFT JOIN t_sys_auth a ON u.id = a.user_id
AND a.identify_type = 3
WHERE
u.rec_status = 0
and
a.rec_status = 0
and
u.id = m.sender_id
limit 1
) as senderName,
(SELECT count(read_status) FROM t_sys_ring_send WHERE ring_id = m.id and read_status = 0) as unread
FROM
t_sys_ring_msg m LEFT JOIN t_sys_ring_send s on m.id = s.ring_id
LEFT JOIN t_pro_role r on s.role_id = r.id
WHERE
(
m.sender_id = #{userId}
or
s.role_id in (
SELECT
r.id as rId
FROM
t_pro_role r LEFT JOIN t_pro_member_role mr on r.id = mr.role_id
LEFT JOIN t_pro_member m on mr.member_id = m.id
WHERE
(m.user_id = #{userId}
or
r.`name` = '全体成员'
)
AND
r.project_id = #{projectId}
)
)
and
m.project_id = #{projectId}
ORDER BY m.time DESC
</select>
<select id="selectRoleIdByUserId" parameterType="java.util.Map" resultType="Long">
SELECT
r.id as rId
FROM
t_pro_role r LEFT JOIN t_pro_member_role mr on r.id = mr.role_id
LEFT JOIN t_pro_member m on mr.member_id = m.id
WHERE
(m.user_id = #{userId}
or
r.`name` = '全体成员'
)
AND
r.project_id = #{projectId}
</select>
</mapper>