package com.ruoyi.framework.recovery.controller;

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.framework.recovery.domain.RecSaleInfo;
import com.ruoyi.framework.recovery.service.IRecSaleInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 发售信息详情Controller
 * 
 * @author jin
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/recovery/info")
public class RecSaleInfoController extends BaseController
{
    @Autowired
    private IRecSaleInfoService recSaleInfoService;

    /**
     * 查询发售信息详情列表
     */
    @PreAuthorize("@ss.hasPermi('recovery:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(RecSaleInfo recSaleInfo)
    {
        startPage();
        List<RecSaleInfo> list = recSaleInfoService.selectRecSaleInfoList(recSaleInfo);
        return getDataTable(list);
    }

    /**
     * 导出发售信息详情列表
     */
    @PreAuthorize("@ss.hasPermi('recovery:info:export')")
    @Log(title = "发售信息详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RecSaleInfo recSaleInfo)
    {
        List<RecSaleInfo> list = recSaleInfoService.selectRecSaleInfoList(recSaleInfo);
        ExcelUtil<RecSaleInfo> util = new ExcelUtil<RecSaleInfo>(RecSaleInfo.class);
        util.exportExcel(response, list, "发售信息详情数据");
    }

    /**
     * 获取发售信息详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('recovery:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(recSaleInfoService.selectRecSaleInfoById(id));
    }

    /**
     * 新增发售信息详情
     */
    @PreAuthorize("@ss.hasPermi('recovery:info:add')")
    @Log(title = "发售信息详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecSaleInfo recSaleInfo)
    {
        return toAjax(recSaleInfoService.insertRecSaleInfo(recSaleInfo));
    }

    /**
     * 修改发售信息详情
     */
    @PreAuthorize("@ss.hasPermi('recovery:info:edit')")
    @Log(title = "发售信息详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecSaleInfo recSaleInfo)
    {
        return toAjax(recSaleInfoService.updateRecSaleInfo(recSaleInfo));
    }

    /**
     * 删除发售信息详情
     */
    @PreAuthorize("@ss.hasPermi('recovery:info:remove')")
    @Log(title = "发售信息详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(recSaleInfoService.deleteRecSaleInfoByIds(ids));
    }
}
