package com.yushu.web.controller.system;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.yushu.common.annotation.Log;
import com.yushu.common.core.controller.BaseController;
import com.yushu.common.core.domain.AjaxResult;
import com.yushu.common.core.page.TableDataInfo;
import com.yushu.common.enums.BusinessType;
import com.yushu.common.utils.poi.ExcelUtil;
import com.yushu.system.domain.AiModel;
import com.yushu.system.service.IAiModelService;

/**
 * AI模型Controller
 * 
 * @author yushu
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/system/ai/model")
public class AiModelController extends BaseController {
    
    @Autowired
    private IAiModelService aiModelService;

    @PreAuthorize("@ss.hasPermi('ai:model:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiModel aiModel) {
        startPage();
        List<AiModel> list = aiModelService.selectAiModelList(aiModel);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('ai:model:query')")
    @GetMapping(value = "/{modelId}")
    public AjaxResult getInfo(@PathVariable("modelId") Long modelId) {
        return success(aiModelService.selectAiModelByModelId(modelId));
    }

    @PreAuthorize("@ss.hasPermi('ai:model:add')")
    @Log(title = "AI模型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiModel aiModel) {
        return toAjax(aiModelService.insertAiModel(aiModel));
    }

    @PreAuthorize("@ss.hasPermi('ai:model:edit')")
    @Log(title = "AI模型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiModel aiModel) {
        return toAjax(aiModelService.updateAiModel(aiModel));
    }

    @PreAuthorize("@ss.hasPermi('ai:model:remove')")
    @Log(title = "AI模型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{modelIds}")
    public AjaxResult remove(@PathVariable Long[] modelIds) {
        return toAjax(aiModelService.deleteAiModelByModelIds(modelIds));
    }
}

