Browse Source

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

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

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

@ -184,6 +184,71 @@ public abstract class ResourceDao {
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 252
	public PageQueryResult<Resource> queryPageAll(Connection con,int pageSize,int pageNo) throws SQLException{
188 253
        int _m_1 = 0;
189 254
        PageQueryResult<Resource> _result = new PageQueryResult<Resource>();
@ -412,7 +477,7 @@ public abstract class ResourceDao {
412 477
	 * @throws SQLException
413 478
	 */
414 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 481
        int _m_1 = 0;
417 482
        PageQueryResult<Resource> _result = new PageQueryResult<Resource>();
418 483
        int _m_3 = 1;
@ -421,7 +486,7 @@ public abstract class ResourceDao {
421 486
        boolean _m_5 = null == industry;
422 487
        boolean _m5 = null == province;
423 488
        boolean _m6 = null == address;
424
        boolean _m7 = null == authentication;
489
        boolean _m7 = null == authType;
425 490
        StringBuilder sql = new StringBuilder();
426 491
        if(!_m_2){
427 492
            sql.append(" WHERE ((RESOURCE_NAME LIKE ?) OR (SUPPORTED_SERVICES LIKE ?) "
@ -446,13 +511,8 @@ public abstract class ResourceDao {
446 511
        	append("(RESOURCE.PROFESSOR_ID IN (SELECT PROFESSOR.ID FROM PROFESSOR WHERE PROFESSOR.ADDRESS LIKE ?))");
447 512
        }
448 513
        if(!_m7){
449
			if(0 == authentication){
450 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 517
        StringBuilder _m_6 = sql;
458 518
        sql = new StringBuilder();
@ -484,6 +544,9 @@ public abstract class ResourceDao {
484 544
            if(!_m6){
485 545
            	ps.setString(_m_3++,address);
486 546
            }
547
            if(!_m7){
548
            	ps.setInt(_m_3++,authType);
549
            }
487 550
            _result.setPageSize(pageSize);
488 551
            ResultSet _pageRs = ps.executeQuery();
489 552
            try{
@ -557,6 +620,9 @@ public abstract class ResourceDao {
557 620
            if(!_m6){
558 621
            	ps.setString(_m_3++,address);
559 622
            }
623
            if(!_m7){
624
            	ps.setInt(_m_3++,authType);
625
            }
560 626
            ResultSet rs = ps.executeQuery();
561 627
            try{
562 628
                List<Resource> _m_13 = new ArrayList<Resource>();

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

@ -10,6 +10,7 @@ import org.jfw.apt.orm.core.enums.DE;
10 10

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

14 15
@PrimaryKey("resourceId")
15 16
@Table
@ -25,6 +26,7 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
25 26
	private String descp;
26 27
	private String professorId;
27 28
	private Professor professor;
29
	private EditProfessor editProfessor;
28 30
	private List<Image> images;
29 31
	/**
30 32
	 * 资源所属(个人/机构)
@ -52,6 +54,13 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
52 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 64
	@Column(DE.id_32)
56 65
	public String getResourceId() {
57 66
		return resourceId;

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

@ -24,6 +24,7 @@ import com.ekexiu.portal.dao.ResourceDao;
24 24
import com.ekexiu.portal.dao.WatchDao;
25 25
import com.ekexiu.portal.po.Operation;
26 26
import com.ekexiu.portal.po.Resource;
27
import com.ekexiu.portal.pojo.EditProfessor;
27 28

28 29
@Path("/resource")
29 30
public class ResourceService {
@ -138,6 +139,9 @@ public class ResourceService {
138 139
	@Path("/resourceInfo")
139 140
	public Resource queryInfo(@JdbcConn Connection con, String resourceId) throws SQLException {
140 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 145
		return resource;
142 146
	}
143 147
	
@ -208,13 +212,14 @@ public class ResourceService {
208 212
	@Path("/pqRes")
209 213
	public PageQueryResult<Resource> queryPageRes(@JdbcConn(false) Connection con, @Nullable String key, 
210 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 216
		if(key!=null) key="%"+key+"%";
213 217
		if(subject!=null) subject ="%"+subject+"%";
214 218
		if(industry!=null)industry="%"+industry+"%";
215 219
		if(province!=null)province="%"+province+"%";
216 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 225
	@Get