package com.leromro.core.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.leromro.common.core.domain.R;
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.leromro.common.annotation.Log;
import com.leromro.common.core.controller.BaseController;
import com.leromro.common.core.domain.AjaxResult;
import com.leromro.common.enums.BusinessType;
import com.leromro.core.domain.OrderFrozenFunds;
import com.leromro.core.service.IOrderFrozenFundsService;
import com.leromro.common.utils.poi.ExcelUtil;
import com.leromro.common.core.page.TableDataInfo;

/**
 * 订单资金冻结Controller
 * 
 * @author ruoyi
 * @date 2025-04-11
 */
@RestController
@Api(tags = "订单资金冻结")
@RequestMapping("/core/volunteer/order-frozen")
public class OrderFrozenFundsController extends BaseController
{
    @Autowired
    private IOrderFrozenFundsService orderFrozenFundsService;

    /**
     * 查询订单资金冻结列表
     */
    @ApiOperation("查询订单资金冻结列表")
    @PreAuthorize("@ss.hasPermi('core:volunteer/order-frozen:list')")
    @GetMapping("/list")
    public TableDataInfo<OrderFrozenFunds> list(OrderFrozenFunds orderFrozenFunds)
    {
        startPage();
        List<OrderFrozenFunds> list = orderFrozenFundsService.selectOrderFrozenFundsList(orderFrozenFunds);
        return getDataTable(list);
    }

    /**
     * 导出订单资金冻结列表
     */
    @ApiOperation("导出订单资金冻结列表")
    @PreAuthorize("@ss.hasPermi('core:volunteer/order-frozen:export')")
    @Log(title = "订单资金冻结", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderFrozenFunds orderFrozenFunds)
    {
        List<OrderFrozenFunds> list = orderFrozenFundsService.selectOrderFrozenFundsList(orderFrozenFunds);
        ExcelUtil<OrderFrozenFunds> util = new ExcelUtil<OrderFrozenFunds>(OrderFrozenFunds.class);
        util.exportExcel(response, list, "订单资金冻结数据");
    }

    /**
     * 获取订单资金冻结详细信息
     */
    @ApiOperation("获取订单资金冻结详细信息")
    @PreAuthorize("@ss.hasPermi('core:volunteer/order-frozen:query')")
    @GetMapping(value = "/{orderFrozenFundsId}")
    public R<OrderFrozenFunds> getInfo(@PathVariable("orderFrozenFundsId") Long orderFrozenFundsId)
    {
        return R.ok(orderFrozenFundsService.selectOrderFrozenFundsByOrderFrozenFundsId(orderFrozenFundsId));
    }

    /**
     * 新增订单资金冻结
     */
    @ApiOperation("新增订单资金冻结")
    @PreAuthorize("@ss.hasPermi('core:volunteer/order-frozen:add')")
    @Log(title = "订单资金冻结", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderFrozenFunds orderFrozenFunds)
    {
        return toAjax(orderFrozenFundsService.insertOrderFrozenFunds(orderFrozenFunds));
    }

    /**
     * 修改订单资金冻结
     */
    @ApiOperation("修改订单资金冻结")
    @PreAuthorize("@ss.hasPermi('core:volunteer/order-frozen:edit')")
    @Log(title = "订单资金冻结", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderFrozenFunds orderFrozenFunds)
    {
        return toAjax(orderFrozenFundsService.updateOrderFrozenFunds(orderFrozenFunds));
    }

    /**
     * 删除订单资金冻结
     */
    @ApiOperation("删除订单资金冻结")
    @PreAuthorize("@ss.hasPermi('core:volunteer/order-frozen:remove')")
    @Log(title = "订单资金冻结", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderFrozenFundsIds}")
    public R<Integer> remove(@PathVariable Long[] orderFrozenFundsIds)
    {
        return R.ok(orderFrozenFundsService.deleteOrderFrozenFundsByOrderFrozenFundsIds(orderFrozenFundsIds));
    }
}
