zzy.zhiyuan.foxmail лет назад: 8
Родитель
Сommit
b9aaa5ad93

+ 19 - 0
src/main/java/com/ekexiu/portal/dao/DemandDao.java

@ -34,6 +34,25 @@ public abstract class DemandDao {
34 34
	@Nullable
35 35
	public abstract Demand queryOne(Connection con,String demandId)throws SQLException;
36 36
	
37
	public int queryCountByStatus(Connection con,String demander,String demandStatus)throws SQLException{
38
		String sql = " SELECT COUNT(1) FROM DEMAND WHERE DEMANDER = ? AND DEMAND_STATUS = ? ";
39
		PreparedStatement ps = con.prepareStatement(sql);
40
		int index = 1;
41
		try {
42
			ps.setString(index++, demander);
43
			ps.setString(index++, demandStatus);
44
			ResultSet rs = ps.executeQuery();
45
			try {
46
				rs.next();
47
				return rs.getInt(1);
48
			} finally {
49
				try{rs.close();}catch(Exception e1){}
50
			}
51
		} finally {
52
            try{ps.close();}catch(Exception e2){}
53
        }
54
	}
55
	
37 56
	@SelectList
38 57
	@OrderBy("ORDER BY CREATE_TIME DESC")
39 58
	public abstract List<Demand> queryByDemander(Connection con,String demander)throws SQLException;

+ 13 - 0
src/main/java/com/ekexiu/portal/service/DemandService.java

@ -101,6 +101,19 @@ public class DemandService {
101 101
		return demand;
102 102
	}
103 103
	
104
	/**
105
	 * 查询发布中的需求总数
106
	 * @param con
107
	 * @param demander 发布者ID
108
	 * @return 返回状态发布中的需求总数
109
	 * @throws SQLException
110
	 */
111
	@Get
112
	@Path("/queryPublish")
113
	public int queryPublish(@JdbcConn Connection con,String demander)throws SQLException{
114
		return this.demandDao.queryCountByStatus(con, demander, "1");
115
	}
116
	
104 117
	@Get
105 118
	@Path("/byDemander")
106 119
	public List<Demand> queryByDemander(@JdbcConn Connection con,String demander)throws SQLException{