提交 d2a5593d 编写于 作者: 0 042003124

完善接口,修改点赞bug

上级 f418c60b
......@@ -26,13 +26,12 @@ exports.main = async (event, context) => {
const res2 = await comment_table.doc(event.commentId).update({
likes:like
})
return{
code:200,
message:"点赞评论成功",
data:{
commentId:comment.data[0]["_id"],
newLikes:like
newlikes:like
}
}
}
......@@ -59,7 +58,7 @@ exports.main = async (event, context) => {
message:"取消点赞评论成功",
data:{
commentId:comment2.data[0]["_id"],
newLikes:like2
newlikes:like2
}
}
}
......
......@@ -12,7 +12,7 @@ exports.main = async (event, context) => {
post_id:event.postId,
owner_id:event.userId
}).get()
if(islike.affectedDocs == 0 && res.affectedDocs == 1){
const res2 = await post_table.doc(event.postId).update({
likes:res.data[0]["likes"] + 1
......
......@@ -12,7 +12,7 @@ exports.main = async (event, context) => {
_id:event.postId
}).get()
const res3 = await comment_table.where({
const res3 = await comment_table.orderBy("date","desc").where({
post_id:event.postId
}).get()
......@@ -36,6 +36,7 @@ exports.main = async (event, context) => {
var comment ={
commenterIcon:res4.data[0]["icon"],
commenterName:res4.data[0]["name"],
commentId:arr[i]["_id"],
commentContent:arr[i]["content"],
commentDatetime:arr[i]["date"],
commentLikes:arr[i]["likes"],
......@@ -50,12 +51,14 @@ exports.main = async (event, context) => {
const res2 = await user_table.where({
_id:res.data[0]["owner_id"]
}).get()
var likepost = 0
const postLike = await post_like.where({
owner_id:event.userId,
post_id:event.postId
}).get()
if(postLike == 1) likepost = 1
if(postLike.affectedDocs == 1) likepost = 1
if(res2.affectedDocs == 1){
return {
code: 200,
......
......@@ -2,8 +2,8 @@
exports.main = async (event, context) => {
const db = uniCloud.database();
const running_table = db.collection('mustgo-running-record')
let res = await running_table.where({
_id: event.userId
let res = await running_table.orderBy("start_date","desc").where({
owner_id: event.userId
}).get()
var arr = new Array
var list = new Array
......
......@@ -2,7 +2,7 @@
exports.main = async (event, context) => {
const db = uniCloud.database();
const walking_table = db.collection('mustgo-walking-record')
var res = await walking_table.where({
var res = await walking_table.orderBy("start_date","desc").where({
owner_id: event.userId
}).get()
......@@ -15,7 +15,7 @@ exports.main = async (event, context) => {
var record = {
walkingId: arr[i]["_id"],
distance: arr[i]["distance"],
steps: arr[i]["steps"],
pace: arr[i]["pace"],
startDatetime: arr[i]["start_date"]
}
list.push(record)
......@@ -24,7 +24,7 @@ exports.main = async (event, context) => {
code: 200,
message: "成功返回健走记录列表",
data: {
runningList: list
walkingList: list
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册