feat: 媒体库添加手动色情标记功能,默认分页改为10条

This commit is contained in:
2025-08-15 21:18:20 +08:00
parent 925ee5b1ea
commit 367240133f
4 changed files with 58 additions and 1 deletions
+28
View File
@@ -137,6 +137,34 @@ func (c *MediaController) Preview(ctx *gin.Context) {
ctx.File(path)
}
// UpdateManualNsfw 处理 PUT /api/media/:id/manual-nsfw:更新手动色情标记。
func (c *MediaController) UpdateManualNsfw(ctx *gin.Context) {
idStr := ctx.Param("id")
var id int64
if _, err := fmt.Sscanf(idStr, "%d", &id); err != nil || id <= 0 {
Error(ctx, http.StatusBadRequest, "无效的 ID")
return
}
var req struct {
Value string `json:"value"`
}
if err := ctx.ShouldBindJSON(&req); err != nil {
Error(ctx, http.StatusBadRequest, "请求参数错误:"+err.Error())
return
}
if req.Value != "Y" && req.Value != "N" {
Error(ctx, http.StatusBadRequest, "值必须是 Y 或 N")
return
}
if err := c.store.UpdateManualNsfw(id, req.Value); err != nil {
Error(ctx, http.StatusInternalServerError, "更新失败:"+err.Error())
return
}
Success(ctx, nil)
}
// toMediaView 给一条数据库记录补上展示用的派生字段。
func toMediaView(m store.MediaInfo) mediaView {
v := mediaView{MediaInfo: m}