package com.ruoyi.web.controller.ss;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ss.recordBalance.domain.RecordBalance;
import com.ruoyi.ss.recordBalance.domain.RecordBalanceVO;
import com.ruoyi.ss.recordBalance.domain.RecordBalanceQuery;
import com.ruoyi.ss.recordBalance.service.RecordBalanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 余额变动记录Controller
 *
 * @author ruoyi
 * @date 2024-07-22
 */
@RestController
@RequestMapping("/ss/recordBalance")
public class RecordBalanceController extends BaseController
{
    @Autowired
    private RecordBalanceService recordBalanceService;

    /**
     * 查询余额变动记录列表
     */
    @PreAuthorize("@ss.hasPermi('ss:recordBalance:list')")
    @GetMapping("/list")
    public TableDataInfo list(RecordBalanceQuery query)
    {
        startPage();
        startOrderBy();
        List<RecordBalanceVO> list = recordBalanceService.selectRecordBalanceList(query);
        return getDataTable(list);
    }

    /**
     * 导出余额变动记录列表
     */
    @PreAuthorize("@ss.hasPermi('ss:recordBalance:export')")
    @Log(title = "余额变动记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RecordBalanceQuery query)
    {
        List<RecordBalanceVO> list = recordBalanceService.selectRecordBalanceList(query);
        ExcelUtil<RecordBalanceVO> util = new ExcelUtil<RecordBalanceVO>(RecordBalanceVO.class);
        util.exportExcel(response, list, "余额变动记录数据");
    }

    /**
     * 获取余额变动记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ss:recordBalance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(recordBalanceService.selectRecordBalanceById(id));
    }

    /**
     * 新增余额变动记录
     */
    @PreAuthorize("@ss.hasPermi('ss:recordBalance:add')")
    @Log(title = "余额变动记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecordBalance recordBalance)
    {
        return toAjax(recordBalanceService.insertRecordBalance(recordBalance));
    }

    /**
     * 修改余额变动记录
     */
    @PreAuthorize("@ss.hasPermi('ss:recordBalance:edit')")
    @Log(title = "余额变动记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecordBalance recordBalance)
    {
        return toAjax(recordBalanceService.updateRecordBalance(recordBalance));
    }

    /**
     * 删除余额变动记录
     */
    @PreAuthorize("@ss.hasPermi('ss:recordBalance:remove')")
    @Log(title = "余额变动记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(recordBalanceService.deleteRecordBalanceByIds(ids));
    }
}
