package com.ruoyi.app.order;

import java.util.List;
import jakarta.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.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.system.domain.DistanceMultiplier;
import com.ruoyi.system.service.IDistanceMultiplierService;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * DistanceMultiplierController
 *
 * @author ruoyi
 * @date 2024-08-23
 */
@RestController
@RequestMapping("/system/multiplier")
public class DistanceMultiplierController extends BaseController
{
    @Autowired
    private IDistanceMultiplierService distanceMultiplierService;

    /**
     * 查询DistanceMultiplier列表
     */
    @PreAuthorize("@ss.hasPermi('system:multiplier:list')")
    @GetMapping("/list")
    public TableDataInfo list(DistanceMultiplier distanceMultiplier)
    {
        startPage();
        List<DistanceMultiplier> list = distanceMultiplierService.selectDistanceMultiplierList(distanceMultiplier);
        return getDataTable(list);
    }

    /**
     * 导出DistanceMultiplier列表
     */
    @PreAuthorize("@ss.hasPermi('system:multiplier:export')")
    @Log(title = "DistanceMultiplier", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DistanceMultiplier distanceMultiplier)
    {
        List<DistanceMultiplier> list = distanceMultiplierService.selectDistanceMultiplierList(distanceMultiplier);
        ExcelUtil<DistanceMultiplier> util = new ExcelUtil<DistanceMultiplier>(DistanceMultiplier.class);
        util.exportExcel(response, list, MessageUtils.message("no.export.excel.distancemultiplier"));
    }

    /**
     * 获取DistanceMultiplier详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:multiplier:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(distanceMultiplierService.selectDistanceMultiplierById(id));
    }

    /**
     * 新增DistanceMultiplier
     */
    @PreAuthorize("@ss.hasPermi('system:multiplier:add')")
    @Log(title = "DistanceMultiplier", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DistanceMultiplier distanceMultiplier)
    {
        return toAjax(distanceMultiplierService.insertDistanceMultiplier(distanceMultiplier));
    }

    /**
     * 修改DistanceMultiplier
     */
    @PreAuthorize("@ss.hasPermi('system:multiplier:edit')")
    @Log(title = "DistanceMultiplier", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DistanceMultiplier distanceMultiplier)
    {
        return toAjax(distanceMultiplierService.updateDistanceMultiplier(distanceMultiplier));
    }

    /**
     * 删除DistanceMultiplier
     */
    @PreAuthorize("@ss.hasPermi('system:multiplier:remove')")
    @Log(title = "DistanceMultiplier", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(distanceMultiplierService.deleteDistanceMultiplierByIds(ids));
    }
}
