package org.jk.rag.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.jk.common.core.domain.R;
import org.jk.common.excel.utils.ExcelUtil;
import org.jk.common.log.annotation.Log;
import org.jk.common.log.enums.BusinessType;
import org.jk.common.mybatis.core.page.PageQuery;
import org.jk.common.mybatis.core.page.TableDataInfo;
import org.jk.common.web.core.BaseController;
import org.jk.system.domain.SysProject;
import org.jk.system.domain.vo.SysProjectExportVo;
import org.jk.system.service.ISysProjectService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author takai
 * @date 2025-05-28
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/project")
public class SysProjectController extends BaseController
{
    private final ISysProjectService sysProjectService;

    /**
     * 查询【请填写功能名称】列表
     */

    @GetMapping("/list")
    public TableDataInfo<SysProject> list(SysProject sysProject, PageQuery pageQuery)
    {
        Page<SysProject> list = sysProjectService.selectPageList(sysProject,pageQuery);
        return TableDataInfo.build(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    //@SaCheckPermission("@ss.hasPermi('system:project:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysProject sysProject)
    {
        List<SysProjectExportVo> list = sysProjectService.selectSysProjectExcelList(sysProject);
        ExcelUtil.exportExcel(list, "【请填写功能名称】数据", SysProjectExportVo.class,response);
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    //@SaCheckPermission("@ss.hasPermi('system:project:query')")
    @GetMapping(value = "/{projectId}")
    public R<SysProject> getInfo(@PathVariable("projectId") String projectId)
    {
        return R.ok(sysProjectService.selectSysProjectByProjectId(projectId));
    }

    /**
     * 新增【请填写功能名称】
     */
    //@SaCheckPermission("@ss.hasPermi('system:project:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Integer> add(@RequestBody SysProject sysProject)
    {
        return R.ok(sysProjectService.insertSysProject(sysProject));
    }

    /**
     * 修改【请填写功能名称】
     */
    //@SaCheckPermission("@ss.hasPermi('system:project:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Integer> edit(@RequestBody SysProject sysProject)
    {
        return R.ok(sysProjectService.updateSysProject(sysProject));
    }

    /**
     * 删除【请填写功能名称】
     */
    //@SaCheckPermission("@ss.hasPermi('system:project:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public R<Integer> remove(@PathVariable String[] projectIds)
    {
        return R.ok(sysProjectService.deleteSysProjectByProjectIds(projectIds));
    }

    @GetMapping("/alllist")
    public R<List<SysProject>> alllist(SysProject sysProject)
    {
        return R.ok(sysProjectService.selectSysProjectList(sysProject));
    }
}
