Browse Source

--企业资源和资源导入;

zzy.zhiyuan.foxmail 7 years ago
parent
commit
601aae9953

+ 15 - 0
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

@ -87,10 +87,25 @@ public abstract class ArticleDao {
87 87
	@OrderBy(" ORDER BY MODIFY_TIME DESC ")
88 88
	public abstract List<Article> queryPro(Connection con, String professorId) throws SQLException;
89 89
	
90
	@SelectList
91
	@OrderBy(" ORDER BY MODIFY_TIME DESC ")
92
	@Where("STATUS = '1'")
93
	public abstract List<Article> queryProPublish(Connection con, String professorId) throws SQLException;
94
	
95
	@SelectList
96
	@OrderBy(" ORDER BY MODIFY_TIME DESC ")
97
	@Where("STATUS IN ('0','1','2')")
98
	public abstract List<Article> queryForDesk(Connection con, String professorId) throws SQLException;
99
	
90 100
	@SelectList
91 101
	@OrderBy(" ORDER BY MODIFY_TIME DESC ")
92 102
	public abstract List<Article> queryOrg(Connection con, String orgId) throws SQLException;
93 103
	
104
	@SelectList
105
	@OrderBy(" ORDER BY MODIFY_TIME DESC ")
106
	@Where("STATUS = '1'")
107
	public abstract List<Article> queryOrgPublish(Connection con, String orgId) throws SQLException;
108
	
94 109
	@LimitSelect
95 110
	@OrderBy(" ORDER BY MODIFY_TIME DESC ")
96 111
	public abstract List<Article> queryLimit(Connection con,String orgId,@LessThan String modifyTime,int rows)throws SQLException;

+ 8 - 0
src/main/java/com/ekexiu/portal/dao/ImageDao.java

@ -25,6 +25,10 @@ public abstract class ImageDao {
25 25
	@From(Image.class)
26 26
	public abstract int updateSort(Connection con, String imageId, @Set int sort) throws SQLException;
27 27
	
28
	@UpdateWith
29
	@From(Image.class)
30
	public abstract int updateAllSort(Connection con, String resourceId, @Set int sort) throws SQLException;
31
	
28 32
	@SelectOne
29 33
	@Nullable
30 34
	public abstract Image query(Connection con, String imageId) throws SQLException;
@ -50,4 +54,8 @@ public abstract class ImageDao {
50 54
	@DeleteWith
51 55
	@From(Image.class)
52 56
	public abstract int deleteRes(Connection con, String resourceId) throws SQLException;
57
	
58
	@DeleteWith
59
	@From(Image.class)
60
	public abstract int deleteBySort(Connection con, String resourceId, int sort) throws SQLException;
53 61
}

+ 30 - 0
src/main/java/com/ekexiu/portal/dao/OrgResStaffDao.java

@ -0,0 +1,30 @@
1
package com.ekexiu.portal.dao;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7
import org.jfw.apt.orm.annotation.dao.DAO;
8
import org.jfw.apt.orm.annotation.dao.method.From;
9
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
10
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
12

13
import com.ekexiu.portal.po.OrgResStaff;
14

15
@DAO
16
public abstract class OrgResStaffDao {
17
	@Insert
18
	public abstract int insert(Connection con, OrgResStaff orgResStaff) throws SQLException;
19
	
20
	@SelectList
21
	public abstract List<OrgResStaff> query(Connection con, String resourceId) throws SQLException;
22
	
23
	@DeleteWith
24
	@From(OrgResStaff.class)
25
	public abstract int delete(Connection con, String resourceId) throws SQLException;
26
	
27
	@DeleteWith
28
	@From(OrgResStaff.class)
29
	public abstract int deletePro(Connection con, String professorId) throws SQLException;
30
}

+ 1 - 2
src/main/java/com/ekexiu/portal/dao/ProfessorDao.java

@ -344,11 +344,10 @@ public abstract class ProfessorDao {
344 344
	public List<EditProfessor> queryByName(Connection con,String name,int total) throws SQLException{
345 345
        int index = 1;
346 346
        String sql = "SELECT P.OFFICE,P.DEPARTMENT,P.TITLE,AUTHENTICATION,AUTH_TYPE,P.AUTH_STATUS,P.ID,P.NAME,P.ADDRESS,P.ORG_AUTH,ORGANIZATION.NAME,P.ORG_ID,P.SCORE_PERCENT "
347
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.NAME LIKE ? ORDER BY P.SCORE_PERCENT DESC LIMIT ? ";
347
        		+ " FROM PROFESSOR P LEFT JOIN ORGANIZATION ON P.ORG_ID = ORGANIZATION.ID WHERE P.NAME LIKE ? ORDER BY P.SCORE_PERCENT DESC LIMIT " + total;
348 348
        PreparedStatement ps = con.prepareStatement(sql);
349 349
        try{
350 350
            ps.setString(index++,name);
351
            ps.setInt(index++, total);
352 351
            ResultSet rs = ps.executeQuery();
353 352
            try{
354 353
                List<EditProfessor> editProfessors = new ArrayList<EditProfessor>();

+ 313 - 7
src/main/java/com/ekexiu/portal/dao/ResourceDao.java

@ -19,6 +19,7 @@ import org.jfw.apt.orm.annotation.dao.method.Where;
19 19
import org.jfw.apt.orm.annotation.dao.method.operator.DeleteWith;
20 20
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
21 21
import org.jfw.apt.orm.annotation.dao.method.operator.LimitSelect;
22
import org.jfw.apt.orm.annotation.dao.method.operator.SelectList;
22 23
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
23 24
import org.jfw.apt.orm.annotation.dao.method.operator.Update;
24 25
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
@ -159,14 +160,14 @@ public abstract class ResourceDao {
159 160
        if(firstPage){
160 161
        	queryResult.setPageNo(1);
161 162
        	sql = new StringBuilder();
162
        	sql.append("(SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME FROM RESOURCE WHERE STATUS = '0'");
163
        	sql.append("(SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '0'");
163 164
        	if(hasProfessorId){
164 165
            	sql.append(" AND PROFESSOR_ID = ?");
165 166
            }
166 167
        	if(hasKey){
167 168
        		sql.append(" AND (RESOURCE_NAME LIKE ? OR SUPPORTED_SERVICES LIKE ? OR SUBJECT LIKE ?)");
168 169
        	}
169
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME FROM RESOURCE WHERE STATUS = '1'");
170
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '1'");
170 171
        	if(hasProfessorId){
171 172
            	sql.append(" AND PROFESSOR_ID = ?");
172 173
            }
@ -187,14 +188,14 @@ public abstract class ResourceDao {
187 188
            --pageNo;
188 189
            int offset = (pageNo * pageSize);
189 190
            sql = new StringBuilder();
190
            sql.append("(SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME FROM RESOURCE WHERE STATUS = '0'");
191
            sql.append("(SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '0'");
191 192
        	if(hasProfessorId){
192 193
            	sql.append(" AND PROFESSOR_ID = ?");
193 194
            }
194 195
        	if(hasKey){
195 196
        		sql.append(" AND (RESOURCE_NAME LIKE ? OR SUPPORTED_SERVICES LIKE ? OR SUBJECT LIKE ?)");
196 197
        	}
197
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME FROM RESOURCE WHERE STATUS = '1'");
198
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '1'");
198 199
        	if(hasProfessorId){
199 200
            	sql.append(" AND PROFESSOR_ID = ?");
200 201
            }
@ -272,6 +273,185 @@ public abstract class ResourceDao {
272 273
                    resource.setPublishTime(publishTime);
273 274
                    resource.setCreateTime(rs.getString(12));
274 275
                    resource.setModifyTime(rs.getString(13));
276
                    int pageViews = rs.getInt(14);
277
                    if(rs.wasNull()){
278
                    	pageViews = 0;
279
                    }
280
                    resource.setPageViews(pageViews);
281
                    resources.add(resource);
282
                }
283
                return queryResult;
284
            }finally{
285
                try{rs.close();}catch(Exception e3){}
286
            }
287
        }finally{
288
            try{ps.close();}catch(Exception e4){}
289
        }
290
    }
291
	
292
	public PageQueryResult<Resource> querySelfForOrg(Connection con,String orgId,@Nullable String key,int pageSize,int pageNo) throws SQLException{
293
        int total = 0;
294
        PageQueryResult<Resource> queryResult = new PageQueryResult<Resource>();
295
        int index = 1;
296
        boolean hasOrgId = null != orgId;
297
        boolean hasKey = null != key;
298
        StringBuilder sql = new StringBuilder();
299
        sql.append("SELECT COUNT(1) FROM RESOURCE WHERE STATUS IN('0','1')");
300
        if(hasOrgId){
301
        	sql.append(" AND ORG_ID = ?");
302
        }
303
        if(hasKey){
304
        	sql.append(" AND (RESOURCE_NAME LIKE ? OR SUPPORTED_SERVICES LIKE ? OR SUBJECT LIKE ?)");
305
        }
306
        PreparedStatement ps = con.prepareStatement(sql.toString());
307
        try{
308
        	if(hasOrgId){
309
        		ps.setString(index++, orgId);
310
        	}
311
        	if(hasKey){
312
        		ps.setString(index++, key);
313
        		ps.setString(index++, key);
314
        		ps.setString(index++, key);
315
        	}
316
        	queryResult.setPageSize(pageSize);
317
            ResultSet rs = ps.executeQuery();
318
            try{
319
                rs.next();
320
                total = rs.getInt(1);
321
            }finally{
322
                try{rs.close();}catch(Exception e1){}
323
            }
324
        }finally{
325
            try{ps.close();}catch(Exception e2){}
326
        }
327
        queryResult.setTotal(total);
328
        if(0== total){
329
        	queryResult.setPageNo(1);
330
        	queryResult.setData(Collections.<Resource>emptyList());
331
            return queryResult;
332
        }
333
        boolean firstPage = (1 == pageNo);
334
        if(firstPage){
335
        	queryResult.setPageNo(1);
336
        	sql = new StringBuilder();
337
        	sql.append("(SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,ORG_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '0'");
338
        	if(hasOrgId){
339
            	sql.append(" AND ORG_ID = ?");
340
            }
341
        	if(hasKey){
342
        		sql.append(" AND (RESOURCE_NAME LIKE ? OR SUPPORTED_SERVICES LIKE ? OR SUBJECT LIKE ?)");
343
        	}
344
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,ORG_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '1'");
345
        	if(hasOrgId){
346
            	sql.append(" AND ORG_ID = ?");
347
            }
348
        	if(hasKey){
349
        		sql.append(" AND (RESOURCE_NAME LIKE ? OR SUPPORTED_SERVICES LIKE ? OR SUBJECT LIKE ?)");
350
        	}
351
        	sql.append(" ORDER BY PUBLISH_TIME DESC)");
352
        	sql.append(" LIMIT ").append(pageSize);
353
        }else{
354
            int pageNum = total / pageSize;
355
            if(total % pageSize != 0){
356
                ++pageNum;
357
            }
358
            if(pageNo > pageNum){
359
                pageNo = pageNum;
360
            }
361
            queryResult.setPageNo(pageNo);
362
            --pageNo;
363
            int offset = (pageNo * pageSize);
364
            sql = new StringBuilder();
365
            sql.append("(SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,ORG_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '0'");
366
        	if(hasOrgId){
367
            	sql.append(" AND ORG_ID = ?");
368
            }
369
        	if(hasKey){
370
        		sql.append(" AND (RESOURCE_NAME LIKE ? OR SUPPORTED_SERVICES LIKE ? OR SUBJECT LIKE ?)");
371
        	}
372
        	sql.append(" ORDER BY MODIFY_TIME DESC) UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,ORG_ID,PUBLISH_TIME,CREATE_TIME,MODIFY_TIME,PAGE_VIEWS FROM RESOURCE WHERE STATUS = '1'");
373
        	if(hasOrgId){
374
            	sql.append(" AND ORG_ID = ?");
375
            }
376
        	if(hasKey){
377
        		sql.append(" AND (RESOURCE_NAME LIKE ? OR SUPPORTED_SERVICES LIKE ? OR SUBJECT LIKE ?)");
378
        	}
379
        	sql.append(" ORDER BY PUBLISH_TIME DESC)");
380
            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
381
        }
382
        ps = con.prepareStatement(sql.toString());
383
        index = 1;
384
        try{
385
        	if(hasOrgId){
386
        		ps.setString(index++, orgId);
387
        	}
388
        	if(hasKey){
389
        		ps.setString(index++, key);
390
        		ps.setString(index++, key);
391
        		ps.setString(index++, key);
392
        	}
393
        	if(hasOrgId){
394
        		ps.setString(index++, orgId);
395
        	}
396
        	if(hasKey){
397
        		ps.setString(index++, key);
398
        		ps.setString(index++, key);
399
        		ps.setString(index++, key);
400
        	}
401
            ResultSet rs = ps.executeQuery();
402
            try{
403
                List<Resource> resources = new ArrayList<Resource>();
404
                queryResult.setData(resources);
405
                int size = 0;
406
                while((size<pageSize) && rs.next()){
407
                    ++size;
408
                    Resource resource =  new Resource();
409
                    resource.setResourceId(rs.getString(1));
410
                    resource.setResourceName(rs.getString(2));
411
                    String subject = rs.getString(3);
412
                    if(rs.wasNull()){
413
                    	subject = null;
414
                    }
415
                    resource.setSubject(subject);
416
                    resource.setSupportedServices(rs.getString(4));
417
                    String orgName = rs.getString(5);
418
                    if(rs.wasNull()){
419
                    	orgName = null;
420
                    }
421
                    resource.setOrgName(orgName);
422
                    String spec = rs.getString(6);
423
                    if(rs.wasNull()){
424
                    	spec = null;
425
                    }
426
                    resource.setSpec(spec);
427
                    String parameter = rs.getString(7);
428
                    if(rs.wasNull()){
429
                    	parameter = null;
430
                    }
431
                    resource.setParameter(parameter);
432
                    String status = rs.getString(8);
433
                    if(rs.wasNull()){
434
                    	status = null;
435
                    }
436
                    resource.setStatus(status);
437
                    String descp = rs.getString(9);
438
                    if(rs.wasNull()){
439
                    	descp = null;
440
                    }
441
                    resource.setDescp(descp);
442
                    resource.setOrgId(rs.getString(10));
443
                    String publishTime = rs.getString(11);
444
                    if(rs.wasNull()){
445
                    	publishTime = null;
446
                    }
447
                    resource.setPublishTime(publishTime);
448
                    resource.setCreateTime(rs.getString(12));
449
                    resource.setModifyTime(rs.getString(13));
450
                    int pageViews = rs.getInt(14);
451
                    if(rs.wasNull()){
452
                    	pageViews = 0;
453
                    }
454
                    resource.setPageViews(pageViews);
275 455
                    resources.add(resource);
276 456
                }
277 457
                return queryResult;
@ -288,7 +468,7 @@ public abstract class ResourceDao {
288 468
        boolean hasProId = null != professorId;
289 469
        boolean hasResId = null != resourceId;
290 470
        StringBuilder sql = new StringBuilder();
291
        sql.append("SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,PAGE_VIEWS FROM RESOURCE");
471
        sql.append("SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,PAGE_VIEWS,ORG_ID,RESOURCE_TYPE FROM RESOURCE");
292 472
        sql.append(" WHERE STATUS = '1'");
293 473
        if(hasResId){
294 474
        	sql.append(" AND RESOURCE_ID != ?");
@ -346,7 +526,11 @@ public abstract class ResourceDao {
346 526
                    	descp = null;
347 527
                    }
348 528
                    resource.setDescp(descp);
349
                    resource.setProfessorId(rs.getString(10));
529
                    String proId = rs.getString(10);
530
                    if(rs.wasNull()){
531
                    	proId = null;
532
                    }
533
                    resource.setProfessorId(proId);
350 534
                    String publishTime = rs.getString(11);
351 535
                    if(rs.wasNull()){
352 536
                    	publishTime = null;
@ -357,6 +541,107 @@ public abstract class ResourceDao {
357 541
                    	pageViews = 0;
358 542
                    }
359 543
                    resource.setPageViews(pageViews);
544
                    String orgid = rs.getString(13);
545
                    if(rs.wasNull()){
546
                    	orgid = null;
547
                    }
548
                    resource.setOrgId(orgid);
549
                    resource.setResourceType(rs.getString(14));
550
                    resources.add(resource);
551
                }
552
                return resources;
553
            }finally{
554
                try{rs.close();}catch(Exception e1){}
555
            }
556
        }finally{
557
            try{ps.close();}catch(Exception e2){}
558
        }
559
	}
560
	
561
	public List<Resource> queryByOrgId(Connection con,String orgId,String resourceId,int rows) throws SQLException{
562
		int index = 1;
563
        boolean hasOrgId = null != orgId;
564
        boolean hasResId = null != resourceId;
565
        StringBuilder sql = new StringBuilder();
566
        sql.append("SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,PAGE_VIEWS,ORG_ID,RESOURCE_TYPE FROM RESOURCE");
567
        sql.append(" WHERE STATUS = '1'");
568
        if(hasResId){
569
        	sql.append(" AND RESOURCE_ID != ?");
570
        }
571
        if(hasOrgId){
572
        	sql.append(" AND ORG_ID = ?");
573
        	sql.append(" ORDER BY PUBLISH_TIME DESC");
574
        }else{
575
        	sql.append(" ORDER BY PAGE_VIEWS DESC");
576
        }
577
        sql.append(" LIMIT ").append(rows);
578
        PreparedStatement ps = con.prepareStatement(sql.toString());
579
        try{
580
        	if(hasResId){
581
        		ps.setString(index++, resourceId);
582
        	}
583
        	if(hasOrgId){
584
        		ps.setString(index++, orgId);
585
        	}
586
            ResultSet rs = ps.executeQuery();
587
            try{
588
                List<Resource> resources = new ArrayList<Resource>();
589
                while(rs.next()){
590
                    Resource resource =  new Resource();
591
                    resource.setResourceId(rs.getString(1));
592
                    resource.setResourceName(rs.getString(2));
593
                    String subject = rs.getString(3);
594
                    if(rs.wasNull()){
595
                    	subject = null;
596
                    }
597
                    resource.setSubject(subject);
598
                    resource.setSupportedServices(rs.getString(4));
599
                    String orgName = rs.getString(5);
600
                    if(rs.wasNull()){
601
                    	orgName = null;
602
                    }
603
                    resource.setOrgName(orgName);
604
                    String spec = rs.getString(6);
605
                    if(rs.wasNull()){
606
                    	spec = null;
607
                    }
608
                    resource.setSpec(spec);
609
                    String parameter = rs.getString(7);
610
                    if(rs.wasNull()){
611
                    	parameter = null;
612
                    }
613
                    resource.setParameter(parameter);
614
                    String status = rs.getString(8);
615
                    if(rs.wasNull()){
616
                    	status = null;
617
                    }
618
                    resource.setStatus(status);
619
                    String descp = rs.getString(9);
620
                    if(rs.wasNull()){
621
                    	descp = null;
622
                    }
623
                    resource.setDescp(descp);
624
                    String proId = rs.getString(10);
625
                    if(rs.wasNull()){
626
                    	proId = null;
627
                    }
628
                    resource.setProfessorId(proId);
629
                    String publishTime = rs.getString(11);
630
                    if(rs.wasNull()){
631
                    	publishTime = null;
632
                    }
633
                    resource.setPublishTime(publishTime);
634
                    int pageViews = rs.getInt(12);
635
                    if(rs.wasNull()){
636
                    	pageViews = 0;
637
                    }
638
                    resource.setPageViews(pageViews);
639
                    String orgid = rs.getString(13);
640
                    if(rs.wasNull()){
641
                    	orgid = null;
642
                    }
643
                    resource.setOrgId(orgid);
644
                    resource.setResourceType(rs.getString(14));
360 645
                    resources.add(resource);
361 646
                }
362 647
                return resources;
@ -382,7 +667,7 @@ public abstract class ResourceDao {
382 667
        boolean hasKeys = null != keys;
383 668
        boolean hasResId = null != resourceId;
384 669
        StringBuilder sql = new StringBuilder();
385
        sql.append("SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,PAGE_VIEWS FROM RESOURCE");
670
        sql.append("SELECT RESOURCE_ID,RESOURCE_NAME,SUBJECT,SUPPORTED_SERVICES,ORG_NAME,SPEC,PARAMETER,STATUS,DESCP,PROFESSOR_ID,PUBLISH_TIME,PAGE_VIEWS,ORG_ID,RESOURCE_TYPE FROM RESOURCE");
386 671
        sql.append(" WHERE STATUS = '1'");
387 672
        if(hasResId){
388 673
        	sql.append(" AND RESOURCE_ID != ?");
@ -458,6 +743,12 @@ public abstract class ResourceDao {
458 743
                    	pageViews = 0;
459 744
                    }
460 745
                    resource.setPageViews(pageViews);
746
                    String orgid = rs.getString(13);
747
                    if(rs.wasNull()){
748
                    	orgid = null;
749
                    }
750
                    resource.setOrgId(orgid);
751
                    resource.setResourceType(rs.getString(14));
461 752
                    resources.add(resource);
462 753
                }
463 754
                return resources;
@ -783,6 +1074,21 @@ public abstract class ResourceDao {
783 1074
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
784 1075
	public abstract List<Resource> queryByName(Connection con, @Like String resourceName, int rows) throws SQLException;
785 1076
	
1077
	@SelectList
1078
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
1079
	@Where("STATUS = '1'")
1080
	public abstract List<Resource> queryProPublish(Connection con,String professorId) throws SQLException;
1081
	
1082
	@SelectList
1083
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
1084
	@Where("STATUS IN ('0','1')")
1085
	public abstract List<Resource> queryForDesk(Connection con,String professorId) throws SQLException;
1086
	
1087
	@SelectList
1088
	@OrderBy("ORDER BY PUBLISH_TIME DESC")
1089
	@Where("STATUS = '1'")
1090
	public abstract List<Resource> queryOrgPublish(Connection con,String orgId) throws SQLException;
1091
	
786 1092
	/**
787 1093
	 * 按专家ID查询发布的所有资源
788 1094
	 * @param con

+ 197 - 0
src/main/java/com/ekexiu/portal/dao/ResourceTmpDao.java

@ -0,0 +1,197 @@
1
package com.ekexiu.portal.dao;
2

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

11
import org.jfw.apt.orm.annotation.dao.DAO;
12
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
13
import org.jfw.util.PageQueryResult;
14

15
import com.ekexiu.portal.po.ResourceTmp;
16

17
@DAO
18
public abstract class ResourceTmpDao {
19
	@Insert
20
	public abstract int insert(Connection con,ResourceTmp rt) throws SQLException;
21
	
22
	public PageQueryResult<ResourceTmp> query(Connection con,String orgName,String key,int pageSize,int pageNo) throws SQLException{
23
        int total = 0;
24
        int index = 1;
25
        PageQueryResult<ResourceTmp> queryResult = new PageQueryResult<ResourceTmp>();
26
        boolean hasKey = null != key;
27
        StringBuilder sql = new StringBuilder();
28
        sql.append(" WHERE ORG_NAME = ?");
29
        if(hasKey){
30
        	sql.append(" AND (NAME LIKE ? OR DOMAIN LIKE ? OR MAJOR_FUNC LIKE ?)");
31
        }
32
        StringBuilder whereSql = sql;
33
        sql = new StringBuilder();
34
        sql.append("SELECT COUNT(1) FROM RESOURCE_TMP");
35
        sql.append(whereSql);
36
        PreparedStatement ps = con.prepareStatement(sql.toString());
37
        try{
38
        	ps.setString(index++, orgName);
39
        	if(hasKey){
40
        		ps.setString(index++, key);
41
        		ps.setString(index++, key);
42
        		ps.setString(index++, key);
43
        	}
44
        	queryResult.setPageSize(pageSize);
45
            ResultSet rs = ps.executeQuery();
46
            try{
47
                rs.next();
48
                total = rs.getInt(1);
49
            }finally{
50
                try{rs.close();}catch(Exception e1){}
51
            }
52
        }finally{
53
            try{ps.close();}catch(Exception e2){}
54
        }
55
        queryResult.setTotal(total);
56
        if(0 == total){
57
        	queryResult.setPageNo(1);
58
        	queryResult.setData(Collections.<ResourceTmp>emptyList());
59
            return queryResult;
60
        }
61
        index = 1;
62
        boolean firstPage = (1 == pageNo);
63
        sql = new StringBuilder();
64
        if(firstPage){
65
        	queryResult.setPageNo(1);
66
            sql.append("SELECT ID,NAME,DOMAIN,COMP,SPEC,IMG,PARAMETER,MAJOR_FUNC,COST,ENABLED_TIME,COMMUNICATION,ORG_NAME,CORPORATION,LINKMAN,TEL,EMAIL,ADDR,ZIP_CODE,CREATE_TIME,MODIFY_TIME FROM RESOURCE_TMP");
67
            sql.append(whereSql);
68
            sql.append(" ORDER BY ID");
69
            sql.append(" LIMIT ").append(pageSize);
70
        }else{
71
            int pageNum = total / pageSize;
72
            if(total % pageSize != 0){
73
                ++pageNum;
74
            }
75
            if(pageNo > pageNum){
76
                pageNo = pageNum;
77
            }
78
            queryResult.setPageNo(pageNo);
79
            --pageNo;
80
            int offset = (pageNo * pageSize);
81
            sql.append("SELECT ID,NAME,DOMAIN,COMP,SPEC,IMG,PARAMETER,MAJOR_FUNC,COST,ENABLED_TIME,COMMUNICATION,ORG_NAME,CORPORATION,LINKMAN,TEL,EMAIL,ADDR,ZIP_CODE,CREATE_TIME,MODIFY_TIME FROM RESOURCE_TMP");
82
            sql.append(whereSql);
83
            sql.append(" ORDER BY ID");
84
            sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
85
        }
86
        ps = con.prepareStatement(sql.toString());
87
        try{
88
        	ps.setString(index++, orgName);
89
        	if(hasKey){
90
        		ps.setString(index++, key);
91
        		ps.setString(index++, key);
92
        		ps.setString(index++, key);
93
        	}
94
            ResultSet rs = ps.executeQuery();
95
            try{
96
                List<ResourceTmp> resourceTmps = new ArrayList<ResourceTmp>();
97
                queryResult.setData(resourceTmps);
98
                int size = 0;
99
                while((size<pageSize) && rs.next()){
100
                    ++size;
101
                    ResourceTmp resourceTmp =  new ResourceTmp();
102
                    resourceTmp.setId(rs.getString(1));
103
                    resourceTmp.setName(rs.getString(2));
104
                    String domain = rs.getString(3);
105
                    if(rs.wasNull()){
106
                    	domain = null;
107
                    }
108
                    resourceTmp.setDomain(domain);
109
                    String comp = rs.getString(4);
110
                    if(rs.wasNull()){
111
                    	comp = null;
112
                    }
113
                    resourceTmp.setComp(comp);
114
                    String spec = rs.getString(5);
115
                    if(rs.wasNull()){
116
                    	spec = null;
117
                    }
118
                    resourceTmp.setSpec(spec);
119
                    String img = rs.getString(6);
120
                    if(rs.wasNull()){
121
                        img = null;
122
                    }
123
                    resourceTmp.setImg(img);
124
                    String parameter = rs.getString(7);
125
                    if(rs.wasNull()){
126
                    	parameter = null;
127
                    }
128
                    resourceTmp.setParameter(parameter);
129
                    String majorFunc = rs.getString(8);
130
                    if(rs.wasNull()){
131
                    	majorFunc = null;
132
                    }
133
                    resourceTmp.setMajorFunc(majorFunc);
134
                    Double cost = rs.getDouble(9);
135
                    if(rs.wasNull()){
136
                    	cost = null;
137
                    }
138
                    resourceTmp.setCost(cost);
139
                    String enabledTime = rs.getString(10);
140
                    if(rs.wasNull()){
141
                    	enabledTime = null;
142
                    }
143
                    resourceTmp.setEnabledTime(enabledTime);
144
                    String communication = rs.getString(11);
145
                    if(rs.wasNull()){
146
                    	communication = null;
147
                    }
148
                    resourceTmp.setCommunication(communication);
149
                    String orgname = rs.getString(12);
150
                    if(rs.wasNull()){
151
                    	orgname = null;
152
                    }
153
                    resourceTmp.setOrgName(orgname);
154
                    String corporation = rs.getString(13);
155
                    if(rs.wasNull()){
156
                    	corporation = null;
157
                    }
158
                    resourceTmp.setCorporation(corporation);
159
                    String linkman = rs.getString(14);
160
                    if(rs.wasNull()){
161
                    	linkman = null;
162
                    }
163
                    resourceTmp.setLinkman(linkman);
164
                    String tel = rs.getString(15);
165
                    if(rs.wasNull()){
166
                    	tel = null;
167
                    }
168
                    resourceTmp.setTel(tel);
169
                    String email = rs.getString(16);
170
                    if(rs.wasNull()){
171
                    	email = null;
172
                    }
173
                    resourceTmp.setEmail(email);
174
                    String addr = rs.getString(17);
175
                    if(rs.wasNull()){
176
                        addr = null;
177
                    }
178
                    resourceTmp.setAddr(addr);
179
                    String zipCode = rs.getString(18);
180
                    if(rs.wasNull()){
181
                    	zipCode = null;
182
                    }
183
                    resourceTmp.setZipCode(zipCode);
184
                    resourceTmp.setCreateTime(rs.getString(19));
185
                    resourceTmp.setModifyTime(rs.getString(20));
186
                    resourceTmps.add(resourceTmp);
187
                }
188
                return queryResult;
189
            }finally{
190
                try{rs.close();}catch(Exception e3){}
191
            }
192
        }finally{
193
            try{ps.close();}catch(Exception e4){}
194
        }
195
    }
196
	
197
}

+ 45 - 0
src/main/java/com/ekexiu/portal/po/OrgResStaff.java

@ -0,0 +1,45 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.Table;
5
import org.jfw.apt.orm.annotation.entry.Unique;
6
import org.jfw.apt.orm.annotation.entry.Uniques;
7
import org.jfw.apt.orm.core.enums.DE;
8

9
import com.ekexiu.portal.basepo.CreateTimeSupported;
10
import com.ekexiu.portal.pojo.EditProfessor;
11

12
@Table
13
@Uniques(@Unique(clolumns = { "resourceId", "professorId" }, name = "ORG_RES_STAFF_UQ"))
14
public class OrgResStaff implements CreateTimeSupported {
15
	private String resourceId;
16
	private String professorId;
17
	private String createTime;
18
	private EditProfessor professor;
19
	public EditProfessor getProfessor() {
20
		return professor;
21
	}
22
	public void setProfessor(EditProfessor professor) {
23
		this.professor = professor;
24
	}
25
	@Column(DE.id_32)
26
	public String getResourceId() {
27
		return resourceId;
28
	}
29
	public void setResourceId(String resourceId) {
30
		this.resourceId = resourceId;
31
	}
32
	@Column(DE.id_32)
33
	public String getProfessorId() {
34
		return professorId;
35
	}
36
	public void setProfessorId(String professorId) {
37
		this.professorId = professorId;
38
	}
39
	public String getCreateTime() {
40
		return createTime;
41
	}
42
	public void setCreateTime(String createTime) {
43
		this.createTime = createTime;
44
	}
45
}

+ 42 - 1
src/main/java/com/ekexiu/portal/po/Resource.java

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

13 13
import com.ekexiu.portal.basepo.CreateTimeSupported;
14 14
import com.ekexiu.portal.basepo.ModifyTimeSupported;
15
import com.ekexiu.portal.pojo.EditOrganization;
15 16
import com.ekexiu.portal.pojo.EditProfessor;
16 17

17 18
@PrimaryKey("resourceId")
@ -45,6 +46,7 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
45 46
	private String professorId;
46 47
	private Professor professor;
47 48
	private EditProfessor editProfessor;
49
	private EditOrganization organization;
48 50
	private List<Image> images;
49 51
	/**
50 52
	 * 资源所属(个人/机构)
@ -65,6 +67,15 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
65 67
	 * 浏览量
66 68
	 */
67 69
	private int pageViews;
70
	/**
71
	 * 所在单位
72
	 */
73
	private String comp;
74
	/**
75
	 * 资源类型(1-个人资源,2-企业资源)
76
	 */
77
	private String resourceType;
78
	private String orgId;
68 79
	
69 80
	public List<Image> getImages() {
70 81
		return images;
@ -73,6 +84,12 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
73 84
		this.images = images;
74 85
	}
75 86
	
87
	public EditOrganization getOrganization() {
88
		return organization;
89
	}
90
	public void setOrganization(EditOrganization organization) {
91
		this.organization = organization;
92
	}
76 93
	public Professor getProfessor() {
77 94
		return professor;
78 95
	}
@ -167,7 +184,7 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
167 184
		this.descp = descp;
168 185
	}
169 186
	
170
	@Column(DE.id_32)
187
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(32)",nullable=true,renewable=false)
171 188
	public String getProfessorId() {
172 189
		return professorId;
173 190
	}
@ -229,4 +246,28 @@ public class Resource implements CreateTimeSupported, ModifyTimeSupported{
229 246
		this.pageViews = pageViews;
230 247
	}
231 248
	
249
	@Column(handlerClass=StringHandler.class,nullable=true,renewable=false)
250
	public String getComp() {
251
		return comp;
252
	}
253
	public void setComp(String comp) {
254
		this.comp = comp;
255
	}
256
	
257
	@Column(handlerClass=FixLenStringHandler.class,nullable=true,renewable=false)
258
	public String getResourceType() {
259
		return resourceType;
260
	}
261
	public void setResourceType(String resourceType) {
262
		this.resourceType = resourceType;
263
	}
264
	
265
	@Column(handlerClass=FixLenStringHandler.class,dbType="CHAR(32)",nullable=true,renewable=false)
266
	public String getOrgId() {
267
		return orgId;
268
	}
269
	public void setOrgId(String orgId) {
270
		this.orgId = orgId;
271
	}
272
	
232 273
}

+ 192 - 0
src/main/java/com/ekexiu/portal/po/ResourceTmp.java

@ -0,0 +1,192 @@
1
package com.ekexiu.portal.po;
2

3
import org.jfw.apt.orm.annotation.entry.Column;
4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.core.enums.DE;
7

8
import com.ekexiu.portal.basepo.CreateTimeSupported;
9
import com.ekexiu.portal.basepo.ModifyTimeSupported;
10

11
@Table
12
@PrimaryKey("id")
13
public class ResourceTmp implements CreateTimeSupported,ModifyTimeSupported {
14
	private String id;
15
	//设备名称 
16
	private String name;
17
	//所属领域
18
	private String domain;
19
	//所在单位 
20
	private String comp;
21
	//厂商及型号规格 
22
	private String spec;
23
	//图片 
24
	private String img;
25
	//性能参数 
26
	private String parameter;
27
	//主要功能及应用领域 
28
	private String majorFunc;
29
	//仪器原值(万元) 
30
	private Double cost;
31
	//启用时间 
32
	private String enabledTime;
33
	//联系方式
34
	private String communication;
35
	//机构名称
36
	private String orgName;
37
	//负责人
38
	private String corporation ;
39
	//联系人 
40
	private String linkman; 
41
	//电话
42
	private String tel;
43
	//邮箱
44
	private String email;
45
	//地址 
46
	private String addr;
47
	//邮编
48
	private String zipCode;
49
	private String createTime;
50
	private String modifyTime;
51
	
52
	@Column(DE.string_de)
53
	public String getId() {
54
		return id;
55
	}
56
	public void setId(String id) {
57
		this.id = id;
58
	}
59
	@Column(DE.text_de)
60
	public String getName() {
61
		return name;
62
	}
63
	public void setName(String name) {
64
		this.name = name;
65
	}
66
	@Column(DE.Text_de)
67
	public String getDomain() {
68
		return domain;
69
	}
70
	public void setDomain(String domain) {
71
		this.domain = domain;
72
	}
73
	@Column(DE.Text_de)
74
	public String getComp() {
75
		return comp;
76
	}
77
	public void setComp(String comp) {
78
		this.comp = comp;
79
	}
80
	@Column(DE.Text_de)
81
	public String getSpec() {
82
		return spec;
83
	}
84
	public void setSpec(String spec) {
85
		this.spec = spec;
86
	}
87
	@Column(DE.Text_de)
88
	public String getImg() {
89
		return img;
90
	}
91
	public void setImg(String img) {
92
		this.img = img;
93
	}
94
	@Column(DE.Text_de)
95
	public String getParameter() {
96
		return parameter;
97
	}
98
	public void setParameter(String parameter) {
99
		this.parameter = parameter;
100
	}
101
	@Column(DE.Text_de)
102
	public String getMajorFunc() {
103
		return majorFunc;
104
	}
105
	public void setMajorFunc(String majorFunc) {
106
		this.majorFunc = majorFunc;
107
	}
108
	@Column(DE.Double_de)
109
	public Double getCost() {
110
		return cost;
111
	}
112
	public void setCost(Double cost) {
113
		this.cost = cost;
114
	}
115
	@Column(DE.Text_de)
116
	public String getEnabledTime() {
117
		return enabledTime;
118
	}
119
	public void setEnabledTime(String enabledTime) {
120
		this.enabledTime = enabledTime;
121
	}
122
	@Column(DE.Text_de)
123
	public String getCommunication() {
124
		return communication;
125
	}
126
	
127
	public void setCommunication(String communication) {
128
		this.communication = communication;
129
	}
130
	@Column(DE.Text_de)
131
	public String getOrgName() {
132
		return orgName;
133
	}
134
	public void setOrgName(String orgName) {
135
		this.orgName = orgName;
136
	}
137
	@Column(DE.Text_de)
138
	public String getCorporation() {
139
		return corporation;
140
	}
141
	public void setCorporation(String corporation) {
142
		this.corporation = corporation;
143
	}
144
	@Column(DE.Text_de)
145
	public String getLinkman() {
146
		return linkman;
147
	}
148
	public void setLinkman(String linkman) {
149
		this.linkman = linkman;
150
	}
151
	@Column(DE.Text_de)
152
	public String getTel() {
153
		return tel;
154
	}
155
	public void setTel(String tel) {
156
		this.tel = tel;
157
	}
158
	@Column(DE.Text_de)
159
	public String getEmail() {
160
		return email;
161
	}
162
	public void setEmail(String email) {
163
		this.email = email;
164
	}
165
	@Column(DE.Text_de)
166
	public String getAddr() {
167
		return addr;
168
	}
169
	public void setAddr(String addr) {
170
		this.addr = addr;
171
	}
172
	@Column(DE.Text_de)
173
	public String getZipCode() {
174
		return zipCode;
175
	}
176
	public void setZipCode(String zipCode) {
177
		this.zipCode = zipCode;
178
	}
179
	public String getCreateTime() {
180
		return createTime;
181
	}
182
	public void setCreateTime(String createTime) {
183
		this.createTime = createTime;
184
	}
185
	public String getModifyTime() {
186
		return modifyTime;
187
	}
188
	public void setModifyTime(String modifyTime) {
189
		this.modifyTime = modifyTime;
190
	}
191
	
192
}

+ 18 - 0
src/main/java/com/ekexiu/portal/service/ArticleService.java

@ -584,12 +584,30 @@ public class ArticleService {
584 584
		return this.articleDao.queryPro(con, professorId);
585 585
	}
586 586
	
587
	@Get
588
	@Path("/qaProPublish")
589
	public List<Article> queryProPublish(@JdbcConn Connection con, String professorId) throws SQLException{
590
		return this.articleDao.queryProPublish(con, professorId);
591
	}
592
	
593
	@Get
594
	@Path("/qaForDesk")
595
	public List<Article> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException{
596
		return this.articleDao.queryForDesk(con, professorId);
597
	}
598
	
587 599
	@Get
588 600
	@Path("/qaOrg")
589 601
	public List<Article> queryOrg(@JdbcConn Connection con,String orgId)throws SQLException{
590 602
		return this.articleDao.queryOrg(con, orgId);
591 603
	}
592 604
	
605
	@Get
606
	@Path("/qaOrgPublish")
607
	public List<Article> queryOrgPublish(@JdbcConn Connection con,String orgId)throws SQLException{
608
		return this.articleDao.queryOrgPublish(con, orgId);
609
	}
610
	
593 611
	@Get
594 612
	@Path("/qlOrg")
595 613
	public List<Article> queryLimitOrg(@JdbcConn Connection con,String orgId,@DefaultValue("com.ekexiu.portal.service.ArticleService.MAX_MODIFYTIME") String modifyTime,@DefaultValue("20") int rows)throws SQLException{

+ 11 - 0
src/main/java/com/ekexiu/portal/service/ProfessorService.java

@ -26,6 +26,7 @@ import com.ekexiu.portal.dao.ArticleDao;
26 26
import com.ekexiu.portal.dao.HonorDao;
27 27
import com.ekexiu.portal.dao.ImageDao;
28 28
import com.ekexiu.portal.dao.OrgDao;
29
import com.ekexiu.portal.dao.OrgResStaffDao;
29 30
import com.ekexiu.portal.dao.PaperDao;
30 31
import com.ekexiu.portal.dao.PartTimeJobDao;
31 32
import com.ekexiu.portal.dao.PatentDao;
@ -88,6 +89,8 @@ public class ProfessorService {
88 89
	private HonorDao honorDao;
89 90
	@Autowrie
90 91
	private ProjectDao projectDao;
92
	@Autowrie
93
	private OrgResStaffDao orgResStaffDao;
91 94

92 95
	public GrowthLogService getGrowthLogService() {
93 96
		return growthLogService;
@ -250,6 +253,14 @@ public class ProfessorService {
250 253
		this.imageDao = imageDao;
251 254
	}
252 255

256
	public OrgResStaffDao getOrgResStaffDao() {
257
		return orgResStaffDao;
258
	}
259

260
	public void setOrgResStaffDao(OrgResStaffDao orgResStaffDao) {
261
		this.orgResStaffDao = orgResStaffDao;
262
	}
263

253 264
	@Post
254 265
	@Path
255 266
	public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName)

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

@ -25,13 +25,17 @@ import com.ekexiu.portal.dao.ArticleDao;
25 25
import com.ekexiu.portal.dao.ArticleResDao;
26 26
import com.ekexiu.portal.dao.ImageDao;
27 27
import com.ekexiu.portal.dao.OperationDao;
28
import com.ekexiu.portal.dao.OrgDao;
29
import com.ekexiu.portal.dao.OrgResStaffDao;
28 30
import com.ekexiu.portal.dao.ProfessorDao;
29 31
import com.ekexiu.portal.dao.ResourceDao;
30 32
import com.ekexiu.portal.dao.WatchDao;
31 33
import com.ekexiu.portal.po.ArticleRes;
32 34
import com.ekexiu.portal.po.Image;
33 35
import com.ekexiu.portal.po.Operation;
36
import com.ekexiu.portal.po.OrgResStaff;
34 37
import com.ekexiu.portal.po.Resource;
38
import com.ekexiu.portal.pojo.EditOrganization;
35 39
import com.ekexiu.portal.pojo.EditProfessor;
36 40

37 41
@Path("/resource")
@ -57,6 +61,10 @@ public class ResourceService {
57 61
	private ArticleResDao articleResDao;
58 62
	@Autowrie
59 63
	private ArticleDao articleDao;
64
	@Autowrie
65
	private OrgResStaffDao orgResStaffDao;
66
	@Autowrie
67
	private OrgDao orgDao;
60 68

61 69
	public String getTimeFormat() {
62 70
		return timeFormat;
@ -146,6 +154,22 @@ public class ResourceService {
146 154
		this.articleDao = articleDao;
147 155
	}
148 156

157
	public OrgResStaffDao getOrgResStaffDao() {
158
		return orgResStaffDao;
159
	}
160

161
	public void setOrgResStaffDao(OrgResStaffDao orgResStaffDao) {
162
		this.orgResStaffDao = orgResStaffDao;
163
	}
164

165
	public OrgDao getOrgDao() {
166
		return orgDao;
167
	}
168

169
	public void setOrgDao(OrgDao orgDao) {
170
		this.orgDao = orgDao;
171
	}
172

149 173
	private String publishTime(){
150 174
		SimpleDateFormat df = new SimpleDateFormat(this.timeFormat);
151 175
		String publishTime = df.format(new Date());
@ -179,6 +203,7 @@ public class ResourceService {
179 203
			resource.setStatus("1");
180 204
			resource.setPageViews(0);
181 205
			resource.setPublishTime(this.publishTime());
206
			resource.setResourceType("1");
182 207
			this.resourceDao.insert(con, resource);
183 208
			//this.growthLogService.addResource(con, resource.getProfessorId());
184 209
			return resourceId;
@ -187,15 +212,15 @@ public class ResourceService {
187 212
			if(imageIds != null){
188 213
				imageLength = imageIds.length;
189 214
				List<Image> images = this.imageDao.queryRes(con, resource.getResourceId());
215
				this.imageDao.updateAllSort(con, resource.getResourceId(), 0);
190 216
				for (int i = 0; i < imageLength; i++) {
191 217
					for (Image image : images) {
192 218
						if(image.getImageId().equals(imageIds[i])){
193 219
							this.imageDao.updateSort(con, image.getImageId(), i+1);
194
						}else{
195
							this.imageDao.deleteId(con, image.getImageId());
196 220
						}
197 221
					}
198 222
				}
223
				this.imageDao.deleteBySort(con, resource.getResourceId(), 0);
199 224
			}
200 225
			if(fns != null){
201 226
				if(imageIds == null){
@ -223,6 +248,7 @@ public class ResourceService {
223 248
			resource.setResourceId(resourceId);
224 249
			resource.setStatus("0");
225 250
			resource.setPageViews(0);
251
			resource.setResourceType("1");
226 252
			this.resourceDao.insert(con, resource);
227 253
			return resourceId;
228 254
		}else if(resource.getResourceId().trim().length() == 32){
@ -230,15 +256,15 @@ public class ResourceService {
230 256
			if(imageIds != null){
231 257
				imageLength = imageIds.length;
232 258
				List<Image> images = this.imageDao.queryRes(con, resource.getResourceId());
259
				this.imageDao.updateAllSort(con, resource.getResourceId(), 0);
233 260
				for (int i = 0; i < imageLength; i++) {
234 261
					for (Image image : images) {
235 262
						if(image.getImageId().equals(imageIds[i])){
236 263
							this.imageDao.updateSort(con, image.getImageId(), i+1);
237
						}else{
238
							this.imageDao.deleteId(con, image.getImageId());
239 264
						}
240 265
					}
241 266
				}
267
				this.imageDao.deleteBySort(con, resource.getResourceId(), 0);
242 268
			}
243 269
			if(fns != null){
244 270
				if(imageIds == null){
@ -266,6 +292,7 @@ public class ResourceService {
266 292
			resource.setResourceId(resourceId);
267 293
			resource.setStatus("2");
268 294
			resource.setPageViews(0);
295
			resource.setResourceType("1");
269 296
			this.resourceDao.insert(con, resource);
270 297
			return resourceId;
271 298
		}else if(resource.getResourceId().trim().length() == 32){
@ -273,15 +300,15 @@ public class ResourceService {
273 300
			if(imageIds != null){
274 301
				imageLength = imageIds.length;
275 302
				List<Image> images = this.imageDao.queryRes(con, resource.getResourceId());
303
				this.imageDao.updateAllSort(con, resource.getResourceId(), 0);
276 304
				for (int i = 0; i < imageLength; i++) {
277 305
					for (Image image : images) {
278 306
						if(image.getImageId().equals(imageIds[i])){
279 307
							this.imageDao.updateSort(con, image.getImageId(), i+1);
280
						}else{
281
							this.imageDao.deleteId(con, image.getImageId());
282 308
						}
283 309
					}
284 310
				}
311
				this.imageDao.deleteBySort(con, resource.getResourceId(), 0);
285 312
			}
286 313
			if(fns != null){
287 314
				if(imageIds == null){
@ -297,6 +324,129 @@ public class ResourceService {
297 324
		}
298 325
	}
299 326
	
327
	@Post
328
	@Path("/orgSave")
329
	public String orgSave(@JdbcConn(true) Connection con, Resource resource,@Nullable String[] fns,@Nullable String[] imageIds,
330
			@Nullable String[] professorIds) throws JfwBaseException, SQLException, IOException {
331
		if(resource.getResourceId() == null){
332
			String resourceId = StringUtil.buildUUID();
333
			if(fns != null){
334
				this.imagesService.saveImg(con, resourceId, fns);
335
			}
336
			resource.setResourceId(resourceId);
337
			resource.setStatus("1");
338
			resource.setPageViews(0);
339
			resource.setPublishTime(this.publishTime());
340
			resource.setResourceType("2");
341
			this.resourceDao.insert(con, resource);
342
			if(professorIds != null){
343
				for (String professorId : professorIds) {
344
					OrgResStaff orgResStaff = new OrgResStaff();
345
					orgResStaff.setResourceId(resourceId);
346
					orgResStaff.setProfessorId(professorId);
347
					this.orgResStaffDao.insert(con, orgResStaff);
348
				}
349
			}
350
			return resourceId;
351
		}else if(resource.getResourceId().trim().length() == 32){
352
			int imageLength = 0;
353
			if(imageIds != null){
354
				imageLength = imageIds.length;
355
				List<Image> images = this.imageDao.queryRes(con, resource.getResourceId());
356
				this.imageDao.updateAllSort(con, resource.getResourceId(), 0);
357
				for (int i = 0; i < imageLength; i++) {
358
					for (Image image : images) {
359
						if(image.getImageId().equals(imageIds[i])){
360
							this.imageDao.updateSort(con, image.getImageId(), i+1);
361
						}
362
					}
363
				}
364
				this.imageDao.deleteBySort(con, resource.getResourceId(), 0);
365
			}
366
			if(fns != null){
367
				if(imageIds == null){
368
					this.imageDao.deleteRes(con, resource.getResourceId());
369
				}
370
				this.imagesService.saveFns(con, resource.getResourceId(), fns, imageLength);
371
			}
372
			this.resourceDao.update(con, resource);
373
			this.resourceDao.updatePublishTime(con, resource.getResourceId(), "1", this.publishTime());
374
			this.orgResStaffDao.delete(con, resource.getResourceId());
375
			if(professorIds != null){
376
				for (String professorId : professorIds) {
377
					OrgResStaff orgResStaff = new OrgResStaff();
378
					orgResStaff.setResourceId(resource.getResourceId());
379
					orgResStaff.setProfessorId(professorId);
380
					this.orgResStaffDao.insert(con, orgResStaff);
381
				}
382
			}
383
			return resource.getResourceId();
384
		}else{
385
			throw new JfwBaseException(-1, "bad parameter:resourceId");
386
		}
387
	}
388
	
389
	@Post
390
	@Path("/orgDraft")
391
	public String orgDraft(@JdbcConn(true) Connection con,Resource resource,@Nullable String[] fns,@Nullable String[] imageIds,
392
			@Nullable String[] professorIds) throws SQLException, IOException, JfwBaseException{
393
		if(resource.getResourceId() == null){
394
			String resourceId = StringUtil.buildUUID();
395
			if(fns != null){
396
				this.imagesService.saveImg(con, resourceId, fns);
397
			}
398
			resource.setResourceId(resourceId);
399
			resource.setStatus("0");
400
			resource.setPageViews(0);
401
			resource.setResourceType("2");
402
			this.resourceDao.insert(con, resource);
403
			if(professorIds != null){
404
				for (String professorId : professorIds) {
405
					OrgResStaff orgResStaff = new OrgResStaff();
406
					orgResStaff.setResourceId(resourceId);
407
					orgResStaff.setProfessorId(professorId);
408
					this.orgResStaffDao.insert(con, orgResStaff);
409
				}
410
			}
411
			return resourceId;
412
		}else if(resource.getResourceId().trim().length() == 32){
413
			int imageLength = 0;
414
			if(imageIds != null){
415
				imageLength = imageIds.length;
416
				List<Image> images = this.imageDao.queryRes(con, resource.getResourceId());
417
				this.imageDao.updateAllSort(con, resource.getResourceId(), 0);
418
				for (int i = 0; i < imageLength; i++) {
419
					for (Image image : images) {
420
						if(image.getImageId().equals(imageIds[i])){
421
							this.imageDao.updateSort(con, image.getImageId(), i+1);
422
						}
423
					}
424
				}
425
				this.imageDao.deleteBySort(con, resource.getResourceId(), 0);
426
			}
427
			if(fns != null){
428
				if(imageIds == null){
429
					this.imageDao.deleteRes(con, resource.getResourceId());
430
				}
431
				this.imagesService.saveFns(con, resource.getResourceId(), fns, imageLength);
432
			}
433
			this.resourceDao.update(con, resource);
434
			this.resourceDao.updateStatus(con, resource.getResourceId(), "0");
435
			this.orgResStaffDao.delete(con, resource.getResourceId());
436
			if(professorIds != null){
437
				for (String professorId : professorIds) {
438
					OrgResStaff orgResStaff = new OrgResStaff();
439
					orgResStaff.setResourceId(resource.getResourceId());
440
					orgResStaff.setProfessorId(professorId);
441
					this.orgResStaffDao.insert(con, orgResStaff);
442
				}
443
			}
444
			return resource.getResourceId();
445
		}else{
446
			throw new JfwBaseException(-1, "bad parameter:resourceId");
447
		}
448
	}
449
	
300 450
	@Post
301 451
	@Path("/delete")
302 452
	public void deleteRes(@JdbcConn(true) Connection con, String resourceId) throws SQLException{
@ -350,11 +500,19 @@ public class ResourceService {
350 500
		Resource resource = this.resourceDao.queryOne(con, resourceId);
351 501
		if(resource != null){
352 502
			resource.setImages(this.imageDao.queryRes(con, resourceId));
353
			EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
354
			if(professor != null){
355
				professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
503
			if(resource.getProfessorId() != null){
504
				EditProfessor professor = this.professorDao.queryBaseInfo(con, resource.getProfessorId());
505
				if(professor != null){
506
					professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
507
				}
508
				resource.setEditProfessor(professor);
509
			}else if(resource.getOrgId() != null){
510
				EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
511
				if(organization != null){
512
					organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
513
				}
514
				resource.setOrganization(organization);
356 515
			}
357
			resource.setEditProfessor(professor);
358 516
		}
359 517
		return resource;
360 518
	}
@ -377,6 +535,24 @@ public class ResourceService {
377 535
		return queryResult;
378 536
	}
379 537
	
538
	@Get
539
	@Path("/pqForOrg")
540
	public PageQueryResult<Resource> queryPageForOrg(@JdbcConn Connection con,String orgId,@Nullable String key,
541
			@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
542
		if(key != null){
543
			key = "%" + key + "%";
544
		}
545
		PageQueryResult<Resource> queryResult = this.resourceDao.querySelfForOrg(con, orgId, key, pageSize, pageNo);
546
		List<Resource> resources = queryResult.getData();
547
		if(!resources.isEmpty()){
548
			for (Resource resource : resources) {
549
				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
550
			}
551
			queryResult.setData(resources);
552
		}
553
		return queryResult;
554
	}
555
	
380 556
	@Get
381 557
	@Path("/ralateRes")
382 558
	public List<Resource> queryLimit(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
@ -404,6 +580,33 @@ public class ResourceService {
404 580
		return resources;
405 581
	}
406 582
	
583
	@Get
584
	@Path("/orgRalateRes")
585
	public List<Resource> queryOrgRalateRes(@JdbcConn Connection con,@Nullable String[] keys,String resourceId,
586
			String orgId,@DefaultValue("10") int rows)throws SQLException{
587
		List<Resource> resources = new ArrayList<Resource>();
588
		if(keys != null){
589
			resources = this.resourceDao.queryLimit(con, keys, resourceId, rows);
590
		}
591
		if(resources.isEmpty()){
592
			resources = this.resourceDao.queryByOrgId(con, orgId, resourceId, rows);
593
			if(resources.isEmpty()){
594
				resources = this.resourceDao.queryByOrgId(con, null, resourceId, rows);
595
			}
596
		}
597
		if(!resources.isEmpty()){
598
			for (Resource resource : resources) {
599
				resource.setImages(this.imagesService.queryRes(con, resource.getResourceId()));
600
				EditOrganization organization = this.orgDao.queryEditOrg(con, resource.getOrgId());
601
				if(organization != null){
602
					organization.setHasOrgLogo(this.imageService.hasOrgLogo(organization.getId()));
603
				}
604
				resource.setOrganization(organization);
605
			}
606
		}
607
		return resources;
608
	}
609
	
407 610
	@Get
408 611
	@Path("/articles")
409 612
	public List<ArticleRes> queryArticles(@JdbcConn Connection con, String resourceId, @DefaultValue("5") int rows) throws SQLException{
@ -416,6 +619,22 @@ public class ResourceService {
416 619
		return articleRes;
417 620
	}
418 621
	
622
	@Get
623
	@Path("/qaLinkman")
624
	public List<OrgResStaff> queryLinkman(@JdbcConn Connection con, String resourceId) throws SQLException{
625
		List<OrgResStaff> orgResStaffs = this.orgResStaffDao.query(con, resourceId);
626
		if(orgResStaffs != null){
627
			for (OrgResStaff orgResStaff : orgResStaffs) {
628
				EditProfessor professor = this.professorDao.queryBaseInfo(con, orgResStaff.getProfessorId());
629
				if(professor != null){
630
					professor.setHasHeadImage(this.imageService.hasProfessorImage(professor.getId()));
631
				}
632
				orgResStaff.setProfessor(professor);
633
			}
634
		}
635
		return orgResStaffs;
636
	}
637
	
419 638
	@Get
420 639
	@Path("/resourceInfo")
421 640
	public Resource queryInfo(@JdbcConn Connection con, String resourceId) throws SQLException {
@ -471,6 +690,42 @@ public class ResourceService {
471 690
		return resources;
472 691
	}
473 692
	
693
	@Get
694
	@Path("/qaProPublish")
695
	public List<Resource> queryProPublish(@JdbcConn Connection con, String professorId) throws SQLException {
696
		List<Resource> resources = this.resourceDao.queryProPublish(con, professorId);
697
		if(!resources.isEmpty()) {
698
			for (Resource resource : resources) {
699
				resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
700
			}
701
		}
702
		return resources;
703
	}
704
	
705
	@Get
706
	@Path("/qaForDesk")
707
	public List<Resource> queryForDesk(@JdbcConn Connection con, String professorId) throws SQLException {
708
		List<Resource> resources = this.resourceDao.queryForDesk(con, professorId);
709
		if(!resources.isEmpty()) {
710
			for (Resource resource : resources) {
711
				resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
712
			}
713
		}
714
		return resources;
715
	}
716
	
717
	@Get
718
	@Path("/qaOrgPublish")
719
	public List<Resource> queryOrgPublish(@JdbcConn Connection con, String orgId) throws SQLException {
720
		List<Resource> resources = this.resourceDao.queryOrgPublish(con, orgId);
721
		if(!resources.isEmpty()) {
722
			for (Resource resource : resources) {
723
				resource.setImages(this.imageDao.queryRes(con, resource.getResourceId()));
724
			}
725
		}
726
		return resources;
727
	}
728
	
474 729
	@Post
475 730
	@Path("/nameAndSupport")
476 731
	public void updateNameAndSupport(@JdbcConn(true) Connection con, String resourceId, 

+ 58 - 0
src/main/java/com/ekexiu/portal/service/ResourceTmpService.java

@ -0,0 +1,58 @@
1
package com.ekexiu.portal.service;
2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5

6
import org.jfw.apt.annotation.Autowrie;
7
import org.jfw.apt.annotation.DefaultValue;
8
import org.jfw.apt.annotation.Nullable;
9
import org.jfw.apt.web.annotation.Path;
10
import org.jfw.apt.web.annotation.operate.Get;
11
import org.jfw.apt.web.annotation.param.JdbcConn;
12
import org.jfw.util.PageQueryResult;
13

14
import com.ekexiu.portal.dao.ProfessorDao;
15
import com.ekexiu.portal.dao.ResourceTmpDao;
16
import com.ekexiu.portal.po.ResourceTmp;
17
import com.ekexiu.portal.pojo.EditProfessor;
18

19
@Path("/resTmp")
20
public class ResourceTmpService {
21
	@Autowrie
22
	private ResourceTmpDao resourceTmpDao;
23
	@Autowrie
24
	private ProfessorDao professorDao;
25

26
	public ResourceTmpDao getResourceTmpDao() {
27
		return resourceTmpDao;
28
	}
29

30
	public void setResourceTmpDao(ResourceTmpDao resourceTmpDao) {
31
		this.resourceTmpDao = resourceTmpDao;
32
	}
33
	
34
	public ProfessorDao getProfessorDao() {
35
		return professorDao;
36
	}
37

38
	public void setProfessorDao(ProfessorDao professorDao) {
39
		this.professorDao = professorDao;
40
	}
41

42
	@Get
43
	@Path("/pq")
44
	public PageQueryResult<ResourceTmp> query(@JdbcConn Connection con,String professorId,@Nullable String key,@DefaultValue("10") int pageSize,@DefaultValue("1") int pageNo)throws SQLException{
45
		EditProfessor professor = this.professorDao.queryBaseInfo(con, professorId);
46
		String orgName = null;
47
		if(professor != null){
48
			orgName = professor.getOrgName();
49
		}
50
		if(orgName == null || "".equals(orgName)){
51
			return null;
52
		}
53
		if(key != null){
54
			key = "%" + key + "%";
55
		}
56
		return this.resourceTmpDao.query(con, orgName, key, pageSize, pageNo);
57
	}
58
}