package com.ruoyi.mall.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.mall.domain.MallExpeditingGoods;
import com.ruoyi.mall.service.IMallExpeditingGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/system/mallexpeditinggoods")
public class MallExpeditingGoodsController extends BaseController {
    @Autowired
    private IMallExpeditingGoodsService mallExpeditingGoodsService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:goods:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallExpeditingGoods mallExpeditingGoods) {
        startPage();
        List<MallExpeditingGoods> list = mallExpeditingGoodsService.selectMallExpeditingGoodsList(mallExpeditingGoods);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:goods:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallExpeditingGoods mallExpeditingGoods) throws IOException {
        List<MallExpeditingGoods> list = mallExpeditingGoodsService.selectMallExpeditingGoodsList(mallExpeditingGoods);
        ExcelUtil<MallExpeditingGoods> util = new ExcelUtil<MallExpeditingGoods>(MallExpeditingGoods.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:goods:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        MallExpeditingGoods mallExpeditingGoods = mallExpeditingGoodsService.selectMallExpeditingGoodsById(id);
        return AjaxResult.success(mallExpeditingGoods);
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:goods:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallExpeditingGoods mallExpeditingGoods) {
        return toAjax(mallExpeditingGoodsService.insertMallExpeditingGoods(mallExpeditingGoods));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:goods:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallExpeditingGoods mallExpeditingGoods) {
        return toAjax(mallExpeditingGoodsService.updateMallExpeditingGoods(mallExpeditingGoods));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:goods:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mallExpeditingGoodsService.deleteMallExpeditingGoodsByIds(ids));
    }
}
