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.TrsRegionWords;
import com.ruoyi.project.service.ITrsRegionWordsService;
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-04-20
 */
@Controller
@RequestMapping("/project/trsregionwords")
public class TrsRegionWordsController extends BaseController
{
    private String prefix = "project/trsregionwords";

    @Autowired
    private ITrsRegionWordsService trsRegionWordsService;

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

    /**
     * 查询内蒙古自治区地区列表
     */
    @RequiresPermissions("project:trsregionwords:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TrsRegionWords trsRegionWords)
    {
        startPage();
        List<TrsRegionWords> list = trsRegionWordsService.selectTrsRegionWordsList(trsRegionWords);
        return getDataTable(list);
    }

    /**
     * 导出内蒙古自治区地区列表
     */
    @RequiresPermissions("project:trsregionwords:export")
    @Log(title = "内蒙古自治区地区", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TrsRegionWords trsRegionWords)
    {
        List<TrsRegionWords> list = trsRegionWordsService.selectTrsRegionWordsList(trsRegionWords);
        ExcelUtil<TrsRegionWords> util = new ExcelUtil<TrsRegionWords>(TrsRegionWords.class);
        return util.exportExcel(list, "内蒙古自治区地区数据");
    }

    /**
     * 新增内蒙古自治区地区
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存内蒙古自治区地区
     */
    @RequiresPermissions("project:trsregionwords:add")
    @Log(title = "内蒙古自治区地区", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TrsRegionWords trsRegionWords)
    {
        return toAjax(trsRegionWordsService.insertTrsRegionWords(trsRegionWords));
    }

    /**
     * 修改内蒙古自治区地区
     */
    @RequiresPermissions("project:trsregionwords:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TrsRegionWords trsRegionWords = trsRegionWordsService.selectTrsRegionWordsById(id);
        mmap.put("trsRegionWords", trsRegionWords);
        return prefix + "/edit";
    }

    /**
     * 修改保存内蒙古自治区地区
     */
    @RequiresPermissions("project:trsregionwords:edit")
    @Log(title = "内蒙古自治区地区", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TrsRegionWords trsRegionWords)
    {
        return toAjax(trsRegionWordsService.updateTrsRegionWords(trsRegionWords));
    }

    /**
     * 删除内蒙古自治区地区
     */
    @RequiresPermissions("project:trsregionwords:remove")
    @Log(title = "内蒙古自治区地区", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(trsRegionWordsService.deleteTrsRegionWordsByIds(ids));
    }
}
