package com.ruoyi.mall.controller;

import java.util.List;
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.mall.domain.MallPrintSetting;
import com.ruoyi.mall.service.IMallPrintSettingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单打印设置Controller
 *
 * @author ruoyi
 * @date 2022-08-03
 */
@RestController
@RequestMapping("/mall/printSetting")
public class MallPrintSettingController extends BaseController
{
    @Autowired
    private IMallPrintSettingService mallPrintSettingService;

    /**
     * 查询订单打印设置列表
     */
    @PreAuthorize("@ss.hasPermi('mall:printSetting:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallPrintSetting mallPrintSetting)
    {
        startPage();
        List<MallPrintSetting> list = mallPrintSettingService.selectMallPrintSettingList(mallPrintSetting);
        return getDataTable(list);
    }

    /**
     * 导出订单打印设置列表
     */
    @PreAuthorize("@ss.hasPermi('mall:printSetting:export')")
    @Log(title = "订单打印设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallPrintSetting mallPrintSetting)
    {
        List<MallPrintSetting> list = mallPrintSettingService.selectMallPrintSettingList(mallPrintSetting);
        ExcelUtil<MallPrintSetting> util = new ExcelUtil<MallPrintSetting>(MallPrintSetting.class);
        return util.exportExcel(list, "订单打印设置数据");
    }

    /**
     * 获取订单打印设置详细信息
     */
    //@PreAuthorize("@ss.hasPermi('mall:printSetting:query')")
    @GetMapping(value = "/{printSettingId}")
    public AjaxResult getInfo(@PathVariable("printSettingId") Integer printSettingId)
    {
        return AjaxResult.success(mallPrintSettingService.selectMallPrintSettingByPrintSettingId(printSettingId));
    }

    /**
     * 新增订单打印设置
     */
    @PreAuthorize("@ss.hasPermi('mall:printSetting:add')")
    @Log(title = "订单打印设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallPrintSetting mallPrintSetting)
    {
        return toAjax(mallPrintSettingService.insertMallPrintSetting(mallPrintSetting));
    }

    /**
     * 修改订单打印设置
     */
    @PreAuthorize("@ss.hasPermi('mall:printSetting:edit')")
    @Log(title = "订单打印设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallPrintSetting mallPrintSetting)
    {
        return toAjax(mallPrintSettingService.updateMallPrintSetting(mallPrintSetting));
    }

    /**
     * 删除订单打印设置
     */
    @PreAuthorize("@ss.hasPermi('mall:printSetting:remove')")
    @Log(title = "订单打印设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{printSettingIds}")
    public AjaxResult remove(@PathVariable Integer[] printSettingIds)
    {
        return toAjax(mallPrintSettingService.deleteMallPrintSettingByPrintSettingIds(printSettingIds));
    }
}
