Browse Source

内容流量查询中文章和资源的查询条件;显示机构发布者

XMTT 7 years ago
parent
commit
ea1431dafa

+ 6 - 6
src/main/java/com/ekexiu/console/system/dao/ArticleDao.java

@ -7,12 +7,10 @@ import org.jfw.apt.orm.annotation.dao.Column;
7 7
import org.jfw.apt.orm.annotation.dao.DAO;
8 8
import org.jfw.apt.orm.annotation.dao.method.From;
9 9
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
10
import org.jfw.apt.orm.annotation.dao.method.Where;
10 11
import org.jfw.apt.orm.annotation.dao.method.operator.PageQuery;
11 12
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
12
import org.jfw.apt.orm.annotation.dao.param.Alias;
13
import org.jfw.apt.orm.annotation.dao.param.GtEq;
14
import org.jfw.apt.orm.annotation.dao.param.Like;
15
import org.jfw.apt.orm.annotation.dao.param.LtEq;
13
import org.jfw.apt.orm.annotation.dao.param.*;
16 14
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
17 15
import org.jfw.util.PageQueryResult;
18 16
@ -33,9 +31,11 @@ public interface ArticleDao {
33 31
34 32
    @PageQuery
35 33
    @OrderBy(" ORDER BY create_time DESC NULLS LAST")
36
    PageQueryResult<ArticleInfo> queryByTime(Connection con, @Nullable @Like String articleTitle, @Nullable @Like String professorName, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
34
    @Where("status='1'")
35
    PageQueryResult<ArticleInfo> queryByTime(Connection con, @Nullable @Like String articleTitle, @SqlColumn(value = {"(p.name is null or p.name like ?)", "(o.name is null or o.name like ?)"}, handlerClass = StringHandler.class) String name, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
37 36
38 37
    @PageQuery
39 38
    @OrderBy(" ORDER BY page_views DESC NULLS LAST")
40
    PageQueryResult<ArticleInfo> queryByPV(Connection con, @Nullable @Like String articleTitle,@Nullable @Like String professorName, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
39
    @Where("status='1'")
40
    PageQueryResult<ArticleInfo> queryByPV(Connection con, @Nullable @Like String articleTitle, @SqlColumn(value = {"(p.name is null or p.name like ?)", "(o.name is null or o.name like ?)"}, handlerClass = StringHandler.class) String name, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
41 41
}

+ 6 - 6
src/main/java/com/ekexiu/console/system/dao/ResourceDao.java

@ -7,12 +7,10 @@ import org.jfw.apt.orm.annotation.dao.Column;
7 7
import org.jfw.apt.orm.annotation.dao.DAO;
8 8
import org.jfw.apt.orm.annotation.dao.method.From;
9 9
import org.jfw.apt.orm.annotation.dao.method.OrderBy;
10
import org.jfw.apt.orm.annotation.dao.method.Where;
10 11
import org.jfw.apt.orm.annotation.dao.method.operator.PageQuery;
11 12
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
12
import org.jfw.apt.orm.annotation.dao.param.Alias;
13
import org.jfw.apt.orm.annotation.dao.param.GtEq;
14
import org.jfw.apt.orm.annotation.dao.param.Like;
15
import org.jfw.apt.orm.annotation.dao.param.LtEq;
13
import org.jfw.apt.orm.annotation.dao.param.*;
16 14
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
17 15
import org.jfw.util.PageQueryResult;
18 16
@ -32,9 +30,11 @@ public interface ResourceDao {
32 30
33 31
    @PageQuery
34 32
    @OrderBy(" ORDER BY create_time DESC NULLS LAST")
35
    PageQueryResult<ResourceInfo> queryByTime(Connection con, @Nullable @Like String resourceName, @Nullable @Like String professorName, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
33
    @Where("status='1'")
34
    PageQueryResult<ResourceInfo> queryByTime(Connection con, @Nullable @Like String resourceName, @SqlColumn(value = {"(p.name is null or p.name like ?)", "(o.name is null or o.name like ?)"}, handlerClass = StringHandler.class) String name, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
36 35
37 36
    @PageQuery
38 37
    @OrderBy(" ORDER BY page_views DESC NULLS LAST")
39
    PageQueryResult<ResourceInfo> queryByPV(Connection con, @Nullable @Like String resourceName,@Nullable @Like String professorName, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
38
    @Where("status='1'")
39
    PageQueryResult<ResourceInfo> queryByPV(Connection con, @Nullable @Like String resourceName,@SqlColumn(value = {"(p.name is null or p.name like ?)", "(o.name is null or o.name like ?)"}, handlerClass = StringHandler.class) String name, @Nullable @GtEq @Alias("createTime") String bt, @Nullable @Alias("createTime") @LtEq String et, int pageSize, int pageNo) throws SQLException;
40 40
}

+ 12 - 1
src/main/java/com/ekexiu/console/system/pojo/ArticleInfo.java

@ -8,9 +8,10 @@ import org.jfw.apt.orm.core.defaultImpl.StringHandler;
8 8
/**
9 9
 * Created by TT on 2017/7/27.
10 10
 */
11
@ExtendView(fromSentence = "article a LEFT JOIN professor p on p.id = a.professor_id ", tableAlias = "a")
11
@ExtendView(fromSentence = "article a LEFT JOIN professor p on p.id = a.professor_id LEFT JOIN organization o on o.id = a.org_id ", tableAlias = "a")
12 12
public class ArticleInfo extends Article{
13 13
    private String professorName;
14
    private String organizationName;
14 15
15 16
    @CalcColumn(handlerClass = StringHandler.class, column = "p.name")
16 17
    public String getProfessorName() {
@ -20,4 +21,14 @@ public class ArticleInfo extends Article{
20 21
    public void setProfessorName(String professorName) {
21 22
        this.professorName = professorName;
22 23
    }
24
25
    @CalcColumn(handlerClass = StringHandler.class, column = "o.name")
26
27
    public String getOrganizationName() {
28
        return organizationName;
29
    }
30
31
    public void setOrganizationName(String organizationName) {
32
        this.organizationName = organizationName;
33
    }
23 34
}

+ 11 - 1
src/main/java/com/ekexiu/console/system/pojo/ResourceInfo.java

@ -8,9 +8,10 @@ import org.jfw.apt.orm.core.defaultImpl.StringHandler;
8 8
/**
9 9
 * Created by TT on 2017/7/27.
10 10
 */
11
@ExtendView(fromSentence = "resource r LEFT JOIN professor p on p.id = r.professor_id ", tableAlias = "r")
11
@ExtendView(fromSentence = "resource r LEFT JOIN professor p on p.id = r.professor_id LEFT JOIN organization o on o.id = r.org_id ", tableAlias = "r")
12 12
public class ResourceInfo extends Resource{
13 13
    private String professorName;
14
    private String organizationName;
14 15
15 16
    @CalcColumn(handlerClass = StringHandler.class, column = "p.name")
16 17
    public String getProfessorName() {
@ -20,4 +21,13 @@ public class ResourceInfo extends Resource{
20 21
    public void setProfessorName(String professorName) {
21 22
        this.professorName = professorName;
22 23
    }
24
25
    @CalcColumn(handlerClass = StringHandler.class, column = "o.name")
26
    public String getOrganizationName() {
27
        return organizationName;
28
    }
29
30
    public void setOrganizationName(String organizationName) {
31
        this.organizationName = organizationName;
32
    }
23 33
}

+ 4 - 4
src/main/java/com/ekexiu/console/system/service/ContentService.java

@ -94,18 +94,18 @@ public class ContentService {
94 94
    public Object pageQuery(@JdbcConn Connection con, int contentType, @Nullable String title, @Nullable String name, int orderBy, @Nullable String bt, @Nullable String et, @DefaultValue("1") int pageNo, @DefaultValue("10") int pageSize)throws SQLException{
95 95
        if (contentType == 3){
96 96
            if (orderBy == 1) {
97
                return this.articleDao.queryByTime(con, title == null ? null : "%" + title + "%",  name == null ? null : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
97
                return this.articleDao.queryByTime(con, title == null ? null : "%" + title + "%",  name == null ? "%" : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
98 98
            }
99 99
            if (orderBy == 2) {
100
                return this.articleDao.queryByPV(con, title == null ? null : "%" + title + "%",  name == null ? null : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
100
                return this.articleDao.queryByPV(con, title == null ? null : "%" + title + "%",  name == null ? "%" : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
101 101
            }
102 102
        }
103 103
        if (contentType == 2){
104 104
            if (orderBy == 1){
105
                return this.resourceDao.queryByTime(con, title == null ? null : "%" + title + "%",  name == null ? null : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
105
                return this.resourceDao.queryByTime(con, title == null ? null : "%" + title + "%",  name == null ? "%" : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
106 106
            }
107 107
            if (orderBy == 2) {
108
                return this.resourceDao.queryByPV(con, title == null ? null : "%" + title + "%",  name == null ? null : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
108
                return this.resourceDao.queryByPV(con, title == null ? null : "%" + title + "%",  name == null ? "%" : "%" + name + "%", bt == null ? null : bt + "000000", et == null ? null : et + "235959", pageSize, pageNo);
109 109
            }
110 110
        }
111 111
        if (contentType == 5){