package com.fuyuanshen.app.controller;

import com.fuyuanshen.app.domain.bo.AppOperationVideoBo;
import com.fuyuanshen.app.domain.vo.AppOperationVideoVo;
import com.fuyuanshen.app.service.IAppOperationVideoService;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
import com.fuyuanshen.common.web.core.BaseController;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * APP 操作视频管理
 * @date 2025-06-27
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/operationVideo")
public class AppOperationVideoController extends BaseController {

    private final IAppOperationVideoService appOperationVideoService;


    /**
     * 查询操作视频列表
     */
    @GetMapping("/listOperationVideos")
    public R<List<AppOperationVideoVo>> listOperationVideos(AppOperationVideoBo bo) {
        return R.ok(appOperationVideoService.queryList(bo));
    }

    /**
     * 查询操作视频详情信息
     */
    @GetMapping("/getOperationVideoInfo")
    public R<AppOperationVideoVo> getOperationVideoInfo(AppOperationVideoBo bo) {
        return R.ok(appOperationVideoService.queryById(bo.getId()));
    }

    /**
     * 操作视频添加
     */
    @PostMapping("/addOperationVideo")
    public R<Void> addOperationVideo(@RequestBody AppOperationVideoBo bo) {
        AppLoginUser loginUser = AppLoginHelper.getLoginUser();
        if (loginUser != null) {
            bo.setCreateBy(loginUser.getUserId());
        }
        return toAjax(appOperationVideoService.insertByBo(bo));
    }

    /**
     * 操作视频编辑
     */
    @PostMapping("/editOperationVideo")
    public R<Void> editOperationVideo(@RequestBody AppOperationVideoBo bo) {
        return toAjax(appOperationVideoService.updateByBo(bo));
    }

    /**
     * 操作视频删除
     */
    @DeleteMapping("/deleteOperationVideo/{id}")
    public R<Void> deleteOperationVideo(@PathVariable Long id) {
        return toAjax(appOperationVideoService.deleteWithValidByIds(List.of(id), true));
    }

}
