jiapeng 7 vuotta sitten
vanhempi
commit
451334d664

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

15
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
15
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
16
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
16
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
17
import org.jfw.apt.orm.annotation.dao.method.operator.LimitQuery;
17
import org.jfw.apt.orm.annotation.dao.method.operator.LimitQuery;
18
import org.jfw.apt.orm.annotation.dao.method.operator.PageQuery;
18
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
19
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
19
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
20
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
20
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
21
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
25
import org.jfw.apt.orm.annotation.dao.param.Set;
26
import org.jfw.apt.orm.annotation.dao.param.Set;
26
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
27
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
27
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
28
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
29
import org.jfw.util.PageQueryResult;
28

30

29
@DAO
31
@DAO
30
public interface PlatformDao {
32
public interface PlatformDao {
151
	List<ButtedOrgInfo> queryButtedOrgInfo(Connection con, String time, String oid,
153
	List<ButtedOrgInfo> queryButtedOrgInfo(Connection con, String time, String oid,
152
			@SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid, int rows) throws SQLException;
154
			@SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid, int rows) throws SQLException;
153

155

156
	@PageQuery
157
	@OrderBy(value = "ORDER BY BUTTE_TIME DESC,ID ASC")
158
	@Exclude({ "descp" })
159
	PageQueryResult<ButtedOrgInfo> pageQueryButtedOrgInfo(Connection con, @SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid,
160
			int pageSize, int pageNo) throws SQLException;
161

154
	@LimitQuery
162
	@LimitQuery
155
	@OrderBy(cols = { @LimitColumn(value = "time", column = "B.CREATE_TIME", handlerClass = StringHandler.class, asc = false),
163
	@OrderBy(cols = { @LimitColumn(value = "time", column = "B.CREATE_TIME", handlerClass = StringHandler.class, asc = false),
156
			@LimitColumn(value = "uid", column = "P.ID", asc = false, handlerClass = StringHandler.class) }, value = "")
164
			@LimitColumn(value = "uid", column = "P.ID", asc = false, handlerClass = StringHandler.class) }, value = "")
158
	List<ButtedProfessorInfo> queryButtedProfessorInfo(Connection con, String time, String uid,
166
	List<ButtedProfessorInfo> queryButtedProfessorInfo(Connection con, String time, String uid,
159
			@SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid, int rows) throws SQLException;
167
			@SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid, int rows) throws SQLException;
160

168

169
	@PageQuery
170
	@OrderBy(value = "ORDER BY BUTTE_TIME DESC,ID ASC")
171
	@Exclude({ "descp" })
172
	PageQueryResult<ButtedProfessorInfo> queryButtedProfessorInfo(Connection con,
173
			@SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid, int pageSize, int pageNo) throws SQLException;
174

161
}
175
}

+ 8 - 1
src/main/java/com/ekexiu/portal/platform/PlatformOrg.java

22
	 * 平台ID
22
	 * 平台ID
23
	 */
23
	 */
24
	private String pid;
24
	private String pid;
25
	
25
	private String logo;
26
	private String name;
26
	private String name;
27
	private String email;
27
	private String email;
28
	private String addr;
28
	private String addr;
100
	public void setCreateTime(String createTime) {
100
	public void setCreateTime(String createTime) {
101
		this.createTime = createTime;
101
		this.createTime = createTime;
102
	}
102
	}
103
	@Column(DE.Text_de)
104
	public String getLogo() {
105
		return logo;
106
	}
107
	public void setLogo(String logo) {
108
		this.logo = logo;
109
	}
103
	
110
	
104
	
111
	
105
}
112
}

+ 57 - 37
src/main/java/com/ekexiu/portal/platform/PlatformService.java

20
import org.jfw.apt.annotation.DefaultValue;
20
import org.jfw.apt.annotation.DefaultValue;
21
import org.jfw.apt.annotation.Nullable;
21
import org.jfw.apt.annotation.Nullable;
22
import org.jfw.apt.web.annotation.Path;
22
import org.jfw.apt.web.annotation.Path;
23
import org.jfw.apt.web.annotation.method.SetCookie;
23
import org.jfw.apt.web.annotation.operate.Get;
24
import org.jfw.apt.web.annotation.operate.Get;
24
import org.jfw.apt.web.annotation.operate.Post;
25
import org.jfw.apt.web.annotation.operate.Post;
25
import org.jfw.apt.web.annotation.param.FieldParam;
26
import org.jfw.apt.web.annotation.param.FieldParam;
27
import org.jfw.apt.web.annotation.param.RequestParam;
28
import org.jfw.apt.web.annotation.param.RequestParam;
28
import org.jfw.apt.web.annotation.param.Upload;
29
import org.jfw.apt.web.annotation.param.Upload;
29
import org.jfw.util.JpgUtil;
30
import org.jfw.util.JpgUtil;
31
import org.jfw.util.PageQueryResult;
30
import org.jfw.util.StringUtil;
32
import org.jfw.util.StringUtil;
31
import org.jfw.util.context.JfwAppContext;
33
import org.jfw.util.context.JfwAppContext;
32
import org.jfw.util.exception.JfwBaseException;
34
import org.jfw.util.exception.JfwBaseException;
65
	private File imgPath;
67
	private File imgPath;
66

68

67
	private int imgMaxWidth = 70;
69
	private int imgMaxWidth = 70;
68
	
70

69
	@Autowrie
71
	@Autowrie
70
	private ImageService imageService;
72
	private ImageService imageService;
71
	
72
	
73

73

74
	public ImageService getImageService() {
74
	public ImageService getImageService() {
75
		return imageService;
75
		return imageService;
111
		this.mailService = mailService;
111
		this.mailService = mailService;
112
	}
112
	}
113

113

114
	@SetCookie(checkResultNull = true, path = "/", value = { "plf_user=result.getId()", "plf_email=result.getEmail()",
115
			"plf_logo=result.getLogo()==null?\"\":result.getLogo()", "plf_name=result.getName()" })
114
	@Post
116
	@Post
115
	@Path("/login")
117
	@Path("/login")
116
	public LoginUserInfo login(@JdbcConn Connection con, String email, String pw) throws JfwBaseException, SQLException {
118
	public LoginUserInfo login(@JdbcConn Connection con, String email, String pw) throws JfwBaseException, SQLException {
117
		LoginUserInfo ret = null;
119
		LoginUserInfo ret = null;
118
		PlatformUser pu = this.platformDao.queryUser(con, email);
120
		PlatformUser pu = this.platformDao.queryUser(con, email);
119
		if (pu != null) {
121
		if (pu != null) {
120
			if(!"1".equals(pu.getState())){
122
			if (!"1".equals(pu.getState())) {
121
				throw new JfwBaseException(-600004, "user disabled");
123
				throw new JfwBaseException(-600004, "user disabled");
122
			}
124
			}
123
			if (pw.equals(pu.getPasswd())) {
125
			if (StringUtil.md5(pw).equals(pu.getPasswd())) {
124
				PlatformInfo pi = this.platformDao.queryInfo(con, pu.getId());
126
				PlatformInfo pi = this.platformDao.queryInfo(con, pu.getId());
125
				if (pi != null) {
127
				if (pi != null) {
126
					ret = new LoginUserInfo();
128
					ret = new LoginUserInfo();
142

144

143
	@Path("/reqResetPw")
145
	@Path("/reqResetPw")
144
	@Post
146
	@Post
145
	public void requestResetPasswordWithEmail(@JdbcConn Connection con, String mail, @Nullable String url) throws SQLException, JfwBaseException {
147
	public void requestResetPasswordWithEmail(@JdbcConn Connection con, String mail,String url) throws SQLException, JfwBaseException {
146
		PlatformUser pu = this.platformDao.queryUser(con, mail);
148
		PlatformUser pu = this.platformDao.queryUser(con, mail);
147
		if (pu == null)
149
		if (pu == null)
148
			throw new JfwBaseException(-600001, "not found user");
150
			throw new JfwBaseException(-600001, "not found user");
154
		final String cachekey = JfwAppContext.cacheObjectAndGenKey(sc);
156
		final String cachekey = JfwAppContext.cacheObjectAndGenKey(sc);
155
		Map<String, String> mailParam = new HashMap<String, String>();
157
		Map<String, String> mailParam = new HashMap<String, String>();
156
		mailParam.put(this.stateCodeWithRestPasswordWithEmail, cachekey);
158
		mailParam.put(this.stateCodeWithRestPasswordWithEmail, cachekey);
157
		if (url != null) {
158
			mailParam.put(this.urlWithRestPasswordWithEmail, url);
159
		}
159
		mailParam.put(this.urlWithRestPasswordWithEmail, url);
160
		try {
160
		try {
161
			mailService.sendSimpleMail(mail, this.templateWithRestPasswordWithEmail, mailParam, this.subjectWithRestPasswordWithEmail);
161
			mailService.sendSimpleMail(mail, this.templateWithRestPasswordWithEmail, mailParam, this.subjectWithRestPasswordWithEmail);
162
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
162
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
189

189

190
	@Path("/reqBindMail")
190
	@Path("/reqBindMail")
191
	@Post
191
	@Post
192
	public void requestBindMail(@JdbcConn Connection con, String mail, String id, @Nullable String url) throws SQLException, JfwBaseException {
192
	public void requestBindMail(@JdbcConn Connection con, String mail, String id, String url) throws SQLException, JfwBaseException {
193
		PlatformUser pu = this.platformDao.queryUser(con, mail);
193
		PlatformUser pu = this.platformDao.queryUser(con, mail);
194
		if (pu != null)
194
		if (pu != null)
195
			throw new JfwBaseException(-600001, "already bind");
195
			throw new JfwBaseException(-600001, "already bind");
206
		final String cachekey = JfwAppContext.cacheObjectAndGenKey(sc);
206
		final String cachekey = JfwAppContext.cacheObjectAndGenKey(sc);
207
		Map<String, String> mailParam = new HashMap<String, String>();
207
		Map<String, String> mailParam = new HashMap<String, String>();
208
		mailParam.put(this.stateCodeWithBindEmail, cachekey);
208
		mailParam.put(this.stateCodeWithBindEmail, cachekey);
209
		if (url != null) {
210
			mailParam.put(this.urlWithBindEmail, url);
211
		}
209

210
		mailParam.put(this.urlWithBindEmail, url);
212
		try {
211
		try {
213
			mailService.sendSimpleMail(mail, this.templateWithBindEmail, mailParam, this.subjectWithBindEmail);
212
			mailService.sendSimpleMail(mail, this.templateWithBindEmail, mailParam, this.subjectWithBindEmail);
214
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
213
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
269
			@FieldParam(value = "oid", valueClass = String.class) }) ResidentOrg po) throws SQLException {
268
			@FieldParam(value = "oid", valueClass = String.class) }) ResidentOrg po) throws SQLException {
270
		return this.platformDao.insert(con, po);
269
		return this.platformDao.insert(con, po);
271
	}
270
	}
271

272
	@Post
272
	@Post
273
	@Path("/buttedOrg")
273
	@Path("/buttedOrg")
274
	public int buttedOrg(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
274
	public int buttedOrg(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
275
			@FieldParam(value = "oid", valueClass = String.class) }) ButtedOrg po) throws SQLException {
275
			@FieldParam(value = "oid", valueClass = String.class) }) ButtedOrg po) throws SQLException {
276
		return this.platformDao.insert(con, po);
276
		return this.platformDao.insert(con, po);
277
	}
277
	}
278

278
	@Post
279
	@Post
279
	@Path("/buttedProfessor")
280
	@Path("/buttedProfessor")
280
	public int buttedProfessor(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
281
	public int buttedProfessor(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
281
			@FieldParam(value = "uid", valueClass = String.class) }) ButtedProfessor po) throws SQLException {
282
			@FieldParam(value = "uid", valueClass = String.class) }) ButtedProfessor po) throws SQLException {
282
		return this.platformDao.insert(con, po);
283
		return this.platformDao.insert(con, po);
283
	}
284
	}
284
	
285

285
	@Post
286
	@Post
286
	@Path("/referencedArticle")
287
	@Path("/referencedArticle")
287
	public int referencedArticle(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
288
	public int referencedArticle(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
288
			@FieldParam(value = "aid", valueClass = String.class) }) ReferencedArticle po) throws SQLException {
289
			@FieldParam(value = "aid", valueClass = String.class) }) ReferencedArticle po) throws SQLException {
289
		return this.platformDao.insert(con, po);
290
		return this.platformDao.insert(con, po);
290
	}
291
	}
291
	
292
	
293
	
294
	
295
	
296
	
297
	
298
	
292

299
	@Post
293
	@Post
300
	@Path("/resident/delete")
294
	@Path("/resident/delete")
301
	public int residentDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
295
	public int residentDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
302
			@FieldParam(value = "oid", valueClass = String.class) }) ResidentOrg po) throws SQLException {
296
			@FieldParam(value = "oid", valueClass = String.class) }) ResidentOrg po) throws SQLException {
303
		return this.platformDao.delete(con, po);
297
		return this.platformDao.delete(con, po);
304
	}
298
	}
299

305
	@Post
300
	@Post
306
	@Path("/buttedOrg/delete")
301
	@Path("/buttedOrg/delete")
307
	public int buttedOrgDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
302
	public int buttedOrgDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
308
			@FieldParam(value = "oid", valueClass = String.class) }) ButtedOrg po) throws SQLException {
303
			@FieldParam(value = "oid", valueClass = String.class) }) ButtedOrg po) throws SQLException {
309
		return this.platformDao.delete(con, po);
304
		return this.platformDao.delete(con, po);
310
	}
305
	}
306

311
	@Post
307
	@Post
312
	@Path("/buttedProfessor/delete")
308
	@Path("/buttedProfessor/delete")
313
	public int buttedProfessorDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
309
	public int buttedProfessorDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
314
			@FieldParam(value = "uid", valueClass = String.class) }) ButtedProfessor po) throws SQLException {
310
			@FieldParam(value = "uid", valueClass = String.class) }) ButtedProfessor po) throws SQLException {
315
		return this.platformDao.delete(con, po);
311
		return this.platformDao.delete(con, po);
316
	}
312
	}
317
	
313

318
	@Post
314
	@Post
319
	@Path("/referencedArticle/delete")
315
	@Path("/referencedArticle/delete")
320
	public int referencedArticleDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
316
	public int referencedArticleDelete(@JdbcConn(true) Connection con, @RequestParam(fields = { @FieldParam(value = "pid", valueClass = String.class),
321
			@FieldParam(value = "aid", valueClass = String.class) }) ReferencedArticle po) throws SQLException {
317
			@FieldParam(value = "aid", valueClass = String.class) }) ReferencedArticle po) throws SQLException {
322
		return this.platformDao.delete(con, po);
318
		return this.platformDao.delete(con, po);
323
	}
319
	}
324
	
325
	
320

326
	@Get
321
	@Get
327
	@Path("/info/residentOrgs")
322
	@Path("/info/residentOrgs")
328
	public List<ResidentOrgInfo> queryResidentOrginfos(@JdbcConn Connection con,@DefaultValue("\"z\"") String time,@DefaultValue("\"z\"") String oid,String pid,@Nullable String key, int rows) throws SQLException{
329
		
330
		List<ResidentOrgInfo> ret = this.platformDao.queryResientOrgInfo(con, time, oid, pid,key==null ?null:("%"+key+"%"), rows);
331
		for(ResidentOrgInfo roi:ret){
323
	public List<ResidentOrgInfo> queryResidentOrginfos(@JdbcConn Connection con, @DefaultValue("\"z\"") String time, @DefaultValue("\"z\"") String oid,
324
			String pid, @Nullable String key, int rows) throws SQLException {
325

326
		List<ResidentOrgInfo> ret = this.platformDao.queryResientOrgInfo(con, time, oid, pid, key == null ? null : ("%" + key + "%"), rows);
327
		for (ResidentOrgInfo roi : ret) {
332
			roi.setHasOrgLogo(this.imageService.hasOrgLogo(roi.getId()));
328
			roi.setHasOrgLogo(this.imageService.hasOrgLogo(roi.getId()));
333
		}
329
		}
334
		return ret;
330
		return ret;
335
	}
331
	}
336
	
332

337
	@Get
333
	@Get
338
	@Path("/info/buttedOrgs")
334
	@Path("/info/buttedOrgs")
339
	public List<ButtedOrgInfo> queryButtedOrginfos(@JdbcConn Connection con,@DefaultValue("\"z\"") String time,@DefaultValue("\"z\"") String oid,String pid,int rows) throws SQLException{
340
		
335
	public List<ButtedOrgInfo> queryButtedOrginfos(@JdbcConn Connection con, @DefaultValue("\"z\"") String time, @DefaultValue("\"z\"") String oid, String pid,
336
			int rows) throws SQLException {
337

341
		List<ButtedOrgInfo> ret = this.platformDao.queryButtedOrgInfo(con, time, oid, pid, rows);
338
		List<ButtedOrgInfo> ret = this.platformDao.queryButtedOrgInfo(con, time, oid, pid, rows);
342
		for(ButtedOrgInfo roi:ret){
339
		for (ButtedOrgInfo roi : ret) {
343
			roi.setHasOrgLogo(this.imageService.hasOrgLogo(roi.getId()));
340
			roi.setHasOrgLogo(this.imageService.hasOrgLogo(roi.getId()));
344
		}
341
		}
345
		return ret;
342
		return ret;
346
	}
343
	}
344

345
	@Get
346
	@Path("/info/pqButtedOrgs")
347
	public PageQueryResult<ButtedOrgInfo> pqButtedOrginfos(@JdbcConn Connection con, String pid, int pageSize, int pageNo) throws SQLException {
348

349
		PageQueryResult<ButtedOrgInfo> ret = this.platformDao.pageQueryButtedOrgInfo(con, pid, pageSize, pageNo);
350
		for (ButtedOrgInfo roi : ret.getData()) {
351
			roi.setHasOrgLogo(this.imageService.hasOrgLogo(roi.getId()));
352
		}
353
		return ret;
354
	}
355

347
	@Get
356
	@Get
348
	@Path("/info/buttedProfessors")
357
	@Path("/info/buttedProfessors")
349
	public List<ButtedProfessorInfo> queryButtedProfessorinfos(@JdbcConn Connection con,@DefaultValue("\"z\"") String time,@DefaultValue("\"z\"") String uid,String pid,int rows) throws SQLException{
350
		
358
	public List<ButtedProfessorInfo> queryButtedProfessorinfos(@JdbcConn Connection con, @DefaultValue("\"z\"") String time, @DefaultValue("\"z\"") String uid,
359
			String pid, int rows) throws SQLException {
360

351
		List<ButtedProfessorInfo> ret = this.platformDao.queryButtedProfessorInfo(con, time, uid, pid, rows);
361
		List<ButtedProfessorInfo> ret = this.platformDao.queryButtedProfessorInfo(con, time, uid, pid, rows);
352
		for(ButtedProfessorInfo roi:ret){
362
		for (ButtedProfessorInfo roi : ret) {
363
			roi.setHasHeadImage(this.imageService.hasProfessorImage(roi.getId()));
364
		}
365
		return ret;
366
	}
367

368
	@Get
369
	@Path("/info/pqButtedProfessors")
370
	public PageQueryResult<ButtedProfessorInfo> pageQueryButtedProfessorinfos(@JdbcConn Connection con, String pid, int pageSize, int pageNo)
371
			throws SQLException {
372
		PageQueryResult<ButtedProfessorInfo> ret = this.platformDao.queryButtedProfessorInfo(con, pid, pageSize, pageNo);
373
		for (ButtedProfessorInfo roi : ret.getData()) {
353
			roi.setHasHeadImage(this.imageService.hasProfessorImage(roi.getId()));
374
			roi.setHasHeadImage(this.imageService.hasProfessorImage(roi.getId()));
354
		}
375
		}
355
		return ret;
376
		return ret;
356
	}
377
	}
357
	
358

378

359
	@Post
379
	@Post
360
	@Path("/upload")
380
	@Path("/upload")

+ 1 - 0
src/main/resources/database.sql

2355
CREATE TABLE PLATFORM_ORG (
2355
CREATE TABLE PLATFORM_ORG (
2356
	ID TEXT NOT NULL,
2356
	ID TEXT NOT NULL,
2357
	PID TEXT NOT NULL,
2357
	PID TEXT NOT NULL,
2358
	LOGO TEXT,
2358
	NAME TEXT NOT NULL,
2359
	NAME TEXT NOT NULL,
2359
	EMAIL TEXT NOT NULL,
2360
	EMAIL TEXT NOT NULL,
2360
	ADDR TEXT,
2361
	ADDR TEXT,