提交 c0ec4075 编写于 作者: 街头小贩's avatar 街头小贩

修正喜好记录的增加bug

上级 2395240b
......@@ -59,7 +59,7 @@ public interface PostsMoodRecordsService {
* @param topicId 话题ID
* @param like 是否为赞,true,false为讨厌
* @param culpritor 操作的肇事信息
* @return -1表示点过赞了,大于0表示点赞成功,0点赞失败
* @return -1表示删除喜好,大于0表示喜好增加成功,0喜好增加失败
*/
long toggleMoodRecord(long id, long topicId, boolean like, ActionEventCulpritor culpritor);
}
\ No newline at end of file
}
......@@ -69,7 +69,14 @@ public class PostsMoodController {
// 移至StrategyInterceptorAdapter
//----------------------------------
boolean liked = (moodStatus == 1);
return TipMessage.Builder.of(()->postsMoodRecordsService.toggleMoodRecord(postsId, tpObj.getId(), liked, aec)>0).success("回复点赞成功").error("点赞失败");
long retVal = postsMoodRecordsService.toggleMoodRecord(postsId, tpObj.getId(), liked, aec);
if(-1 == retVal){
return TipMessage.ofSuccess("操作成功", "DEL");
}
if(retVal > 0){
return TipMessage.ofSuccess("操作成功", "ADD");
}
return TipMessage.ofError("操作失败");
}
//查看点赞的计数
......@@ -97,4 +104,4 @@ public class PostsMoodController {
Map<String, Object> result = Map.ofEntries(Map.entry("topic", tpObj.getId()), Map.entry("result", data));
return callBackFun + "(" + new Gson().toJson(result) + ");";
}
}
\ No newline at end of file
}
......@@ -26,11 +26,19 @@ define('jForumXhrDefer', ['require','jquery'], function (require, $) {
});
};
//回复点赞计数更新
da.updateMoodCounter = function(jqEle){
da.updateMoodCounter = function(jqEle, inputVal){
var cc = jqEle.find('span');
var upC = 1;
if(cc.length == 1){
upC += parseInt(cc.html());
//是+是-
var curVal = parseInt(cc.html());
if('ADD' === inputVal){
curVal += 1;
}
if('DEL' === inputVal){
curVal -= 1;
}
upC = curVal;
}else{
cc = $('<span></span>').appendTo(jqEle);
}
......@@ -107,4 +115,4 @@ define('jForumXhrDefer', ['require','jquery'], function (require, $) {
return da;
})();
return jForumXhrDefer;
});
\ No newline at end of file
});
......@@ -81,7 +81,7 @@ define('jForumXhr', ['require','jquery','jForumUtils','jForumTemplate','jForumXh
//成功:有回调的执行回调,没有回调的提示
if (response.level === 'acc') {
try {
xhrDefer[callFun](jqEle);
xhrDefer[callFun](jqEle, response.input);
} catch (e) { console.error(e.message); }
} else { //失败:都提示
showTipMessage = true;
......@@ -159,4 +159,4 @@ define('jForumXhr', ['require','jquery','jForumUtils','jForumTemplate','jForumXh
return jqXhr;
})();
return jForumXhr;
});
\ No newline at end of file
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册