| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.jdbc.core.BeanPropertyRowMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | public class MailAccountImpl extends BaseService implements MailAccountIfc { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void addEmailAccount(T482102Entity account) { |
| | | String sql = "set nocount on\n"; |
| | |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer updateEmailAccount(T482102Entity account) { |
| | | String sql = "set nocount on\n"; |
| | |
| | | } |
| | | sql += " smtpSSL='" + account.isSmtpSSL() + "'," + " smtpPort=" + account.getSmtpPort() + ",smtpHost=" + GridUtils.prossSqlParm(account.getSmtpHost()) + "," + |
| | | " invalid='" + account.isInvalid() + "',bisync_flag='" + account.isBiSyncFlag() + "',proxyFlag='" + account.isProxyFlag() + "'," + |
| | | " mailType=" + account.getMailType() + ",mailStatus=" + GridUtils.prossSqlParm(account.getMailStatus()) + "," + |
| | | " update_time=convert(varchar(19),getdate(),120) " + |
| | | " where userCode=" + GridUtils.prossSqlParm(account.getUserCode()) + " and accountId=" + account.getAccountId(); |
| | | sql += "select @@ROWCOUNT"; |
| | | " mailType=" + account.getMailType() + ",mailStatus=" + GridUtils.prossSqlParm(account.getMailStatus()) + |
| | | // " ,update_time=convert(varchar(19),getdate(),120) " + |
| | | " where userCode=" + GridUtils.prossSqlParm(account.getUserCode()) + " and accountId=" + account.getAccountId() + "\n"; |
| | | sql += " select @@ROWCOUNT"; |
| | | return jdbcTemplate.queryForObject(sql, Integer.class); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer updateEmailTime(Integer accountId) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "update t482102 set update_time=convert(varchar(19),getdate(),120) " + |
| | | " where accountId=" + accountId + "\n"; |
| | | sql += " select @@ROWCOUNT"; |
| | | return jdbcTemplate.queryForObject(sql, Integer.class); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer updateMailStatus(String status, Integer accountId) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "update t482102 set mailStatus=" + GridUtils.prossSqlParm(status) + ",update_time=convert(varchar(19),getdate(),120) " + |
| | | " where accountId=" + accountId; |
| | | sql += "select @@ROWCOUNT"; |
| | | sql += "update t482102 set mailStatus=" + GridUtils.prossSqlParm(status) + //",update_time=convert(varchar(19),getdate(),120) " + |
| | | " where accountId=" + accountId + "\n"; |
| | | sql += " select @@ROWCOUNT"; |
| | | return jdbcTemplate.queryForObject(sql, Integer.class); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer updateAliasEmail(String aliasEmail, Integer accountId) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "update t482102 set alias_email=" + GridUtils.prossSqlParm(aliasEmail) + ",update_time=convert(varchar(19),getdate(),120) " + |
| | | " where accountId=" + accountId; |
| | | sql += "select @@ROWCOUNT"; |
| | | sql += "update t482102 set alias_email=" + GridUtils.prossSqlParm(aliasEmail) + //",update_time=convert(varchar(19),getdate(),120) " + |
| | | " where accountId=" + accountId + "\n"; |
| | | sql += " select @@ROWCOUNT"; |
| | | return jdbcTemplate.queryForObject(sql, Integer.class); |
| | | } catch (Exception e) { |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public Integer deleteEmailAccount(String userCode, Integer accountId) { |
| | | String sql = "set nocount on\n"; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<T482102Entity> getAccountList() { |
| | | String sql = "set nocount on\n"; |
| | | sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
| | | "isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
| | | "receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
| | | "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
| | | "from t482102 where invalid=1"; |
| | | sql += " order by accountId"; |
| | | return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |
| | | } |
| | | |
| | | @Override |
| | | public List<T482102Entity> getAccount(String userCode) { |
| | | String sql = "set nocount on\n"; |
| | | try { |
| | | sql += "select companyId,companyName,email,password,alias_email as aliasEmail,userCode,userName,accountId,receive_server_user_name as receiveServerUserName," + |
| | | "isnull(bisync_flag,0) as biSyncFlag,isnull(proxyFlag,0) as proxyFlag,mailDomain,isnull(mailType,0) as mailType,mailStatus,keywordList,siteUrl,receiveProtocol," + |
| | | "receiveEmail,receivePassword,receiveSSL,receivePort,receiveHost,smtpEmail,smtpPassword,smtpSSL,smtpPort,smtpHost," + |
| | | "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion " + |
| | | "from t482102 " + |
| | | "isnull(invalid,0) as invalid,create_time as createTime,update_time as updateTime,DocVersion, " + |
| | | "(case when isnull(mailStatus,'')='正常' then 0 else -1 end) as mailStatusCode from t482102 " + |
| | | "where userCode=" + GridUtils.prossSqlParm(userCode); |
| | | sql += " order by accountId"; |
| | | return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(T482102Entity.class)); |