package com.seer.teach.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.admin.request.AdminAiScenarioConfigPageReq;
import com.seer.teach.admin.request.AdminAiScenarioConfigReq;
import com.seer.teach.admin.response.AdminAiScenarioConfigResp;
import com.seer.teach.admin.service.AdminAiScenarioConfigService;
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;

/**
 * AiScenarioConfig控制器
 *
 * @author System
 * @since 2025-10-27
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/teacher/ai/scenario-config")
@Tag(name = "管理端 - AI场景配置")
public class AdminAiScenarioConfigController {

    private final AdminAiScenarioConfigService adminAiScenarioConfigService;

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

    @PostMapping("/list")
    @Operation(summary = "获取AiScenarioConfig列表")
    @SaCheckPermission("teacher:admin:ai-scenario-config:list")
    public ResultBean<List<AdminAiScenarioConfigResp>> list(@RequestBody AdminAiScenarioConfigReq queryRequest) {
        return ResultBean.success(adminAiScenarioConfigService.list(queryRequest));
    }

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

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

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

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