UPDATE article AS A
INNER JOIN (
SELECT RP.relTypeCode, RP.relId,
SUM(IF(RP.point > 0, RP.point, 0)) AS goodReactionPoint,
SUM(IF(RP.point < 0, RP.point * -1, 0)) AS badReactionPoint
FROM reactionPoint AS RP
GROUP BY RP.relTypeCode, RP.relId
) AS RP_SUM
ON A.id = RP_SUM.relId
SET A.goodReactionPoint = RP_SUM.goodReactionPoint,
A.badReactionPoint = RP_SUM.badReactionPoint;
article테이블에 업데이트
1) needLoginInterceptor인터셉터에 addPathPatterns추가
registry.addInterceptor(needLoginInterceptor).addPathPatterns("/usr/article/write")
.addPathPatterns("/usr/article/doWrite").addPathPatterns("/usr/article/modify")
.addPathPatterns("/usr/article/doModify").addPathPatterns("/usr/article/doDelete")
.addPathPatterns("/usr/article/doDelete").addPathPatterns("/usr/reactionPoint/doGoodReaction")
.addPathPatterns("/usr/reactionPoint/doBadReaction");
"/usr/reactionPoint/doGoodReaction"
, "/usr/reactionPoint/doBadReaction"
의 uri요청시 인터셉터가 적용하도록2) 좋아요 싫어요 버튼 클릭시 해당 uri로 이동
<c:if test="${actorCanMakeReaction}">
<span> </span>
<a href="/usr/reactionPoint/doGoodReaction" class="btn btn-outline btn-xs">좋아요 👍</a>
<span> </span>
<a href="/usr/reactionPoint/doBadReaction" class="btn btn-outline btn-xs">싫어요 👎</a>
</c:if>