Skip to content

Commit

Permalink
#444 Add a feature to register "like" on comment
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Aug 9, 2017
1 parent 4fde788 commit e4b1ba6
Show file tree
Hide file tree
Showing 37 changed files with 1,267 additions and 93 deletions.
Binary file modified document/database/A5M2_knowledge.pdf
Binary file not shown.
93 changes: 66 additions & 27 deletions document/database/knowledge.a5er
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,44 @@ SqlSeparator=0
ShowTag=1
ShowCommonAttributes=0

[Relation]
Entity1=COMMENTS
Entity2=LIKE_COMMENTS
RelationType1=1
RelationType2=3
Fields1=COMMENT_NO
Fields2=COMMENT_NO
Cardinarity1=
Cardinarity2=
Position="MAIN",0,3695,3149,4099,R,R
Dependence=0
Caption=
PName=
LineMode=0
Bar1=370
Bar2=315
Bar3=410
TermPos1=R
TermPos2=R

[Entity]
PName=LIKE_COMMENTS
LName=コメントのイイネ
Comment=
TableOption=
Page=Main
Left=1600
Top=1450
Field="NO","NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,""
Field="コメント番号","COMMENT_NO","bigint","NOT NULL",,"","",$FFFFFFFF,""
Field="種類","LIKE_CLASS","@INT",,,"1","",$FFFFFFFF,""
Index=IDX_LIKE_COMMENTS_COMMENT_NO=0,COMMENT_NO
EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170809123907
Position="Main",1600,1450

[Entity]
PName=TOKENS
LName=認証トークン
Expand Down Expand Up @@ -228,7 +266,7 @@ Fields1=KNOWLEDGE_ID
Fields2=ITEM_NO
Cardinarity1=
Cardinarity2=
Position="MAIN",0,4194,5115,6199,R,R
Position="MAIN",0,4194,5115,6198,R,R
Dependence=0
Caption=
PName=
Expand All @@ -247,7 +285,7 @@ Comment=
TableOption=
Page=MAIN
Left=2450
Top=1600
Top=1800
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,""
Field="回答ID","ANSWER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,""
Field="項目NO","ITEM_NO","@INT","NOT NULL",2,"","",$FFFFFFFF,""
Expand All @@ -256,7 +294,7 @@ EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170222220138
Position="MAIN",2450,1600
Position="MAIN",2450,1800

[Relation]
Entity1=SURVEYS
Expand Down Expand Up @@ -285,14 +323,14 @@ Comment=
TableOption=
Page=MAIN
Left=1950
Top=1600
Top=1800
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,""
Field="回答ID","ANSWER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,""
EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170222215330
Position="MAIN",1950,1600
Position="MAIN",1950,1800

[Relation]
Entity1=SURVEY_ITEMS
Expand All @@ -303,7 +341,7 @@ Fields1=KNOWLEDGE_ID,ITEM_NO
Fields2=KNOWLEDGE_ID,ITEM_NO
Cardinarity1=
Cardinarity2=
Position="MAIN",0,4139,4896,5178,R,R
Position="MAIN",0,4139,4896,5177,R,R
Dependence=1
Caption=
PName=
Expand All @@ -322,7 +360,7 @@ Comment=
TableOption=
Page=MAIN
Left=2450
Top=1100
Top=1300
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,""
Field="項目NO","ITEM_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,""
Field="選択肢番号","CHOICE_NO","@INT","NOT NULL",2,"","",$FFFFFFFF,""
Expand All @@ -332,7 +370,7 @@ EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170220203842
Position="MAIN",2450,1100
Position="MAIN",2450,1300

[Relation]
Entity1=SURVEYS
Expand Down Expand Up @@ -362,7 +400,7 @@ Comment=
TableOption=
Page=MAIN
Left=2500
Top=1350
Top=1550
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,""
Field="項目NO","ITEM_NO","@INT","NOT NULL",1,"","",$FFFFFFFF,""
Field="項目名","ITEM_NAME","@VARCHAR(32)","NOT NULL",,"","",$FFFFFFFF,""
Expand All @@ -372,7 +410,7 @@ EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170220203458
Position="MAIN",2500,1350
Position="MAIN",2500,1550

[Relation]
Entity1=KNOWLEDGES
Expand Down Expand Up @@ -401,15 +439,15 @@ Comment=
TableOption=
Page=MAIN
Left=1950
Top=1400
Top=1600
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,""
Field="タイトル","TITLE","@VARCHAR(256)","NOT NULL",,"","",$FFFFFFFF,""
Field="説明","DESCRIPTION","text",,,"","",$FFFFFFFF,""
EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170220203309
Position="MAIN",1950,1400
Position="MAIN",1950,1600

[Relation]
Entity1=EVENTS
Expand Down Expand Up @@ -459,7 +497,7 @@ Comment=
TableOption=
Page=MAIN
Left=1350
Top=1500
Top=1700
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,""
Field="開催日","START_DATE_TIME","@DATETIME","NOT NULL",,"","UTC",$FFFFFFFF,""
Field="タイムゾーン","TIME_ZONE","@VARCHAR(64)",,,"","",$FFFFFFFF,""
Expand All @@ -468,7 +506,7 @@ EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170307155432
Position="MAIN",1350,1500
Position="MAIN",1350,1700

[Entity]
PName=PARTICIPANTS
Expand All @@ -477,15 +515,15 @@ Comment=
TableOption=
Page=MAIN
Left=1350
Top=1750
Top=1900
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",0,"","",$FFFFFFFF,""
Field="ユーザID","USER_ID","@INT","NOT NULL",1,"","",$FFFFFFFF,""
Field="ステータス","STATUS","@INT","NOT NULL",,"","",$FFFFFFFF,""
EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20170222215215
Position="MAIN",1350,1750
Position="MAIN",1350,1900

[Relation]
Entity1=SERVICE_CONFIGS
Expand Down Expand Up @@ -748,15 +786,15 @@ Fields1=HOOK_ID
Fields2=HOOK_ID
Cardinarity1=
Cardinarity2=
Position="MAIN",0,4081,5073,3934,R,R
Position="MAIN",0,4081,5073,4018,R,R
Dependence=1
Caption=
PName=
ModifiedDateTime=20160603134957
LineMode=0
Bar1=408
Bar2=507
Bar3=393
Bar3=402
TermPos1=R
TermPos2=R

Expand Down Expand Up @@ -1150,15 +1188,15 @@ Comment=
TableOption=
Page=MAIN
Left=50
Top=500
Top=450
Field="HASH","HASH","@VARCHAR(32)","NOT NULL",0,"","",$FFFFFFFF,""
Field="種類","TYPE","@INT","NOT NULL",,"","",$FFFFFFFF,""
Field="通知する種類のID","ID","bigint","NOT NULL",,"","",$FFFFFFFF,""
EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20150331055404
Position="MAIN",50,500
Position="MAIN",50,450

[Entity]
PName=NOTIFY_CONFIGS
Expand All @@ -1167,7 +1205,7 @@ Comment=
TableOption=
Page=MAIN
Left=50
Top=140
Top=100
Field="ユーザID","USER_ID","@INT","NOT NULL",0,"","",$FFFFFFFF,""
Field="メール通知する","NOTIFY_MAIL","@INT",,,"","",$FFFFFFFF,""
Field="デスクトップ通知する","NOTIFY_DESKTOP","@INT",,,"","",$FFFFFFFF,""
Expand All @@ -1183,7 +1221,7 @@ EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20150328062820
Position="MAIN",50,140
Position="MAIN",50,100

[Relation]
Entity1=COMMENTS
Expand Down Expand Up @@ -1254,15 +1292,16 @@ Comment=
TableOption=
Page=MAIN
Left=50
Top=650
Top=600
Field="NO","NO","BIGSERIAL","NOT NULL",0,"","",$FFFFFFFF,""
Field="ナレッジID","KNOWLEDGE_ID","bigint","NOT NULL",,"","",$FFFFFFFF,""
Field="種類","LIKE_CLASS","@INT",,,"1","",$FFFFFFFF,""
Index=IDX_LIKES_KNOWLEDGE_ID=0,KNOWLEDGE_ID
EffectMode=None
Color=$000000
BkColor=$FFFFFF
ModifiedDateTime=20150416233511
Position="MAIN",50,650
ModifiedDateTime=20170809123852
Position="MAIN",50,600

[Relation]
Entity1=KNOWLEDGES
Expand Down Expand Up @@ -1505,14 +1544,14 @@ Fields1=TAG_ID
Fields2=TAG_ID
Cardinarity1=
Cardinarity2=
Position="MAIN",0,4552,5672,4659,R,R
Position="MAIN",0,4552,5672,4574,R,R
Dependence=1
Caption=
PName=
LineMode=0
Bar1=455
Bar2=567
Bar3=466
Bar3=457
TermPos1=R
TermPos2=R

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.support.project.knowledge.dao.KnowledgeHistoriesDao;
import org.support.project.knowledge.dao.KnowledgeItemValuesDao;
import org.support.project.knowledge.dao.KnowledgesDao;
import org.support.project.knowledge.dao.LikeCommentsDao;
import org.support.project.knowledge.dao.LikesDao;
import org.support.project.knowledge.dao.StocksDao;
import org.support.project.knowledge.dao.TagsDao;
Expand Down Expand Up @@ -186,6 +187,9 @@ public Boundary view() throws InvalidParamException, ParseException {
for (CommentsEntity commentsEntity : comments) {
MarkDown markDown2 = MarkdownLogic.get().markdownToHtml(commentsEntity.getComment());
commentsEntity.setComment(markDown2.getHtml());

Long likeCount = LikeCommentsDao.get().selectOnCommentNo(commentsEntity.getCommentNo());
commentsEntity.setLikeCount(likeCount);
}
setAttribute("comments", comments);

Expand Down Expand Up @@ -639,11 +643,6 @@ public Boundary stocks() throws InvalidParamException {
return forward("stocks.jsp");
}






/**
* いいねを押下
*
Expand All @@ -660,6 +659,20 @@ public Boundary like() throws InvalidParamException {
likeCount.setCount(count);
return send(likeCount);
}
/**
* コメントにイイネを押下
* @return
* @throws InvalidParamException
*/
@Post
public Boundary likecomment() throws InvalidParamException {
Long commentNo = super.getPathLong(Long.valueOf(-1));
KnowledgeLogic knowledgeLogic = KnowledgeLogic.get();
Long count = knowledgeLogic.addLikeComment(commentNo, getLoginedUser());
LikeCount likeCount = new LikeCount();
likeCount.setCount(count);
return send(likeCount);
}

/**
* タイトルとコンテンツの危険なタグをエスケープした結果を返す
Expand Down Expand Up @@ -768,6 +781,10 @@ public Boundary likes() throws InvalidParamException {
return forward("likes.jsp");
}





/**
* 編集履歴の表示
*
Expand Down Expand Up @@ -920,4 +937,5 @@ public Boundary items() throws ParseException {
return super.send(listdata);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.support.project.knowledge.dao;

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;

/**
* コメントのイイネ
*/
@DI(instance = Instance.Singleton)
public class LikeCommentsDao extends GenLikeCommentsDao {

/** SerialVersion */
private static final long serialVersionUID = 1L;
/**
* Get instance from DI container.
* @return instance
*/
public static LikeCommentsDao get() {
return Container.getComp(LikeCommentsDao.class);
}

public Long selectOnCommentNo(Long commentNo) {
String sql = "SELECT COUNT(*) FROM LIKE_COMMENTS WHERE COMMENT_NO = ?";
return super.executeQuerySingle(sql, Long.class, commentNo);
}



}
Loading

0 comments on commit e4b1ba6

Please sign in to comment.