feat: import services and standardize Go 1.26.5
This commit is contained in:
54
apps/base/cms/internal/logic/post/modify.go
Normal file
54
apps/base/cms/internal/logic/post/modify.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package post
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-apps/cms/internal/models"
|
||||
"git.apinb.com/bsm-apps/cms/internal/utils"
|
||||
pb "git.apinb.com/bsm-apps/cms/pb"
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
// 修改文章
|
||||
func Modify(ctx context.Context, in *pb.PostItem) (reply *pb.StatusReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if in.GetSiteIdentity() == "" || in.GetIdentity() == "" {
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
var data = &models.CmsPost{
|
||||
SiteIdentity: in.SiteIdentity,
|
||||
Title: in.Title,
|
||||
Description: in.Description,
|
||||
CoverPath: in.CoverPath,
|
||||
Author: in.Author,
|
||||
Content: in.Content,
|
||||
TargetUrl: in.TargetUrl,
|
||||
SourceUrl: in.SourceUrl,
|
||||
HasAccessory: in.HasAccessory,
|
||||
Types: in.PostType,
|
||||
Hash: utils.FormatKey(in.Key),
|
||||
Lang: in.Lang,
|
||||
SourceOrigin: in.SourceOrigin,
|
||||
Rights: in.Rights,
|
||||
ExtendUrl: in.ExtendUrl,
|
||||
ExtendData: in.ExtendData,
|
||||
ExtendImg: in.ExtendImg,
|
||||
ExtendDesc: in.ExtendDesc,
|
||||
}
|
||||
err = models.ModifyPost(in.Identity, data, in.AccessoryIdentityArray, in.CategoryIdentityArray, in.TagsIdentityArray)
|
||||
if err != nil {
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
|
||||
return &pb.StatusReply{
|
||||
Code: 0,
|
||||
Message: "OK",
|
||||
Timeseq: time.Now().Unix(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user