Parcourir la Source

Merge remote-tracking branch 'origin/dev' into test

jiapeng 7 ans auparavant
Parent
commit
bf0d0bab09

+ 341 - 331
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

@ -5,6 +5,7 @@ import java.sql.PreparedStatement;
5 5
import java.sql.ResultSet;
6 6
import java.sql.SQLException;
7 7
import java.util.ArrayList;
8
import java.util.Collections;
8 9
import java.util.List;
9 10

10 11
import org.jfw.apt.annotation.Nullable;
@ -12,7 +13,6 @@ import org.jfw.apt.orm.annotation.dao.DAO;
12 13
import org.jfw.apt.orm.annotation.dao.Dynamic;
13 14
import org.jfw.apt.orm.annotation.dao.method.Exclude;
14 15
import org.jfw.apt.orm.annotation.dao.method.From;
15
import org.jfw.apt.orm.annotation.dao.method.Or;
16 16
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
17 17
import org.jfw.apt.orm.annotation.dao.method.SetSentence;
18 18
import org.jfw.apt.orm.annotation.dao.method.Where;
@ -31,11 +31,11 @@ import org.jfw.apt.orm.annotation.dao.param.In;
31 31
import org.jfw.apt.orm.annotation.dao.param.LessThan;
32 32
import org.jfw.apt.orm.annotation.dao.param.Like;
33 33
import org.jfw.apt.orm.annotation.dao.param.Set;
34
import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
35 34
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
36 35
import org.jfw.util.PageQueryResult;
37 36

38 37
import com.ekexiu.portal.po.Article;
38
import com.ekexiu.portal.pojo.FindInfo;
39 39
import com.ekexiu.portal.pojo.SelfArticle;
40 40

41 41
@DAO
@ -476,375 +476,384 @@ public abstract class ArticleDao {
476 476
	@OrderBy(" ORDER BY SORT_NUM DESC, PUBLISH_TIME DESC")
477 477
	@Where("STATUS = '1'")
478 478
	public abstract PageQueryResult<Article> firstPageQuery(Connection con,
479
			@GroupSqlColumn(isAnd=false, handlerClass = StringHandler.class, value = { "PROFESSOR_ID IN (SELECT ID FROM PROFESSOR WHERE NAME LIKE ?)",
480
					"ORG_ID IN (SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?) ",
481
					 "ARTICLE_TITLE LIKE ?",
482
					"SUBJECT LIKE ?" },additional=1) @Nullable String key,
479
			@GroupSqlColumn(isAnd = false, handlerClass = StringHandler.class, value = { "PROFESSOR_ID IN (SELECT ID FROM PROFESSOR WHERE NAME LIKE ?)",
480
					"ORG_ID IN (SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?) ", "ARTICLE_TITLE LIKE ?",
481
					"SUBJECT LIKE ?" }, additional = 1) @Nullable String key,
483 482
			int pageSize, int pageNo) throws SQLException;
484 483

485
//	public PageQueryResult<Article> firstPageQuery(Connection con, String key, int pageSize, int pageNo) throws SQLException {
486
//		int total = 0;
487
//		PageQueryResult<Article> queryResult = new PageQueryResult<Article>();
488
//		int index = 1;
489
//		boolean hasKey = null != key;
490
//		StringBuilder sql = new StringBuilder();
491
//		sql.append(" WHERE STATUS = '1'");
492
//		if (hasKey) {
493
//			sql.append(" AND (PROFESSOR_ID IN (SELECT ID FROM PROFESSOR WHERE NAME LIKE ?)");
494
//			sql.append(" OR ORG_ID IN (SELECT ID FROM ORGANIZATION WHERE NAME LIKE ? OR FOR_SHORT LIKE ?)");
495
//			sql.append(" OR ARTICLE_TITLE LIKE ? OR SUBJECT LIKE ?)");
496
//		}
497
//		StringBuilder whereSql = sql;
498
//		sql = new StringBuilder();
499
//		sql.append("SELECT COUNT(1) FROM ARTICLE");
500
//		sql.append(whereSql);
501
//		PreparedStatement ps = con.prepareStatement(sql.toString());
502
//		try {
503
//			if (hasKey) {
504
//				ps.setString(index++, key);
505
//				ps.setString(index++, key);
506
//				ps.setString(index++, key);
507
//				ps.setString(index++, key);
508
//				ps.setString(index++, key);
509
//			}
510
//			queryResult.setPageSize(pageSize);
511
//			ResultSet rs = ps.executeQuery();
512
//			try {
513
//				rs.next();
514
//				total = rs.getInt(1);
515
//			} finally {
516
//				try {
517
//					rs.close();
518
//				} catch (Exception e1) {
519
//				}
520
//			}
521
//		} finally {
522
//			try {
523
//				ps.close();
524
//			} catch (Exception e2) {
525
//			}
526
//		}
527
//		queryResult.setTotal(total);
528
//		if (0 == total) {
529
//			queryResult.setPageNo(1);
530
//			queryResult.setData(Collections.<Article> emptyList());
531
//			return queryResult;
532
//		}
533
//		index = 1;
534
//		boolean firstPage = (1 == pageNo);
535
//		if (firstPage) {
536
//			queryResult.setPageNo(1);
537
//			sql = new StringBuilder();
538
//			sql.append(
539
//					"SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,'',SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME,SHARE_ID,COL_NUM FROM ARTICLE");
540
//			sql.append(whereSql);
541
//			sql.append(" ORDER BY SORT_NUM DESC, PUBLISH_TIME DESC");
542
//			sql.append(" LIMIT ").append(pageSize);
543
//		} else {
544
//			int pageNum = total / pageSize;
545
//			if (total % pageSize != 0) {
546
//				++pageNum;
547
//			}
548
//			if (pageNo > pageNum) {
549
//				pageNo = pageNum;
550
//			}
551
//			queryResult.setPageNo(pageNo);
552
//			--pageNo;
553
//			int offset = (pageNo * pageSize);
554
//			sql = new StringBuilder();
555
//			sql.append(
556
//					"SELECT ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,'',SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME,SHARE_ID,COL_NUM FROM ARTICLE");
557
//			sql.append(whereSql);
558
//			sql.append(" ORDER BY SORT_NUM DESC,PUBLISH_TIME DESC");
559
//			sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
560
//		}
561
//		ps = con.prepareStatement(sql.toString());
562
//		try {
563
//			if (hasKey) {
564
//				ps.setString(index++, key);
565
//				ps.setString(index++, key);
566
//				ps.setString(index++, key);
567
//				ps.setString(index++, key);
568
//				ps.setString(index++, key);
569
//			}
570
//			ResultSet rs = ps.executeQuery();
571
//			try {
572
//				List<Article> articles = new ArrayList<Article>();
573
//				queryResult.setData(articles);
574
//				int size = 0;
575
//				while ((size < pageSize) && rs.next()) {
576
//					++size;
577
//					Article article = new Article();
578
//					article.setArticleId(rs.getString(1));
579
//					String professorId = rs.getString(2);
580
//					if (rs.wasNull()) {
581
//						professorId = null;
582
//					}
583
//					article.setProfessorId(professorId);
584
//					article.setArticleTitle(rs.getString(3));
585
//					String articleContent = rs.getString(4);
586
//					if (rs.wasNull()) {
587
//						articleContent = null;
588
//					}
589
//					article.setArticleContent(articleContent);
590
//					String subject = rs.getString(5);
591
//					if (rs.wasNull()) {
592
//						subject = null;
593
//					}
594
//					article.setSubject(subject);
595
//					String industry = rs.getString(6);
596
//					if (rs.wasNull()) {
597
//						industry = null;
598
//					}
599
//					article.setIndustry(industry);
600
//					String publishTime = rs.getString(7);
601
//					if (rs.wasNull()) {
602
//						publishTime = null;
603
//					}
604
//					article.setPublishTime(publishTime);
605
//					String articleImg = rs.getString(8);
606
//					if (rs.wasNull()) {
607
//						articleImg = null;
608
//					}
609
//					article.setArticleImg(articleImg);
610
//					String orgId = rs.getString(9);
611
//					if (rs.wasNull()) {
612
//						orgId = null;
613
//					}
614
//					article.setOrgId(orgId);
615
//					String articleType = rs.getString(10);
616
//					if (rs.wasNull()) {
617
//						articleType = null;
618
//					}
619
//					article.setArticleType(articleType);
620
//					article.setArticleAgree(rs.getInt(11));
621
//					article.setPageViews(rs.getInt(12));
622
//					String status = rs.getString(13);
623
//					if (rs.wasNull()) {
624
//						status = null;
625
//					}
626
//					article.setStatus(status);
627
//					article.setCreateTime(rs.getString(14));
628
//					article.setModifyTime(rs.getString(15));
629
//					article.setShareId(rs.getLong(16));
630
//					article.setColNum(rs.getInt(17));
631
//					articles.add(article);
632
//				}
633
//				return queryResult;
634
//			} finally {
635
//				try {
636
//					rs.close();
637
//				} catch (Exception e3) {
638
//				}
639
//			}
640
//		} finally {
641
//			try {
642
//				ps.close();
643
//			} catch (Exception e4) {
644
//			}
645
//		}
646
//	}
647

648
	@PageQuery
649
	@Exclude("articleContent")
650
	@OrderBy(" ORDER BY selfOrderField DESC,SHARE_ID ASC ")
651
	@Where("STATUS IN ('1','0','2')")
652
	public abstract PageQueryResult<SelfArticle> queryPageForSelf(Connection con, @Nullable String professorId, @Nullable String orgId,
653
			@Like @Nullable String articleTitle, int pageSize, int pageNo) throws SQLException;
654

655
	// public PageQueryResult<FindInfo> queryPage(Connection con,int
656
	// pageSize,int pageNo) throws SQLException{
484
	// public PageQueryResult<Article> firstPageQuery(Connection con, String
485
	// key, int pageSize, int pageNo) throws SQLException {
657 486
	// int total = 0;
658
	// PageQueryResult<FindInfo> queryResult = new PageQueryResult<FindInfo>();
659
	// String sql = null;
660
	// sql = "SELECT SUM(NUM) FROM (SELECT COUNT(1) NUM FROM ARTICLE UNION ALL
661
	// SELECT COUNT(1) NUM FROM RESOURCE) TBL";
662
	// PreparedStatement ps = con.prepareStatement(sql);
663
	// try{
487
	// PageQueryResult<Article> queryResult = new PageQueryResult<Article>();
488
	// int index = 1;
489
	// boolean hasKey = null != key;
490
	// StringBuilder sql = new StringBuilder();
491
	// sql.append(" WHERE STATUS = '1'");
492
	// if (hasKey) {
493
	// sql.append(" AND (PROFESSOR_ID IN (SELECT ID FROM PROFESSOR WHERE NAME
494
	// LIKE ?)");
495
	// sql.append(" OR ORG_ID IN (SELECT ID FROM ORGANIZATION WHERE NAME LIKE ?
496
	// OR FOR_SHORT LIKE ?)");
497
	// sql.append(" OR ARTICLE_TITLE LIKE ? OR SUBJECT LIKE ?)");
498
	// }
499
	// StringBuilder whereSql = sql;
500
	// sql = new StringBuilder();
501
	// sql.append("SELECT COUNT(1) FROM ARTICLE");
502
	// sql.append(whereSql);
503
	// PreparedStatement ps = con.prepareStatement(sql.toString());
504
	// try {
505
	// if (hasKey) {
506
	// ps.setString(index++, key);
507
	// ps.setString(index++, key);
508
	// ps.setString(index++, key);
509
	// ps.setString(index++, key);
510
	// ps.setString(index++, key);
511
	// }
664 512
	// queryResult.setPageSize(pageSize);
665 513
	// ResultSet rs = ps.executeQuery();
666
	// try{
514
	// try {
667 515
	// rs.next();
668 516
	// total = rs.getInt(1);
669
	// }finally{
670
	// try{rs.close();}catch(Exception e1){}
517
	// } finally {
518
	// try {
519
	// rs.close();
520
	// } catch (Exception e1) {
521
	// }
522
	// }
523
	// } finally {
524
	// try {
525
	// ps.close();
526
	// } catch (Exception e2) {
671 527
	// }
672
	// }finally{
673
	// try{ps.close();}catch(Exception e2){}
674 528
	// }
675 529
	// queryResult.setTotal(total);
676
	// if(0== total){
530
	// if (0 == total) {
677 531
	// queryResult.setPageNo(1);
678
	// queryResult.setData(Collections.<FindInfo>emptyList());
532
	// queryResult.setData(Collections.<Article> emptyList());
679 533
	// return queryResult;
680 534
	// }
535
	// index = 1;
681 536
	// boolean firstPage = (1 == pageNo);
682
	// if(firstPage){
537
	// if (firstPage) {
683 538
	// queryResult.setPageNo(1);
684
	// sql = "SELECT
685
	// ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID
686
	// FROM ARTICLE"
687
	// + " UNION ALL SELECT
688
	// RESOURCE_ID,RESOURCE_NAME,NULL,'3',CREATE_TIME,NULL,PROFESSOR_ID FROM
689
	// RESOURCE";
690
	// sql = sql + " ORDER BY CREATE_TIME DESC ";
691
	// sql = sql + " LIMIT " + pageSize;
692
	// }else{
539
	// sql = new StringBuilder();
540
	// sql.append(
541
	// "SELECT
542
	// ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,'',SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME,SHARE_ID,COL_NUM
543
	// FROM ARTICLE");
544
	// sql.append(whereSql);
545
	// sql.append(" ORDER BY SORT_NUM DESC, PUBLISH_TIME DESC");
546
	// sql.append(" LIMIT ").append(pageSize);
547
	// } else {
693 548
	// int pageNum = total / pageSize;
694
	// if(total % pageSize != 0){
549
	// if (total % pageSize != 0) {
695 550
	// ++pageNum;
696 551
	// }
697
	// if(pageNo > pageNum){
552
	// if (pageNo > pageNum) {
698 553
	// pageNo = pageNum;
699 554
	// }
700 555
	// queryResult.setPageNo(pageNo);
701 556
	// --pageNo;
702 557
	// int offset = (pageNo * pageSize);
703
	// sql = "SELECT
704
	// ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID
705
	// FROM ARTICLE"
706
	// + " UNION ALL SELECT
707
	// RESOURCE_ID,RESOURCE_NAME,NULL,'3',CREATE_TIME,NULL,PROFESSOR_ID FROM
708
	// RESOURCE";
709
	// sql = sql + " ORDER BY CREATE_TIME DESC ";
710
	// sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
711
	// }
712
	// ps = con.prepareStatement(sql);
713
	// try{
558
	// sql = new StringBuilder();
559
	// sql.append(
560
	// "SELECT
561
	// ARTICLE_ID,PROFESSOR_ID,ARTICLE_TITLE,'',SUBJECT,INDUSTRY,PUBLISH_TIME,ARTICLE_IMG,ORG_ID,ARTICLE_TYPE,ARTICLE_AGREE,PAGE_VIEWS,STATUS,CREATE_TIME,MODIFY_TIME,SHARE_ID,COL_NUM
562
	// FROM ARTICLE");
563
	// sql.append(whereSql);
564
	// sql.append(" ORDER BY SORT_NUM DESC,PUBLISH_TIME DESC");
565
	// sql.append(" LIMIT ").append(pageSize).append(" OFFSET ").append(offset);
566
	// }
567
	// ps = con.prepareStatement(sql.toString());
568
	// try {
569
	// if (hasKey) {
570
	// ps.setString(index++, key);
571
	// ps.setString(index++, key);
572
	// ps.setString(index++, key);
573
	// ps.setString(index++, key);
574
	// ps.setString(index++, key);
575
	// }
714 576
	// ResultSet rs = ps.executeQuery();
715
	// try{
716
	// List<FindInfo> findInfos = new ArrayList<FindInfo>();
717
	// queryResult.setData(findInfos);
577
	// try {
578
	// List<Article> articles = new ArrayList<Article>();
579
	// queryResult.setData(articles);
718 580
	// int size = 0;
719
	// while((size<pageSize) && rs.next()){
581
	// while ((size < pageSize) && rs.next()) {
720 582
	// ++size;
721
	// FindInfo findInfo = new FindInfo();
722
	// findInfo.setId(rs.getString(1));
723
	// findInfo.setName(rs.getString(2));
724
	// String image = rs.getString(3);
725
	// if(rs.wasNull()){
726
	// image = null;
727
	// }
728
	// findInfo.setImage(image);
729
	// findInfo.setType(rs.getString(4));
730
	// findInfo.setCreateTime(rs.getString(5));
731
	// String orgId = rs.getString(6);
732
	// if(rs.wasNull()){
733
	// findInfo.setOwner(rs.getString(7));
734
	// }else{
735
	// findInfo.setOwner(orgId);
736
	// }
737
	// findInfos.add(findInfo);
738
	// }
739
	// return queryResult;
740
	// }finally{
741
	// try{rs.close();}catch(Exception e3){}
583
	// Article article = new Article();
584
	// article.setArticleId(rs.getString(1));
585
	// String professorId = rs.getString(2);
586
	// if (rs.wasNull()) {
587
	// professorId = null;
742 588
	// }
743
	// }finally{
744
	// try{ps.close();}catch(Exception e4){}
589
	// article.setProfessorId(professorId);
590
	// article.setArticleTitle(rs.getString(3));
591
	// String articleContent = rs.getString(4);
592
	// if (rs.wasNull()) {
593
	// articleContent = null;
745 594
	// }
595
	// article.setArticleContent(articleContent);
596
	// String subject = rs.getString(5);
597
	// if (rs.wasNull()) {
598
	// subject = null;
746 599
	// }
747
	//
748
	// public PageQueryResult<FindInfo> queryFindHot(Connection con,int
749
	// pageSize,int pageNo) throws SQLException{
750
	// int total = 0;
751
	// PageQueryResult<FindInfo> queryResult = new PageQueryResult<FindInfo>();
752
	// String sql = null;
753
	// sql = "SELECT SUM(NUM) FROM ((SELECT COUNT(1) NUM FROM ARTICLE WHERE
754
	// STATUS = '1') UNION ALL (SELECT COUNT(1) NUM FROM RESOURCE WHERE STATUS =
755
	// '1')) TBL";
756
	// PreparedStatement ps = con.prepareStatement(sql);
757
	// try{
758
	// queryResult.setPageSize(pageSize);
759
	// ResultSet rs = ps.executeQuery();
760
	// try{
761
	// rs.next();
762
	// total = rs.getInt(1);
763
	// }finally{
764
	// try{rs.close();}catch(Exception e1){}
600
	// article.setSubject(subject);
601
	// String industry = rs.getString(6);
602
	// if (rs.wasNull()) {
603
	// industry = null;
765 604
	// }
766
	// }finally{
767
	// try{ps.close();}catch(Exception e2){}
605
	// article.setIndustry(industry);
606
	// String publishTime = rs.getString(7);
607
	// if (rs.wasNull()) {
608
	// publishTime = null;
768 609
	// }
769
	// queryResult.setTotal(total);
770
	// if(0== total){
771
	// queryResult.setPageNo(1);
772
	// queryResult.setData(Collections.<FindInfo>emptyList());
773
	// return queryResult;
610
	// article.setPublishTime(publishTime);
611
	// String articleImg = rs.getString(8);
612
	// if (rs.wasNull()) {
613
	// articleImg = null;
774 614
	// }
775
	// boolean firstPage = (1 == pageNo);
776
	// if(firstPage){
777
	// queryResult.setPageNo(1);
778
	// sql = "(SELECT
779
	// ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,PUBLISH_TIME,ORG_ID,PROFESSOR_ID
780
	// FROM ARTICLE WHERE STATUS = '1')"
781
	// + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN
782
	// RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL
783
	// END,"
784
	// + " PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
785
	// sql = sql + " ORDER BY PUBLISH_TIME DESC ";
786
	// sql = sql + " LIMIT " + pageSize;
787
	// }else{
788
	// int pageNum = total / pageSize;
789
	// if(total % pageSize != 0){
790
	// ++pageNum;
615
	// article.setArticleImg(articleImg);
616
	// String orgId = rs.getString(9);
617
	// if (rs.wasNull()) {
618
	// orgId = null;
791 619
	// }
792
	// if(pageNo > pageNum){
793
	// pageNo = pageNum;
620
	// article.setOrgId(orgId);
621
	// String articleType = rs.getString(10);
622
	// if (rs.wasNull()) {
623
	// articleType = null;
794 624
	// }
795
	// queryResult.setPageNo(pageNo);
796
	// --pageNo;
797
	// int offset = (pageNo * pageSize);
798
	// sql = "(SELECT
799
	// ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,PUBLISH_TIME,ORG_ID,PROFESSOR_ID
800
	// FROM ARTICLE WHERE STATUS = '1')"
801
	// + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN
802
	// RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL
803
	// END,"
804
	// + " PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
805
	// sql = sql + " ORDER BY PUBLISH_TIME DESC ";
806
	// sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
807
	// }
808
	// ps = con.prepareStatement(sql);
809
	// try{
810
	// ResultSet rs = ps.executeQuery();
811
	// try{
812
	// List<FindInfo> findInfos = new ArrayList<FindInfo>();
813
	// queryResult.setData(findInfos);
814
	// int size = 0;
815
	// while((size<pageSize) && rs.next()){
816
	// ++size;
817
	// FindInfo findInfo = new FindInfo();
818
	// findInfo.setId(rs.getString(1));
819
	// findInfo.setName(rs.getString(2));
820
	// String image = rs.getString(3);
821
	// if(rs.wasNull()){
822
	// image = null;
625
	// article.setArticleType(articleType);
626
	// article.setArticleAgree(rs.getInt(11));
627
	// article.setPageViews(rs.getInt(12));
628
	// String status = rs.getString(13);
629
	// if (rs.wasNull()) {
630
	// status = null;
823 631
	// }
824
	// findInfo.setImage(image);
825
	// findInfo.setType(rs.getString(4));
826
	// String createTime = rs.getString(5);
827
	// if(rs.wasNull()){
828
	// createTime = null;
632
	// article.setStatus(status);
633
	// article.setCreateTime(rs.getString(14));
634
	// article.setModifyTime(rs.getString(15));
635
	// article.setShareId(rs.getLong(16));
636
	// article.setColNum(rs.getInt(17));
637
	// articles.add(article);
829 638
	// }
830
	// findInfo.setCreateTime(createTime);
831
	// String orgId = rs.getString(6);
832
	// if(rs.wasNull()){
833
	// findInfo.setOwner(rs.getString(7));
834
	// }else{
835
	// findInfo.setOwner(orgId);
639
	// return queryResult;
640
	// } finally {
641
	// try {
642
	// rs.close();
643
	// } catch (Exception e3) {
836 644
	// }
837
	// findInfos.add(findInfo);
838 645
	// }
839
	// return queryResult;
840
	// }finally{
841
	// try{rs.close();}catch(Exception e3){}
646
	// } finally {
647
	// try {
648
	// ps.close();
649
	// } catch (Exception e4) {
842 650
	// }
843
	// }finally{
844
	// try{ps.close();}catch(Exception e4){}
845 651
	// }
846 652
	// }
847
	//
653

654
	@PageQuery
655
	@Exclude("articleContent")
656
	@OrderBy(" ORDER BY selfOrderField DESC,SHARE_ID ASC ")
657
	@Where("STATUS IN ('1','0','2')")
658
	public abstract PageQueryResult<SelfArticle> queryPageForSelf(Connection con, @Nullable String professorId, @Nullable String orgId,
659
			@Like @Nullable String articleTitle, int pageSize, int pageNo) throws SQLException;
660

661
	public PageQueryResult<FindInfo> queryPage(Connection con, int pageSize, int pageNo) throws SQLException {
662
		int total = 0;
663
		PageQueryResult<FindInfo> queryResult = new PageQueryResult<FindInfo>();
664
		String sql = null;
665
		sql = "SELECT SUM(NUM) FROM (SELECT COUNT(1) NUM FROM ARTICLE UNION ALL SELECT COUNT(1) NUM FROM RESOURCE) TBL";
666
		PreparedStatement ps = con.prepareStatement(sql);
667
		try {
668
			queryResult.setPageSize(pageSize);
669
			ResultSet rs = ps.executeQuery();
670
			try {
671
				rs.next();
672
				total = rs.getInt(1);
673
			} finally {
674
				try {
675
					rs.close();
676
				} catch (Exception e1) {
677
				}
678
			}
679
		} finally {
680
			try {
681
				ps.close();
682
			} catch (Exception e2) {
683
			}
684
		}
685
		queryResult.setTotal(total);
686
		if (0 == total) {
687
			queryResult.setPageNo(1);
688
			queryResult.setData(Collections.<FindInfo> emptyList());
689
			return queryResult;
690
		}
691
		boolean firstPage = (1 == pageNo);
692
		if (firstPage) {
693
			queryResult.setPageNo(1);
694
			sql = "SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE"
695
					+ " UNION ALL SELECT RESOURCE_ID,RESOURCE_NAME,NULL,'3',CREATE_TIME,NULL,PROFESSOR_ID FROM RESOURCE";
696
			sql = sql + " ORDER BY CREATE_TIME DESC ";
697
			sql = sql + " LIMIT " + pageSize;
698
		} else {
699
			int pageNum = total / pageSize;
700
			if (total % pageSize != 0) {
701
				++pageNum;
702
			}
703
			if (pageNo > pageNum) {
704
				pageNo = pageNum;
705
			}
706
			queryResult.setPageNo(pageNo);
707
			--pageNo;
708
			int offset = (pageNo * pageSize);
709
			sql = "SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE"
710
					+ " UNION ALL SELECT RESOURCE_ID,RESOURCE_NAME,NULL,'3',CREATE_TIME,NULL,PROFESSOR_ID FROM RESOURCE";
711
			sql = sql + " ORDER BY CREATE_TIME DESC ";
712
			sql = sql + " LIMIT " + pageSize + " OFFSET " + offset;
713
		}
714
		ps = con.prepareStatement(sql);
715
		try {
716
			ResultSet rs = ps.executeQuery();
717
			try {
718
				List<FindInfo> findInfos = new ArrayList<FindInfo>();
719
				queryResult.setData(findInfos);
720
				int size = 0;
721
				while ((size < pageSize) && rs.next()) {
722
					++size;
723
					FindInfo findInfo = new FindInfo();
724
					findInfo.setId(rs.getString(1));
725
					findInfo.setName(rs.getString(2));
726
					String image = rs.getString(3);
727
					if (rs.wasNull()) {
728
						image = null;
729
					}
730
					findInfo.setImage(image);
731
					findInfo.setType(rs.getString(4));
732
					findInfo.setCreateTime(rs.getString(5));
733
					String orgId = rs.getString(6);
734
					if (rs.wasNull()) {
735
						findInfo.setOwner(rs.getString(7));
736
					} else {
737
						findInfo.setOwner(orgId);
738
					}
739
					findInfos.add(findInfo);
740
				}
741
				return queryResult;
742
			} finally {
743
				try {
744
					rs.close();
745
				} catch (Exception e3) {
746
				}
747
			}
748
		} finally {
749
			try {
750
				ps.close();
751
			} catch (Exception e4) {
752
			}
753
		}
754
	}
755

756
	public PageQueryResult<FindInfo> queryFindHot(Connection con, int pageSize, int pageNo) throws SQLException {
757
		int total = 0;
758
		PageQueryResult<FindInfo> queryResult = new PageQueryResult<FindInfo>();
759
		String sql = null;
760
		sql = "SELECT SUM(NUM) FROM ((SELECT COUNT(1) NUM FROM ARTICLE WHERE STATUS = '1') UNION ALL (SELECT COUNT(1) NUM FROM RESOURCE WHERE STATUS = '1')) TBL";
761
		PreparedStatement ps = con.prepareStatement(sql);
762
		try {
763
			queryResult.setPageSize(pageSize);
764
			ResultSet rs = ps.executeQuery();
765
			try {
766
				rs.next();
767
				total = rs.getInt(1);
768
			} finally {
769
				try {
770
					rs.close();
771
				} catch (Exception e1) {
772
				}
773
			}
774
		} finally {
775
			try {
776
				ps.close();
777
			} catch (Exception e2) {
778
			}
779
		}
780
		queryResult.setTotal(total);
781
		if (0 == total) {
782
			queryResult.setPageNo(1);
783
			queryResult.setData(Collections.<FindInfo> emptyList());
784
			return queryResult;
785
		}
786
		boolean firstPage = (1 == pageNo);
787
		if (firstPage) {
788
			queryResult.setPageNo(1);
789
			sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
790
					+ " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
791
					+ " PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
792
			sql = sql + " ORDER BY PUBLISH_TIME DESC ";
793
			sql = sql + " LIMIT " + pageSize;
794
		} else {
795
			int pageNum = total / pageSize;
796
			if (total % pageSize != 0) {
797
				++pageNum;
798
			}
799
			if (pageNo > pageNum) {
800
				pageNo = pageNum;
801
			}
802
			queryResult.setPageNo(pageNo);
803
			--pageNo;
804
			int offset = (pageNo * pageSize);
805
			sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
806
					+ " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
807
					+ " PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
808
			sql = sql + " ORDER BY PUBLISH_TIME DESC ";
809
			sql = sql + " LIMIT " + pageSize + " OFFSET " + offset;
810
		}
811
		ps = con.prepareStatement(sql);
812
		try {
813
			ResultSet rs = ps.executeQuery();
814
			try {
815
				List<FindInfo> findInfos = new ArrayList<FindInfo>();
816
				queryResult.setData(findInfos);
817
				int size = 0;
818
				while ((size < pageSize) && rs.next()) {
819
					++size;
820
					FindInfo findInfo = new FindInfo();
821
					findInfo.setId(rs.getString(1));
822
					findInfo.setName(rs.getString(2));
823
					String image = rs.getString(3);
824
					if (rs.wasNull()) {
825
						image = null;
826
					}
827
					findInfo.setImage(image);
828
					findInfo.setType(rs.getString(4));
829
					String createTime = rs.getString(5);
830
					if (rs.wasNull()) {
831
						createTime = null;
832
					}
833
					findInfo.setCreateTime(createTime);
834
					String orgId = rs.getString(6);
835
					if (rs.wasNull()) {
836
						findInfo.setOwner(rs.getString(7));
837
					} else {
838
						findInfo.setOwner(orgId);
839
					}
840
					findInfos.add(findInfo);
841
				}
842
				return queryResult;
843
			} finally {
844
				try {
845
					rs.close();
846
				} catch (Exception e3) {
847
				}
848
			}
849
		} finally {
850
			try {
851
				ps.close();
852
			} catch (Exception e4) {
853
			}
854
		}
855
	}
856

848 857
	@SelectOne
849 858
	@Nullable
850 859
	public abstract Article query(Connection con, long shareId) throws SQLException;
@ -853,7 +862,8 @@ public abstract class ArticleDao {
853 862
	@Exclude("articleContent")
854 863
	@OrderBy(" ORDER BY PUBLISH_TIME DESC,SHARE_ID ASC ")
855 864
	@Where("STATUS='1'")
856
	public abstract PageQueryResult<Article> queryFind(Connection con, Integer colNum,@Nullable @In(include=false) String[] articleId, int pageSize, int pageNo) throws SQLException;
865
	public abstract PageQueryResult<Article> queryFind(Connection con, Integer colNum, @Nullable @In(include = false) String[] articleId, int pageSize,
866
			int pageNo) throws SQLException;
857 867

858 868
	@LimitSelect
859 869
	@Exclude("articleContent")

+ 38 - 36
src/main/java/com/ekexiu/portal/service/ArticleService.java

@ -44,8 +44,10 @@ import com.ekexiu.portal.po.ArticleAgree;
44 44
import com.ekexiu.portal.po.ArticleOrg;
45 45
import com.ekexiu.portal.po.ArticlePro;
46 46
import com.ekexiu.portal.po.ArticleRes;
47
import com.ekexiu.portal.po.Image;
47 48
import com.ekexiu.portal.pojo.EditOrganization;
48 49
import com.ekexiu.portal.pojo.EditProfessor;
50
import com.ekexiu.portal.pojo.FindInfo;
49 51
import com.ekexiu.portal.pojo.SelfArticle;
50 52

51 53
@Path("/article")
@ -770,42 +772,42 @@ public class ArticleService {
770 772
		return this.articleDao.queryPageForSelf(con, professorId, orgId, articleTitle, pageSize, pageNo);
771 773
	}
772 774

773
//	@Get
774
//	@Path("/pqFind")
775
//	public PageQueryResult<FindInfo> queryPage(@JdbcConn Connection con, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
776
//		PageQueryResult<FindInfo> queryResult = this.articleDao.queryPage(con, pageSize, pageNo);
777
//		List<FindInfo> findInfos = queryResult.getData();
778
//		for (FindInfo findInfo : findInfos) {
779
//			if ("3".equals(findInfo.getType())) {
780
//				List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
781
//				if (images.size() > 0) {
782
//					findInfo.setImage(findInfo.getId() + ".jpg");
783
//				}
784
//			}
785
//		}
786
//		queryResult.setData(findInfos);
787
//		return queryResult;
788
//	}
789

790
//	@Get
791
//	@Path("/findHot")
792
//	public PageQueryResult<FindInfo> queryFindHot(@JdbcConn Connection con, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo)
793
//			throws SQLException {
794
//		PageQueryResult<FindInfo> queryResult = this.articleDao.queryFindHot(con, pageSize, pageNo);
795
//		List<FindInfo> findInfos = queryResult.getData();
796
//		if (!findInfos.isEmpty()) {
797
//			for (FindInfo findInfo : findInfos) {
798
//				if ("3".equals(findInfo.getType()) || "4".equals(findInfo.getType())) {
799
//					List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
800
//					if (images.size() > 0) {
801
//						findInfo.setImage(images.get(0).getImageSrc());
802
//					}
803
//				}
804
//			}
805
//			queryResult.setData(findInfos);
806
//		}
807
//		return queryResult;
808
//	}
775
	@Get
776
	@Path("/pqFind")
777
	public PageQueryResult<FindInfo> queryPage(@JdbcConn Connection con, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException {
778
		PageQueryResult<FindInfo> queryResult = this.articleDao.queryPage(con, pageSize, pageNo);
779
		List<FindInfo> findInfos = queryResult.getData();
780
		for (FindInfo findInfo : findInfos) {
781
			if ("3".equals(findInfo.getType())) {
782
				List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
783
				if (images.size() > 0) {
784
					findInfo.setImage(findInfo.getId() + ".jpg");
785
				}
786
			}
787
		}
788
		queryResult.setData(findInfos);
789
		return queryResult;
790
	}
791

792
	@Get
793
	@Path("/findHot")
794
	public PageQueryResult<FindInfo> queryFindHot(@JdbcConn Connection con, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo)
795
			throws SQLException {
796
		PageQueryResult<FindInfo> queryResult = this.articleDao.queryFindHot(con, pageSize, pageNo);
797
		List<FindInfo> findInfos = queryResult.getData();
798
		if (!findInfos.isEmpty()) {
799
			for (FindInfo findInfo : findInfos) {
800
				if ("3".equals(findInfo.getType()) || "4".equals(findInfo.getType())) {
801
					List<Image> images = this.imagesService.queryRes(con, findInfo.getId());
802
					if (images.size() > 0) {
803
						findInfo.setImage(images.get(0).getImageSrc());
804
					}
805
				}
806
			}
807
			queryResult.setData(findInfos);
808
		}
809
		return queryResult;
810
	}
809 811

810 812
	@Get
811 813
	@Path("/ralatePro")