package com.ruoyi.mall.controller;

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

/**
 * 录取率范围设定Controller
 * 
 * @author ruoyi
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/mall/MallAcceptRateSetting")
public class MallAcceptRateSettingController extends BaseController
{
    @Autowired
    private IMallAcceptRateSettingService mallAcceptRateSettingService;

    /**
     * 查询录取率范围设定列表
     */
    @PreAuthorize("@ss.hasPermi('mall:MallAcceptRateSetting:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallAcceptRateSetting mallAcceptRateSetting)
    {
        startPage();
        List<MallAcceptRateSetting> list = mallAcceptRateSettingService.selectMallAcceptRateSettingList(mallAcceptRateSetting);
        return getDataTable(list);
    }

    /**
     * 导出录取率范围设定列表
     */
    @PreAuthorize("@ss.hasPermi('mall:MallAcceptRateSetting:export')")
    @Log(title = "录取率范围设定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallAcceptRateSetting mallAcceptRateSetting)
    {
        List<MallAcceptRateSetting> list = mallAcceptRateSettingService.selectMallAcceptRateSettingList(mallAcceptRateSetting);
        ExcelUtil<MallAcceptRateSetting> util = new ExcelUtil<MallAcceptRateSetting>(MallAcceptRateSetting.class);
        util.exportExcel(response, list, "录取率范围设定数据");
    }

    /**
     * 获取录取率范围设定详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:MallAcceptRateSetting:query')")
    @GetMapping(value = "/{rateMatchId}")
    public AjaxResult getInfo(@PathVariable("rateMatchId") Long rateMatchId)
    {
        return AjaxResult.success(mallAcceptRateSettingService.selectMallAcceptRateSettingByRateMatchId(rateMatchId));
    }

    /**
     * 新增录取率范围设定
     */
    @PreAuthorize("@ss.hasPermi('mall:MallAcceptRateSetting:add')")
    @Log(title = "录取率范围设定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallAcceptRateSetting mallAcceptRateSetting)
    {
        return toAjax(mallAcceptRateSettingService.insertMallAcceptRateSetting(mallAcceptRateSetting));
    }

    /**
     * 修改录取率范围设定
     */
    @PreAuthorize("@ss.hasPermi('mall:MallAcceptRateSetting:edit')")
    @Log(title = "录取率范围设定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallAcceptRateSetting mallAcceptRateSetting)
    {
        return toAjax(mallAcceptRateSettingService.updateMallAcceptRateSetting(mallAcceptRateSetting));
    }

    /**
     * 删除录取率范围设定
     */
    @PreAuthorize("@ss.hasPermi('mall:MallAcceptRateSetting:remove')")
    @Log(title = "录取率范围设定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rateMatchIds}")
    public AjaxResult remove(@PathVariable Long[] rateMatchIds)
    {
        return toAjax(mallAcceptRateSettingService.deleteMallAcceptRateSettingByRateMatchIds(rateMatchIds));
    }
}
