package com.ruoyi.frequency.mallorderstatus.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.frequency.mallorderstatus.entity.MallOrderStatus;
import com.ruoyi.frequency.mallorderstatus.service.MallOrderStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单流程Controller
 *
 * @author liwenlong
 * @date 2024-01-25
 */
@RestController
@RequestMapping("/frequency/mallorderstatus")
public class MallOrderStatusController extends BaseController
{
    @Autowired
    private MallOrderStatusService mallOrderStatusService;

    /**
     * 查询订单流程列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:list')")
    @GetMapping("/list")
    public TableDataInfo<MallOrderStatus> list(MallOrderStatus mallOrderStatus)
    {
        startPage();
        List<MallOrderStatus> list = mallOrderStatusService.selectMallOrderStatusList(mallOrderStatus);
        return getDataTable(list);
    }

    /**
     * 导出订单流程列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:export')")
    @Log(title = "订单流程", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallOrderStatus mallOrderStatus)
    {
        List<MallOrderStatus> list = mallOrderStatusService.selectMallOrderStatusList(mallOrderStatus);
        ExcelUtil<MallOrderStatus> util = new ExcelUtil<MallOrderStatus>(MallOrderStatus.class);
        return util.exportExcel(list, "订单流程数据");
    }

    /**
     * 获取订单流程详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<MallOrderStatus> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallOrderStatusService.selectMallOrderStatusById(id));
    }

    /**
     * 新增订单流程
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:add')")
    @Log(title = "订单流程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallOrderStatus mallOrderStatus)
    {
        return toAjax(mallOrderStatusService.insertMallOrderStatus(mallOrderStatus));
    }

    /**
     * 修改订单流程
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:edit')")
    @Log(title = "订单流程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallOrderStatus mallOrderStatus)
    {
        return toAjax(mallOrderStatusService.updateMallOrderStatus(mallOrderStatus));
    }

    /**
     * 删除订单流程
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallorderstatus:remove')")
    @Log(title = "订单流程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(mallOrderStatusService.deleteMallOrderStatusByIds(ids,delFlag));
    }
}
