refactor: reorganize modules and add Linux build tooling
This commit is contained in:
40
module/social/feed/internal/logic/post/add_comment.go
Normal file
40
module/social/feed/internal/logic/post/add_comment.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
"git.apinb.com/bsm-sdk/core/types"
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
"bsm/full/module/social/feed/internal/models"
|
||||
pb "bsm/full/module/social/feed/pb"
|
||||
)
|
||||
|
||||
// 新建评论
|
||||
func AddComment(ctx context.Context, in *pb.CommentItem) (reply *pb.StatusReply, err error) {
|
||||
auth, err := service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var data = &models.FeedComment{
|
||||
Std_IICUDS: types.Std_IICUDS{Identity: utils.UUID()},
|
||||
PostIdentity: in.PostIdentity,
|
||||
Content: in.Content,
|
||||
}
|
||||
if in.Identity != "" {
|
||||
data.ParentIdentity = in.Identity
|
||||
}
|
||||
if err := models.AddComment(data, auth.Identity); err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: data.Identity,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user