package com.jianshui.web.controller.platform;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.jianshui.common.annotation.Log;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.enums.BusinessType;
import com.jianshui.platform.domain.InvoiceParamConfig;
import com.jianshui.platform.service.IInvoiceParamConfigService;
import com.jianshui.common.utils.poi.ExcelUtil;
import com.jianshui.common.core.page.TableDataInfo;

/**
 * 导入设置Controller
 * 
 * @author kane
 * @date 2023-06-28
 */
@RestController
@RequestMapping("/platform/exportmanage")
public class InvoiceParamConfigController extends BaseController
{
    @Autowired
    private IInvoiceParamConfigService invoiceParamConfigService;

    /**
     * 查询导入设置列表
     */
    @PreAuthorize("@ss.hasPermi('platform:exportmanage:list')")
    @GetMapping("/list")
    public TableDataInfo list(InvoiceParamConfig invoiceParamConfig)
    {
        startPage();
        List<InvoiceParamConfig> list = invoiceParamConfigService.selectInvoiceParamConfigList(invoiceParamConfig);
        return getDataTable(list);
    }

    /**
     * 查询单个导入设置列表
     */
    @PreAuthorize("@ss.hasPermi('platform:exportmanage:list')")
    @GetMapping("/findByName")
    public AjaxResult findByName()
    {
        return invoiceParamConfigService.findByName();
    }


    /**
     * 导出导入设置列表
     */
    @PreAuthorize("@ss.hasPermi('platform:exportmanage:export')")
    @Log(title = "导入设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvoiceParamConfig invoiceParamConfig)
    {
        List<InvoiceParamConfig> list = invoiceParamConfigService.selectInvoiceParamConfigList(invoiceParamConfig);
        ExcelUtil<InvoiceParamConfig> util = new ExcelUtil<InvoiceParamConfig>(InvoiceParamConfig.class);
        util.exportExcel(response, list, "导入设置数据");
    }

    /**
     * 获取导入设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:exportmanage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(invoiceParamConfigService.selectInvoiceParamConfigById(id));
    }

    /**
     * 新增导入设置
     */
    @PreAuthorize("@ss.hasPermi('platform:exportmanage:add')")
    @Log(title = "导入设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvoiceParamConfig invoiceParamConfig)
    {
        return toAjax(invoiceParamConfigService.insertInvoiceParamConfig(invoiceParamConfig));
    }

    /**
     * 修改导入设置
     */
    @PreAuthorize("@ss.hasPermi('platform:exportmanage:edit')")
    @Log(title = "导入设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvoiceParamConfig invoiceParamConfig)
    {
        return toAjax(invoiceParamConfigService.updateInvoiceParamConfig(invoiceParamConfig));
    }

    /**
     * 删除导入设置
     */
    @PreAuthorize("@ss.hasPermi('platform:exportmanage:remove')")
    @Log(title = "导入设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(invoiceParamConfigService.deleteInvoiceParamConfigByIds(ids));
    }
}
