已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
31
backend/api/internal/logic/client/user/content_detail.go
Normal file
31
backend/api/internal/logic/client/user/content_detail.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// 功能:公开安全内容详情,仅允许读取已启用发布的图文内容;版本: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})
|
||||
}
|
||||
Reference in New Issue
Block a user