32 lines
1.3 KiB
Go
32 lines
1.3 KiB
Go
|
|
// 功能:公开安全内容详情,仅允许读取已启用发布的图文内容;版本:1.0.0。
|
|||
|
|
package user
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"errors"
|
|||
|
|
"git.apinb.com/bsm-sdk/core/errcode"
|
|||
|
|
"git.apinb.com/bsm-sdk/core/infra"
|
|||
|
|
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
|||
|
|
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
|
|||
|
|
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
|||
|
|
"github.com/gin-gonic/gin"
|
|||
|
|
"gorm.io/gorm"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// PublicSafetyContent 按公开标识重新校验发布状态,旧链接不能访问草稿和下架内容。
|
|||
|
|
func PublicSafetyContent(ctx *gin.Context) {
|
|||
|
|
var content models.CmsContent
|
|||
|
|
err := impl.DBService.Where("identity = ? AND status = ? AND publish_status = ? AND content_type IN ?",
|
|||
|
|
ctx.Param("identity"), common.StatusEnable, "published", []string{"notice", "safety_article", "law"}).Take(&content).Error
|
|||
|
|
if err != nil {
|
|||
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|||
|
|
infra.Response.Error(ctx, errcode.ErrRecordNotFound)
|
|||
|
|
} else {
|
|||
|
|
infra.Response.Error(ctx, err)
|
|||
|
|
}
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
// 白名单输出正文所需字段,避免内部主键及未来管理字段泄露。
|
|||
|
|
infra.Response.Success(ctx, gin.H{"identity": content.Identity, "title": content.Title,
|
|||
|
|
"body": content.Body, "content_type": content.ContentType, "version_no": content.VersionNo})
|
|||
|
|
}
|