YxyMailFolderServiceImpl.java
5.2 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package com.espeed.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.espeed.dao.YxyMailFolderDao;
import com.espeed.dao.YxySendMailMasterBaseDao;
import com.espeed.dao.YxyUserAddressDao;
import com.espeed.pojo.YxyMailFolder;
import com.espeed.service.YxyMailFolderService;
public class YxyMailFolderServiceImpl implements YxyMailFolderService{
/**查询所有类别*/
public List<YxyMailFolder> findFolderAll(String loginid, String domain)throws Exception {
String hql="from YxyMailFolder where user_loginid='"+loginid+"' and company_domain='"+domain+"' order by create_timer desc";
List<YxyMailFolder> typelist=yxymailfolderdao.findByHql(hql);
//查询各类别下的地址量
String sql="select user_addr_type_id,count(*) from yxy_user_address where user_loginid='"+loginid+"' and user_domain='"+domain+"' GROUP by user_addr_type_id";
List<Object> list=yxyuseraddressdao.findBySqlQuery(sql);
//遍历集合赋值
for(int i=0;i<list.size();i++){
Object [] obj=(Object[]) list.get(i);
int count=Integer.parseInt(obj[1].toString());
int typeid=Integer.parseInt(obj[0].toString());
for(int j=0;j<typelist.size();j++){
int id=typelist.get(j).getFolder_id();
if(typeid==id){
typelist.get(j).setEmailnun(count);
break;
}
}
}
return yxymailfolderdao.findByHql(hql);
}
/**查询本地分类中是否含有地址*/
public List<YxyMailFolder> findFolderAddr(String loginid, String domain) throws Exception {
//先到分类中进行查找
String hql="from YxyMailFolder where user_loginid='"+loginid+"' and company_domain='"+domain+"' order by create_timer desc";
List<YxyMailFolder> mailFolders = yxymailfolderdao.findByHql(hql);
List<YxyMailFolder> temp = new ArrayList<YxyMailFolder>();
//查询各类别下的地址量
String sql="select user_addr_type_id,count(*) from yxy_user_address where user_loginid='"+loginid+"' and user_domain='"+domain+"' GROUP by user_addr_type_id";
List<Object> list=yxyuseraddressdao.findBySqlQuery(sql);
//遍历集合赋值
for(int i=0;i<list.size();i++){
Object [] obj=(Object[]) list.get(i);
int count=Integer.parseInt(obj[1].toString());
int typeid=Integer.parseInt(obj[0].toString());
for(int j=0;j<mailFolders.size();j++){
if(mailFolders.get(j).getFolder_id() == typeid){
if(count > 0 ){
mailFolders.get(j).setEmailnun(count);
temp.add(mailFolders.get(j));
}
}
}
}
return temp;
}
/**查询类别名称是否存在*/
public int findIsExits(String loginid, String domain, String typename)throws Exception {
String hql="from YxyMailFolder where user_loginid='"+loginid+"' and company_domain='"+domain+"' and folder_name='"+typename+"'";
List<YxyMailFolder> list=yxymailfolderdao.findByHql(hql);
if(list.size()>0){
return 0;
}else{
return 1;
}
}
/**删除文件类别*/
public void delUserFolder(int typeid,int deltype)throws Exception {
String hql="delete YxyMailFolder where folder_id="+typeid;
yxymailfolderdao.updateByHql(hql);
if(deltype==1){
//删除该类别下的地址
String hql1="delete YxyUserAddress where user_addr_type_id="+typeid;
yxyuseraddressdao.updateByHql(hql1);
//类别下的邮件
String hql2="delete YxySendMailMasterBase where has_classify="+typeid;
yxysendmailmasterbasedao.updateByHql(hql2);
}else{
//修改为默认
String hql1="update YxyUserAddress set user_addr_type_id=0 where user_addr_type_id="+typeid;
yxyuseraddressdao.updateByHql(hql1);
String hql2="update YxySendMailMasterBase set has_classify=0 where has_classify="+typeid;
yxysendmailmasterbasedao.updateByHql(hql2);
}
}
/**添加文件类别*/
public void addUserFolder(YxyMailFolder o) throws Exception {
yxymailfolderdao.addPojo(o);
}
/**编辑类别*/
public void editUserFolder(int typeid,String foldername) throws Exception{
String hql="update YxyMailFolder set folder_name='"+foldername+"' where folder_id="+typeid;
yxymailfolderdao.updateByHql(hql);
}
/**清空类别下的数据*/
public void delTypeData(int typeid) throws Exception {
//删除该类别下的地址
String hql1="delete YxyUserAddress where user_addr_type_id="+typeid;
yxyuseraddressdao.updateByHql(hql1);
//类别下的邮件
String hql2="delete YxySendMailMasterBase where has_classify="+typeid;
yxysendmailmasterbasedao.updateByHql(hql2);
}
private YxyMailFolderDao yxymailfolderdao;//文件类别dao
private YxySendMailMasterBaseDao yxysendmailmasterbasedao;//邮件信息dao
private YxyUserAddressDao yxyuseraddressdao;//地址dao
public YxyMailFolderDao getYxymailfolderdao() {
return yxymailfolderdao;
}
public void setYxymailfolderdao(YxyMailFolderDao yxymailfolderdao) {
this.yxymailfolderdao = yxymailfolderdao;
}
public YxySendMailMasterBaseDao getYxysendmailmasterbasedao() {
return yxysendmailmasterbasedao;
}
public void setYxysendmailmasterbasedao(
YxySendMailMasterBaseDao yxysendmailmasterbasedao) {
this.yxysendmailmasterbasedao = yxysendmailmasterbasedao;
}
public YxyUserAddressDao getYxyuseraddressdao() {
return yxyuseraddressdao;
}
public void setYxyuseraddressdao(YxyUserAddressDao yxyuseraddressdao) {
this.yxyuseraddressdao = yxyuseraddressdao;
}
}