提交 | 用户 | age
|
385e2d
|
1 |
package com.yc.crm.mail.service; |
X |
2 |
|
|
3 |
import com.yc.action.grid.GridUtils; |
|
4 |
import com.yc.crm.mail.entity.T482102Entity; |
|
5 |
import com.yc.service.BaseService; |
|
6 |
import org.apache.commons.lang3.StringUtils; |
|
7 |
import org.springframework.jdbc.core.BeanPropertyRowMapper; |
|
8 |
import org.springframework.stereotype.Service; |
|
9 |
|
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
/** |
|
13 |
* @BelongsProject: eCoWorksV3 |
|
14 |
* @BelongsPackage: com.yc.crm.service |
|
15 |
* @author: xinyb |
|
16 |
* @CreateTime: 2024-07-26 09:06 |
|
17 |
* @Description: |
|
18 |
*/ |
|
19 |
@Service |
|
20 |
public class MailAccountImpl extends BaseService implements MailAccountIfc { |
|
21 |
@Override |
|
22 |
public void addEmailAccount(T482102Entity account) { |
|
23 |
String sql = "set nocount on\n"; |
|
24 |
try { |
6a63e2
|
25 |
sql += "insert into t482102(companyId,companyName,email,password,alias_email,userCode,userName,receiveProtocol," + |
X |
26 |
"receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost," + |
877259
|
27 |
"smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost,invalid,bisync_flag,proxyFlag,mailType,mailStatus,create_time,update_time)\n" + |
385e2d
|
28 |
"values(" + GridUtils.prossSqlParm(account.getCompanyId()) + "," + GridUtils.prossSqlParm(account.getCompanyName()) + "," + GridUtils.prossSqlParm(account.getEmail()) + "," + |
f5cc47
|
29 |
GridUtils.prossSqlParm(account.getPassword()) + "," + |
385e2d
|
30 |
GridUtils.prossSqlParm(account.getAliasEmail()) + "," + GridUtils.prossSqlParm(account.getUserCode()) + "," + GridUtils.prossSqlParm(account.getUserName()) + "," + |
6a63e2
|
31 |
GridUtils.prossSqlParm(account.getReceiveProtocol()) + "," + GridUtils.prossSqlParm(account.getReceiveEmail()) + "," + GridUtils.prossSqlParm(account.getReceivePassword()) + "," + |
X |
32 |
"'" + account.isReceiveSSL() + "'," + account.getReceivePort() + "," + GridUtils.prossSqlParm(account.getReceiveHost()) + "," + |
|
33 |
GridUtils.prossSqlParm(account.getSmtpEmail()) + "," + GridUtils.prossSqlParm(account.getSmtpPassword()) + ",'" + account.isSmtpSSL() + "'," + |
8c1986
|
34 |
account.getSmtpPort() + "," + GridUtils.prossSqlParm(account.getSmtpHost()) + ",'" + account.isInvalid() + "','" + account.isBiSyncFlag() + "','" + account.isProxyFlag() + "'," + |
877259
|
35 |
account.getMailType() + "," + GridUtils.prossSqlParm(account.getMailStatus()) + ",convert(varchar(19),getdate(),120),convert(varchar(19),getdate(),120))"; |
385e2d
|
36 |
jdbcTemplate.update(sql); |
X |
37 |
} catch (Exception e) { |
|
38 |
throw e; |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public Integer updateEmailAccount(T482102Entity account) { |
|
44 |
String sql = "set nocount on\n"; |
|
45 |
try { |
6a63e2
|
46 |
sql += "update t482102 set alias_email=" + GridUtils.prossSqlParm(account.getAliasEmail()) + ","; |
X |
47 |
if (StringUtils.isNotBlank(account.getPassword())) { |
|
48 |
sql += "password=" + GridUtils.prossSqlParm(account.getPassword()) + ","; |
|
49 |
} |
8c1986
|
50 |
sql += " receiveEmail=" + GridUtils.prossSqlParm(account.getReceiveEmail()) + ","; |
6a63e2
|
51 |
if (StringUtils.isNotBlank(account.getReceivePassword())) { |
X |
52 |
sql += "receivePassword=" + GridUtils.prossSqlParm(account.getReceivePassword()) + ","; |
|
53 |
} |
|
54 |
sql += " receiveSSL='" + account.isReceiveSSL() + "',receivePort=" + account.getReceivePort() + ", " + |
|
55 |
" receiveHost=" + GridUtils.prossSqlParm(account.getReceiveHost()) + "," + |
|
56 |
" smtpEmail=" + GridUtils.prossSqlParm(account.getSmtpEmail()) + ","; |
|
57 |
if (StringUtils.isNotBlank(account.getSmtpPassword())) { |
|
58 |
sql += "smtpPassword=" + GridUtils.prossSqlParm(account.getSmtpPassword()) + ","; |
|
59 |
} |
|
60 |
sql += " smtpSSL='" + account.isSmtpSSL() + "'," + " smtpPort=" + account.getSmtpPort() + ",smtpHost=" + GridUtils.prossSqlParm(account.getSmtpHost()) + "," + |
8c1986
|
61 |
" invalid='" + account.isInvalid() + "',bisync_flag='" + account.isBiSyncFlag() + "',proxyFlag='" + account.isProxyFlag() + "'," + |
7cf738
|
62 |
" mailType=" + account.getMailType() + ",mailStatus=" + GridUtils.prossSqlParm(account.getMailStatus()) + |
X |
63 |
// " ,update_time=convert(varchar(19),getdate(),120) " + |
385e2d
|
64 |
" where userCode=" + GridUtils.prossSqlParm(account.getUserCode()) + " and accountId=" + account.getAccountId(); |
7cf738
|
65 |
sql += "select @@ROWCOUNT"; |
X |
66 |
return jdbcTemplate.queryForObject(sql, Integer.class); |
|
67 |
} catch (Exception e) { |
|
68 |
throw e; |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public Integer updateEmailTime(Integer accountId) { |
|
74 |
String sql = "set nocount on\n"; |
|
75 |
try { |
|
76 |
sql += "update t482102 set update_time=convert(varchar(19),getdate(),120) " + |
|
77 |
" where accountId=" + accountId; |
877259
|
78 |
sql += "select @@ROWCOUNT"; |
X |
79 |
return jdbcTemplate.queryForObject(sql, Integer.class); |
|
80 |
} catch (Exception e) { |
|
81 |
throw e; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public Integer updateMailStatus(String status, Integer accountId) { |
|
87 |
String sql = "set nocount on\n"; |
|
88 |
try { |
7cf738
|
89 |
sql += "update t482102 set mailStatus=" + GridUtils.prossSqlParm(status) + //",update_time=convert(varchar(19),getdate(),120) " + |
877259
|
90 |
" where accountId=" + accountId; |
X |
91 |
sql += "select @@ROWCOUNT"; |
|
92 |
return jdbcTemplate.queryForObject(sql, Integer.class); |
|
93 |
} catch (Exception e) { |
|
94 |
throw e; |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public Integer updateAliasEmail(String aliasEmail, Integer accountId) { |
|
100 |
String sql = "set nocount on\n"; |
|
101 |
try { |
7cf738
|
102 |
sql += "update t482102 set alias_email=" + GridUtils.prossSqlParm(aliasEmail) + //",update_time=convert(varchar(19),getdate(),120) " + |
877259
|
103 |
" where accountId=" + accountId; |
385e2d
|
104 |
sql += "select @@ROWCOUNT"; |
f5cc47
|
105 |
return jdbcTemplate.queryForObject(sql, Integer.class); |
385e2d
|
106 |
} catch (Exception e) { |
X |
107 |
throw e; |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
@Override |
|
112 |
public Integer deleteEmailAccount(String userCode, Integer accountId) { |
|
113 |
String sql = "set nocount on\n"; |
|
114 |
try { |
|
115 |
sql += "delete t482102 where userCode='" + userCode + "' and accountId=" + accountId + "\n"; |
|
116 |
sql += "select @@ROWCOUNT"; |
f5cc47
|
117 |
return jdbcTemplate.queryForObject(sql, Integer.class); |
385e2d
|
118 |
} catch (Exception e) { |
X |
119 |
throw e; |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
877259
|
124 |
public List<T482102Entity> getAccount(String userCode) { |
385e2d
|
125 |
String sql = "set nocount on\n"; |
X |
126 |
try { |
|
127 |
sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
877259
|
128 |
"isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
6a63e2
|
129 |
"receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
X |
130 |
"isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
385e2d
|
131 |
"from t482102 " + |
X |
132 |
"where userCode=" + GridUtils.prossSqlParm(userCode); |
877259
|
133 |
sql += " order by accountId"; |
385e2d
|
134 |
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |
X |
135 |
} catch (Exception e) { |
|
136 |
throw e; |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
877259
|
141 |
public T482102Entity getAccountInfo(String userCode, Integer accountId) throws Exception { |
X |
142 |
String sql = "set nocount on\n"; |
|
143 |
try { |
|
144 |
sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
|
145 |
"isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
|
146 |
"receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
|
147 |
"isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
|
148 |
"from t482102 " + |
|
149 |
"where userCode=" + GridUtils.prossSqlParm(userCode) + " and accountId=" + accountId; |
|
150 |
sql += " order by accountId"; |
|
151 |
List<T482102Entity> t482101HEntity = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |
|
152 |
if (t482101HEntity.size() > 0) { |
|
153 |
return t482101HEntity.get(0); |
|
154 |
} |
385e2d
|
155 |
return null; |
877259
|
156 |
} catch (Exception e) { |
X |
157 |
throw e; |
|
158 |
} |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public T482102Entity getAccountInfo(String userCode, String eMail) throws Exception { |
|
163 |
String sql = "set nocount on\n"; |
|
164 |
try { |
7caeae
|
165 |
sql += "select top 1 companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
877259
|
166 |
"isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
X |
167 |
"receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
|
168 |
"isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
|
169 |
"from t482102 " + |
|
170 |
"where userCode=" + GridUtils.prossSqlParm(userCode) + " and email=" + GridUtils.prossSqlParm(eMail); |
|
171 |
sql += " order by accountId"; |
|
172 |
List<T482102Entity> t482101HEntity = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |
|
173 |
if (t482101HEntity.size() > 0) { |
|
174 |
return t482101HEntity.get(0); |
|
175 |
} |
|
176 |
return null; |
|
177 |
} catch (Exception e) { |
|
178 |
throw e; |
385e2d
|
179 |
} |
X |
180 |
} |
|
181 |
} |