Skip to content

Commit

Permalink
#444 Add a page of liked users list
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Aug 9, 2017
1 parent 5d80f87 commit 497d3c3
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>org.support-project</groupId>
<artifactId>web</artifactId>
<version>1.10.0</version>
<version>1.11.0-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.support.project.knowledge.entity.KnowledgeHistoriesEntity;
import org.support.project.knowledge.entity.KnowledgeItemValuesEntity;
import org.support.project.knowledge.entity.KnowledgesEntity;
import org.support.project.knowledge.entity.LikeCommentsEntity;
import org.support.project.knowledge.entity.LikesEntity;
import org.support.project.knowledge.entity.StocksEntity;
import org.support.project.knowledge.entity.TagsEntity;
Expand Down Expand Up @@ -782,8 +783,44 @@ public Boundary likes() throws InvalidParamException {
}


/**
* いいねを押したユーザを一覧表示(コメントに対し)
*
* @return
* @throws InvalidParamException
*/
@Get
public Boundary likecomments() throws InvalidParamException {
// 共通処理呼の表示条件の保持の呼び出し
setViewParam();

Long commentNo = super.getPathLong(Long.valueOf(-1));
CommentsEntity comment = CommentsDao.get().selectOnKey(commentNo);
if (comment == null) {
return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND");
}
setAttribute("knowledgeId", comment.getKnowledgeId());
setAttribute("commentNo", comment.getKnowledgeId());

Integer page = 0;
String p = getParamWithDefault("page", "");
if (StringUtils.isInteger(p)) {
page = Integer.parseInt(p);
}

List<LikeCommentsEntity> likes = LikeCommentsDao.get().selectOnCommentNo(commentNo, page * PAGE_LIMIT, PAGE_LIMIT);
setAttribute("likes", likes);

int previous = page - 1;
if (previous < 0) {
previous = 0;
}
setAttribute("page", page);
setAttribute("previous", previous);
setAttribute("next", page + 1);

return forward("likes.jsp");
}

/**
* 編集履歴の表示
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.support.project.knowledge.dao;

import java.util.List;

import org.support.project.di.Container;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.dao.gen.GenLikeCommentsDao;
import org.support.project.knowledge.entity.LikeCommentsEntity;
import org.support.project.ormapping.common.SQLManager;

/**
* コメントのイイネ
Expand All @@ -26,6 +30,11 @@ public Long selectOnCommentNo(Long commentNo) {
return super.executeQuerySingle(sql, Long.class, commentNo);
}

public List<LikeCommentsEntity> selectOnCommentNo(Long commentNo, int offset, int limit) {
String sql = SQLManager.getInstance().getSql("/org/support/project/knowledge/dao/sql/LikeCommentsDao/LikeCommentsDao_selectOnCommentNo.sql");
return executeQueryList(sql, LikeCommentsEntity.class, commentNo, limit, offset);
}



}
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package org.support.project.knowledge.entity;

import org.support.project.knowledge.entity.gen.GenLikeCommentsEntity;

import java.util.List;
import java.util.Map;

import org.support.project.common.bean.ValidateError;
import org.support.project.di.Container;
import org.support.project.di.DI;
import org.support.project.di.Instance;

import java.sql.Timestamp;
import org.support.project.knowledge.entity.gen.GenLikeCommentsEntity;


/**
Expand All @@ -22,6 +15,8 @@ public class LikeCommentsEntity extends GenLikeCommentsEntity {
/** SerialVersion */
private static final long serialVersionUID = 1L;

private String userName;

/**
* Get instance from DI container.
* @return instance
Expand All @@ -46,4 +41,18 @@ public LikeCommentsEntity(Long no) {
super( no);
}

/**
* @return the userName
*/
public String getUserName() {
return userName;
}

/**
* @param userName the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT
LIKE_COMMENTS.*,
USERS.USER_NAME
FROM
LIKE_COMMENTS
LEFT OUTER JOIN USERS ON (LIKE_COMMENTS.INSERT_USER = USERS.USER_ID)
WHERE
LIKE_COMMENTS.COMMENT_NO = ?
AND LIKE_COMMENTS.DELETE_FLAG = 0
ORDER BY
LIKE_COMMENTS.UPDATE_DATETIME DESC LIMIT ? OFFSET ?;




Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</c:if>
</c:forEach>

<a href="<%=request.getContextPath()%>/open.knowledge/likeComments/<%=jspUtil.out("comment.getCommentNo()")%><%=jspUtil.out("params")%>"
<a href="<%=request.getContextPath()%>/open.knowledge/likecomments/<%=jspUtil.out("comment.getCommentNo()")%><%=jspUtil.out("params")%>"
class="text-primary btn-link">
<i class="fa fa-thumbs-o-up"></i>&nbsp;<%=jspUtil.label("knowledge.view.like")%> ×
<span id="like_comment_count_<%=comment.getCommentNo()%>">
Expand Down Expand Up @@ -174,7 +174,7 @@
</c:if>
</c:forEach>

<a href="<%=request.getContextPath()%>/open.knowledge/likeComments/<%=jspUtil.out("comment.getCommentNo()")%><%=jspUtil.out("params")%>"
<a href="<%=request.getContextPath()%>/open.knowledge/likecomments/<%=jspUtil.out("comment.getCommentNo()")%><%=jspUtil.out("params")%>"
class="text-primary btn-link">
<i class="fa fa-thumbs-o-up"></i>&nbsp;<%=jspUtil.label("knowledge.view.like")%> ×
<span id="like_comment_count_<%=comment.getCommentNo()%>">
Expand Down

0 comments on commit 497d3c3

Please sign in to comment.