package com.seer.teach.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.admin.request.AdminAiModelPageReq;
import com.seer.teach.admin.request.AdminAiModelQueryReq;
import com.seer.teach.admin.request.AdminAiModelReq;
import com.seer.teach.admin.response.AdminAiModelResp;
import com.seer.teach.admin.service.AdminAiModelService;
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;

/**
 * AiModel控制器
 *
 * @author ZS
 * @since 2025-10-27
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/teacher/ai/model")
@Tag(name = "管理端 - 模型管理")
public class AdminAiModelController {

    private final AdminAiModelService adminAiModelService;

    @PostMapping("/paged")
    @Operation(summary = "分页查询AiModel")
    @SaCheckPermission("teacher:admin:ai-model:list")
    public ResultBean<PageListBean<AdminAiModelResp>> pageList(@RequestBody AdminAiModelPageReq pageRequest) {
        return ResultBean.success(adminAiModelService.pageList(pageRequest));
    }

    @PostMapping("/list")
    @Operation(summary = "获取AiModel列表")
    @SaCheckPermission("teacher:admin:ai-model:list")
    public ResultBean<List<AdminAiModelResp>> list(@RequestBody AdminAiModelQueryReq queryRequest) {
        return ResultBean.success(adminAiModelService.list(queryRequest));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取AiModel")
    @SaCheckPermission("teacher:admin:ai-model:detail")
    public ResultBean<AdminAiModelResp> getById(@PathVariable Integer id) {
        return ResultBean.success(adminAiModelService.getDetail(id));
    }

    @PostMapping
    @Operation(summary = "新增AiModel")
    @SaCheckPermission("teacher:admin:ai-model:save")
    public ResultBean<Boolean> save(@RequestBody AdminAiModelReq requestParam) {
        return ResultBean.success(adminAiModelService.save(requestParam));
    }

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

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