package com.easyproject.web.controller.coze;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.easyproject.service.domain.coze.CozeTokenSet;
import com.easyproject.system.service.coze.ICozeTokenSetService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.easyproject.common.annotation.Log;
import com.easyproject.common.core.controller.BaseController;
import com.easyproject.common.core.domain.AjaxResult;
import com.easyproject.common.enums.BusinessType;
import com.easyproject.common.core.page.TableDataInfo;

/**
 * AI令牌Controller
 *
 * @author easyproject
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/system/cozeTokenSet")
public class CozeTokenSetController extends BaseController {
    @Autowired
    private ICozeTokenSetService cozeTokenSetService;

    /**
     * 查询AI令牌列表
     */
    @PreAuthorize("@ss.hasPermi('system:cozeTokenSet:list')")
    @GetMapping("/list")
    public TableDataInfo list(CozeTokenSet cozeTokenSet) {
        startPage();
        List<CozeTokenSet> list = cozeTokenSetService.selectCozeTokenSetList(cozeTokenSet);
        return getDataTable(list);
    }

    /**
     * 获取AI令牌详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cozeTokenSet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(cozeTokenSetService.selectCozeTokenSetById(id));
    }

    /**
     * 新增AI令牌
     */
    @PreAuthorize("@ss.hasPermi('system:cozeTokenSet:add')")
    @Log(title = "AI令牌", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CozeTokenSet cozeTokenSet) {
        return toAjax(cozeTokenSetService.insertCozeTokenSet(cozeTokenSet));
    }

    /**
     * 修改AI令牌
     */
    @PreAuthorize("@ss.hasPermi('system:cozeTokenSet:edit')")
    @Log(title = "AI令牌", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CozeTokenSet cozeTokenSet) {
        return toAjax(cozeTokenSetService.updateCozeTokenSet(cozeTokenSet));
    }

    /**
     * 删除AI令牌
     */
    @PreAuthorize("@ss.hasPermi('system:cozeTokenSet:remove')")
    @Log(title = "AI令牌", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(cozeTokenSetService.deleteCozeTokenSetByIds(ids));
    }
}
