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.MallGoodsPostFee;
import com.ruoyi.mall.service.IMallGoodsPostFeeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品邮费Controller
 * 
 * @author chang
 * @date 2021-11-25
 */
@RestController
@RequestMapping("/mall/mallGoodsPostFee")
public class MallGoodsPostFeeController extends BaseController
{
    @Autowired
    private IMallGoodsPostFeeService mallGoodsPostFeeService;

    /**
     * 查询商品邮费列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallGoodsPostFee:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallGoodsPostFee mallGoodsPostFee)
    {
        startPage();
        List<MallGoodsPostFee> list = mallGoodsPostFeeService.selectMallGoodsPostFeeList(mallGoodsPostFee);
        return getDataTable(list);
    }

    /**
     * 导出商品邮费列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallGoodsPostFee:export')")
    @Log(title = "商品邮费", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallGoodsPostFee mallGoodsPostFee)
    {
        List<MallGoodsPostFee> list = mallGoodsPostFeeService.selectMallGoodsPostFeeList(mallGoodsPostFee);
        ExcelUtil<MallGoodsPostFee> util = new ExcelUtil<MallGoodsPostFee>(MallGoodsPostFee.class);
        return util.exportExcel(list, "商品邮费数据");
    }

    /**
     * 获取商品邮费详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallGoodsPostFee:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallGoodsPostFeeService.selectMallGoodsPostFeeById(id));
    }

    /**
     * 新增商品邮费
     */
    @PreAuthorize("@ss.hasPermi('mall:mallGoodsPostFee:add')")
    @Log(title = "商品邮费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallGoodsPostFee mallGoodsPostFee)
    {
        return toAjax(mallGoodsPostFeeService.insertMallGoodsPostFee(mallGoodsPostFee));
    }

    /**
     * 修改商品邮费
     */
    @PreAuthorize("@ss.hasPermi('mall:mallGoodsPostFee:edit')")
    @Log(title = "商品邮费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallGoodsPostFee mallGoodsPostFee)
    {
        return toAjax(mallGoodsPostFeeService.updateMallGoodsPostFee(mallGoodsPostFee));
    }

    /**
     * 删除商品邮费
     */
    @PreAuthorize("@ss.hasPermi('mall:mallGoodsPostFee:remove')")
    @Log(title = "商品邮费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallGoodsPostFeeService.deleteMallGoodsPostFeeByIds(ids));
    }
}
