package com.ruoyi.system.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.IActSuppliesConvertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 模板转换页面接口
 * */

@RestController
@RequestMapping("/ActSuppliesConvert/ActSuppliesConvert")
public class ActSuppliesConvertController extends BaseController{

    @Autowired
    private IActSuppliesConvertService actSuppliesConvertService;

    /**
     * 模板转换页面查询模板接口
     * */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvert:ActSuppliesConvert:list')")
    @GetMapping("/list")
    public TableDataInfo  templitelist(ActSuppliesTemplate sysSupplies){

        List<ActSuppliesTemplate> list = actSuppliesConvertService.templiteList(sysSupplies);
        return getDataTable(list);

    }

    /**
     * 模板转换页面查询模板详细内容接口
     * */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvert:ActSuppliesConvert:listid')")
    @GetMapping("/listid/{id}")
    public TableDataInfo  templitelistid(@PathVariable("id") Integer id){

        List<ActSuppliesTemplate> list = actSuppliesConvertService.templiteListid(id);
        return getDataTable(list);

    }

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

        List<ActSuppliesRole> list = actSuppliesConvertService.roleList(id);
        return getDataTable(list);

    }

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

        List<ActSuppliesRoleDetail> list = actSuppliesConvertService.roleListid(id);
        return getDataTable(list);

    }

    /**
     * 模板转换页面根据规则ID查询规则详情接口
     * */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvert:ActSuppliesConvert:saveSuppliesname')")
    @GetMapping("/saveSuppliesname/{name}")
    public AjaxResult  saveSuppliesname(@PathVariable("name") String name){

        return AjaxResult.success(actSuppliesConvertService.selectSuppliesname(name));

    }

    /**
     * 物料转换
     * */
    @PreAuthorize("@ss.hasPermi('ActSuppliesConvert:ActSuppliesConvert:converSupplies')")
    @PostMapping("/converSupplies")
    public TableDataInfo  convertSupplies(@RequestBody String[] names){


        List<String> list = actSuppliesConvertService.converSupplies(names);

        return getDataTable(list);

    }

}
