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.TrsDomainResults;
import com.ruoyi.project.service.ITrsDomainResultsService;
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;

/**
 * 领域常识监测Controller
 * 
 * @author ruoyi
 * @date 2025-03-24
 */
@Controller
@RequestMapping("/project/domainresults")
public class TrsDomainResultsController extends BaseController
{
    private String prefix = "project/domainresults";

    @Autowired
    private ITrsDomainResultsService trsDomainResultsService;

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

    /**
     * 查询领域常识监测列表
     */
    @RequiresPermissions("project:domainresults:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TrsDomainResults trsDomainResults)
    {
        startPage();
        List<TrsDomainResults> list = trsDomainResultsService.selectTrsDomainResultsList(trsDomainResults);
        return getDataTable(list);
    }

    /**
     * 导出领域常识监测列表
     */
    @RequiresPermissions("project:domainresults:export")
    @Log(title = "领域常识监测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TrsDomainResults trsDomainResults)
    {
        List<TrsDomainResults> list = trsDomainResultsService.selectTrsDomainResultsList(trsDomainResults);
        ExcelUtil<TrsDomainResults> util = new ExcelUtil<TrsDomainResults>(TrsDomainResults.class);
        return util.exportExcel(list, "领域常识监测数据");
    }

    /**
     * 新增领域常识监测
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存领域常识监测
     */
    @RequiresPermissions("project:domainresults:add")
    @Log(title = "领域常识监测", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TrsDomainResults trsDomainResults)
    {
        return toAjax(trsDomainResultsService.insertTrsDomainResults(trsDomainResults));
    }

    /**
     * 修改领域常识监测
     */
    @RequiresPermissions("project:domainresults:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TrsDomainResults trsDomainResults = trsDomainResultsService.selectTrsDomainResultsById(id);
        mmap.put("trsDomainResults", trsDomainResults);
        return prefix + "/edit";
    }

    /**
     * 修改保存领域常识监测
     */
    @RequiresPermissions("project:domainresults:edit")
    @Log(title = "领域常识监测", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TrsDomainResults trsDomainResults)
    {
        return toAjax(trsDomainResultsService.updateTrsDomainResults(trsDomainResults));
    }

    /**
     * 删除领域常识监测
     */
    @RequiresPermissions("project:domainresults:remove")
    @Log(title = "领域常识监测", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(trsDomainResultsService.deleteTrsDomainResultsByIds(ids));
    }
}
