ソースを参照

--add isSignIn();update signIn();

zzy.zhiyuan.foxmail 8 年 前
コミット
6d519cb394
共有1 個のファイルを変更した41 個の追加6 個の削除を含む
  1. 41 6
      src/main/java/com/ekexiu/portal/service/GrowthLogService.java

+ 41 - 6
src/main/java/com/ekexiu/portal/service/GrowthLogService.java

@ -86,6 +86,23 @@ public class GrowthLogService {
86 86
		return this.growthLogDao.queryLastSignIn(con, professorId, "5");
87 87
	}
88 88
	
89
	@Get
90
	@Path("/isSignIn")
91
	public boolean isSignIn(@JdbcConn Connection con,String professorId)throws SQLException{
92
		GrowthLog growthLog = this.growthLogDao.queryLastSignIn(con, professorId, "5");
93
		if(growthLog != null){
94
			SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
95
			String date = sdf.format(new Date());
96
			if(date.equals(growthLog.getCreateTime().substring(0, 8))){
97
				return false;
98
			}else{
99
				return true;
100
			}
101
		}else{
102
			return true;
103
		}
104
	}
105
	
89 106
	@Get
90 107
	@Path("/queryByPro")
91 108
	public List<GrowthLog> queryByPro(@JdbcConn Connection con,String professorId,@DefaultValue("com.ekexiu.portal.service.GrowthLogService.MAX_CREATE_TIME") String createTime,@DefaultValue("20") int rows)throws SQLException{
@ -94,8 +111,8 @@ public class GrowthLogService {
94 111
	
95 112
	@Get
96 113
	@Path("/queryInvite")
97
	public List<InviteUserScore> queryInvite(@JdbcConn Connection con,String professorId,@DefaultValue("com.ekexiu.portal.service.GrowthLogService.MAX_CREATE_TIME") String createTime,@DefaultValue("20") int rows)throws SQLException{
98
		return this.growthLogDao.queryInvite(con, professorId, createTime, rows);
114
	public List<InviteUserScore> queryInvite(@JdbcConn Connection con,String professorId,@DefaultValue("20") int rows,@DefaultValue("0") int offset)throws SQLException{
115
		return this.growthLogDao.queryInvite(con, professorId, rows, offset);
99 116
	}
100 117
	
101 118
	@Get
@ -225,7 +242,7 @@ public class GrowthLogService {
225 242
	 */
226 243
	@Post
227 244
	@Path("/signIn")
228
	public void signIn(@JdbcConn(true) Connection con,String professorId)throws SQLException, JfwBaseException{
245
	public Map<String, Integer> signIn(@JdbcConn(true) Connection con,String professorId)throws SQLException, JfwBaseException{
229 246
		//获取当天日期(年月日)
230 247
		String today = this.getDate() + "%";
231 248
		//获取前一天日期(年月日)
@ -239,31 +256,49 @@ public class GrowthLogService {
239 256
		growthLog.setId(StringUtil.buildUUID());
240 257
		growthLog.setProfessorId(professorId);
241 258
		growthLog.setOperate("5");
259
		int todayScore;
260
		int lastDayScore;
242 261
		if(lastLog == null){
243 262
			growthLog.setSignInDays(1);
244 263
			growthLog.setScore(this.rule.getSignInOneDay());
264
			todayScore = this.rule.getSignInOneDay();
265
			lastDayScore = this.rule.getSignInTwoDays();
245 266
		}else{
246 267
			int days = lastLog.getSignInDays();
247 268
			growthLog.setSignInDays(days+1);
248
			if(days > 5){
249
				growthLog.setScore(this.rule.getSignInSixDays());
250
			}else if(5 == days){
269
			if(days > 4){
251 270
				growthLog.setScore(this.rule.getSignInSixDays());
271
				todayScore = this.rule.getSignInSixDays();
272
				lastDayScore = this.rule.getSignInSixDays();
252 273
			}else if(4 == days){
253 274
				growthLog.setScore(this.rule.getSignInFiveDays());
275
				todayScore = this.rule.getSignInFiveDays();
276
				lastDayScore = this.rule.getSignInSixDays();
254 277
			}else if(3 == days){
255 278
				growthLog.setScore(this.rule.getSignInFourDays());
279
				todayScore = this.rule.getSignInFourDays();
280
				lastDayScore = this.rule.getSignInFiveDays();
256 281
			}else if(2 == days){
257 282
				growthLog.setScore(this.rule.getSignInThreeDays());
283
				todayScore = this.rule.getSignInThreeDays();
284
				lastDayScore = this.rule.getSignInFourDays();
258 285
			}else if(1 == days){
259 286
				growthLog.setScore(this.rule.getSignInTwoDays());
287
				todayScore = this.rule.getSignInTwoDays();
288
				lastDayScore = this.rule.getSignInThreeDays();
260 289
			}else{
261 290
				growthLog.setScore(this.rule.getSignInOneDay());
291
				todayScore = this.rule.getSignInOneDay();
292
				lastDayScore = this.rule.getSignInTwoDays();
262 293
			}
263 294
		}
264 295
		this.growthLogDao.insert(con, growthLog);
265 296
		this.professorDao.updateScoreValue(con, professorId, growthLog.getScore());
266 297
		this.professorDao.updateGrowthValue(con, professorId, growthLog.getScore());
298
		Map<String, Integer> map = new HashMap<String, Integer>();
299
		map.put("todayScore", todayScore);
300
		map.put("lastDayScore", lastDayScore);
301
		return map;
267 302
	}
268 303
	
269 304
	/**