package com.cool.modules.aiconfig.controller.admin;

import cn.hutool.json.JSONObject;
import com.cool.core.annotation.CoolRestController;
import com.cool.core.base.BaseController;
import com.cool.modules.aiconfig.entity.AiModelEntity;
import com.cool.modules.aiconfig.service.AiModelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import com.cool.core.request.R;

import static com.cool.modules.aiconfig.entity.table.AiModelEntityTableDef.AI_MODEL_ENTITY;

/**
 * AI模型配置管理
 */
@Tag(name = "AI模型配置", description = "AI模型配置管理")
@CoolRestController(api = {"add", "delete", "update", "page", "list", "info"})
public class AdminAiModelController extends BaseController<AiModelService, AiModelEntity> {

    @Override
    protected void init(HttpServletRequest request, JSONObject requestParams) {
        setPageOption(createOp()
                .keyWordLikeFields(AI_MODEL_ENTITY.MODEL_NAME, AI_MODEL_ENTITY.MODEL_KEY, AI_MODEL_ENTITY.MODEL_TYPE)
        );
    }

    @Operation(summary = "获取启用的模型列表", description = "获取所有状态为启用的模型列表")
    @GetMapping("/enabled")
    public R getEnabledModels() {
        return R.ok(this.service.getEnabledModels());
    }
}
