feat: import services and standardize Go 1.26.5
This commit is contained in:
50
apps/social/feed/internal/logic/post/change.go
Normal file
50
apps/social/feed/internal/logic/post/change.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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"
|
||||
"git.apinb.com/bsm-social/feed/internal/models"
|
||||
pb "git.apinb.com/bsm-social/feed/pb"
|
||||
)
|
||||
|
||||
// 修改推文
|
||||
func Change(ctx context.Context, in *pb.PostItem) (reply *pb.StatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetContent() == "" || in.Identity == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
var postData = models.FeedPost{
|
||||
Std_IICUDS: types.Std_IICUDS{Identity: in.Identity},
|
||||
Content: in.Content,
|
||||
IsOpen: in.IsOpen,
|
||||
}
|
||||
|
||||
if len(in.GetAttachs()) != 0 {
|
||||
for _, val := range in.Attachs {
|
||||
postData.Attachs = append(postData.Attachs, models.FeedRelateAttach{
|
||||
Identity: utils.UUID(),
|
||||
AttachType: val.AttachType,
|
||||
Url: val.Url,
|
||||
})
|
||||
}
|
||||
}
|
||||
err = models.ChargePost(&postData)
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
return &pb.StatusReply{
|
||||
Data: postData.Identity,
|
||||
Timeseq: time.Now().UnixNano(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user