Przeglądaj źródła

--add queryLastSignIn();

zzy.zhiyuan.foxmail 8 lat temu
rodzic
commit
9e56634f7d

+ 46 - 0
src/main/java/com/ekexiu/portal/dao/GrowthLogDao.java

@ -33,6 +33,52 @@ public abstract class GrowthLogDao {
33 33
	@Nullable
34 34
	public abstract GrowthLog querySignIn(Connection con,String professorId,String operate,@Like String createTime)throws SQLException;
35 35
	
36
	public GrowthLog queryLastSignIn(Connection con,String professorId,String operate)throws SQLException{
37
		int index = 1;
38
		String sql = "SELECT ID,PROFESSOR_ID,OPERATE,SCORE,SIGN_IN_DAYS,INVITE_PRO,CREATE_TIME FROM GROWTH_LOG WHERE PROFESSOR_ID = ? AND OPERATE = ? ORDER BY CREATE_TIME DESC LIMIT 1";
39
		PreparedStatement ps = con.prepareStatement(sql);
40
		try{
41
			ps.setString(index++, professorId);
42
			ps.setString(index++, operate);
43
			ResultSet rs = ps.executeQuery();
44
			try{
45
				if(rs.next()){
46
                    GrowthLog growthLog = new GrowthLog();
47
                    growthLog.setId(rs.getString(1));
48
                    growthLog.setProfessorId(rs.getString(2));
49
                    String oper = rs.getString(3);
50
                    if(rs.wasNull()){
51
                    	oper = null;
52
                    }
53
                    growthLog.setOperate(oper);
54
                    Integer score = rs.getInt(4);
55
                    if(rs.wasNull()){
56
                    	score = null;
57
                    }
58
                    growthLog.setScore(score);
59
                    Integer signInDays = rs.getInt(5);
60
                    if(rs.wasNull()){
61
                    	signInDays = null;
62
                    }
63
                    growthLog.setSignInDays(signInDays);
64
                    String invitePro = rs.getString(6);
65
                    if(rs.wasNull()){
66
                    	invitePro = null;
67
                    }
68
                    growthLog.setInvitePro(invitePro);
69
                    growthLog.setCreateTime(rs.getString(7));
70
                    return growthLog;
71
                }else{
72
                    return null;
73
                }
74
			}finally{
75
				try{rs.close();}catch(Exception e1){}
76
			}
77
		}finally{
78
            try{ps.close();}catch(Exception e2){}
79
        }
80
	}
81
	
36 82
	@LimitSelect
37 83
	@OrderBy("ORDER BY CREATE_TIME DESC")
38 84
	@Where("INVITE_PRO IS NULL")

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

@ -80,6 +80,12 @@ public class GrowthLogService {
80 80
		this.rule = rule;
81 81
	}
82 82
	
83
	@Get
84
	@Path("/lastSignInTime")
85
	public GrowthLog queryLastSignIn(@JdbcConn Connection con,String professorId)throws SQLException{
86
		return this.growthLogDao.queryLastSignIn(con, professorId, "5");
87
	}
88
	
83 89
	@Get
84 90
	@Path("/queryByPro")
85 91
	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{