Browse Source

--update queryFindHot();

zzy.zhiyuan.foxmail 7 years ago
parent
commit
5272facca3
1 changed files with 11 additions and 7 deletions
  1. 11 7
      src/main/java/com/ekexiu/portal/dao/ArticleDao.java

+ 11 - 7
src/main/java/com/ekexiu/portal/dao/ArticleDao.java

839
        boolean firstPage = (1 == pageNo);
839
        boolean firstPage = (1 == pageNo);
840
        if(firstPage){
840
        if(firstPage){
841
        	queryResult.setPageNo(1);
841
        	queryResult.setPageNo(1);
842
        	sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
842
        	sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
843
                + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
843
                + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
844
                + " CREATE_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
845
            sql = sql + " ORDER BY CREATE_TIME DESC ";
844
                + " PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
845
            sql = sql + " ORDER BY PUBLISH_TIME DESC ";
846
            sql = sql + " LIMIT " + pageSize;
846
            sql = sql + " LIMIT " + pageSize;
847
        }else{
847
        }else{
848
            int pageNum = total / pageSize;
848
            int pageNum = total / pageSize;
855
            queryResult.setPageNo(pageNo);
855
            queryResult.setPageNo(pageNo);
856
            --pageNo;
856
            --pageNo;
857
            int offset = (pageNo * pageSize);
857
            int offset = (pageNo * pageSize);
858
            sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,CREATE_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
858
            sql = "(SELECT ARTICLE_ID,ARTICLE_TITLE,ARTICLE_IMG,ARTICLE_TYPE,PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM ARTICLE WHERE STATUS = '1')"
859
                + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
859
                + " UNION ALL (SELECT RESOURCE_ID,RESOURCE_NAME,NULL,CASE WHEN RESOURCE_TYPE = '1' THEN '3' WHEN RESOURCE_TYPE = '2' THEN '4' ELSE NULL END,"
860
                + " CREATE_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
861
            sql = sql + " ORDER BY CREATE_TIME DESC ";
860
                + " PUBLISH_TIME,ORG_ID,PROFESSOR_ID FROM RESOURCE WHERE STATUS = '1')";
861
            sql = sql + " ORDER BY PUBLISH_TIME DESC ";
862
            sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
862
            sql = sql + " LIMIT " + pageSize+ " OFFSET " + offset;
863
        }
863
        }
864
        ps = con.prepareStatement(sql);
864
        ps = con.prepareStatement(sql);
879
                    }
879
                    }
880
                    findInfo.setImage(image);
880
                    findInfo.setImage(image);
881
                    findInfo.setType(rs.getString(4));
881
                    findInfo.setType(rs.getString(4));
882
                    findInfo.setCreateTime(rs.getString(5));
882
                    String createTime = rs.getString(5);
883
                    if(rs.wasNull()){
884
                    	createTime = null;
885
                    }
886
                    findInfo.setCreateTime(createTime);
883
                    String orgId = rs.getString(6);
887
                    String orgId = rs.getString(6);
884
                    if(rs.wasNull()){
888
                    if(rs.wasNull()){
885
                    	findInfo.setOwner(rs.getString(7));
889
                    	findInfo.setOwner(rs.getString(7));