YxyUserInfoServiceImpl.java
9.7 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
package com.espeed.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.espeed.centre.pojo.YxyUserInfo;
import com.espeed.dao.CentreLoginDao;
import com.espeed.dao.XLicenceFunDao;
import com.espeed.dao.XMailAccountDao;
import com.espeed.dao.YxyCompanyWebInfoDao;
import com.espeed.dao.YxySysParamatersValueDao;
import com.espeed.dao.YxyUserInfoDao;
import com.espeed.pojo.YxyCompanyWebInfo;
import com.espeed.pojo.YxySysParamatersValue;
import com.espeed.service.YxyUserInfoService;
import com.espeed.tool.Md5Code;
import com.espeed.vo.PageBean;
import com.espeed.webmail.pojo.XLicenceFun;
import com.espeed.webmail.pojo.XMailAccount;
public class YxyUserInfoServiceImpl implements YxyUserInfoService{
/**查询用户信息*/
public List<YxyUserInfo> findVerificationUser(String loginid, String domain)throws Exception {
List<YxyUserInfo> users = new ArrayList<YxyUserInfo>();
String sql = "select company_id from centre_company where domain = '"+domain+"'";
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size()>0){
int company_id = Integer.parseInt(objects.get(0).toString());
String hql="from YxyUserInfo where login_id='"+loginid+"' and company_id="+company_id;
return yxyuserinfodao.findByHql(hql);
}
return users;
}
/**查询所有用户*/
public List<YxyUserInfo> findByUser(int company_id) throws Exception {
String hql="from YxyUserInfo where company_id="+company_id;
return yxyuserinfodao.findByHql(hql);
}
/**查询所有用户根据域*/
//public List<YxyUserInfo> findDomainUser(String domain) throws Exception {
public List<YxyUserInfo> findDomainUser(YxyUserInfo user)throws Exception{
if(user.getUser_role()==1)//系统管理员
{
String hql="from YxyUserInfo where company_id="+user.getCompany_id()+" ORDER BY enrol_time desc";
return yxyuserinfodao.findByHql(hql);
}
else if(user.getUser_role()==2)//部门管理员
{
String ids = "";
//获取子部门
String sql="select dept_id from centre_department where parent_dept_id = "+user.getDept_id();
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
ids += obj.toString() + ",";
}
ids += String.valueOf(user.getDept_id());
}else{
ids = String.valueOf(user.getDept_id());
}
String hql="from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
return yxyuserinfodao.findByHql(hql);
}
else
{
return new ArrayList<YxyUserInfo>();
}
//String hql="from YxyUserInfo where companydomain='"+domain+"'";
//return yxyuserinfodao.findByHql(hql);
}
/**查询所有用户根据域*/
//public List<YxyUserInfo> findDomainUser(String domain, PageBean pb)throws Exception {
public List<YxyUserInfo> findDomainUser(YxyUserInfo user,PageBean pb)throws Exception {
if(user.getUser_role()==1)//系统管理员
{
String hql="from YxyUserInfo where company_id="+user.getCompany_id()+" ORDER BY enrol_time desc";
String hqlcount="select count(*) from YxyUserInfo where company_id="+user.getCompany_id()+" ORDER BY enrol_time desc";
return yxyuserinfodao.findByHqlPage(hql, hqlcount, pb);
}
else if(user.getUser_role()==2)//部门管理员
{
String ids = "";
//获取子部门
String sql="select dept_id from centre_department where parent_dept_id = "+user.getDept_id();
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size() > 0){
for(Object obj : objects){
ids += obj.toString() + ",";
}
ids += String.valueOf(user.getDept_id());
}else{
ids = String.valueOf(user.getDept_id());
}
String hql="from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
String hqlcount="select count(*) from YxyUserInfo where company_id="+user.getCompany_id()+" and dept_id in("+ids+") ORDER BY enrol_time desc";
return yxyuserinfodao.findByHqlPage(hql, hqlcount, pb);
}
else
{
return new ArrayList<YxyUserInfo>();
}
}
/**更新该用户登录时间*/
public void updateUserLoginDate(String date,String loginid,String domain) throws Exception {
//String hql="update YxyUserInfo set lastdate='"+date+"' where loginid='"+loginid+"' and companydomain='"+domain+"'";
//yxyuserinfodao.updateByHql(hql);
}
/**http调用查询用户信息*/
public YxyUserInfo findHttpInfo(String loginid, String domain, String aip)throws Exception {
String hql="from YxyUserInfo where loginid='"+loginid+"' and companydomain='"+domain+"' and domainaip='"+aip+"'";
List<YxyUserInfo> o=yxyuserinfodao.findByHql(hql);
if(o.size()>0){
return o.get(0);
}else{
return null;
}
}
/**实体更新*/
public void updatePojo(YxyUserInfo o) throws Exception {
yxyuserinfodao.updatePojo(o);
}
/**开通用户营销*/
public void updateOpenYxy(String logindid,String domain,String username,
int ismange,int deptid,int pdeptid,int new_tol_num,int new_month_num,int new_day_num)throws Exception
{
//添加用户基本信息
YxyUserInfo user=new YxyUserInfo();
// user.setCompanydomain(domain);
// user.setLoginid(logindid);
// user.setUsername(username);
// user.setUserrole(ismange+"");
// user.setDeptid(deptid);
// user.setPdeptid(pdeptid);
yxyuserinfodao.addPojo(user);
//需要添加的集合
List<YxySysParamatersValue> paramvaluelist=new ArrayList<YxySysParamatersValue>();
//添加日发送量
YxySysParamatersValue daypara=new YxySysParamatersValue();
daypara.setCompany_domain(domain);
daypara.setOwner_loginid(logindid);
daypara.setOwner_type(4);
daypara.setPara_id(1);
daypara.setPara_value(new_day_num+"");
paramvaluelist.add(daypara);
//添加月发送量
YxySysParamatersValue monthpara=new YxySysParamatersValue();
monthpara.setCompany_domain(domain);
monthpara.setOwner_loginid(logindid);
monthpara.setOwner_type(4);
monthpara.setPara_id(2);
monthpara.setPara_value(new_month_num+"");
paramvaluelist.add(monthpara);
//添加总发送量
YxySysParamatersValue tolpara=new YxySysParamatersValue();
tolpara.setCompany_domain(domain);
tolpara.setOwner_loginid(logindid);
tolpara.setOwner_type(4);
tolpara.setPara_id(34);
tolpara.setPara_value(new_tol_num+"");
paramvaluelist.add(tolpara);
//添加参数值
yxysysparamatersvaluedao.addPojoPi(paramvaluelist);
}
/**更改用户状态*/
public void updateUserStatus(String loginid,int company_id,int delete_flag)throws Exception
{
String hql = "update YxyUserInfo set delete_flag = "+delete_flag+" where login_id = '"+loginid+"' and company_id = "+company_id;
yxyuserinfodao.updateByHql(hql);
}
/**获取webmail访问路径信息*/
public List<YxyCompanyWebInfo> findWebmailInfo(String hql)throws Exception
{
return yxycompanywebinfodao.findByHql(hql);
}
/**个人版登录验证*/
public int findLoginInfo(String loginid,String domain,String password)throws Exception{
String sql = "select credential from centre_login where identity_type = 11 and identity = '"+loginid+"###"+domain+"'";
List<Object> objects = yxyuserinfodao.findBySqlQuery(sql);
if(objects.size()>0){
String credential = objects.get(0).toString();
if(password.equals(credential)){
return 1;//登录成功
}else{
return -5;//密码不正确
}
}else{
return -4;//帐号不存在
}
}
/**查询企业授权模块信息*/
public List<XLicenceFun> getCompanyLicences(String hql)throws Exception{
return xlicencefundao.findByHql(hql);
}
/**修改用户密码*/
public void updateUserPassword(int user_id,String password)throws Exception{
password = Md5Code.createMd5(password);
String hql = "update CentreLogin set credential = '"+password+"' where identity_type = 11 and user_id = "+user_id;
centrelogindao.updateByHql(hql);
}
/**验证用户密码*/
public int verifyUserPassword(int user_id,String password)throws Exception{
password = Md5Code.createMd5(password);
String hql = "select count(*) from CentreLogin where identity_type = 11 and user_id = "+user_id+" and credential = '"+password+"'";
int counts = centrelogindao.findByHqlCount(hql);
if(counts > 0){//密码正确
return 1;
}else{//密码不正确
return 0;
}
}
/**查询用户邮箱*/
public List<XMailAccount> findUserAccountByHql(String hql)throws Exception{
return xmailaccountdao.findByHql(hql);
}
private YxyUserInfoDao yxyuserinfodao;
private YxySysParamatersValueDao yxysysparamatersvaluedao;
private YxyCompanyWebInfoDao yxycompanywebinfodao;
private XLicenceFunDao xlicencefundao;
private CentreLoginDao centrelogindao;
private XMailAccountDao xmailaccountdao;//邮箱帐号dao
public YxyUserInfoDao getYxyuserinfodao() {
return yxyuserinfodao;
}
public void setYxyuserinfodao(YxyUserInfoDao yxyuserinfodao) {
this.yxyuserinfodao = yxyuserinfodao;
}
public YxySysParamatersValueDao getYxysysparamatersvaluedao() {
return yxysysparamatersvaluedao;
}
public void setYxysysparamatersvaluedao(
YxySysParamatersValueDao yxysysparamatersvaluedao) {
this.yxysysparamatersvaluedao = yxysysparamatersvaluedao;
}
public YxyCompanyWebInfoDao getYxycompanywebinfodao() {
return yxycompanywebinfodao;
}
public void setYxycompanywebinfodao(YxyCompanyWebInfoDao yxycompanywebinfodao) {
this.yxycompanywebinfodao = yxycompanywebinfodao;
}
public XLicenceFunDao getXlicencefundao() {
return xlicencefundao;
}
public void setXlicencefundao(XLicenceFunDao xlicencefundao) {
this.xlicencefundao = xlicencefundao;
}
public CentreLoginDao getCentrelogindao() {
return centrelogindao;
}
public void setCentrelogindao(CentreLoginDao centrelogindao) {
this.centrelogindao = centrelogindao;
}
public XMailAccountDao getXmailaccountdao() {
return xmailaccountdao;
}
public void setXmailaccountdao(XMailAccountDao xmailaccountdao) {
this.xmailaccountdao = xmailaccountdao;
}
}