Blame view

backend/mail/src/main/resources/mapper/MailSettingMapper.xml 4.47 KB
8d73e917   陈威   初始化提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?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.hotent.mail.persistence.dao.MailSettingDao">
	<resultMap id="MailSetting" type="com.hotent.mail.model.MailSetting">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="userId" column="USER_ID_" jdbcType="VARCHAR"/>
		<result property="sendHost" column="SEND_HOST_" jdbcType="VARCHAR"/>
		<result property="sendPort" column="SEND_PORT_" jdbcType="VARCHAR"/>
		<result property="receiveHost" column="RECEIVE_HOST_" jdbcType="VARCHAR"/>
		<result property="receivePort" column="RECEIVE_PORT_" jdbcType="VARCHAR"/>
		<result property="protocal" column="PROTOCAL_" jdbcType="VARCHAR"/>
		<result property="nickName" column="USER_NAME_" jdbcType="VARCHAR"/>
		<result property="mailAddress" column="MAIL_ADDRESS_" jdbcType="VARCHAR"/>
		<result property="password" column="MAIL_PASS_" jdbcType="VARCHAR"/>
		<result property="smtpHost" column="SMTP_HOST_" jdbcType="VARCHAR"/>
		<result property="smtpPort" column="SMTP_PORT_" jdbcType="VARCHAR"/>
		<result property="popHost" column="POP_HOST_" jdbcType="VARCHAR"/>
		<result property="popPort" column="POP_PORT_" jdbcType="VARCHAR"/>
		<result property="imapHost" column="IMAP_HOST_" jdbcType="VARCHAR"/>
		<result property="imapPort" column="IMAP_PORT_" jdbcType="VARCHAR"/>
		<result property="isDefault" column="IS_DEFAULT_" jdbcType="NUMERIC"/>
		<result property="mailType" column="MAIL_TYPE_" jdbcType="VARCHAR"/>
		<result property="SSL" column="USE_SSL_" jdbcType="NUMERIC"/>
		<result property="validate" column="IS_VALIDATE_" jdbcType="NUMERIC"/>
		<result property="isDeleteRemote" column="IS_DELETE_REMOTE_" jdbcType="NUMERIC"/>
		<result property="isHandleAttach" column="IS_HANDLE_ATTACH_" jdbcType="NUMERIC"/>
		<result property="lastMessageId" column="LAST_MESSAGE_ID_" jdbcType="VARCHAR"/>
		<result property="lastReceiveTime" column="LAST_RECEIVE_TIME_" jdbcType="TIMESTAMP"/>
	</resultMap>
	
	<sql id="columns">
		ID_,USER_ID_,SEND_HOST_,SEND_PORT_,RECEIVE_HOST_,RECEIVE_PORT_,PROTOCAL_,USER_NAME_,MAIL_ADDRESS_,MAIL_PASS_,SMTP_HOST_,SMTP_PORT_,POP_HOST_,POP_PORT_,IMAP_HOST_,IMAP_PORT_,IS_DEFAULT_,MAIL_TYPE_,USE_SSL_,IS_VALIDATE_,IS_DELETE_REMOTE_,IS_HANDLE_ATTACH_,LAST_MESSAGE_ID_,LAST_RECEIVE_TIME_
	</sql>
	
	<sql id="dynamicWhere">
		<where>
			<if test="@com.hotent.base.ognl.Ognl@isNotEmpty(userId)"> AND USER_ID_  =#{userId} </if>
			<if test="@com.hotent.base.ognl.Ognl@isNotEmpty(nickName)"> AND USER_NAME_  LIKE #{nickName}  </if>
			<if test="@com.hotent.base.ognl.Ognl@isNotEmpty(mailAddress)"> AND MAIL_ADDRESS_  LIKE #{mailAddress}  </if>
			<if test="@com.hotent.base.ognl.Ognl@isNotEmpty(isDefault)"> AND IS_DEFAULT_  =#{isDefault} </if>
		</where>
	</sql>
	
	<update id="updateDefault" parameterType="com.hotent.mail.model.MailSetting">
		UPDATE portal_sys_mail_setting SET
		IS_DEFAULT_=#{isDefault,jdbcType=NUMERIC}
		WHERE
		ID_=#{id}
	</update>
	
	<select id="getAllByUserId" resultMap="MailSetting">
		SELECT <include refid="columns"/>
		FROM portal_sys_mail_setting
		<include refid="dynamicWhere" />
		<if test="@com.hotent.base.ognl.Ognl@isNotEmpty(orderField)">
		order by ${orderField} ${orderSeq}
		</if>
		<if test="@com.hotent.base.ognl.Ognl@isEmpty(orderField)">
		order by  ID_ desc
		</if>
	</select>
	
	<select id="getMailByAddress" parameterType="java.lang.String" resultMap="MailSetting">
		SELECT <include refid="columns"/>
		FROM portal_sys_mail_setting
		WHERE
		MAIL_ADDRESS_=#{address}
	</select>
	
	<select id="getMailByUserId" parameterType="java.lang.String" resultMap="MailSetting">
		SELECT <include refid="columns"/>
		FROM portal_sys_mail_setting
		WHERE
		USER_ID_=#{userId}
	</select>
		
	<select id="getByIsDefault" parameterType="java.lang.String" resultMap="MailSetting">
		SELECT <include refid="columns"/>
		FROM portal_sys_mail_setting
		WHERE
		USER_ID_=#{userId} and IS_DEFAULT_=1
	</select>
	
	<select id="getCountByAddress" parameterType="java.lang.String" resultType="int">
		SELECT COUNT(1)
		FROM portal_sys_mail_setting
		WHERE
		MAIL_ADDRESS_=#{address}
	</select>
	
	<select id="getCountByUserId" parameterType="java.lang.String" resultType="int">
		SELECT COUNT(1)
		FROM portal_sys_mail_setting
		WHERE
		USER_ID_=#{userId}
	</select>
	
	<update id="updateLastEnvelop">
		UPDATE portal_sys_mail_setting SET
		LAST_MESSAGE_ID_=#{messageId,jdbcType=VARCHAR},
		LAST_RECEIVE_TIME_=#{receiveTime,jdbcType=TIMESTAMP}
		WHERE
		ID_=#{id}
	</update>
</mapper>