feat: 更新服务层文档,增加中文注释以提升可读性
This commit is contained in:
@@ -18,18 +18,18 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// content implements content-related domain operations.
|
||||
// content 实现内容域相关的业务能力(创建/更新/定价/授权等)。
|
||||
//
|
||||
// @provider
|
||||
type content struct{}
|
||||
|
||||
// ContentDetailResult is the internal detail result used by controllers.
|
||||
// ContentDetailResult 为内容详情的内部结果(供 controller 组合返回)。
|
||||
type ContentDetailResult struct {
|
||||
// Content is the content entity.
|
||||
// Content 内容实体。
|
||||
Content *models.Content
|
||||
// Price is the price settings (may be nil).
|
||||
// Price 定价信息(可能为 nil,表示未设置价格)。
|
||||
Price *models.ContentPrice
|
||||
// HasAccess indicates whether the user can access main assets.
|
||||
// HasAccess 当前用户是否拥有主资源访问权限。
|
||||
HasAccess bool
|
||||
}
|
||||
|
||||
@@ -39,11 +39,13 @@ func (s *content) Create(ctx context.Context, tenantID, userID int64, form *dto.
|
||||
"user_id": userID,
|
||||
}).Info("services.content.create")
|
||||
|
||||
// 关键默认值:未传可见性时默认“租户内可见”。
|
||||
visibility := form.Visibility
|
||||
if visibility == "" {
|
||||
visibility = consts.ContentVisibilityTenantOnly
|
||||
}
|
||||
|
||||
// 试看策略:默认固定时长;并强制不允许下载。
|
||||
previewSeconds := consts.DefaultContentPreviewSeconds
|
||||
if form.PreviewSeconds != nil && *form.PreviewSeconds > 0 {
|
||||
previewSeconds = *form.PreviewSeconds
|
||||
@@ -96,6 +98,7 @@ func (s *content) Update(ctx context.Context, tenantID, userID, contentID int64,
|
||||
}
|
||||
if form.Status != nil {
|
||||
m.Status = *form.Status
|
||||
// 发布动作:首次发布时补齐发布时间,便于后续排序/检索与审计。
|
||||
if m.Status == consts.ContentStatusPublished && m.PublishedAt.IsZero() {
|
||||
m.PublishedAt = time.Now()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user