feat: 添加日志管理和敏感词过滤功能
- 新增日志管理模块:操作日志、登录日志、数据变更日志 - 新增敏感词过滤器 (sanitizer) - 新增日志异步写入管理器 - 新增日志定时清理服务 - 优化帖子相关服务和上传服务
This commit is contained in:
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"carrot_bbs/internal/model"
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -35,11 +36,24 @@ func (r *PostRepository) Create(post *model.Post, images []string) error {
|
||||
}
|
||||
|
||||
// 创建图片记录
|
||||
for i, url := range images {
|
||||
// 支持格式:["url", "url|preview_url|preview_url_large", ...]
|
||||
for i, imageData := range images {
|
||||
parts := strings.Split(imageData, "|")
|
||||
url := parts[0]
|
||||
var previewURL, previewURLLarge string
|
||||
if len(parts) >= 2 && parts[1] != "" {
|
||||
previewURL = parts[1]
|
||||
}
|
||||
if len(parts) >= 3 && parts[2] != "" {
|
||||
previewURLLarge = parts[2]
|
||||
}
|
||||
|
||||
image := &model.PostImage{
|
||||
PostID: post.ID,
|
||||
URL: url,
|
||||
SortOrder: i,
|
||||
PostID: post.ID,
|
||||
URL: url,
|
||||
PreviewURL: previewURL,
|
||||
PreviewURLLarge: previewURLLarge,
|
||||
SortOrder: i,
|
||||
}
|
||||
if err := tx.Create(image).Error; err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user