-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f56f664
commit 7f0eb69
Showing
14 changed files
with
251 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/org/support/project/knowledge/control/open/TagControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.support.project.knowledge.control.open; | ||
|
||
import java.util.List; | ||
|
||
import org.support.project.knowledge.control.Control; | ||
import org.support.project.knowledge.dao.TagsDao; | ||
import org.support.project.knowledge.entity.TagsEntity; | ||
import org.support.project.web.boundary.Boundary; | ||
import org.support.project.web.exception.InvalidParamException; | ||
|
||
public class TagControl extends Control { | ||
private static final int LIST_LIMIT = 20; | ||
|
||
/** | ||
* タグの一覧を表示 | ||
* (ページきりかえあり) | ||
* @return | ||
* @throws InvalidParamException | ||
*/ | ||
public Boundary list() throws InvalidParamException { | ||
Integer offset = super.getPathInteger(0); | ||
int userId = super.getLoginUserId(); | ||
|
||
TagsDao tagsDao = TagsDao.get(); | ||
List<TagsEntity> tags; | ||
if (super.getLoginedUser() != null && super.getLoginedUser().isAdmin()) { | ||
tags = tagsDao.selectWithKnowledgeCountAdmin(offset * LIST_LIMIT, LIST_LIMIT); | ||
} else { | ||
tags = tagsDao.selectWithKnowledgeCount(userId, offset * LIST_LIMIT, LIST_LIMIT); | ||
} | ||
setAttribute("tags", tags); | ||
|
||
int previous = offset -1; | ||
if (previous < 0) { | ||
previous = 0; | ||
} | ||
setAttribute("offset", offset); | ||
setAttribute("previous", previous); | ||
setAttribute("next", offset + 1); | ||
|
||
return forward("list.jsp"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ort/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectKnowledgeWithUserName.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT | ||
KNOWLEDGES.* | ||
,USERS.USER_NAME AS INSERT_USER_NAME | ||
FROM | ||
KNOWLEDGES | ||
LEFT OUTER JOIN USERS | ||
ON USERS.USER_ID = KNOWLEDGES.INSERT_USER | ||
WHERE | ||
KNOWLEDGES.DELETE_FLAG = 0 | ||
ORDER BY UPDATE_DATETIME DESC | ||
LIMIT ? OFFSET ? | ||
|
15 changes: 15 additions & 0 deletions
15
...ources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCount.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
SELECT TAGS.*, COUNT(KNOWLEDGE_TAGS.KNOWLEDGE_ID) AS KNOWLEDGE_COUNT FROM TAGS | ||
INNER JOIN KNOWLEDGE_TAGS ON (TAGS.TAG_ID = KNOWLEDGE_TAGS.TAG_ID) | ||
WHERE EXISTS ( | ||
SELECT KNOWLEDGES.KNOWLEDGE_ID FROM KNOWLEDGES | ||
INNER JOIN KNOWLEDGE_USERS ON (KNOWLEDGES.KNOWLEDGE_ID = KNOWLEDGE_USERS.KNOWLEDGE_ID) | ||
WHERE KNOWLEDGE_TAGS.KNOWLEDGE_ID = KNOWLEDGES.KNOWLEDGE_ID | ||
AND KNOWLEDGES.DELETE_FLAG = 0 | ||
AND KNOWLEDGE_USERS.USER_ID IN (0,?) | ||
|
||
) | ||
AND TAGS.DELETE_FLAG = 0 | ||
GROUP BY TAGS.TAG_ID | ||
ORDER BY KNOWLEDGE_COUNT DESC | ||
LIMIT ? OFFSET ? | ||
|
12 changes: 12 additions & 0 deletions
12
...s/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT TAGS.*, COUNT(KNOWLEDGE_TAGS.KNOWLEDGE_ID) AS KNOWLEDGE_COUNT FROM TAGS | ||
INNER JOIN KNOWLEDGE_TAGS ON (TAGS.TAG_ID = KNOWLEDGE_TAGS.TAG_ID) | ||
WHERE EXISTS ( | ||
SELECT KNOWLEDGES.KNOWLEDGE_ID FROM KNOWLEDGES | ||
INNER JOIN KNOWLEDGE_USERS ON (KNOWLEDGES.KNOWLEDGE_ID = KNOWLEDGE_USERS.KNOWLEDGE_ID) | ||
WHERE KNOWLEDGE_TAGS.KNOWLEDGE_ID = KNOWLEDGES.KNOWLEDGE_ID | ||
AND KNOWLEDGES.DELETE_FLAG = 0 | ||
) | ||
AND TAGS.DELETE_FLAG = 0 | ||
GROUP BY TAGS.TAG_ID | ||
ORDER BY KNOWLEDGE_COUNT DESC | ||
LIMIT ? OFFSET ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<%@page import="org.support.project.knowledge.logic.KnowledgeLogic"%> | ||
<%@page import="org.support.project.web.util.JspUtil"%> | ||
<%@page pageEncoding="UTF-8" isELIgnored="false" session="false" errorPage="/WEB-INF/views/commons/errors/jsp_error.jsp"%> | ||
<%@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); %> | ||
|
||
<c:import url="/WEB-INF/views/commons/layout/layoutMain.jsp"> | ||
|
||
<c:param name="PARAM_HEAD"> | ||
</c:param> | ||
|
||
<c:param name="PARAM_SCRIPTS"> | ||
</c:param> | ||
|
||
<c:param name="PARAM_CONTENT"> | ||
|
||
<h4>タグ一覧</h4> | ||
|
||
<nav> | ||
<ul class="pager"> | ||
<li class="previous"> | ||
<a href="<%= request.getContextPath() %>/open.tag/list/${previous}"> | ||
<span aria-hidden="true">←</span>Previous | ||
</a> | ||
</li> | ||
<li class="next"> | ||
<a href="<%= request.getContextPath() %>/open.tag/list/${next}"> | ||
Next <span aria-hidden="true">→</span> | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
<c:if test="${empty tags}"> | ||
<div class="col-sm-12"> | ||
一覧に表示するタグがありません | ||
</div> | ||
</c:if> | ||
|
||
<div class="list-group"> | ||
<c:forEach var="tag" items="${tags}"> | ||
<a class="list-group-item " | ||
href="<%= request.getContextPath() %>/open.knowledge/list?tag=${tag.tagId}" > | ||
<span class="badge">${tag.knowledgeCount}</span> | ||
<i class="fa fa-tag"></i> ${tag.tagName} | ||
</a> | ||
</c:forEach> | ||
</div> | ||
|
||
<nav> | ||
<ul class="pager"> | ||
<li class="previous"> | ||
<a href="<%= request.getContextPath() %>/open.tag/list/${previous}"> | ||
<span aria-hidden="true">←</span>Previous | ||
</a> | ||
</li> | ||
<li class="next"> | ||
<a href="<%= request.getContextPath() %>/open.tag/list/${next}"> | ||
Next <span aria-hidden="true">→</span> | ||
</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
</c:param> | ||
|
||
</c:import> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters