package com.ruoyi.web.controller.system;

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.ss.dividendRefund.domain.DividendRefund;
import com.ruoyi.ss.dividendRefund.domain.DividendRefundQuery;
import com.ruoyi.ss.dividendRefund.domain.DividendRefundVO;
import com.ruoyi.ss.dividendRefund.service.DividendRefundService;
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.util.List;

/**
 * 分成退款记录Controller
 *
 * @author ruoyi
 * @date 2025-01-25
 */
@RestController
@RequestMapping("/ss/dividendRefund")
public class DividendRefundController extends BaseController
{
    @Autowired
    private DividendRefundService dividendRefundService;

    /**
     * 查询分成退款记录列表
     */
    @PreAuthorize("@ss.hasPermi('ss:dividendRefund:list')")
    @GetMapping("/list")
    public TableDataInfo list(DividendRefundQuery query)
    {
        startPage();
        startOrderBy();
        List<DividendRefundVO> list = dividendRefundService.selectDividendRefundList(query);
        return getDataTable(list);
    }

    /**
     * 导出分成退款记录列表
     */
    @PreAuthorize("@ss.hasPermi('ss:dividendRefund:export')")
    @Log(title = "分成退款记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DividendRefundQuery query)
    {
        List<DividendRefundVO> list = dividendRefundService.selectDividendRefundList(query);
        ExcelUtil<DividendRefundVO> util = new ExcelUtil<DividendRefundVO>(DividendRefundVO.class);
        util.exportExcel(response, list, "分成退款记录数据");
    }

    /**
     * 获取分成退款记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ss:dividendRefund:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dividendRefundService.selectDividendRefundById(id));
    }

    /**
     * 新增分成退款记录
     */
    @PreAuthorize("@ss.hasPermi('ss:dividendRefund:add')")
    @Log(title = "分成退款记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DividendRefund dividendRefund)
    {
        return toAjax(dividendRefundService.insertDividendRefund(dividendRefund));
    }

    /**
     * 修改分成退款记录
     */
    @PreAuthorize("@ss.hasPermi('ss:dividendRefund:edit')")
    @Log(title = "分成退款记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DividendRefund dividendRefund)
    {
        return toAjax(dividendRefundService.updateDividendRefund(dividendRefund));
    }

    /**
     * 删除分成退款记录
     */
    @PreAuthorize("@ss.hasPermi('ss:dividendRefund:remove')")
    @Log(title = "分成退款记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dividendRefundService.deleteDividendRefundByIds(ids));
    }
}
