朋友圈功能完善&bug修改
This commit is contained in:
@@ -5,10 +5,8 @@ package user
|
||||
import (
|
||||
"acquaintances/biz/dal/mysql"
|
||||
"acquaintances/biz/model"
|
||||
"context"
|
||||
"github.com/cloudwego/hertz/pkg/common/hlog"
|
||||
|
||||
user "acquaintances/biz/model/user"
|
||||
"context"
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||
)
|
||||
@@ -24,7 +22,6 @@ func CreateMoment(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusBadRequest, "请求参数错误")
|
||||
return
|
||||
}
|
||||
hlog.Errorf("+++++++")
|
||||
// 验证用户是否存在(实际项目中应通过token获取用户ID并验证)
|
||||
exists, err := mysql.CheckUserExists(req.UserID)
|
||||
if err != nil {
|
||||
@@ -101,7 +98,7 @@ func ListMomentsAppoint(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteMoment .
|
||||
// DeleteMoment . 删除动态
|
||||
// @router /v1/Moments/ [DELETE]
|
||||
func DeleteMoment(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
@@ -121,7 +118,7 @@ func DeleteMoment(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// LikeMoment .
|
||||
// LikeMoment .点赞
|
||||
// @router /v1/Moments/like/ [POST]
|
||||
func LikeMoment(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
@@ -141,7 +138,7 @@ func LikeMoment(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// UnlikeMoment .
|
||||
// UnlikeMoment .取消点赞
|
||||
// @router /v1/Moments/dislike/ [POST]
|
||||
func UnlikeMoment(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
@@ -161,7 +158,7 @@ func UnlikeMoment(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListMomentLikes .
|
||||
// ListMomentLikes .获取点赞人员列表
|
||||
// @router /v1/Moments/like/list/ [GET]
|
||||
func ListMomentLikes(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
@@ -171,13 +168,19 @@ func ListMomentLikes(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
data, total, err := mysql.GetLikeUserList(req)
|
||||
if err != nil {
|
||||
c.JSON(consts.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(user.ListMomentLikesResponse)
|
||||
resp.Likes = data
|
||||
resp.Total = total
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// CommentMoment .
|
||||
// CommentMoment .评论
|
||||
// @router /v1/Moments/comment/ [POST]
|
||||
func CommentMoment(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
@@ -187,13 +190,16 @@ func CommentMoment(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
if err := mysql.CommentMoment(req); err != nil {
|
||||
c.JSON(consts.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(user.CommentMomentResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// ListMomentComments .
|
||||
// ListMomentComments .获取评论列表
|
||||
// @router /v1/Moments/comment/list/ [GET]
|
||||
func ListMomentComments(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
@@ -203,13 +209,19 @@ func ListMomentComments(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
data, total, err := mysql.ListMomentComments(req)
|
||||
if err != nil {
|
||||
c.JSON(consts.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(user.ListMomentCommentsResponse)
|
||||
resp.Comments = data
|
||||
resp.Total = total
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
// DeleteComment .
|
||||
// DeleteComment .删除评论
|
||||
// @router /v1/Moments/comment/ [DELETE]
|
||||
func DeleteComment(ctx context.Context, c *app.RequestContext) {
|
||||
var err error
|
||||
@@ -219,7 +231,11 @@ func DeleteComment(ctx context.Context, c *app.RequestContext) {
|
||||
c.JSON(consts.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = mysql.DeleteComment(req)
|
||||
if err != nil {
|
||||
c.JSON(consts.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
resp := new(user.DeleteCommentResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
|
Reference in New Issue
Block a user