YxyMailIpServiceImpl.java
3.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
package com.espeed.service.impl;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.espeed.dao.YxyLinkInfoDao;
import com.espeed.dao.YxyReadingInfoDao;
import com.espeed.dao.YxyReplyInfoDao;
import com.espeed.dao.YxyUnsubscribeInfoDao;
import com.espeed.service.YxyMailIpService;
import com.espeed.tool.getArea;
/**
* ip处理service实现类
* @author 陈南巧
*/
public class YxyMailIpServiceImpl implements YxyMailIpService {
private static String ipPattern = "^(1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|[1-9])\\."
+"(00?\\d|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
+"(00?\\d|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)\\."
+"(00?\\d|1\\d{2}|2[0-4]\\d|25[0-5]|[1-9]\\d|\\d)$";
public Map<String,String> updateIpOfArea(int id,int type,String ip)throws Exception{
Map<String,String> map = new HashMap<String,String>();
if(type != 1 && type != 2 && type != 3 && type != 4){
map.put("result", "1");
map.put("area", "未知");
return map;
}
if(ip == null || ip.equals("") || ip.split("\\.").length != 4){
map.put("result", "1");
map.put("area", "未知");
return map;
}
Pattern pattern = Pattern.compile(ipPattern);
Matcher matcher = pattern.matcher(ip);
if(!matcher.matches()){
map.put("result", "1");
map.put("area", "未知");
return map;
}
String area = getArea.getArea(ip);
if(area!=null&&!area.equals("error")){
map.put("result", "1");
map.put("area", area);
area=area.replace("'", "");
if(type==1){
String hql = "update YxyReadingInfo set yxy_reading_area = '"+area+"' where yxy_reading_id = "+id;
yxyreadinginfodao.updateByHql(hql);
}else if(type==2){
String hql = "update YxyUnsubscribeInfo set area = '"+area+"' where unsubscribe_id = "+id;
yxyunsubscribeinfodao.updateByHql(hql);
}else if(type==3){
String hql = "update YxyReplyInfo set area = '"+area+"' where replyid = "+id;
yxyreplyinfodao.updateByHql(hql);
}else if(type==4){
String hql = "update YxyLinkInfo set area = '"+area+"' where id = "+id;
yxylinkinfodao.updateByHql(hql);
}
}else{
map.put("result", "0");
}
return map;
}
private YxyReadingInfoDao yxyreadinginfodao;//点读dao
private YxyUnsubscribeInfoDao yxyunsubscribeinfodao;//退订dao
private YxyReplyInfoDao yxyreplyinfodao;//回复dao
private YxyLinkInfoDao yxylinkinfodao;//链接dao
public YxyReadingInfoDao getYxyreadinginfodao() {
return yxyreadinginfodao;
}
public void setYxyreadinginfodao(YxyReadingInfoDao yxyreadinginfodao) {
this.yxyreadinginfodao = yxyreadinginfodao;
}
public YxyUnsubscribeInfoDao getYxyunsubscribeinfodao() {
return yxyunsubscribeinfodao;
}
public void setYxyunsubscribeinfodao(YxyUnsubscribeInfoDao yxyunsubscribeinfodao) {
this.yxyunsubscribeinfodao = yxyunsubscribeinfodao;
}
public YxyReplyInfoDao getYxyreplyinfodao() {
return yxyreplyinfodao;
}
public void setYxyreplyinfodao(YxyReplyInfoDao yxyreplyinfodao) {
this.yxyreplyinfodao = yxyreplyinfodao;
}
public YxyLinkInfoDao getYxylinkinfodao() {
return yxylinkinfodao;
}
public void setYxylinkinfodao(YxyLinkInfoDao yxylinkinfodao) {
this.yxylinkinfodao = yxylinkinfodao;
}
}