package cn.reghao.tnb.content.app.vod.controller;

import cn.reghao.jutil.jdk.result.Result;
import cn.reghao.jutil.web.WebResult;
import cn.reghao.tnb.content.app.vod.model.dto.VideoEdit;
import cn.reghao.tnb.content.app.vod.model.dto.VideoErrorReport;
import cn.reghao.tnb.content.app.vod.model.dto.VideoVipTags;
import cn.reghao.tnb.content.app.vod.model.po.VipTag;
import cn.reghao.tnb.content.app.vod.service.VideoEditService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author reghao
 * @date 2025-08-02 20:12:33
 */
@Tag(name = "视频稿件编辑接口")
@RestController
@RequestMapping("/api/content/video/edit")
public class VideoEditController {
    private final VideoEditService videoEditService;

    public VideoEditController(VideoEditService videoEditService) {
        this.videoEditService = videoEditService;
    }

    @Operation(summary = "视频报错", description = "N")
    @PostMapping("/report")
    public String errorReport(@RequestBody @Validated VideoErrorReport videoErrorReport) {
        Result result = videoEditService.errorReport(videoErrorReport);
        return WebResult.result(result);
    }

    @Operation(summary = "更新视频稿件所有者", description = "N")
    @PostMapping("/update_owner")
    public String editVideo(@RequestBody @Validated VideoEdit videoEdit) {
        videoEditService.updateVideoOwner(videoEdit);
        return WebResult.success();
    }

    @Operation(summary = "获取视频稿件 VIP 标签", description = "N")
    @GetMapping(value = "/vip_tags", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getVipTags() {
        List<VipTag> list = videoEditService.getVipTags();
        return WebResult.success(list);
    }

    @Operation(summary = "设置视频稿件 VIP 标签", description = "N")
    @PostMapping(value = "/vip_tags", produces = MediaType.APPLICATION_JSON_VALUE)
    public String addVipTags(@RequestBody @Validated VideoVipTags videoVipTags) {
        videoEditService.addVipTags(videoVipTags);
        return WebResult.success();
    }
}
