package com.yushu.web.controller.system;

import java.util.List;
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.system.domain.AiModelConfig;
import com.yushu.system.service.IAiModelConfigService;

/**
 * AI模型配置Controller
 * 
 * @author yushu
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/system/ai/config")
public class AiModelConfigController extends BaseController {
    
    @Autowired
    private IAiModelConfigService aiModelConfigService;

    @PreAuthorize("@ss.hasPermi('ai:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiModelConfig aiModelConfig) {
        startPage();
        List<AiModelConfig> list = aiModelConfigService.selectAiModelConfigList(aiModelConfig);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('ai:config:query')")
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") Long configId) {
        return success(aiModelConfigService.selectAiModelConfigByConfigId(configId));
    }

    @PreAuthorize("@ss.hasPermi('ai:config:add')")
    @Log(title = "AI配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiModelConfig aiModelConfig) {
        return toAjax(aiModelConfigService.insertAiModelConfig(aiModelConfig));
    }

    @PreAuthorize("@ss.hasPermi('ai:config:edit')")
    @Log(title = "AI配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiModelConfig aiModelConfig) {
        return toAjax(aiModelConfigService.updateAiModelConfig(aiModelConfig));
    }

    @PreAuthorize("@ss.hasPermi('ai:config:remove')")
    @Log(title = "AI配置", businessType = BusinessType.DELETE)
    @DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable Long[] configIds) {
        return toAjax(aiModelConfigService.deleteAiModelConfigByConfigIds(configIds));
    }
}

