123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?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.fjhx.email.mapper.MailMapper">
- <resultMap id="getMailboxInfoListByUserIdResultMap"
- autoMapping="true"
- type="com.fjhx.email.entity.dto.MailboxInfo">
- <id column="id" property="id"/>
- <result column="type" property="type"/>
- <result column="skip" property="skip"/>
- <result column="mail_user" property="mailUser"/>
- <result column="mail_password" property="mailPassword"/>
- <result column="receive_host" property="receiveHost"/>
- <result column="receive_port" property="receivePort"/>
- <result column="receive_protocol" property="receiveProtocol"/>
- <collection property="mailFolderInfoList"
- autoMapping="true"
- ofType="com.fjhx.email.entity.dto.MailFolderInfo"
- javaType="java.util.List">
- <id column="folder_id" property="id"/>
- <result column="folder_name" property="name"/>
- <result column="skip" property="skip"/>
- <result column="last_uid" property="lastUid"/>
- <result column="last_received_date" property="lastReceivedDate"/>
- </collection>
- </resultMap>
- <select id="getMailboxInfoListByUserId" resultMap="getMailboxInfoListByUserIdResultMap">
- select
- type,
- skip,
- id,
- mail_user,
- mail_password,
- receive_host,
- receive_port,
- receive_protocol,
- folder_id,
- folder_name,
- last_uid,
- last_received_date
- from (
- (select 1 type,
- 0 skip,
- pm.id,
- pm.mail_user,
- pm.mail_password,
- pm.receive_host,
- pm.receive_port,
- pm.receive_protocol,
- pf.id folder_id,
- pf.name folder_name,
- pf.last_uid,
- pf.last_received_date
- from personal_mailbox pm
- inner join personal_folder pf on pm.id = pf.mailbox_id
- where pm.status = 1
- and pm.sync_status = 1
- and pm.type = #{mailType}
- and pm.del_flag = 0
- and pm.user_id in
- <foreach collection="userIdList" item="userId" open="(" separator="," close=")">
- #{userId}
- </foreach>
- and pf.sync_status = 1
- and pf.del_flag = 0
- )
- union all
- (select 2 type,
- 0 skip,
- em.id,
- CONCAT(em.mail_user_prefix,'@',ed.domain_name) mail_user,
- em.mail_password,
- ed.receive_host,
- ed.receive_port,
- ed.receive_protocol,
- ef.id folder_id,
- ef.name folder_name,
- ef.last_uid,
- ef.last_received_date
- from enterprise_domain ed
- inner join enterprise_mailbox em on ed.id = em.domain_id
- inner join enterprise_folder ef on em.id = ef.mailbox_id
- where ed.type = #{mailType}
- and ed.del_flag = 0
- and em.status = 1
- and em.sync_status = 1
- and em.del_flag = 0
- and em.user_id in
- <foreach collection="userIdList" item="userId" open="(" separator="," close=")">
- #{userId}
- </foreach>
- and ef.sync_status = 1
- and ef.del_flag = 0
- )
- ) t
- ORDER BY
- t.id ASC,
- t.folder_id DESC
- </select>
- </mapper>
|