package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.system.domain.ActSuppliesTemplate;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ActSuppliesConvertrole;
import com.ruoyi.system.service.IActSuppliesConvertroleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通用规则Controller
 * 
 * @author ruoyi
 * @date 2023-08-29
 */
@RestController
@RequestMapping("/ActSuppliesConvertrole/ActSuppliesConvertrole")
public class ActSuppliesConvertroleController extends BaseController
{
    @Autowired
    private IActSuppliesConvertroleService actSuppliesConvertService;

    /**
     * 查询模板
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:listTemp')")
    @GetMapping("/listTemp")
    public TableDataInfo listTemp()
    {

        startPage();
        List<ActSuppliesTemplate> list = actSuppliesConvertService.selectActSuppliesConvertListTemp();
        return getDataTable(list);

    }

    /**
     * 查询通用规则列表
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActSuppliesConvertrole actSuppliesConvertrole)
    {
        startPage();
        List<ActSuppliesConvertrole> list = actSuppliesConvertService.selectActSuppliesConvertList(actSuppliesConvertrole);
        return getDataTable(list);
    }

    /**
     * 导出通用规则列表
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:export')")
    @GetMapping("/export")
    public AjaxResult export(ActSuppliesConvertrole actSuppliesConvertrole)
    {
        List<ActSuppliesConvertrole> list = actSuppliesConvertService.selectActSuppliesConvertList(actSuppliesConvertrole);
        ExcelUtil<ActSuppliesConvertrole> util = new ExcelUtil<ActSuppliesConvertrole>(ActSuppliesConvertrole.class);
        return util.exportExcel(list, "通用规则数据");
    }

    /**
     * 获取通用规则详细信息
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(actSuppliesConvertService.selectActSuppliesConvertById(id));
    }

    /**
     * 新增通用规则
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ActSuppliesConvertrole actSuppliesConvertrole)
    {
        return toAjax(actSuppliesConvertService.insertActSuppliesConvert(actSuppliesConvertrole));
    }

    /**
     * 修改通用规则
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ActSuppliesConvertrole actSuppliesConvertrole)
    {
        return toAjax(actSuppliesConvertService.updateActSuppliesConvert(actSuppliesConvertrole));
    }

    /**
     * 删除通用规则
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:remove')")
    @Log(title = "通用规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(actSuppliesConvertService.deleteActSuppliesConvertByIds(ids));
    }

    /**
     * 获取通用规则列表
     */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:convertRoleList')")
    @GetMapping(value = "/convertRoleList/{id}")
    public TableDataInfo convertRoleList(@PathVariable("id") Integer id)
    {
        List<ActSuppliesConvertrole> list = actSuppliesConvertService.convertRoleList(id);
        return getDataTable(list);
    }

    /**
     * 模板转换页面根据规则ID查询规则详情接口
     * */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvertrole:ActSuppliesConvertrole:convertRoleListid')")
    @GetMapping("/convertRoleListid/{id}")
    public TableDataInfo  convertRoleListid(@PathVariable("id") Integer id){

        List<ActSuppliesConvertrole> list = actSuppliesConvertService.convertRoleListid(id);
        return getDataTable(list);

    }

}
