ソースを参照

--update queryCountByStatus();

zzy.zhiyuan.foxmail 8 年 前
コミット
3c2c915e89
共有2 個のファイルを変更した11 個の追加19 個の削除を含む
  1. 8 18
      src/main/java/com/ekexiu/portal/dao/DemandDao.java
  2. 3 1
      src/main/java/com/ekexiu/portal/service/DemandService.java

+ 8 - 18
src/main/java/com/ekexiu/portal/dao/DemandDao.java

@ -9,15 +9,19 @@ import java.util.Collections;
9 9
import java.util.List;
10 10

11 11
import org.jfw.apt.annotation.Nullable;
12
import org.jfw.apt.orm.annotation.dao.Column;
12 13
import org.jfw.apt.orm.annotation.dao.DAO;
13 14
import org.jfw.apt.orm.annotation.dao.method.From;
14 15
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
15 16
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
17
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
16 18
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
17 19
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
18 20
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
19 21
import org.jfw.apt.orm.annotation.dao.param.Set;
22
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
20 23
import org.jfw.util.PageQueryResult;
24
import org.jfw.util.exception.JfwBaseException;
21 25

22 26
import com.ekexiu.portal.po.Demand;
23 27

@ -34,24 +38,10 @@ public abstract class DemandDao {
34 38
	@Nullable
35 39
	public abstract Demand queryOne(Connection con,String demandId)throws SQLException;
36 40
	
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
	}
41
	@QueryVal
42
	@Column(handlerClass=IntHandler.class,value="COUNT(1)")
43
	@From(Demand.class)
44
	public abstract int queryCountByStatus(Connection con,String demander,String demandStatus)throws SQLException, JfwBaseException;
55 45
	
56 46
	@SelectList
57 47
	@OrderBy("ORDER BY CREATE_TIME DESC")

+ 3 - 1
src/main/java/com/ekexiu/portal/service/DemandService.java

@ -15,6 +15,7 @@ import org.jfw.apt.web.annotation.operate.Post;
15 15
import org.jfw.apt.web.annotation.param.JdbcConn;
16 16
import org.jfw.util.PageQueryResult;
17 17
import org.jfw.util.StringUtil;
18
import org.jfw.util.exception.JfwBaseException;
18 19

19 20
import com.ekexiu.portal.dao.DemandDao;
20 21
import com.ekexiu.portal.dao.DemandSubOrIndusDao;
@ -107,10 +108,11 @@ public class DemandService {
107 108
	 * @param demander 发布者ID
108 109
	 * @return 返回状态发布中的需求总数
109 110
	 * @throws SQLException
111
	 * @throws JfwBaseException 
110 112
	 */
111 113
	@Get
112 114
	@Path("/queryPublish")
113
	public int queryPublish(@JdbcConn Connection con,String demander)throws SQLException{
115
	public int queryPublish(@JdbcConn Connection con,String demander)throws SQLException, JfwBaseException{
114 116
		return this.demandDao.queryCountByStatus(con, demander, "1");
115 117
	}
116 118