package com.seer.teach.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.admin.request.AdminAiScenarioPageReq;
import com.seer.teach.admin.request.AdminAiScenarioReq;
import com.seer.teach.admin.response.AdminAiScenarioResp;
import com.seer.teach.admin.service.AdminAiScenarioService;
import com.seer.teach.common.PageListBean;
import com.seer.teach.common.ResultBean;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * AiScenario控制器
 *
 * @author System
 * @since 2025-10-27
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/teacher/ai/scenario")
@Tag(name = "管理端 - AI场景定义")
public class AdminAiScenarioController {

    private final AdminAiScenarioService adminAiScenarioService;

    @PostMapping("/paged")
    @Operation(summary = "分页查询AiScenario")
    @SaCheckPermission("teacher:admin:ai-scenario:list")
    public ResultBean<PageListBean<AdminAiScenarioResp>> pageList(@RequestBody AdminAiScenarioPageReq pageRequest) {
        return ResultBean.success(adminAiScenarioService.pageList(pageRequest));
    }

    @PostMapping("/list")
    @Operation(summary = "获取AiScenario列表")
    @SaCheckPermission("teacher:admin:ai-scenario:list")
    public ResultBean<List<AdminAiScenarioResp>> list(@RequestBody AdminAiScenarioReq queryRequest) {
        return ResultBean.success(adminAiScenarioService.list(queryRequest));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取AiScenario")
    @SaCheckPermission("teacher:admin:ai-scenario:detail")
    public ResultBean<AdminAiScenarioResp> getById(@PathVariable Long id) {
        return ResultBean.success(adminAiScenarioService.getDetail(id));
    }

    @PostMapping
    @Operation(summary = "新增AiScenario")
    @SaCheckPermission("teacher:admin:ai-scenario:save")
    public ResultBean<Boolean> save(@RequestBody AdminAiScenarioReq requestParam) {
        return ResultBean.success(adminAiScenarioService.save(requestParam));
    }

    @PutMapping("/{id}")
    @Operation(summary = "更新AiScenario")
    @SaCheckPermission("teacher:admin:ai-scenario:update")
    public ResultBean<Boolean> update(@PathVariable("id") Long id,@RequestBody AdminAiScenarioReq requestParam) {
        requestParam.setId(id);
        return ResultBean.success(adminAiScenarioService.updateById(requestParam));
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除AiScenario")
    @SaCheckPermission("teacher:admin:ai-scenario:delete")
    public ResultBean<Boolean> delete(@PathVariable Long id) {
        return ResultBean.success(adminAiScenarioService.deleteById(id));
    }
}