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.PlatformFinance;
import com.leromro.core.service.IPlatformFinanceService;
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/platform-finance")
public class PlatformFinanceController extends BaseController
{
    @Autowired
    private IPlatformFinanceService platformFinanceService;

    /**
     * 查询平台资金流水列表
     */
    @ApiOperation("查询平台资金流水列表")
    @PreAuthorize("@ss.hasPermi('core:platform-finance:list')")
    @GetMapping("/list")
    public TableDataInfo<PlatformFinance> list(PlatformFinance platformFinance)
    {
        startPage();
        List<PlatformFinance> list = platformFinanceService.selectPlatformFinanceList(platformFinance);
        return getDataTable(list);
    }

    /**
     * 导出平台资金流水列表
     */
    @ApiOperation("导出平台资金流水列表")
    @PreAuthorize("@ss.hasPermi('core:platform-finance:export')")
    @Log(title = "平台资金流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlatformFinance platformFinance)
    {
        List<PlatformFinance> list = platformFinanceService.selectPlatformFinanceList(platformFinance);
        ExcelUtil<PlatformFinance> util = new ExcelUtil<PlatformFinance>(PlatformFinance.class);
        util.exportExcel(response, list, "平台资金流水数据");
    }

    /**
     * 获取平台资金流水详细信息
     */
    @ApiOperation("获取平台资金流水详细信息")
    @PreAuthorize("@ss.hasPermi('core:platform-finance:query')")
    @GetMapping(value = "/{platformFinanceId}")
    public R<PlatformFinance> getInfo(@PathVariable("platformFinanceId") Long platformFinanceId)
    {
        return R.ok(platformFinanceService.selectPlatformFinanceByPlatformFinanceId(platformFinanceId));
    }

    /**
     * 新增平台资金流水
     */
    @ApiOperation("新增平台资金流水")
    @PreAuthorize("@ss.hasPermi('core:platform-finance:add')")
    @Log(title = "平台资金流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformFinance platformFinance)
    {
        return toAjax(platformFinanceService.insertPlatformFinance(platformFinance));
    }

    /**
     * 修改平台资金流水
     */
    @ApiOperation("修改平台资金流水")
    @PreAuthorize("@ss.hasPermi('core:platform-finance:edit')")
    @Log(title = "平台资金流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformFinance platformFinance)
    {
        return toAjax(platformFinanceService.updatePlatformFinance(platformFinance));
    }

    /**
     * 删除平台资金流水
     */
    @ApiOperation("删除平台资金流水")
    @PreAuthorize("@ss.hasPermi('core:platform-finance:remove')")
    @Log(title = "平台资金流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{platformFinanceIds}")
    public R<Integer> remove(@PathVariable Long[] platformFinanceIds)
    {
        return R.ok(platformFinanceService.deletePlatformFinanceByPlatformFinanceIds(platformFinanceIds));
    }
}
