fix version 1

This commit is contained in:
2026-09-22 21:15:34 +08:00
parent 9f86366638
commit d63d7e8b3a
277 changed files with 9959 additions and 1514 deletions

View File

@@ -7,7 +7,6 @@ import (
"bsm/full/module/base/cms/internal/impl"
"bsm/full/module/base/cms/internal/models"
pb "bsm/full/module/base/cms/pb"
"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"
@@ -32,12 +31,16 @@ func AddComment(ctx context.Context, in *pb.CommentItem) (*pb.StatusReply, error
Cms: in.Cms,
}
authName := map[string]any{}
err = impl.DBService.Table("mall_staff").Take(&authName, "identity=?", auth.Identity).Error
if err != nil {
if err = impl.DBService.Table("mall_staff").Take(&authName, "identity=?", auth.Identity).Error; err != nil {
// 非 mall_staff 用户(普通会员等)查不到记录时不阻断评论,仅记录日志
printer.Error(err.Error())
return nil, errcode.ErrDB
}
data.OwnerName = authName["name"].(string)
// 安全类型断言:未命中或 name 为 NULL 时取不到名字,避免 panic
if v, ok := authName["name"].(string); ok {
data.OwnerName = v
} else {
data.OwnerName = auth.Identity
}
err = models.AddComment(&data, auth.Identity)
if err != nil {
return nil, err