diff --git a/pom.xml b/pom.xml
index 356971a94..425e2f3a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.support-project
knowledge
war
- 0.3.2
+ 0.3.3
webapp for knowledge
https://support-project.org/
@@ -17,7 +17,7 @@
org.support-project
web
- 0.3.2
+ 0.3.3
diff --git a/src/main/java/org/support/project/knowledge/control/open/TagControl.java b/src/main/java/org/support/project/knowledge/control/open/TagControl.java
new file mode 100644
index 000000000..381fc5bce
--- /dev/null
+++ b/src/main/java/org/support/project/knowledge/control/open/TagControl.java
@@ -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 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");
+ }
+
+}
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 83fd1af5a..7ad02301b 100644
--- a/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java
+++ b/src/main/java/org/support/project/knowledge/dao/KnowledgesDao.java
@@ -53,7 +53,8 @@ public Integer getNextId() {
public List selectKnowledge(int offset, int limit, Integer userId) {
- String sql = "SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 ORDER BY UPDATE_DATETIME DESC Limit ? offset ?;";
+ // String sql = "SELECT * FROM KNOWLEDGES WHERE DELETE_FLAG = 0 ORDER BY UPDATE_DATETIME DESC Limit ? offset ?;";
+ String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectKnowledgeWithUserName.sql");
return executeQuery(sql, KnowledgesEntity.class, limit, offset);
}
diff --git a/src/main/java/org/support/project/knowledge/dao/TagsDao.java b/src/main/java/org/support/project/knowledge/dao/TagsDao.java
index 4ebdb2b84..3e89750bd 100644
--- a/src/main/java/org/support/project/knowledge/dao/TagsDao.java
+++ b/src/main/java/org/support/project/knowledge/dao/TagsDao.java
@@ -8,6 +8,7 @@
import org.support.project.knowledge.dao.gen.GenTagsDao;
import org.support.project.knowledge.entity.TagsEntity;
import org.support.project.ormapping.common.SQLManager;
+import org.support.project.web.bean.LoginedUser;
/**
* タグ
@@ -95,5 +96,27 @@ public List selectTagsWithCountOnUser(int userid, int offset, int li
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectTagsWithCountOnUser.sql");
return executeQuery(sql, TagsEntity.class, userid, limit, offset);
}
+
+ /**
+ * タグの一覧と、それに紐づくナレッジの件数を取得
+ * @param offset
+ * @param loginedUser
+ * @return
+ */
+ public List selectWithKnowledgeCount(int userId, int offset, int limit) {
+ String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCount.sql");
+ return executeQuery(sql, TagsEntity.class, userId, limit, offset);
+ }
+ /**
+ * タグの一覧と、それに紐づくナレッジの件数を取得
+ * 管理者用で、ナレッジにアクセス可能かのアクセス権限チェックはしない
+ * @param offset
+ * @param limit
+ * @return
+ */
+ public List selectWithKnowledgeCountAdmin(int offset, int limit) {
+ String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql");
+ return executeQuery(sql, TagsEntity.class, 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 9e5e211f0..750e02b26 100644
--- a/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java
+++ b/src/main/java/org/support/project/knowledge/logic/KnowledgeLogic.java
@@ -453,12 +453,29 @@ public List getKnowledges(List ids, LoginedUser logine
//List knowledgesEntities = knowledgesDao.selectKnowledges(knowledgeIds);
//アクセス権を考慮して取得
List knowledgesEntities = new ArrayList<>();
+ List addSuccess = new ArrayList();
+ List addFail = new ArrayList();
for (Long integer : knowledgeIds) {
KnowledgesEntity entity = select(integer, loginedUser);
if (entity != null) {
+ addSuccess.add(integer.toString());
knowledgesEntities.add(entity);
+ } else {
+ addFail.add(integer.toString());
}
}
+ if (addSuccess.isEmpty()) {
+ LOG.debug("History: add success. [Empty]");
+ } else {
+ LOG.debug("History: add success. " + String.join(",", addSuccess.toArray(new String[0])));
+ }
+
+ if (addFail.isEmpty()) {
+ LOG.debug("History: add fail. [Empty]");
+ } else {
+ LOG.debug("History: add fail. " + String.join(",", addFail.toArray(new String[0])));
+ }
+
return knowledgesEntities;
}
diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml
index 869d0699f..a33aac829 100644
--- a/src/main/resources/log4j.xml
+++ b/src/main/resources/log4j.xml
@@ -51,9 +51,17 @@
+
+
+
+
+
+
+
+
-
+
diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectKnowledgeWithUserName.sql b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectKnowledgeWithUserName.sql
new file mode 100644
index 000000000..a8fcb865b
--- /dev/null
+++ b/src/main/resources/org/support/project/knowledge/dao/sql/KnowledgesDao/KnowledgesDao_selectKnowledgeWithUserName.sql
@@ -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 ?
+
diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCount.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCount.sql
new file mode 100644
index 000000000..19ff0d44c
--- /dev/null
+++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCount.sql
@@ -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 ?
+
diff --git a/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql
new file mode 100644
index 000000000..9104c809c
--- /dev/null
+++ b/src/main/resources/org/support/project/knowledge/dao/sql/TagsDao/TagsDao_selectWithKnowledgeCountAdmin.sql
@@ -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 ?
diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp
index 461d2ed71..078cfb389 100644
--- a/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp
+++ b/src/main/webapp/WEB-INF/views/commons/layout/commonHeader.jsp
@@ -12,6 +12,7 @@
+
diff --git a/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp b/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp
index b24bae538..b59ddc961 100644
--- a/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp
+++ b/src/main/webapp/WEB-INF/views/commons/layout/commonScripts.jsp
@@ -22,7 +22,20 @@