Browse Source

添加APP搜索资源详细信息的接口。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
4f46c9d98d

+ 74 - 8
src/main/java/com/ekexiu/portal/dao/ResourceDao.java

184
        }
184
        }
185
    }
185
    }
186
	
186
	
187
	/**
188
	 * 查询资源详细信息
189
	 * @param con
190
	 * @param resourceId
191
	 * @return
192
	 * @throws SQLException
193
	 */
194
	public Resource queryInfo(Connection con,String resourceId) throws SQLException{
195
        List<Image> images = this.imageDao.queryRes(con, resourceId);
196
		int _m_1 = 1;
197
        String sql = "SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,INDUSTRY,SUPPORTED_SERVICES,DESCP,PROFESSOR_ID,"
198
        		+ " ASCRIPTION,HOPE_PAY_METHOD,COOPERATION_NOTES,CREATE_TIME,MODIFY_TIME "
199
        		+ " FROM RESOURCE WHERE RESOURCE_ID = ?";
200
        PreparedStatement ps = con.prepareStatement(sql);
201
        try{
202
            ps.setString(_m_1++,resourceId);
203
            ResultSet rs = ps.executeQuery();
204
            try{
205
                if(rs.next()){
206
                    Resource _result = new Resource();
207
                    _result.setResourceId(rs.getString(1));
208
                    _result.setResourceName(rs.getString(2));
209
                    String _m_2 = rs.getString(3);
210
                    if(rs.wasNull()){
211
                        _m_2 = null;
212
                    }
213
                    _result.setSubject(_m_2);
214
                    String _m_3 = rs.getString(4);
215
                    if(rs.wasNull()){
216
                        _m_3 = null;
217
                    }
218
                    _result.setIndustry(_m_3);
219
                    _result.setSupportedServices(rs.getString(5));
220
                    String _m_4 = rs.getString(6);
221
                    if(rs.wasNull()){
222
                        _m_4 = null;
223
                    }
224
                    _result.setDescp(_m_4);
225
                    _result.setProfessorId(rs.getString(7));
226
                    _result.setAscription(rs.getString(8));
227
                    String hopePay = rs.getString(9);
228
                    if(rs.wasNull()){
229
                    	hopePay = null;
230
                    }
231
                    _result.setHopePayMethod(hopePay);
232
                    String _m_5 = rs.getString(10);
233
                    if(rs.wasNull()){
234
                        _m_5 = null;
235
                    }
236
                    _result.setCooperationNotes(_m_5);
237
                    _result.setCreateTime(rs.getString(11));
238
                    _result.setModifyTime(rs.getString(12));
239
                    _result.setImages(images);
240
                    return _result;
241
                }else{
242
                    return null;
243
                }
244
            }finally{
245
                try{rs.close();}catch(Exception _m_6){}
246
            }
247
        }finally{
248
            try{ps.close();}catch(Exception _m_7){}
249
        }
250
    }
251
	
187
	public PageQueryResult<Resource> queryPageAll(Connection con,int pageSize,int pageNo) throws SQLException{
252
	public PageQueryResult<Resource> queryPageAll(Connection con,int pageSize,int pageNo) throws SQLException{
188
        int _m_1 = 0;
253
        int _m_1 = 0;
189
        PageQueryResult<Resource> _result = new PageQueryResult<Resource>();
254
        PageQueryResult<Resource> _result = new PageQueryResult<Resource>();
412
	 * @throws SQLException
477
	 * @throws SQLException
413
	 */
478
	 */
414
	public PageQueryResult<Resource> queryPageRes(Connection con,String key,String subject,String industry,
479
	public PageQueryResult<Resource> queryPageRes(Connection con,String key,String subject,String industry,
415
			String province,String address,Integer authentication,int pageSize,int pageNo) throws SQLException{
480
			String province,String address,Integer authType,int pageSize,int pageNo) throws SQLException{
416
        int _m_1 = 0;
481
        int _m_1 = 0;
417
        PageQueryResult<Resource> _result = new PageQueryResult<Resource>();
482
        PageQueryResult<Resource> _result = new PageQueryResult<Resource>();
418
        int _m_3 = 1;
483
        int _m_3 = 1;
421
        boolean _m_5 = null == industry;
486
        boolean _m_5 = null == industry;
422
        boolean _m5 = null == province;
487
        boolean _m5 = null == province;
423
        boolean _m6 = null == address;
488
        boolean _m6 = null == address;
424
        boolean _m7 = null == authentication;
489
        boolean _m7 = null == authType;
425
        StringBuilder sql = new StringBuilder();
490
        StringBuilder sql = new StringBuilder();
426
        if(!_m_2){
491
        if(!_m_2){
427
            sql.append(" WHERE ((RESOURCE_NAME LIKE ?) OR (SUPPORTED_SERVICES LIKE ?) "
492
            sql.append(" WHERE ((RESOURCE_NAME LIKE ?) OR (SUPPORTED_SERVICES LIKE ?) "
446
        	append("(RESOURCE.PROFESSOR_ID IN (SELECT PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.ADDRESS LIKE ?))");
511
        	append("(RESOURCE.PROFESSOR_ID IN (SELECT PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.ADDRESS LIKE ?))");
447
        }
512
        }
448
        if(!_m7){
513
        if(!_m7){
449
			if(0 == authentication){
450
				sql.append(sql.length() > 0 ? " AND " : " WHERE ").
514
				sql.append(sql.length() > 0 ? " AND " : " WHERE ").
451
				append("(RESOURCE.PROFESSOR_ID IN (SELECT PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.AUTHENTICATION = '0'))");
452
			}else if(1 == authentication){
453
				sql.append(sql.length() > 0 ? " AND " : " WHERE ").
454
				append("(RESOURCE.PROFESSOR_ID IN (SELECT PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.AUTHENTICATION = '1'))");
455
			}
515
				append("(RESOURCE.PROFESSOR_ID IN (SELECT PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.AUTH_TYPE = ?))");
456
		}
516
		}
457
        StringBuilder _m_6 = sql;
517
        StringBuilder _m_6 = sql;
458
        sql = new StringBuilder();
518
        sql = new StringBuilder();
484
            if(!_m6){
544
            if(!_m6){
485
            	ps.setString(_m_3++,address);
545
            	ps.setString(_m_3++,address);
486
            }
546
            }
547
            if(!_m7){
548
            	ps.setInt(_m_3++,authType);
549
            }
487
            _result.setPageSize(pageSize);
550
            _result.setPageSize(pageSize);
488
            ResultSet _pageRs = ps.executeQuery();
551
            ResultSet _pageRs = ps.executeQuery();
489
            try{
552
            try{
557
            if(!_m6){
620
            if(!_m6){
558
            	ps.setString(_m_3++,address);
621
            	ps.setString(_m_3++,address);
559
            }
622
            }
623
            if(!_m7){
624
            	ps.setInt(_m_3++,authType);
625
            }
560
            ResultSet rs = ps.executeQuery();
626
            ResultSet rs = ps.executeQuery();
561
            try{
627
            try{
562
                List<Resource> _m_13 = new ArrayList<Resource>();
628
                List<Resource> _m_13 = new ArrayList<Resource>();

+ 9 - 0
src/main/java/com/ekexiu/portal/po/Resource.java

10

10

11
import com.ekexiu.portal.basepo.CreateTimeSupported;
11
import com.ekexiu.portal.basepo.CreateTimeSupported;
12
import com.ekexiu.portal.basepo.ModifyTimeSupported;
12
import com.ekexiu.portal.basepo.ModifyTimeSupported;
13
import com.ekexiu.portal.pojo.EditProfessor;
13

14

14
@PrimaryKey("resourceId")
15
@PrimaryKey("resourceId")
15
@Table
16
@Table
25
	private String descp;
26
	private String descp;
26
	private String professorId;
27
	private String professorId;
27
	private Professor professor;
28
	private Professor professor;
29
	private EditProfessor editProfessor;
28
	private List<Image> images;
30
	private List<Image> images;
29
	/**
31
	/**
30
	 * 资源所属(个人/机构)
32
	 * 资源所属(个人/机构)
52
		this.professor = professor;
54
		this.professor = professor;
53
	}
55
	}
54
	
56
	
57
	public EditProfessor getEditProfessor() {
58
		return editProfessor;
59
	}
60
	public void setEditProfessor(EditProfessor editProfessor) {
61
		this.editProfessor = editProfessor;
62
	}
63
	
55
	@Column(DE.id_32)
64
	@Column(DE.id_32)
56
	public String getResourceId() {
65
	public String getResourceId() {
57
		return resourceId;
66
		return resourceId;

+ 7 - 2
src/main/java/com/ekexiu/portal/service/ResourceService.java

24
import com.ekexiu.portal.dao.WatchDao;
24
import com.ekexiu.portal.dao.WatchDao;
25
import com.ekexiu.portal.po.Operation;
25
import com.ekexiu.portal.po.Operation;
26
import com.ekexiu.portal.po.Resource;
26
import com.ekexiu.portal.po.Resource;
27
import com.ekexiu.portal.pojo.EditProfessor;
27

28

28
@Path("/resource")
29
@Path("/resource")
29
public class ResourceService {
30
public class ResourceService {
138
	@Path("/resourceInfo")
139
	@Path("/resourceInfo")
139
	public Resource queryInfo(@JdbcConn Connection con, String resourceId) throws SQLException {
140
	public Resource queryInfo(@JdbcConn Connection con, String resourceId) throws SQLException {
140
		Resource resource = this.resourceDao.queryInfo(con, resourceId);
141
		Resource resource = this.resourceDao.queryInfo(con, resourceId);
142
		EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
143
		professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
144
		resource.setProfessor(professor);
141
		return resource;
145
		return resource;
142
	}
146
	}
143
	
147
	
208
	@Path("/pqRes")
212
	@Path("/pqRes")
209
	public PageQueryResult<Resource> queryPageRes(@JdbcConn(false) Connection con, @Nullable String key, 
213
	public PageQueryResult<Resource> queryPageRes(@JdbcConn(false) Connection con, @Nullable String key, 
210
			@Nullable String subject, @Nullable String industry, @Nullable String province, @Nullable String address, 
214
			@Nullable String subject, @Nullable String industry, @Nullable String province, @Nullable String address, 
211
			@Nullable Integer authentication, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
215
			@DefaultValue("1") Integer authType, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
212
		if(key!=null) key="%"+key+"%";
216
		if(key!=null) key="%"+key+"%";
213
		if(subject!=null) subject ="%"+subject+"%";
217
		if(subject!=null) subject ="%"+subject+"%";
214
		if(industry!=null)industry="%"+industry+"%";
218
		if(industry!=null)industry="%"+industry+"%";
215
		if(province!=null)province="%"+province+"%";
219
		if(province!=null)province="%"+province+"%";
216
		if(address!=null)address="%"+address+"%";
220
		if(address!=null)address="%"+address+"%";
217
		return this.resourceDao.queryPageRes(con, key, subject, industry, province, address, authentication, pageSize, pageNo);
221
		System.out.println(authType);
222
		return this.resourceDao.queryPageRes(con, key, subject, industry, province, address, authType, pageSize, pageNo);
218
	}
223
	}
219
	
224
	
220
	@Get
225
	@Get