diff --git a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java index 4bd859a49..f61e8e425 100644 --- a/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java +++ b/src/main/java/org/support/project/knowledge/control/open/KnowledgeControl.java @@ -76,10 +76,12 @@ import org.support.project.web.dao.SystemConfigsDao; import org.support.project.web.dao.UserConfigsDao; import org.support.project.web.dao.UsersDao; +import org.support.project.web.dao.ReadMarksDao; import org.support.project.web.entity.GroupsEntity; import org.support.project.web.entity.SystemConfigsEntity; import org.support.project.web.entity.UserConfigsEntity; import org.support.project.web.entity.UsersEntity; +import org.support.project.web.entity.ReadMarksEntity; import org.support.project.web.exception.InvalidParamException; /** @@ -685,6 +687,37 @@ public Boundary show_history() throws InvalidParamException { return forward("show_history.jsp"); } + @Get + public Boundary show_unread() throws InvalidParamException { + LoginedUser loginedUser = super.getLoginedUser(); + KnowledgeLogic knowledgeLogic = KnowledgeLogic.get(); + + Integer offset = getOffsetParameter(); + List unreadIds = knowledgeLogic.getUnreadKnowledgeIds(loginedUser, offset * PAGE_LIMIT, PAGE_LIMIT); + + List getIds = new ArrayList<>(); + for(Long i : unreadIds) { + getIds.add(String.valueOf(i)); + } + + List unreadKnowledges = knowledgeLogic.getKnowledges(getIds, loginedUser); + ArrayList knowledgeIds = new ArrayList<>(); + for(KnowledgesEntity e : unreadKnowledges) { + knowledgeIds.add(e.getKnowledgeId()); + } + + List stocks = knowledgeLogic.setStockInfo(unreadKnowledges, loginedUser); + setAttribute("unreads", stocks); + LOG.trace("未読取得完了"); + + // ナレッジの公開先の情報を取得 + setKnowledgeTargets(loginedUser, knowledgeIds); + // タグとグループの情報を取得(一覧画面の右側のサブリスト部分に表示する情報をセット) + setSublistInformations(loginedUser); + + return forward("show_unread.jsp"); + } + /** * 人気のKnowledgeを表示 * diff --git a/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java b/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java index 840873241..7b3df5903 100644 --- a/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java +++ b/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java @@ -340,4 +340,22 @@ public void updatePoint(long knowledgeId, int point) { executeUpdate(sql, point, knowledgeId); } + @Aspect(advice = org.support.project.ormapping.transaction.Transaction.class) + public List getUnreadKnowledgeIds(Integer userId, + int exclude_public_flag, + int offset, int limit) { + // TODO check protected knowledges + String sql = "SELECT knowledge_id FROM KNOWLEDGES " + + "WHERE knowledge_id NOT IN (SELECT DISTINCT knowledge_id FROM VIEW_HISTORIES WHERE INSERT_USER = ?) " + + "AND public_flag <> ?" + + "ORDER BY UPDATE_DATETIME DESC " + + "Limit ? offset ? " + ; + return executeQueryList(sql, + Long.class, + userId, + exclude_public_flag, + limit, offset); + } + } diff --git a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java index c3a80fd62..00bfadabf 100644 --- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java +++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java @@ -990,6 +990,25 @@ private void setTags(KnowledgesEntity entity) { entity.setTagNames(builder.toString()); } + /** + * get unread knowledges + * + * @param user + * @param offset + * @param limit + */ + public List getUnreadKnowledgeIds(LoginedUser user, + int offset, + int limit) { + Integer userId = user.getUserId(); + + return KnowledgesDao.get().getUnreadKnowledgeIds(userId, + PUBLIC_FLAG_PRIVATE, + offset, + limit); + + } + /** * ナレッジを取得 * diff --git a/src/main/resources/appresource.properties b/src/main/resources/appresource.properties index f59c3b142..d701bd4b1 100644 --- a/src/main/resources/appresource.properties +++ b/src/main/resources/appresource.properties @@ -229,6 +229,7 @@ knowledge.list.info.group=Required SignIn knowledge.list.kind.list=List knowledge.list.kind.stock=Stock knowledge.list.kind.history=History +knowledge.list.kind.history=Unread knowledge.list.kind.popular=Popular knowledge.list.invalid.keyword=Invalid search keyword knowledge.list.link.stock=Link to stock list diff --git a/src/main/resources/appresource_ja.properties b/src/main/resources/appresource_ja.properties index 0a9460acd..e85dd2b04 100644 --- a/src/main/resources/appresource_ja.properties +++ b/src/main/resources/appresource_ja.properties @@ -229,6 +229,7 @@ knowledge.list.info.group=グループ機能はサインインする必要があ knowledge.list.kind.list=一覧 knowledge.list.kind.stock=ストック knowledge.list.kind.history=履歴 +knowledge.list.kind.unread=未読 knowledge.list.kind.popular=人気 knowledge.list.invalid.keyword=検索のキーワードが不正です knowledge.list.link.stock=ストックの一覧へ diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp index 3a9ddb446..f97756701 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/list.jsp @@ -57,6 +57,7 @@
  • <%=jspUtil.label("knowledge.list.kind.popular")%>
  • <% if (jspUtil.logined()) { %>
  • <%= jspUtil.label("knowledge.list.kind.stock") %>
  • +
  • <%=jspUtil.label("knowledge.list.kind.unread")%>
  • <% } %>
  • <%=jspUtil.label("knowledge.list.kind.history")%>
  • diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/popularity.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/popularity.jsp index b2e9a1bdd..e4bdf40e5 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/popularity.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/popularity.jsp @@ -29,6 +29,7 @@ <% if (jspUtil.logined()) { %>
  • <%= jspUtil.label("knowledge.list.kind.stock") %>
  • +
  • <%=jspUtil.label("knowledge.list.kind.unread")%>
  • <% } %>
  • <%=jspUtil.label("knowledge.list.kind.history")%>
  • diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/show_history.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/show_history.jsp index 8bb892357..ed8feefa0 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/show_history.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/show_history.jsp @@ -31,6 +31,7 @@
  • <%=jspUtil.label("knowledge.list.kind.popular")%>
  • <% if (jspUtil.logined()) { %>
  • <%=jspUtil.label("knowledge.list.kind.stock")%>
  • +
  • <%=jspUtil.label("knowledge.list.kind.unread")%>
  • <% } %> diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/show_unread.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/show_unread.jsp new file mode 100644 index 000000000..07497187b --- /dev/null +++ b/src/main/webapp/WEB-INF/views/open/knowledge/show_unread.jsp @@ -0,0 +1,68 @@ +<%@page import="java.util.List"%> +<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> +<%@page import="org.support.project.common.util.NumberUtils"%> +<%@page import="org.support.project.knowledge.logic.KnowledgeLogic"%> +<%@page import="org.support.project.web.util.JspUtil"%> + +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +<% +JspUtil jspUtil = new JspUtil(request, pageContext); +%> + + + + + + + + + + + + + + + + + +
    + <% + request.setAttribute("list_data", jspUtil.getValue("unreads", List.class)); + %> + + +
    + + + + +
    + +
    + + diff --git a/src/main/webapp/WEB-INF/views/open/knowledge/stocks.jsp b/src/main/webapp/WEB-INF/views/open/knowledge/stocks.jsp index 9d4c5f297..77ae0670a 100644 --- a/src/main/webapp/WEB-INF/views/open/knowledge/stocks.jsp +++ b/src/main/webapp/WEB-INF/views/open/knowledge/stocks.jsp @@ -30,6 +30,7 @@
  • <%=jspUtil.label("knowledge.list.kind.popular")%>
  • <% if (jspUtil.logined()) { %> + <% } %>
  • <%=jspUtil.label("knowledge.list.kind.history")%>