package com.ruoyi.project.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.TrsWordResults;
import com.ruoyi.project.service.ITrsWordResultsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * WordresultsController
 * 
 * @author ruoyi
 * @date 2025-09-05
 */
@Controller
@RequestMapping("/project/wordresults")
public class TrsWordResultsController extends BaseController
{
    private String prefix = "project/wordresults";

    @Autowired
    private ITrsWordResultsService trsWordResultsService;

    @RequiresPermissions("project:wordresults:view")
    @GetMapping()
    public String wordresults()
    {
        return prefix + "/wordresults";
    }

    /**
     * 查询Wordresults列表
     */
    @RequiresPermissions("project:wordresults:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TrsWordResults trsWordResults)
    {
        startPage();
        List<TrsWordResults> list = trsWordResultsService.selectTrsWordResultsList(trsWordResults);
        return getDataTable(list);
    }

    @RequestMapping("/wordlist")
    @ResponseBody
    public AjaxResult wordlist(TrsWordResults trsWordResults)
    {
        List<TrsWordResults> list = trsWordResultsService.selectTrsWordResultsList(trsWordResults);
        return AjaxResult.success(list);
    }

    /**
     * 导出Wordresults列表
     */
    @RequiresPermissions("project:wordresults:export")
    @Log(title = "Wordresults", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TrsWordResults trsWordResults)
    {
        List<TrsWordResults> list = trsWordResultsService.selectTrsWordResultsList(trsWordResults);
        ExcelUtil<TrsWordResults> util = new ExcelUtil<TrsWordResults>(TrsWordResults.class);
        return util.exportExcel(list, "Wordresults数据");
    }

    /**
     * 新增Wordresults
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存Wordresults
     */
    @RequiresPermissions("project:wordresults:add")
    @Log(title = "Wordresults", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TrsWordResults trsWordResults)
    {
        return toAjax(trsWordResultsService.insertTrsWordResults(trsWordResults));
    }

    /**
     * 修改Wordresults
     */
    @RequiresPermissions("project:wordresults:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TrsWordResults trsWordResults = trsWordResultsService.selectTrsWordResultsById(id);
        mmap.put("trsWordResults", trsWordResults);
        return prefix + "/edit";
    }

    /**
     * 修改保存Wordresults
     */
//    @RequiresPermissions("project:wordresults:edit")
    @Log(title = "Wordresults", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TrsWordResults trsWordResults)
    {
        return toAjax(trsWordResultsService.updateTrsWordResults(trsWordResults));
    }

    /**
     * 删除Wordresults
     */
    @RequiresPermissions("project:wordresults:remove")
    @Log(title = "Wordresults", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(trsWordResultsService.deleteTrsWordResultsByIds(ids));
    }
}
