jiapeng 6 years ago
parent
commit
451334d664

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

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

29 31
@DAO
30 32
public interface PlatformDao {
@ -151,6 +153,12 @@ public interface PlatformDao {
151 153
	List<ButtedOrgInfo> queryButtedOrgInfo(Connection con, String time, String oid,
152 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 162
	@LimitQuery
155 163
	@OrderBy(cols = { @LimitColumn(value = "time", column = "B.CREATE_TIME", handlerClass = StringHandler.class, asc = false),
156 164
			@LimitColumn(value = "uid", column = "P.ID", asc = false, handlerClass = StringHandler.class) }, value = "")
@ -158,4 +166,10 @@ public interface PlatformDao {
158 166
	List<ButtedProfessorInfo> queryButtedProfessorInfo(Connection con, String time, String uid,
159 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,7 +22,7 @@ public class PlatformOrg implements CreateTimeSupported {
22 22
	 * 平台ID
23 23
	 */
24 24
	private String pid;
25
	
25
	private String logo;
26 26
	private String name;
27 27
	private String email;
28 28
	private String addr;
@ -100,6 +100,13 @@ public class PlatformOrg implements CreateTimeSupported {
100 100
	public void setCreateTime(String createTime) {
101 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,6 +20,7 @@ import org.jfw.apt.annotation.Autowrie;
20 20
import org.jfw.apt.annotation.DefaultValue;
21 21
import org.jfw.apt.annotation.Nullable;
22 22
import org.jfw.apt.web.annotation.Path;
23
import org.jfw.apt.web.annotation.method.SetCookie;
23 24
import org.jfw.apt.web.annotation.operate.Get;
24 25
import org.jfw.apt.web.annotation.operate.Post;
25 26
import org.jfw.apt.web.annotation.param.FieldParam;
@ -27,6 +28,7 @@ import org.jfw.apt.web.annotation.param.JdbcConn;
27 28
import org.jfw.apt.web.annotation.param.RequestParam;
28 29
import org.jfw.apt.web.annotation.param.Upload;
29 30
import org.jfw.util.JpgUtil;
31
import org.jfw.util.PageQueryResult;
30 32
import org.jfw.util.StringUtil;
31 33
import org.jfw.util.context.JfwAppContext;
32 34
import org.jfw.util.exception.JfwBaseException;
@ -65,11 +67,9 @@ public class PlatformService {
65 67
	private File imgPath;
66 68

67 69
	private int imgMaxWidth = 70;
68
	
70

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

74 74
	public ImageService getImageService() {
75 75
		return imageService;
@ -111,16 +111,18 @@ public class PlatformService {
111 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 116
	@Post
115 117
	@Path("/login")
116 118
	public LoginUserInfo login(@JdbcConn Connection con, String email, String pw) throws JfwBaseException, SQLException {
117 119
		LoginUserInfo ret = null;
118 120
		PlatformUser pu = this.platformDao.queryUser(con, email);
119 121
		if (pu != null) {
120
			if(!"1".equals(pu.getState())){
122
			if (!"1".equals(pu.getState())) {
121 123
				throw new JfwBaseException(-600004, "user disabled");
122 124
			}
123
			if (pw.equals(pu.getPasswd())) {
125
			if (StringUtil.md5(pw).equals(pu.getPasswd())) {
124 126
				PlatformInfo pi = this.platformDao.queryInfo(con, pu.getId());
125 127
				if (pi != null) {
126 128
					ret = new LoginUserInfo();
@ -142,7 +144,7 @@ public class PlatformService {
142 144

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

190 190
	@Path("/reqBindMail")
191 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 193
		PlatformUser pu = this.platformDao.queryUser(con, mail);
194 194
		if (pu != null)
195 195
			throw new JfwBaseException(-600001, "already bind");
@ -206,9 +206,8 @@ public class PlatformService {
206 206
		final String cachekey = JfwAppContext.cacheObjectAndGenKey(sc);
207 207
		Map<String, String> mailParam = new HashMap<String, String>();
208 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 211
		try {
213 212
			mailService.sendSimpleMail(mail, this.templateWithBindEmail, mailParam, this.subjectWithBindEmail);
214 213
			JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
@ -269,92 +268,113 @@ public class PlatformService {
269 268
			@FieldParam(value = "oid", valueClass = String.class) }) ResidentOrg po) throws SQLException {
270 269
		return this.platformDao.insert(con, po);
271 270
	}
271

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

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

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

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

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

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

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

326 321
	@Get
327 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 328
			roi.setHasOrgLogo(this.imageService.hasOrgLogo(roi.getId()));
333 329
		}
334 330
		return ret;
335 331
	}
336
	
332

337 333
	@Get
338 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 338
		List<ButtedOrgInfo> ret = this.platformDao.queryButtedOrgInfo(con, time, oid, pid, rows);
342
		for(ButtedOrgInfo roi:ret){
339
		for (ButtedOrgInfo roi : ret) {
343 340
			roi.setHasOrgLogo(this.imageService.hasOrgLogo(roi.getId()));
344 341
		}
345 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 356
	@Get
348 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 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 374
			roi.setHasHeadImage(this.imageService.hasProfessorImage(roi.getId()));
354 375
		}
355 376
		return ret;
356 377
	}
357
	
358 378

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

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

@ -2355,6 +2355,7 @@ COMMENT ON COLUMN BUTTED_PROFESSOR.CREATE_TIME is '对接时间';
2355 2355
CREATE TABLE PLATFORM_ORG (
2356 2356
	ID TEXT NOT NULL,
2357 2357
	PID TEXT NOT NULL,
2358
	LOGO TEXT,
2358 2359
	NAME TEXT NOT NULL,
2359 2360
	EMAIL TEXT NOT NULL,
2360 2361
	ADDR TEXT,