瀏覽代碼

资源查询接口和资源申请查询接口添加分页。

zzy.zhiyuan.foxmail 8 年之前
父節點
當前提交
443605cdc3

+ 335 - 127
src/main/java/com/ekexiu/portal/dao/OperationDao.java

@ -1,7 +1,13 @@
1 1
package com.ekexiu.portal.dao;
2 2

3
import java.math.BigDecimal;
3 4
import java.sql.Connection;
5
import java.sql.PreparedStatement;
6
import java.sql.ResultSet;
4 7
import java.sql.SQLException;
8
import java.util.ArrayList;
9
import java.util.Collections;
10
import java.util.List;
5 11

6 12
import org.jfw.apt.orm.annotation.dao.DAO;
7 13
import org.jfw.apt.orm.annotation.dao.method.From;
@ -10,6 +16,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10 16
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
11 17
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
12 18
import org.jfw.apt.orm.annotation.dao.param.Set;
19
import org.jfw.util.PageQueryResult;
13 20

14 21
import com.ekexiu.portal.po.Operation;
15 22
import com.ekexiu.portal.po.Professor;
@ -125,158 +132,359 @@ public abstract class OperationDao {
125 132
        }
126 133
    }
127 134
	
135
//	/**
136
//	 * 按资源请求者ID查资源申请
137
//	 * @param con
138
//	 * @param demandId 请求者ID
139
//	 * @return
140
//	 * @throws java.sql.SQLException
141
//	 */
142
//	public java.util.List<com.ekexiu.portal.po.Operation> queryDem(java.sql.Connection con,java.lang.String demandId) throws java.sql.SQLException{
143
//        int _m_1 = 1;
144
//        String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID WHERE DEMAND_ID = ?";
145
//        java.sql.PreparedStatement ps = con.prepareStatement(sql);
146
//        try{
147
//            ps.setString(_m_1++,demandId);
148
//            java.sql.ResultSet rs = ps.executeQuery();
149
//            try{
150
//                java.util.List<com.ekexiu.portal.po.Operation> _result = new java.util.ArrayList<com.ekexiu.portal.po.Operation>();
151
//                while(rs.next()){
152
//                    com.ekexiu.portal.po.Operation _obj =  new com.ekexiu.portal.po.Operation();
153
//                    _obj.setReplyNotes(rs.getString(1));
154
//                    _obj.setCreateTime(rs.getString(2));
155
//                    _obj.setOperationId(rs.getString(3));
156
//                    _obj.setOperationStatus(rs.getInt(4));
157
//                    Professor professor = new Professor();
158
//                    professor.setId(rs.getString(5));
159
//                    _obj.setDetailDemand(rs.getString(6));
160
//                    _obj.setDeliverTime(rs.getString(7));
161
//                    Resource resource = new Resource();
162
//                    resource.setResourceId(rs.getString(8));
163
//                    _obj.setDealPrice(rs.getBigDecimal(9));
164
//                    _obj.setDealTime(rs.getString(10));
165
//                    _obj.setPayMethod(rs.getString(11));
166
//                    professor.setName(rs.getString(12));
167
//                    _obj.setProfessor(professor);
168
//                    resource.setResourceName(rs.getString(13));
169
//                    Professor professor2 = new Professor();
170
//                    professor2.setId(rs.getString(14));
171
//                    professor2.setName(rs.getString(15));
172
//                    resource.setProfessor(professor2);
173
//                    _obj.setResource(resource);
174
//                    _obj.setApplysquare(rs.getString(16));
175
//                    _result.add(_obj);
176
//                }
177
//                return _result;
178
//            }finally{
179
//                try{rs.close();}catch(Exception _m_2){}
180
//            }
181
//        }finally{
182
//            try{ps.close();}catch(Exception _m_3){}
183
//        }
184
//    }
185
	
128 186
	/**
129
	 * 按资源请求者ID查资源申请
187
	 * 分页按资源请者ID查资源申请
130 188
	 * @param con
131
	 * @param demandId 请求者ID
132
	 * @return
133
	 * @throws java.sql.SQLException
189
	 * @param demandId 资源申源申请者ID
190
	 * @param pageSize 每页记录数
191
	 * @param pageNo 当前页码
192
	 * @return 返回该用户ID申请的所有资源
193
	 * @throws SQLException
134 194
	 */
135
	public java.util.List<com.ekexiu.portal.po.Operation> queryPro(java.sql.Connection con,java.lang.String demandId) throws java.sql.SQLException{
136
        int _m_1 = 1;
137
        String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID WHERE DEMAND_ID = ?";
138
        java.sql.PreparedStatement ps = con.prepareStatement(sql);
195
	public PageQueryResult<Operation> queryDemPage(Connection con,String demandId,int pageSize,int pageNoSize,int pageNo) throws SQLException{
196
        int _m_1 = 0;
197
        PageQueryResult<Operation> _result = new PageQueryResult<Operation>();
198
        int _m_2 = 1;
199
        String sql = null;
200
        sql = "  WHERE OPERATION.DEMAND_ID = ?        ";
201
        String _m_3 = sql;
202
        sql = "SELECT COUNT(1) FROM OPERATION";
203
        sql = sql + _m_3;
204
        PreparedStatement ps = con.prepareStatement(sql);
139 205
        try{
140
            ps.setString(_m_1++,demandId);
141
            java.sql.ResultSet rs = ps.executeQuery();
206
            ps.setString(_m_2++,demandId);
207
            _result.setPageSize(pageSize);
208
            ResultSet _pageRs = ps.executeQuery();
142 209
            try{
143
                java.util.List<com.ekexiu.portal.po.Operation> _result = new java.util.ArrayList<com.ekexiu.portal.po.Operation>();
144
                while(rs.next()){
145
                    com.ekexiu.portal.po.Operation _obj =  new com.ekexiu.portal.po.Operation();
146
                    _obj.setReplyNotes(rs.getString(1));
210
                _pageRs.next();
211
                _m_1 = _pageRs.getInt(1);
212
            }finally{
213
                try{_pageRs.close();}catch(Exception _m_4){}
214
            }
215
        }finally{
216
            try{ps.close();}catch(Exception _m_5){}
217
        }
218
        _result.setTotal(_m_1);
219
        if(0== _m_1){
220
            _result.setPageNo(1);
221
            _result.setData(Collections.<Operation>emptyList());
222
            return _result;
223
        }
224
        _m_2 = 1;
225
        boolean _m_6 = (1 == pageNo);
226
        if(_m_6){
227
            _result.setPageNo(1);
228
            sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
229
            sql = sql + _m_3;
230
            sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
231
            sql = sql + " LIMIT " + pageSize;
232
        }else{
233
            int _m_7 = _m_1 / pageSize;
234
            if(_m_1 % pageSize != 0){
235
                ++_m_7;
236
            }
237
            if(pageNo > _m_7){
238
                pageNo = _m_7;
239
            }
240
            _result.setPageNo(pageNo);
241
            --pageNo;
242
            int _m_8 = (pageNo * pageSize);
243
            sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
244
            sql = sql + _m_3;
245
            sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
246
            sql = sql + " LIMIT " + pageSize+ " OFFSET "+_m_8;
247
        }
248
        ps = con.prepareStatement(sql);
249
        try{
250
            ps.setString(_m_2++,demandId);
251
            ResultSet rs = ps.executeQuery();
252
            try{
253
                List<Operation> _m_9 = new ArrayList<Operation>();
254
                _result.setData(_m_9);
255
                int _m_10 = 0;
256
                while((_m_10<pageSize) && rs.next()){
257
                    ++_m_10;
258
                    Operation _obj =  new Operation();
259
                    String _m_11 = rs.getString(1);
260
                    if(rs.wasNull()){
261
                        _m_11 = null;
262
                    }
263
                    _obj.setReplyNotes(_m_11);
147 264
                    _obj.setCreateTime(rs.getString(2));
148
                    _obj.setOperationId(rs.getString(3));
149
                    _obj.setOperationStatus(rs.getInt(4));
265
                    String _m_12 = rs.getString(3);
266
                    if(rs.wasNull()){
267
                        _m_12 = null;
268
                    }
269
                    _obj.setApplysquare(_m_12);
270
                    _obj.setOperationId(rs.getString(4));
271
                    _obj.setOperationStatus(rs.getInt(5));
150 272
                    Professor professor = new Professor();
151
                    professor.setId(rs.getString(5));
152
                    _obj.setDetailDemand(rs.getString(6));
153
                    _obj.setDeliverTime(rs.getString(7));
273
                    professor.setId(rs.getString(6));
274
                    _obj.setDetailDemand(rs.getString(7));
275
                    _obj.setDeliverTime(rs.getString(8));
154 276
                    Resource resource = new Resource();
155
                    resource.setResourceId(rs.getString(8));
156
                    _obj.setDealPrice(rs.getBigDecimal(9));
157
                    _obj.setDealTime(rs.getString(10));
158
                    _obj.setPayMethod(rs.getString(11));
159
                    professor.setName(rs.getString(12));
277
					resource.setResourceId(rs.getString(9));
278
                    BigDecimal _m_13 = rs.getBigDecimal(10);
279
                    if(rs.wasNull()){
280
                        _m_13 = null;
281
                    }
282
                    _obj.setDealPrice(_m_13);
283
                    String _m_14 = rs.getString(11);
284
                    if(rs.wasNull()){
285
                        _m_14 = null;
286
                    }
287
                    _obj.setDealTime(_m_14);
288
                    String _m_15 = rs.getString(12);
289
                    if(rs.wasNull()){
290
                        _m_15 = null;
291
                    }
292
                    _obj.setPayMethod(_m_15);
293
                    professor.setName(rs.getString(13));
160 294
                    _obj.setProfessor(professor);
161
                    resource.setResourceName(rs.getString(13));
162
                    Professor professor2 = new Professor();
163
                    professor2.setId(rs.getString(14));
164
                    professor2.setName(rs.getString(15));
295
					resource.setResourceName(rs.getString(14));
296
					Professor professor2 = new Professor();
297
                    professor2.setId(rs.getString(15));
298
                    professor2.setName(rs.getString(16));
165 299
                    resource.setProfessor(professor2);
166
                    _obj.setResource(resource);
167
                    _obj.setApplysquare(rs.getString(16));
168
                    _result.add(_obj);
300
					_obj.setResource(resource);
301
                    _m_9.add(_obj);
169 302
                }
170 303
                return _result;
171 304
            }finally{
172
                try{rs.close();}catch(Exception _m_2){}
305
                try{rs.close();}catch(Exception _m_16){}
173 306
            }
174 307
        }finally{
175
            try{ps.close();}catch(Exception _m_3){}
308
            try{ps.close();}catch(Exception _m_17){}
176 309
        }
177 310
    }
178 311
	
179 312
	/**
180
	 * 按资源所有者ID查资源申请
181
	 * @param con
182
	 * @param professorId 资源拥有者ID
183
	 * @return
184
	 * @throws java.sql.SQLException
185
	 */
186
	public java.util.List<com.ekexiu.portal.po.Operation> queryDem(java.sql.Connection con,java.lang.String professorId) throws java.sql.SQLException{
187
		int _m_1 = 1;
188
		String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID WHERE RESOURCE.PROFESSOR_ID = ?";
189
		java.sql.PreparedStatement ps = con.prepareStatement(sql);
190
		try{
191
			ps.setString(_m_1++,professorId);
192
			java.sql.ResultSet rs = ps.executeQuery();
193
			try{
194
				java.util.List<com.ekexiu.portal.po.Operation> _result = new java.util.ArrayList<com.ekexiu.portal.po.Operation>();
195
				while(rs.next()){
196
					com.ekexiu.portal.po.Operation _obj =  new com.ekexiu.portal.po.Operation();
197
					_obj.setReplyNotes(rs.getString(1));
198
					_obj.setCreateTime(rs.getString(2));
199
					_obj.setOperationId(rs.getString(3));
200
					_obj.setOperationStatus(rs.getInt(4));
201
					Professor professor = new Professor();
202
					professor.setId(rs.getString(5));
203
					_obj.setDetailDemand(rs.getString(6));
204
					_obj.setDeliverTime(rs.getString(7));
205
					Resource resource = new Resource();
206
					resource.setResourceId(rs.getString(8));
207
					_obj.setDealPrice(rs.getBigDecimal(9));
208
					_obj.setDealTime(rs.getString(10));
209
					_obj.setPayMethod(rs.getString(11));
210
					professor.setName(rs.getString(12));
211
					_obj.setProfessor(professor);
212
					resource.setResourceName(rs.getString(13));
213
					Professor professor2 = new Professor();
214
                    professor2.setId(rs.getString(14));
215
                    professor2.setName(rs.getString(15));
216
                    resource.setProfessor(professor2);
217
					_obj.setResource(resource);
218
					_obj.setApplysquare(rs.getString(16));
219
					_result.add(_obj);
220
				}
221
				return _result;
222
			}finally{
223
				try{rs.close();}catch(Exception _m_2){}
224
			}
225
		}finally{
226
			try{ps.close();}catch(Exception _m_3){}
227
		}
228
	}
229
	
230
	/**
231
	 * 按资源ID查资源申请,返回资申请人姓名和资源名称
313
	 * 分页按资源ID查资源申请,返回资申请人姓名和资源名称
232 314
	 * @param con
233 315
	 * @param resourceId 资源ID
234
	 * @return
235
	 * @throws java.sql.SQLException
316
	 * @param pageSize 每页记录数
317
	 * @param pageNo 当前页码
318
	 * @return 返回当前资源ID下的所有资源申请记录
319
	 * @throws SQLException
236 320
	 */
237
	public java.util.List<com.ekexiu.portal.po.Operation> queryRes(java.sql.Connection con,java.lang.String resourceId) throws java.sql.SQLException{
238
		int _m_1 = 1;
239
		String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID WHERE OPERATION.RESOURCE_ID = ?";
240
		java.sql.PreparedStatement ps = con.prepareStatement(sql);
241
		try{
242
			ps.setString(_m_1++,resourceId);
243
			java.sql.ResultSet rs = ps.executeQuery();
244
			try{
245
				java.util.List<com.ekexiu.portal.po.Operation> _result = new java.util.ArrayList<com.ekexiu.portal.po.Operation>();
246
				while(rs.next()){
247
					com.ekexiu.portal.po.Operation _obj =  new com.ekexiu.portal.po.Operation();
248
					_obj.setReplyNotes(rs.getString(1));
249
					_obj.setCreateTime(rs.getString(2));
250
					_obj.setOperationId(rs.getString(3));
251
					_obj.setOperationStatus(rs.getInt(4));
252
					Professor professor = new Professor();
253
					professor.setId(rs.getString(5));
254
					_obj.setDetailDemand(rs.getString(6));
255
					_obj.setDeliverTime(rs.getString(7));
256
					Resource resource = new Resource();
257
					resource.setResourceId(rs.getString(8));
258
					_obj.setDealPrice(rs.getBigDecimal(9));
259
					_obj.setDealTime(rs.getString(10));
260
					_obj.setPayMethod(rs.getString(11));
261
					professor.setName(rs.getString(12));
262
					_obj.setProfessor(professor);
263
					resource.setResourceName(rs.getString(13));
321
	public PageQueryResult<Operation> queryResPage(Connection con,String resourceId,int pageSize,int pageNo) throws SQLException{
322
        int _m_1 = 0;
323
        PageQueryResult<Operation> _result = new PageQueryResult<Operation>();
324
        int _m_2 = 1;
325
        String sql = null;
326
        sql = " WHERE OPERATION.RESOURCE_ID = ? ";
327
        String _m_3 = sql;
328
        sql = "SELECT COUNT(1) FROM OPERATION";
329
        sql = sql + _m_3;
330
        PreparedStatement ps = con.prepareStatement(sql);
331
        try{
332
            ps.setString(_m_2++,resourceId);
333
            _result.setPageSize(pageSize);
334
            ResultSet _pageRs = ps.executeQuery();
335
            try{
336
                _pageRs.next();
337
                _m_1 = _pageRs.getInt(1);
338
            }finally{
339
                try{_pageRs.close();}catch(Exception _m_4){}
340
            }
341
        }finally{
342
            try{ps.close();}catch(Exception _m_5){}
343
        }
344
        _result.setTotal(_m_1);
345
        if(0== _m_1){
346
            _result.setPageNo(1);
347
            _result.setData(Collections.<Operation>emptyList());
348
            return _result;
349
        }
350
        _m_2 = 1;
351
        boolean _m_6 = (1 == pageNo);
352
        if(_m_6){
353
            _result.setPageNo(1);
354
            sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION.OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID ";
355
            sql = sql + _m_3;
356
            sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
357
            sql = sql + " LIMIT " + pageSize;
358
        }else{
359
            int _m_7 = _m_1 / pageSize;
360
            if(_m_1 % pageSize != 0){
361
                ++_m_7;
362
            }
363
            if(pageNo > _m_7){
364
                pageNo = _m_7;
365
            }
366
            _result.setPageNo(pageNo);
367
            --pageNo;
368
            int _m_8 = (pageNo * pageSize);
369
            sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,APPLYSQUARE,OPERATION.OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID";
370
            sql = sql + _m_3;
371
            sql = sql + "ORDER BY OPERATION.CREATE_TIME DESC";
372
            sql = sql + " LIMIT " + pageSize+ " OFFSET "+_m_8;
373
        }
374
        ps = con.prepareStatement(sql);
375
        try{
376
            ps.setString(_m_2++,resourceId);
377
            ResultSet rs = ps.executeQuery();
378
            try{
379
                List<Operation> _m_9 = new ArrayList<Operation>();
380
                _result.setData(_m_9);
381
                int _m_10 = 0;
382
                while((_m_10<pageSize) && rs.next()){
383
                    ++_m_10;
384
                    Operation _obj =  new Operation();
385
                    String _m_11 = rs.getString(1);
386
                    if(rs.wasNull()){
387
                        _m_11 = null;
388
                    }
389
                    _obj.setReplyNotes(_m_11);
390
                    _obj.setCreateTime(rs.getString(2));
391
                    String _m_12 = rs.getString(3);
392
                    if(rs.wasNull()){
393
                        _m_12 = null;
394
                    }
395
                    _obj.setApplysquare(_m_12);
396
                    _obj.setOperationId(rs.getString(4));
397
                    _obj.setOperationStatus(rs.getInt(5));
398
                    Professor professor = new Professor();
399
                    professor.setId(rs.getString(6));
400
                    _obj.setDetailDemand(rs.getString(7));
401
                    _obj.setDeliverTime(rs.getString(8));
402
                    Resource resource = new Resource();
403
					resource.setResourceId(rs.getString(9));
404
                    BigDecimal _m_13 = rs.getBigDecimal(10);
405
                    if(rs.wasNull()){
406
                        _m_13 = null;
407
                    }
408
                    _obj.setDealPrice(_m_13);
409
                    String _m_14 = rs.getString(11);
410
                    if(rs.wasNull()){
411
                        _m_14 = null;
412
                    }
413
                    _obj.setDealTime(_m_14);
414
                    String _m_15 = rs.getString(12);
415
                    if(rs.wasNull()){
416
                        _m_15 = null;
417
                    }
418
                    _obj.setPayMethod(_m_15);
419
                    professor.setName(rs.getString(13));
420
                    _obj.setProfessor(professor);
421
					resource.setResourceName(rs.getString(14));
264 422
					Professor professor2 = new Professor();
265
                    professor2.setId(rs.getString(14));
266
                    professor2.setName(rs.getString(15));
423
                    professor2.setId(rs.getString(15));
424
                    professor2.setName(rs.getString(16));
267 425
                    resource.setProfessor(professor2);
268 426
					_obj.setResource(resource);
269
					_obj.setApplysquare(rs.getString(16));
270
					_result.add(_obj);
271
				}
272
				return _result;
273
			}finally{
274
				try{rs.close();}catch(Exception _m_2){}
275
			}
276
		}finally{
277
			try{ps.close();}catch(Exception _m_3){}
278
		}
279
	}
427
                    _m_9.add(_obj);
428
                }
429
                return _result;
430
            }finally{
431
                try{rs.close();}catch(Exception _m_16){}
432
            }
433
        }finally{
434
            try{ps.close();}catch(Exception _m_17){}
435
        }
436
    }
437
	
438
//	/**
439
//	 * 按资源ID查资源申请,返回资申请人姓名和资源名称
440
//	 * @param con
441
//	 * @param resourceId 资源ID
442
//	 * @return
443
//	 * @throws java.sql.SQLException
444
//	 */
445
//	public java.util.List<com.ekexiu.portal.po.Operation> queryRes(java.sql.Connection con,java.lang.String resourceId) throws java.sql.SQLException{
446
//		int _m_1 = 1;
447
//		String sql = "SELECT REPLY_NOTES,OPERATION.CREATE_TIME,OPERATION_ID,OPERATION_STATUS,DEMAND_ID,DETAIL_DEMAND,DELIVER_TIME,OPERATION.RESOURCE_ID,DEAL_PRICE,DEAL_TIME,PAY_METHOD,P1.NAME,RESOURCE_NAME,RESOURCE.PROFESSOR_ID,P2.NAME,APPLYSQUARE FROM OPERATION INNER JOIN PROFESSOR P1 ON DEMAND_ID = P1.ID INNER JOIN RESOURCE ON OPERATION.RESOURCE_ID = RESOURCE.RESOURCE_ID INNER JOIN PROFESSOR P2 ON RESOURCE.PROFESSOR_ID = P2.ID WHERE OPERATION.RESOURCE_ID = ?";
448
//		java.sql.PreparedStatement ps = con.prepareStatement(sql);
449
//		try{
450
//			ps.setString(_m_1++,resourceId);
451
//			java.sql.ResultSet rs = ps.executeQuery();
452
//			try{
453
//				java.util.List<com.ekexiu.portal.po.Operation> _result = new java.util.ArrayList<com.ekexiu.portal.po.Operation>();
454
//				while(rs.next()){
455
//					com.ekexiu.portal.po.Operation _obj =  new com.ekexiu.portal.po.Operation();
456
//					_obj.setReplyNotes(rs.getString(1));
457
//					_obj.setCreateTime(rs.getString(2));
458
//					_obj.setOperationId(rs.getString(3));
459
//					_obj.setOperationStatus(rs.getInt(4));
460
//					Professor professor = new Professor();
461
//					professor.setId(rs.getString(5));
462
//					_obj.setDetailDemand(rs.getString(6));
463
//					_obj.setDeliverTime(rs.getString(7));
464
//					Resource resource = new Resource();
465
//					resource.setResourceId(rs.getString(8));
466
//					_obj.setDealPrice(rs.getBigDecimal(9));
467
//					_obj.setDealTime(rs.getString(10));
468
//					_obj.setPayMethod(rs.getString(11));
469
//					professor.setName(rs.getString(12));
470
//					_obj.setProfessor(professor);
471
//					resource.setResourceName(rs.getString(13));
472
//					Professor professor2 = new Professor();
473
//                    professor2.setId(rs.getString(14));
474
//                    professor2.setName(rs.getString(15));
475
//                    resource.setProfessor(professor2);
476
//					_obj.setResource(resource);
477
//					_obj.setApplysquare(rs.getString(16));
478
//					_result.add(_obj);
479
//				}
480
//				return _result;
481
//			}finally{
482
//				try{rs.close();}catch(Exception _m_2){}
483
//			}
484
//		}finally{
485
//			try{ps.close();}catch(Exception _m_3){}
486
//		}
487
//	}
280 488
	
281 489
	@DeleteWith
282 490
	@From(Operation.class)

+ 134 - 24
src/main/java/com/ekexiu/portal/dao/ResourceDao.java

@ -1,7 +1,11 @@
1 1
package com.ekexiu.portal.dao;
2 2

3 3
import java.sql.Connection;
4
import java.sql.PreparedStatement;
5
import java.sql.ResultSet;
4 6
import java.sql.SQLException;
7
import java.util.ArrayList;
8
import java.util.Collections;
5 9
import java.util.List;
6 10

7 11
import org.jfw.apt.orm.annotation.dao.DAO;
@ -13,6 +17,7 @@ import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
13 17
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
14 18
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
15 19
import org.jfw.apt.orm.annotation.dao.param.Set;
20
import org.jfw.util.PageQueryResult;
16 21

17 22
import com.ekexiu.portal.po.Professor;
18 23
import com.ekexiu.portal.po.Resource;
@ -98,57 +103,162 @@ public abstract class ResourceDao {
98 103
        }
99 104
    }
100 105
	
101
	public java.util.List<com.ekexiu.portal.po.Resource> query(java.sql.Connection conSize,int pageNo) throws java.sql.SQLException{
102
        String sql = "SELECT RESOURCE_ID,RESOURCE_NAME,RESOURCE.SUBJECT,RESOURCE.INDUSTRY,SUPPORTED_SERVICES,RESOURCE.DESCP,PROFESSOR_ID,ASCRIPTION,HOPE_PAY_METHOD,COOPERATION_NOTES,RESOURCE.CREATE_TIME,RESOURCE.MODIFY_TIME,PROFESSOR.NAME FROM RESOURCE LEFT JOIN PROFESSOR ON PROFESSOR_ID = PROFESSOR.ID ORDER BY RESOURCE_NAME ";
103
        java.sql.PreparedStatement ps = con.prepareStatement(sql);
106
	public PageQueryResult<Resource> queryPageAll(Connection con,int pageSize,int pageNoSize,int pageNo) throws SQLException{
107
        int _m_1 = 0;
108
        PageQueryResult<Resource> _result = new PageQueryResult<Resource>();
109
        String sql = null;
110
        sql = " SELECT COUNT(1) FROM RESOURCE ";
111
        PreparedStatement ps = con.prepareStatement(sql);
104 112
        try{
105
            java.sql.ResultSet rs = ps.executeQuery();
113
            _result.setPageSize(pageSize);
114
            ResultSet _pageRs = ps.executeQuery();
106 115
            try{
107
                java.util.List<com.ekexiu.portal.po.Resource> _result = new java.util.ArrayList<com.ekexiu.portal.po.Resource>();
108
                while(rs.next()){
109
                    com.ekexiu.portal.po.Resource _obj =  new com.ekexiu.portal.po.Resource();
116
                _pageRs.next();
117
                _m_1 = _pageRs.getInt(1);
118
            }finally{
119
                try{_pageRs.close();}catch(Exception _m_3){}
120
            }
121
        }finally{
122
            try{ps.close();}catch(Exception _m_4){}
123
        }
124
        _result.setTotal(_m_1);
125
        if(0== _m_1){
126
            _result.setPageNo(1);
127
            _result.setData(Collections.<Resource>emptyList());
128
            return _result;
129
        }
130
        boolean _m_5 = (1 == pageNo);
131
        if(_m_5){
132
            _result.setPageNo(1);
133
            sql = " SELECT RESOURCE_ID,RESOURCE_NAME,RESOURCE.SUBJECT,RESOURCE.INDUSTRY,SUPPORTED_SERVICES,RESOURCE.DESCP,PROFESSOR_ID,ASCRIPTION,HOPE_PAY_METHOD,COOPERATION_NOTES,RESOURCE.CREATE_TIME,RESOURCE.MODIFY_TIME,PROFESSOR.NAME FROM RESOURCE LEFT JOIN PROFESSOR ON PROFESSOR_ID = PROFESSOR.ID ";
134
            sql = sql + " ORDER BY RESOURCE_NAME ";
135
            sql = sql + " LIMIT " + pageSize;
136
        }else{
137
            int _m_6 = _m_1 / pageSize;
138
            if(_m_1 % pageSize != 0){
139
                ++_m_6;
140
            }
141
            if(pageNo > _m_6){
142
                pageNo = _m_6;
143
            }
144
            _result.setPageNo(pageNo);
145
            --pageNo;
146
            int _m_7 = (pageNo * pageSize);
147
            sql = " SELECT RESOURCE_ID,RESOURCE_NAME,RESOURCE.SUBJECT,RESOURCE.INDUSTRY,SUPPORTED_SERVICES,RESOURCE.DESCP,PROFESSOR_ID,ASCRIPTION,HOPE_PAY_METHOD,COOPERATION_NOTES,RESOURCE.CREATE_TIME,RESOURCE.MODIFY_TIME,PROFESSOR.NAME FROM RESOURCE LEFT JOIN PROFESSOR ON PROFESSOR_ID = PROFESSOR.ID ";
148
            sql = sql + " ORDER BY RESOURCE_NAME ";
149
            sql = sql + " LIMIT " + pageSize+ " OFFSET "+_m_7;
150
        }
151
        ps = con.prepareStatement(sql);
152
        try{
153
            ResultSet rs = ps.executeQuery();
154
            try{
155
                List<Resource> _m_8 = new ArrayList<Resource>();
156
                _result.setData(_m_8);
157
                int _m_9 = 0;
158
                while((_m_9<pageSize) && rs.next()){
159
                    ++_m_9;
160
                    Resource _obj =  new Resource();
110 161
                    _obj.setResourceId(rs.getString(1));
111 162
                    _obj.setResourceName(rs.getString(2));
112
                    java.lang.String _m_1 = rs.getString(3);
163
                    String _m_10 = rs.getString(3);
113 164
                    if(rs.wasNull()){
114
                        _m_1 = null;
165
                        _m_10 = null;
115 166
                    }
116
                    _obj.setSubject(_m_1);
117
                    java.lang.String _m_2 = rs.getString(4);
167
                    _obj.setSubject(_m_10);
168
                    String _m_11 = rs.getString(4);
118 169
                    if(rs.wasNull()){
119
                        _m_2 = null;
170
                        _m_11 = null;
120 171
                    }
121
                    _obj.setIndustry(_m_2);
172
                    _obj.setIndustry(_m_11);
122 173
                    _obj.setSupportedServices(rs.getString(5));
123
                    java.lang.String _m_3 = rs.getString(6);
174
                    String _m_12 = rs.getString(6);
124 175
                    if(rs.wasNull()){
125
                        _m_3 = null;
176
                        _m_12 = null;
126 177
                    }
127
                    _obj.setDescp(_m_3);
178
                    _obj.setDescp(_m_12);
128 179
                    Professor professor = new Professor();
129 180
                    professor.setId(rs.getString(7));
130
                    _obj.setAscription(rs.getString(8));
131
                    _obj.setHopePayMethod(rs.getString(9));
132
                    java.lang.String _m_4 = rs.getString(10);
181
                    String _m_13 = rs.getString(8);
133 182
                    if(rs.wasNull()){
134
                        _m_4 = null;
183
                        _m_13 = null;
184
                    }
185
                    _obj.setAscription(_m_13);
186
                    String _m_14 = rs.getString(9);
187
                    if(rs.wasNull()){
188
                        _m_14 = null;
135 189
                    }
136
                    _obj.setCooperationNotes(_m_4);
190
                    _obj.setHopePayMethod(_m_14);
191
                    String _m_15 = rs.getString(10);
192
                    if(rs.wasNull()){
193
                        _m_15 = null;
194
                    }
195
                    _obj.setCooperationNotes(_m_15);
137 196
                    _obj.setCreateTime(rs.getString(11));
138 197
                    _obj.setModifyTime(rs.getString(12));
139 198
                    professor.setName(rs.getString(13));
140 199
                    _obj.setProfessor(professor);
141
                    _result.add(_obj);
200
                    _m_8.add(_obj);
142 201
                }
143 202
                return _result;
144 203
            }finally{
145
                try{rs.close();}catch(Exception _m_5){}
204
                try{rs.close();}catch(Exception _m_16){}
146 205
            }
147 206
        }finally{
148
            try{ps.close();}catch(Exception _m_6){}
207
            try{ps.close();}catch(Exception _m_17){}
149 208
        }
150 209
    }
151 210
	
211
//	public java.util.List<com.ekexiu.portal.po.Resource> query(java.sql.Connection con) throws java.sql.SQLException{
212
//        String sql = "SELECT RESOURCE_ID,RESOURCE_NAME,RESOURCE.SUBJECT,RESOURCE.INDUSTRY,SUPPORTED_SERVICES,RESOURCE.DESCP,PROFESSOR_ID,ASCRIPTION,HOPE_PAY_METHOD,COOPERATION_NOTES,RESOURCE.CREATE_TIME,RESOURCE.MODIFY_TIME,PROFESSOR.NAME FROM RESOURCE LEFT JOIN PROFESSOR ON PROFESSOR_ID = PROFESSOR.ID ORDER BY RESOURCE_NAME ";
213
//        java.sql.PreparedStatement ps = con.prepareStatement(sql);
214
//        try{
215
//            java.sql.ResultSet rs = ps.executeQuery();
216
//            try{
217
//                java.util.List<com.ekexiu.portal.po.Resource> _result = new java.util.ArrayList<com.ekexiu.portal.po.Resource>();
218
//                while(rs.next()){
219
//                    com.ekexiu.portal.po.Resource _obj =  new com.ekexiu.portal.po.Resource();
220
//                    _obj.setResourceId(rs.getString(1));
221
//                    _obj.setResourceName(rs.getString(2));
222
//                    String _m_1 = rs.getString(3);
223
//                    if(rs.wasNull()){
224
//                        _m_1 = null;
225
//                    }
226
//                    _obj.setSubject(_m_1);
227
//                    String _m_2 = rs.getString(4);
228
//                    if(rs.wasNull()){
229
//                        _m_2 = null;
230
//                    }
231
//                    _obj.setIndustry(_m_2);
232
//                    _obj.setSupportedServices(rs.getString(5));
233
//                    String _m_3 = rs.getString(6);
234
//                    if(rs.wasNull()){
235
//                        _m_3 = null;
236
//                    }
237
//                    _obj.setDescp(_m_3);
238
//                    Professor professor = new Professor();
239
//                    professor.setId(rs.getString(7));
240
//                    _obj.setAscription(rs.getString(8));
241
//                    _obj.setHopePayMethod(rs.getString(9));
242
//                    String _m_4 = rs.getString(10);
243
//                    if(rs.wasNull()){
244
//                        _m_4 = null;
245
//                    }
246
//                    _obj.setCooperationNotes(_m_4);
247
//                    _obj.setCreateTime(rs.getString(11));
248
//                    _obj.setModifyTime(rs.getString(12));
249
//                    professor.setName(rs.getString(13));
250
//                    _obj.setProfessor(professor);
251
//                    _result.add(_obj);
252
//                }
253
//                return _result;
254
//            }finally{
255
//                try{rs.close();}catch(Exception _m_5){}
256
//            }
257
//        }finally{
258
//            try{ps.close();}catch(Exception _m_6){}
259
//        }
260
//    }
261
	
152 262
	@SelectList
153 263
	@OrderBy(" ORDER BY CREATE_TIME DESC ")
154 264
	public abstract List<Resource> queryPro(Connection con, String professorId) throws SQLException;

+ 19 - 11
src/main/java/com/ekexiu/portal/service/OperationService.java

@ -65,24 +65,32 @@ public class OperationService {
65 65
		return this.operationDao.query(con);
66 66
	}
67 67
	
68
	@Get
69
	@Path("/qapro")
70
	public List<Operation> queryPro(@JdbcConn Connection con, String demandId) throws SQLException{
71
		return this.operationDao.queryPro(con, demandId);
72
	}
68
//	@Get
69
//	@Path("/qadem")
70
//	public List<Operation> queryDem(@JdbcConn Connection con, String demandId) throws SQLException{
71
//		return this.operationDao.queryDem(con, demandId);
72
//	}
73 73
	
74 74
	@Get
75
	@Path("/qadem")
76
	public List<Operation> queryDem(@JdbcConn Connection con, String professorId) throws SQLException{
77
		return this.operationDao.queryDem(con, professorId);
75
	@Path("/pqdem")
76
	public PageQueryResult<Operation> queryDemPage(@JdbcConn Connection con, String demandId, 
77
			@DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException{
78
		return this.operationDao.queryDemPage(con, demandId, pageSize, pageNo);
78 79
	}
79 80
	
80 81
	@Get
81
	@Path("/qares")
82
	public List<Operation> queryRes(@JdbcConn Connection con, String resourceId) throws SQLException{
83
		return this.operationDao.queryRes(con, resourceId);
82
	@Path("/pqres")
83
	public PageQueryResult<Operation> queryResPage(@JdbcConn Connection con, String resourceId, 
84
			@DefaultValue("3") int pageSize, @DefaultValue("1") int pageNo) throws SQLException{
85
		return this.operationDao.queryResPage(con, resourceId, pageSize, pageNo);
84 86
	}
85 87
	
88
//	@Get
89
//	@Path("/qares")
90
//	public List<Operation> queryRes(@JdbcConn Connection con, String resourceId) throws SQLException{
91
//		return this.operationDao.queryRes(con, resourceId);
92
//	}
93
	
86 94
	@Post
87 95
	@Path("/detailDemand")
88 96
	public void updateDetailDemand(@JdbcConn(true) Connection con, String operationId, String detailDemand) throws SQLException{

+ 10 - 4
src/main/java/com/ekexiu/portal/service/ResourceService.java

@ -82,12 +82,18 @@ public class ResourceService {
82 82
	public Resource query(@JdbcConn Connection con, @PathVar String resourceId) throws SQLException {
83 83
		return this.resourceDao.query(con, resourceId);
84 84
	}
85

85
	
86 86
	@Get
87
	@Path("/qa")
88
	public List<Resource> queryAll(@JdbcConn Connection con) throws SQLException {
89
		return this.resourceDao.query(con);
87
	@Path("/pqall")
88
	public PageQueryResult<Resource> queryPageAll(@JdbcConn Connection con, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
89
		return this.resourceDao.queryPageAll(con, pageSize, pageNo);
90 90
	}
91

92
//	@Get
93
//	@Path("/qa")
94
//	public List<Resource> queryAll(@JdbcConn Connection con) throws SQLException {
95
//		return this.resourceDao.query(con);
96
//	}
91 97
	
92 98
	@Get
93 99
	@Path("/qapro")