package com.ruoyi.web.work.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.work.domain.Record;
import com.ruoyi.web.work.service.IRecordService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 资金交易记录
 * @author lsw
 * @date 2024-04-26
 */
@RestController
@RequestMapping("/work/record")
public class RecordController extends BaseController {
    @Autowired
    private IRecordService recordService;

    @PreAuthorize("@ss.hasPermi('work:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(Record record){
        record.setCompanyId(getLoginUser().getUser().getCompanyId());
        startPage();
        List<Record> list = recordService.selectList(record);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('work:record:query')")
    @GetMapping(value = "/detail/{id}")
    public AjaxResult detail(@PathVariable("id") Long id){
        return AjaxResult.success(recordService.getById(id));
    }

}
