jiapeng vor 7 Jahren
Ursprung
Commit
488cb37ea8

+ 38 - 0
src/main/java/com/ekexiu/portal/platform/ButtedOrg.java

@ -0,0 +1,38 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey({"pid","oid"})
11
@Table
12
public class ButtedOrg implements CreateTimeSupported {
13
	private String pid;
14
	private String oid;
15
	private String createTime;
16
	
17
	@Column(DE.text_de)
18
	public String getPid() {
19
		return pid;
20
	}
21
	public void setPid(String pid) {
22
		this.pid = pid;
23
	}
24
	@Column(DE.text_de)
25
	public String getOid() {
26
		return oid;
27
	}
28
	public void setOid(String oid) {
29
		this.oid = oid;
30
	}
31
	public String getCreateTime() {
32
		return createTime;
33
	}
34
	public void setCreateTime(String createTime) {
35
		this.createTime = createTime;
36
	}
37
	
38
}

+ 38 - 0
src/main/java/com/ekexiu/portal/platform/ButtedProfessor.java

@ -0,0 +1,38 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey({"pid","uid"})
11
@Table
12
public class ButtedProfessor implements CreateTimeSupported {
13
	private String pid;
14
	private String uid;
15
	private String createTime;
16
	
17
	@Column(DE.text_de)
18
	public String getPid() {
19
		return pid;
20
	}
21
	public void setPid(String pid) {
22
		this.pid = pid;
23
	}
24
	@Column(DE.text_de)
25
	public String getUid() {
26
		return uid;
27
	}
28
	public void setUid(String uid) {
29
		this.uid = uid;
30
	}
31
	public String getCreateTime() {
32
		return createTime;
33
	}
34
	public void setCreateTime(String createTime) {
35
		this.createTime = createTime;
36
	}
37
	
38
}

+ 33 - 0
src/main/java/com/ekexiu/portal/platform/LoginUserInfo.java

@ -0,0 +1,33 @@
1
package com.ekexiu.portal.platform;
2

3
public class LoginUserInfo {
4
	private String id;
5
	private String name;
6
	private String email;
7
	private String logo;
8
	public String getId() {
9
		return id;
10
	}
11
	public void setId(String id) {
12
		this.id = id;
13
	}
14
	public String getName() {
15
		return name;
16
	}
17
	public void setName(String name) {
18
		this.name = name;
19
	}
20
	public String getEmail() {
21
		return email;
22
	}
23
	public void setEmail(String email) {
24
		this.email = email;
25
	}
26
	public String getLogo() {
27
		return logo;
28
	}
29
	public void setLogo(String logo) {
30
		this.logo = logo;
31
	}
32
	
33
}

+ 61 - 0
src/main/java/com/ekexiu/portal/platform/PlatformDao.java

@ -0,0 +1,61 @@
1
package com.ekexiu.portal.platform;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.annotation.Nullable;
8
import org.jfw.apt.orm.annotation.dao.DAO;
9
import org.jfw.apt.orm.annotation.dao.method.From;
10
import org.jfw.apt.orm.annotation.dao.method.Where;
11
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
12
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
13
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
14
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
15
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
16
import org.jfw.apt.orm.annotation.dao.param.Alias;
17
import org.jfw.apt.orm.annotation.dao.param.In;
18
import org.jfw.apt.orm.annotation.dao.param.Set;
19

20
@DAO
21
public interface PlatformDao {
22

23
	
24
	@SelectOne
25
	@Nullable
26
	@Where("STATE='1'")
27
	PlatformUser login(Connection con,String email,String passwd)throws SQLException;
28
	@Nullable
29
	@SelectOne
30
	PlatformInfo  queryInfo(Connection con,String id)throws SQLException;
31
	
32
	@SelectOne
33
	@Nullable 
34
	PlatformUser queryUser(Connection con,String email)throws SQLException;
35
	
36
	@SelectOne
37
	@Nullable 
38
	PlatformUser queryUserById(Connection con,String id)throws SQLException;
39
	
40
	@SelectList
41
	List<PlatformInfo> queryInfos(Connection con,@In String[] id)throws SQLException;
42
	
43
	@UpdateWith
44
	@From(PlatformUser.class)
45
	int updatePasswd(Connection con,String id ,@Alias("passwd") String oldpw ,@Set String passwd)throws SQLException;
46
	
47
	@UpdateWith
48
	@From(PlatformUser.class)
49
	int updatePasswd(Connection con,String id,String email ,@Alias("passwd") String oldpw ,@Set String passwd)throws SQLException;
50
	
51
	@UpdateWith
52
	@From(PlatformUser.class)
53
	int updateMail(Connection con,String id,@Alias("email") String oldemail ,String passwd ,@Set String email)throws SQLException;
54
	
55
	
56
	@Update
57
	int update(Connection con,PlatformInfo pi)throws SQLException;
58
	
59
	@Insert
60
	int insert(Connection con,PlatformOrg org) throws SQLException;
61
}

+ 125 - 0
src/main/java/com/ekexiu/portal/platform/PlatformInfo.java

@ -0,0 +1,125 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7
import org.jfw.apt.orm.core.enums.DE;
8
@PrimaryKey("id")
9
@Table
10
public class PlatformInfo {
11
	private String id;
12
	private String name;
13
	private String logo;
14
	private String linkman;
15
	private String linkphone;
16
	private String linkeamil;
17
	private String province;
18
	private String city;
19
	private String addr;
20
	private String url;
21
	private String industry;
22
	private String descp;
23
	private String createTime;
24
	private String modifyTime;
25
	
26
	@Column(DE.id_10)
27
	public String getId() {
28
		return id;
29
	}
30
	public void setId(String id) {
31
		this.id = id;
32
	}
33
	@Column(DE.text_de)
34
	public String getName() {
35
		return name;
36
	}
37
	public void setName(String name) {
38
		this.name = name;
39
	}
40
	@Column(DE.Text_de)
41
	public String getLogo() {
42
		return logo;
43
	}
44
	public void setLogo(String logo) {
45
		this.logo = logo;
46
	}
47
	@Column(DE.text_de)
48
	public String getLinkman() {
49
		return linkman;
50
	}
51
	public void setLinkman(String linkman) {
52
		this.linkman = linkman;
53
	}
54
	@Column(DE.text_de)
55
	public String getLinkphone() {
56
		return linkphone;
57
	}
58
	public void setLinkphone(String linkphone) {
59
		this.linkphone = linkphone;
60
	}
61
	@Column(DE.text_de)
62
	public String getLinkeamil() {
63
		return linkeamil;
64
	}
65
	public void setLinkeamil(String linkeamil) {
66
		this.linkeamil = linkeamil;
67
	}
68
	@Column(DE.Text_de)
69
	public String getProvince() {
70
		return province;
71
	}
72
	public void setProvince(String province) {
73
		this.province = province;
74
	}
75
	@Column(DE.Text_de)
76
	public String getCity() {
77
		return city;
78
	}
79
	public void setCity(String city) {
80
		this.city = city;
81
	}
82
	@Column(DE.Text_de)
83
	public String getAddr() {
84
		return addr;
85
	}
86
	public void setAddr(String addr) {
87
		this.addr = addr;
88
	}
89
	@Column(DE.Text_de)
90
	public String getUrl() {
91
		return url;
92
	}
93
	public void setUrl(String url) {
94
		this.url = url;
95
	}
96
	@Column(DE.Text_de)
97
	public String getIndustry() {
98
		return industry;
99
	}
100
	public void setIndustry(String industry) {
101
		this.industry = industry;
102
	}
103
	@Column(DE.text_de)
104
	public String getDescp() {
105
		return descp;
106
	}
107
	public void setDescp(String descp) {
108
		this.descp = descp;
109
	}
110
	
111
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = false)
112
	public String getCreateTime() {
113
		return createTime;
114
	}
115
	public void setCreateTime(String createTime) {
116
		this.createTime = createTime;
117
	}
118
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = true)
119
	public String getModifyTime() {
120
		return modifyTime;
121
	}
122
	public void setModifyTime(String modifyTime) {
123
		this.modifyTime = modifyTime;
124
	}
125
}

+ 94 - 0
src/main/java/com/ekexiu/portal/platform/PlatformOrg.java

@ -0,0 +1,94 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey("id")
11
@Table
12
public class PlatformOrg implements CreateTimeSupported {
13
	private String id;
14
	private String pid;
15
	private String name;
16
	private String email;
17
	private String addr;
18
	private String linkman;
19
	private String linkphone;
20
	private String industry;
21
	private String descp;
22
	private String createTime;
23
	@Column(DE.text_de)
24
	public String getId() {
25
		return id;
26
	}
27
	public void setId(String id) {
28
		this.id = id;
29
	}
30
	public String getPid() {
31
		return pid;
32
	}
33
	@Column(DE.text_de)
34
	public void setPid(String pid) {
35
		this.pid = pid;
36
	}
37
	@Column(DE.text_de)
38
	public String getName() {
39
		return name;
40
	}
41
	public void setName(String name) {
42
		this.name = name;
43
	}
44
	@Column(DE.text_de)
45
	public String getEmail() {
46
		return email;
47
	}
48
	public void setEmail(String email) {
49
		this.email = email;
50
	}
51
	@Column(DE.Text_de)
52
	public String getAddr() {
53
		return addr;
54
	}
55
	public void setAddr(String addr) {
56
		this.addr = addr;
57
	}
58
	@Column(DE.Text_de)
59
	public String getLinkman() {
60
		return linkman;
61
	}
62
	public void setLinkman(String linkman) {
63
		this.linkman = linkman;
64
	}
65
	@Column(DE.Text_de)
66
	public String getLinkphone() {
67
		return linkphone;
68
	}
69
	public void setLinkphone(String linkphone) {
70
		this.linkphone = linkphone;
71
	}
72
	@Column(DE.Text_de)
73
	public String getIndustry() {
74
		return industry;
75
	}
76
	public void setIndustry(String industry) {
77
		this.industry = industry;
78
	}
79
	@Column(DE.Text_de)
80
	public String getDescp() {
81
		return descp;
82
	}
83
	public void setDescp(String descp) {
84
		this.descp = descp;
85
	}
86
	public String getCreateTime() {
87
		return createTime;
88
	}
89
	public void setCreateTime(String createTime) {
90
		this.createTime = createTime;
91
	}
92
	
93
	
94
}

+ 412 - 0
src/main/java/com/ekexiu/portal/platform/PlatformService.java

@ -0,0 +1,412 @@
1
package com.ekexiu.portal.platform;
2

3
import java.io.ByteArrayInputStream;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileOutputStream;
7
import java.io.IOException;
8
import java.io.InputStream;
9
import java.io.OutputStream;
10
import java.sql.Connection;
11
import java.sql.SQLException;
12
import java.util.HashMap;
13
import java.util.LinkedList;
14
import java.util.List;
15
import java.util.Map;
16
import java.util.concurrent.TimeUnit;
17
import java.util.concurrent.atomic.AtomicInteger;
18

19
import org.jfw.apt.annotation.Autowrie;
20
import org.jfw.apt.annotation.Nullable;
21
import org.jfw.apt.web.annotation.Path;
22
import org.jfw.apt.web.annotation.operate.Get;
23
import org.jfw.apt.web.annotation.operate.Post;
24
import org.jfw.apt.web.annotation.param.JdbcConn;
25
import org.jfw.apt.web.annotation.param.RequestParam;
26
import org.jfw.apt.web.annotation.param.Upload;
27
import org.jfw.util.JpgUtil;
28
import org.jfw.util.StringUtil;
29
import org.jfw.util.context.JfwAppContext;
30
import org.jfw.util.exception.JfwBaseException;
31
import org.jfw.util.io.IoUtil;
32
import org.jfw.util.state.StateCode;
33
import org.jfw.util.web.fileupload.Item;
34
import org.jfw.util.web.fileupload.UploadItemIterator;
35

36
import com.ekexiu.portal.mail.MailService;
37

38
@Path("/platform")
39
public class PlatformService {
40
	private static final AtomicInteger FN_IDX = new AtomicInteger(1);
41

42
	private long restPasswordWithEmailTimeout = 60 * 10;
43

44
	private String urlWithRestPasswordWithEmail = "MAIL_REST_URL";
45
	private String stateCodeWithRestPasswordWithEmail = "MAIL_REST_SC";
46
	private String templateWithRestPasswordWithEmail = "";
47
	private String subjectWithRestPasswordWithEmail = "「科袖」平台账户密码找回";
48
	
49
	
50
	private long bindEmailTimeout = 60 * 10;
51

52
	private String urlWithBindEmail = "MAIL_REST_URL";
53
	private String stateCodeWithBindEmail = "MAIL_REST_SC";
54
	private String templateWithBindEmail = "";
55
	private String subjectWithBindEmail = "「科袖」平台账户邮箱绑定";
56

57
	@Autowrie
58
	private PlatformDao platformDao;
59

60
	@Autowrie
61
	private MailService mailService;
62

63
	private File imgPath;
64

65
	private int imgMaxWidth = 70;
66

67
	public int getImgMaxWidth() {
68
		return imgMaxWidth;
69
	}
70

71
	public void setImgMaxWidth(int imgMaxWidth) {
72
		this.imgMaxWidth = imgMaxWidth;
73
	}
74

75
	public File getImgPath() {
76
		return imgPath;
77
	}
78

79
	public void setImgPath(File imgPath) {
80
		this.imgPath = imgPath;
81
	}
82

83
	public PlatformDao getPlatformDao() {
84
		return platformDao;
85
	}
86

87
	public void setPlatformDao(PlatformDao platformDao) {
88
		this.platformDao = platformDao;
89
	}
90

91
	public MailService getMailService() {
92
		return mailService;
93
	}
94

95
	public void setMailService(MailService mailService) {
96
		this.mailService = mailService;
97
	}
98

99
	@Post
100
	@Path("/login")
101
	public LoginUserInfo login(@JdbcConn Connection con, String email, String pw) throws JfwBaseException, SQLException {
102
		LoginUserInfo ret = null;
103
		PlatformUser pu = this.platformDao.queryUser(con, email);
104
		if (pu != null) {
105
			if (pw.equals(pu.getPasswd())) {
106
				PlatformInfo pi = this.platformDao.queryInfo(con, pu.getId());
107
				if (pi != null) {
108
					ret = new LoginUserInfo();
109
					ret.setEmail(email);
110
					ret.setId(pu.getId());
111
					ret.setLogo(pi.getLogo());
112
					ret.setName(pi.getName());
113
				} else {
114
					throw new JfwBaseException(-600003, "user info not exists");
115
				}
116
			} else {
117
				throw new JfwBaseException(-600002, "invalid login param");
118
			}
119
		} else {
120
			throw new JfwBaseException(-600001, "not found user");
121
		}
122
		return ret;
123
	}
124

125
	@Path("reqResetPw")
126
	@Post
127
	public void requestResetPasswordWithEmail(@JdbcConn Connection con, String mail, @Nullable String url) throws SQLException, JfwBaseException {
128
		PlatformUser pu = this.platformDao.queryUser(con, mail);
129
		if (pu == null)
130
			throw new JfwBaseException(-600001, "not found user");
131
		StateCode<String, String> sc = new StateCode<String, String>();
132
		sc.setCode(pu.getId());
133
		sc.setKey(pu.getEmail());
134
		sc.setValue(pu.getPasswd());
135

136
		final String cachekey = JfwAppContext.cacheObjectAndGenKey(sc);
137
		Map<String, String> mailParam = new HashMap<String, String>();
138
		mailParam.put(this.stateCodeWithRestPasswordWithEmail, cachekey);
139
		if (url != null) {
140
			mailParam.put(this.urlWithRestPasswordWithEmail, url);
141
		}
142
		try {
143
			mailService.sendSimpleMail(mail, this.templateWithRestPasswordWithEmail, mailParam, this.subjectWithRestPasswordWithEmail);
144
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
145

146
				@Override
147
				public void run() {
148
					JfwAppContext.removeCachedObject(cachekey);
149
				}
150
			}, this.restPasswordWithEmailTimeout, TimeUnit.SECONDS);
151
		} catch (Exception e) {
152
			JfwAppContext.removeCachedObject(cachekey);
153
			throw new JfwBaseException(-600002, "mail service error");
154
		}
155
	}
156
	
157
	
158
	
159

160
	@Post
161
	@Path("/restpw")
162
	public void restpw(@JdbcConn(true) Connection con, String code, String pw) throws SQLException, JfwBaseException {
163
		@SuppressWarnings("unchecked")
164
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(code);
165
		if (sc == null) {
166
			throw new JfwBaseException(-600001, " code expire");
167
		}
168
		JfwAppContext.removeCachedObject(code);
169
		pw = StringUtil.md5(pw);
170
		if (this.platformDao.updatePasswd(con, sc.getCode(), sc.getKey(), sc.getValue(), pw) == 0) {
171
			throw new JfwBaseException(-600002, "user too fresh");
172
		}
173
	}
174
	
175
	@Path("reqBindMail")
176
	@Post
177
	public void requestBindMail(@JdbcConn Connection con, String mail, String id,@Nullable String url) throws SQLException, JfwBaseException {
178
		PlatformUser pu = this.platformDao.queryUser(con, mail);
179
		if (pu != null)
180
			throw new JfwBaseException(-600001, "already bind");
181
		pu = this.platformDao.queryUserById(con, id);
182
		if (pu == null)
183
			throw new JfwBaseException(-600002, "not exists user["+id+"]");
184
		
185
		StateCode<String, String> sc = new StateCode<String, String>();
186
		sc.setCode(pu.getId());
187
		sc.setKey(pu.getEmail());
188
		sc.setValue(pu.getPasswd());
189
		sc.setDescp(mail);
190

191
		final String cachekey = JfwAppContext.cacheObjectAndGenKey(sc);
192
		Map<String, String> mailParam = new HashMap<String, String>();
193
		mailParam.put(this.stateCodeWithBindEmail, cachekey);
194
		if (url != null) {
195
			mailParam.put(this.urlWithBindEmail, url);
196
		}
197
		try {
198
			mailService.sendSimpleMail(mail, this.templateWithBindEmail, mailParam, this.subjectWithBindEmail);
199
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
200
				@Override
201
				public void run() {
202
					JfwAppContext.removeCachedObject(cachekey);
203
				}
204
			}, this.bindEmailTimeout, TimeUnit.SECONDS);
205
		} catch (Exception e) {
206
			JfwAppContext.removeCachedObject(cachekey);
207
			throw new JfwBaseException(-600003, "mail service error");
208
		}
209
	}
210
	
211
	
212
	
213

214
	@Post
215
	@Path("/bindMail")
216
	public void bindMail(@JdbcConn(true) Connection con, String code) throws SQLException, JfwBaseException {
217
		@SuppressWarnings("unchecked")
218
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(code);
219
		if (sc == null) {
220
			throw new JfwBaseException(-600001, " code expire");
221
		}
222
		JfwAppContext.removeCachedObject(code);
223

224
		if (this.platformDao.updateMail(con, sc.getCode(), sc.getKey(), sc.getValue(), sc.getDescp()) == 0) {
225
			throw new JfwBaseException(-600002, "user too fresh");
226
		}
227
	}
228

229
	
230
	@Post
231
	@Path("/modifypw")
232
	public int modifypw(@JdbcConn(true) Connection con,String id,String opw,String npw) throws SQLException{
233
		return this.platformDao.updatePasswd(con, id,StringUtil.md5(opw),StringUtil.md5(npw));
234
	}
235
	
236
	@Post
237
	@Path("/info")
238
	public int updateInfo(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "createTime", "modifyTime" }) PlatformInfo pi) throws SQLException {
239
		return this.platformDao.update(con, pi);
240
	}
241
	
242
	@Get
243
	@Path("/info")
244
	public PlatformInfo info(@JdbcConn Connection con,String id) throws SQLException{
245
		return this.platformDao.queryInfo(con, id);
246
	}
247
	@Post
248
	@Path("/add/org")
249
	public int addOrg(@JdbcConn(true) Connection con, @RequestParam(excludeFields = { "createTime", "id" }) PlatformOrg po)throws SQLException{
250
		po.setId(StringUtil.buildUUID());
251
		return this.platformDao.insert(con, po);
252
	}
253

254
	@Post
255
	@Path("/upload")
256
	public List<UploadFile> upload(@Upload UploadItemIterator it) throws Exception {
257
		List<UploadFile> ret = new LinkedList<UploadFile>();
258
		try {
259
			while (it.hasNext()) {
260
				Item item = it.next();
261
				if (!item.isFormField()) {
262
					String name = normalizeFileName(item.getName());
263
					int index = name.lastIndexOf('.');
264
					String ext = index >= 0 ? name.substring(index + 1) : "";
265
					ext = ext.trim();
266
					long fileLen = 0;
267
					int len = 0;
268
					UploadFile uf = this.buildTargetFile(ext);
269
					uf.setName(name);
270
					File file = uf.getFn();
271
					ret.add(uf);
272
					byte[] buf = new byte[8092];
273
					OutputStream of = new FileOutputStream(file);
274
					try {
275
						InputStream in = item.getInputStream();
276
						try {
277
							while ((len = in.read(buf)) >= 0) {
278
								if (len > 0) {
279
									of.write(buf, 0, len);
280
									fileLen += len;
281
								}
282
							}
283
							uf.setSize(fileLen);
284
						} finally {
285
							in.close();
286
						}
287
					} finally {
288
						of.close();
289
					}
290
					this.saveSmallImg(uf.getUri().substring(1));
291
				}
292
			}
293
			return ret;
294
		} catch (Exception e) {
295
			this.remove(ret);
296
			throw e;
297
		} finally {
298
			if (it != null)
299
				it.clean();
300
		}
301
	}
302

303
	private void remove(List<UploadFile> list) {
304
		for (UploadFile file : list) {
305
			if (file.fn != null)
306
				file.fn.delete();
307
		}
308
	}
309

310
	private void saveSmallImg(String img) throws IOException {
311
		int idx = img.indexOf('.');
312
		if (idx > 0) {
313
			String dname = img.substring(0, idx) + "_s.jpg";
314
			File dest = new File(this.imgPath, dname);
315
			if (dest.exists())
316
				return;
317
			File src = new File(this.imgPath, img);
318
			byte[] obs = IoUtil.readStream(new FileInputStream(src), true);
319
			obs = JpgUtil.read(obs);
320
			FileOutputStream out = new FileOutputStream(dest);
321
			try {
322
				JpgUtil.scalingZoom(new ByteArrayInputStream(obs), out, this.imgMaxWidth);
323
				out.flush();
324
			} finally {
325
				IoUtil.close(out);
326
			}
327
		}
328

329
	}
330

331
	private UploadFile buildTargetFile(String ext) {
332
		StringBuilder sb = new StringBuilder();
333
		sb.append(System.currentTimeMillis() / (1000 * 60 * 60 * 24));
334
		File path = new File(this.imgPath, sb.toString());
335
		if (!path.exists()) {
336
			synchronized (this) {
337
				if (!path.mkdirs())
338
					throw new RuntimeException("mkdir error[" + path + "]");
339
				FN_IDX.set(1);
340
			}
341
		}
342
		File file;
343
		do {
344
			String fn = FN_IDX.toString();
345
			if (ext.isEmpty()) {
346
				file = new File(path, fn);
347
			} else {
348
				file = new File(path, fn + "." + ext);
349
			}
350
			FN_IDX.incrementAndGet();
351
		} while (file.exists());
352
		sb.append("/").append(file.getName());
353
		UploadFile uf = new UploadFile();
354
		uf.setFn(file);
355
		uf.setUri("/" + sb.toString());
356
		return uf;
357
	}
358

359
	private String normalizeFileName(String fn) {
360
		int index = fn.indexOf('\\');
361
		if (index >= 0) {
362
			fn = fn.substring(fn.lastIndexOf('\\') + 1);
363
		}
364
		index = fn.indexOf('/');
365
		if (index >= 0) {
366
			fn = fn.substring(fn.lastIndexOf('/') + 1);
367
		}
368
		if (fn.length() == 0)
369
			throw new RuntimeException("invalid filename in Multipart/data request");
370
		return fn;
371
	}
372

373
	public static class UploadFile {
374
		private String name;
375
		private String uri;
376
		private long size;
377
		private transient File fn;
378

379
		public File getFn() {
380
			return fn;
381
		}
382

383
		public void setFn(File fn) {
384
			this.fn = fn;
385
		}
386

387
		public String getName() {
388
			return name;
389
		}
390

391
		public void setName(String name) {
392
			this.name = name;
393
		}
394

395
		public String getUri() {
396
			return uri;
397
		}
398

399
		public void setUri(String uri) {
400
			this.uri = uri;
401
		}
402

403
		public long getSize() {
404
			return size;
405
		}
406

407
		public void setSize(long size) {
408
			this.size = size;
409
		}
410
	}
411

412
}

+ 77 - 0
src/main/java/com/ekexiu/portal/platform/PlatformUser.java

@ -0,0 +1,77 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.annotation.entry.Unique;
7
import org.jfw.apt.orm.annotation.entry.Uniques;
8
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
9
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
10
import org.jfw.apt.orm.core.enums.DE;
11

12

13
@Uniques({@Unique(clolumns = { "email" }, name = "PLATFORM_USER__UN__EMAIL")})
14
@PrimaryKey("id")
15
@Table
16
public class PlatformUser {
17
	private String id;
18
	private String email;
19
	private String phone;
20
	private String passwd;
21
	private String state;
22
	private String createTime;
23
	private String modifyTime;
24
	
25
	@Column(DE.id_32)
26
	public String getId() {
27
		return id;
28
	}
29
	public void setId(String id) {
30
		this.id = id;
31
	}
32
	@Column(DE.text_de)
33
	public String getEmail() {
34
		return email;
35
	}
36
	public void setEmail(String email) {
37
		this.email = email;
38
	}
39
	@Column(DE.Text_de)
40
	public String getPhone() {
41
		return phone;
42
	}
43
	public void setPhone(String phone) {
44
		this.phone = phone;
45
	}
46
	@Column(handlerClass = StringHandler.class, dbType = "TEXT", insertable = true, nullable = false, renewable = false)
47
	public String getPasswd() {
48
		return passwd;
49
	}
50
	public void setPasswd(String passwd) {
51
		this.passwd = passwd;
52
	}
53
	@Column(DE.singleChar)
54
	public String getState() {
55
		return state;
56
	}
57
	public void setState(String state) {
58
		this.state = state;
59
	}
60
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = false)
61
	public String getCreateTime() {
62
		return createTime;
63
	}
64
	public void setCreateTime(String createTime) {
65
		this.createTime = createTime;
66
	}
67
	@Column(handlerClass = FixLenStringHandler.class, dbType = "CHAR(14)", fixSqlValueWithInsert = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", fixSqlValueWithUpdate = "TO_CHAR(NOW(),'YYYYMMDDHH24MISS')", insertable = true, nullable = false, queryable = true, renewable = true)
68
	public String getModifyTime() {
69
		return modifyTime;
70
	}
71
	public void setModifyTime(String modifyTime) {
72
		this.modifyTime = modifyTime;
73
	}
74
	
75
	
76
	
77
}

+ 36 - 0
src/main/java/com/ekexiu/portal/platform/ReferencedArticle.java

@ -0,0 +1,36 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
@PrimaryKey({"pid","aid"})
9
@Table
10
public class ReferencedArticle {
11
	private String pid;
12
	private String aid;
13
	private String createTime;
14
	
15
	@Column(DE.text_de)
16
	public String getPid() {
17
		return pid;
18
	}
19
	public void setPid(String pid) {
20
		this.pid = pid;
21
	}
22
	@Column(DE.text_de)
23
	public String getAid() {
24
		return aid;
25
	}
26
	public void setAid(String aid) {
27
		this.aid = oid;
28
	}
29
	public String getCreateTime() {
30
		return createTime;
31
	}
32
	public void setCreateTime(String createTime) {
33
		this.createTime = createTime;
34
	}
35
	
36
}

+ 38 - 0
src/main/java/com/ekexiu/portal/platform/ResidentOrg.java

@ -0,0 +1,38 @@
1
package com.ekexiu.portal.platform;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9

10
@PrimaryKey({"pid","oid"})
11
@Table
12
public class ResidentOrg implements CreateTimeSupported {
13
	private String pid;
14
	private String oid;
15
	private String createTime;
16
	
17
	@Column(DE.text_de)
18
	public String getPid() {
19
		return pid;
20
	}
21
	public void setPid(String pid) {
22
		this.pid = pid;
23
	}
24
	@Column(DE.text_de)
25
	public String getOid() {
26
		return oid;
27
	}
28
	public void setOid(String oid) {
29
		this.oid = oid;
30
	}
31
	public String getCreateTime() {
32
		return createTime;
33
	}
34
	public void setCreateTime(String createTime) {
35
		this.createTime = createTime;
36
	}
37
	
38
}