package com.ruoyi.logistics.controller;

import java.util.List;
import java.io.IOException;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.logistics.annotation.SimpleDictExportUtil;
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.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.logistics.domain.BizFinancialAdjustmentRecord;
import com.ruoyi.logistics.service.IBizFinancialAdjustmentRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * PC-调账流水记录
 * 
 * @author RuiJing
 * @date 2026-01-29
 */
@RestController
@RequestMapping("/adjustmentRecord")
public class BizFinancialAdjustmentRecordController extends BaseController
{
    @Autowired
    private IBizFinancialAdjustmentRecordService bizFinancialAdjustmentRecordService;
    @Resource
    SimpleDictExportUtil simpleDictExportUtil;
    /**
     * 查询调账流水记录列表
     */
    @RequiresPermissions("system:adjustmentRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(BizFinancialAdjustmentRecord bizFinancialAdjustmentRecord)
    {
        startPage();
        List<BizFinancialAdjustmentRecord> list = bizFinancialAdjustmentRecordService.selectBizFinancialAdjustmentRecordList(bizFinancialAdjustmentRecord);
        return getDataTable(list);
    }

    /**
     * 导出调账流水记录列表
     */
    @RequiresPermissions("system:adjustmentRecord:export")
    @Log(title = "调账流水记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizFinancialAdjustmentRecord bizFinancialAdjustmentRecord)
    {
        List<BizFinancialAdjustmentRecord> list = bizFinancialAdjustmentRecordService.selectBizFinancialAdjustmentRecordList(bizFinancialAdjustmentRecord);
        simpleDictExportUtil.handleDictList(list);

        ExcelUtil<BizFinancialAdjustmentRecord> util = new ExcelUtil<BizFinancialAdjustmentRecord>(BizFinancialAdjustmentRecord.class);
        util.exportExcel(response, list, "调账流水记录数据");
    }

    /**
     * 获取调账流水记录详细信息
     */
    @RequiresPermissions("system:adjustmentRecord:query")
    @GetMapping(value = "/{financialAdjustId}")
    public AjaxResult getInfo(@PathVariable("financialAdjustId") Long financialAdjustId)
    {
        return success(bizFinancialAdjustmentRecordService.selectBizFinancialAdjustmentRecordByFinancialAdjustId(financialAdjustId));
    }

    /**
     * 新增调账流水记录
     */
    @RequiresPermissions("system:adjustmentRecord:add")
    @Log(title = "调账流水记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizFinancialAdjustmentRecord bizFinancialAdjustmentRecord)
    {
        return toAjax(bizFinancialAdjustmentRecordService.insertBizFinancialAdjustmentRecord(bizFinancialAdjustmentRecord));
    }

    /**
     * 修改调账流水记录
     */
    @RequiresPermissions("system:adjustmentRecord:edit")
    @Log(title = "调账流水记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizFinancialAdjustmentRecord bizFinancialAdjustmentRecord)
    {
        return toAjax(bizFinancialAdjustmentRecordService.updateBizFinancialAdjustmentRecord(bizFinancialAdjustmentRecord));
    }

    /**
     * 删除调账流水记录
     */
    @RequiresPermissions("system:adjustmentRecord:remove")
    @Log(title = "调账流水记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{financialAdjustIds}")
    public AjaxResult remove(@PathVariable Long[] financialAdjustIds)
    {
        return toAjax(bizFinancialAdjustmentRecordService.deleteBizFinancialAdjustmentRecordByFinancialAdjustIds(financialAdjustIds));
    }
}
