package com.ruoyi.web.bst;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.balanceLog.domain.BalanceLogQuery;
import com.ruoyi.bst.balanceLog.domain.BalanceLogVO;
import com.ruoyi.bst.balanceLog.service.BalanceLogService;
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;

/**
 * 余额日志Controller
 *
 * @author ruoyi
 * @date 2025-03-14
 */
@RestController
@RequestMapping("/bst/balanceLog")
public class BalanceLogController extends BaseController
{
    @Autowired
    private BalanceLogService balanceLogService;

    /**
     * 查询余额日志列表
     */
    @PreAuthorize("@ss.hasPermi('bst:balanceLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(BalanceLogQuery query)
    {
        startPage();
        startOrderBy();
        query.setScope(true);
        List<BalanceLogVO> list = balanceLogService.selectBalanceLogList(query);
        return getDataTable(list);
    }

    /**
     * 导出余额日志列表
     */
    @PreAuthorize("@ss.hasPermi('bst:balanceLog:export')")
    @Log(title = "余额日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BalanceLogQuery query)
    {
        query.setScope(true);
        List<BalanceLogVO> list = balanceLogService.selectBalanceLogList(query);
        ExcelUtil<BalanceLogVO> util = new ExcelUtil<BalanceLogVO>(BalanceLogVO.class);
        util.exportExcel(response, list, "余额日志数据");
    }

    /**
     * 获取余额日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('bst:balanceLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(balanceLogService.selectBalanceLogById(id, true));
    }
}
