package com.ruoyi.web.controller.app;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.ss.recordBalance.domain.RecordBalanceQuery;
import com.ruoyi.ss.recordBalance.service.RecordBalanceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wjh
 * 2024/8/6
 */
@RestController
@RequestMapping("/app/recordBalance")
public class AppRecordBalanceController extends BaseController {

    @Autowired
    private RecordBalanceService recordBalanceService;

    @ApiOperation("查询本人余额变动列表")
    @GetMapping("/list")
    public TableDataInfo list(RecordBalanceQuery query) {
        startPage();
        PageHelper.orderBy(" srb.create_time desc");
        query.setUserId(getUserId());
        return getDataTable(recordBalanceService.selectRecordBalanceList(query));
    }

    @ApiOperation("查询本人余额变动详情")
    @GetMapping("/{id}")
    public AjaxResult getDetail(@PathVariable Long id) {
        return success(recordBalanceService.selectRecordBalanceById(id, getUserId()));
    }

}
