package com.ruoyi.invest.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
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.invest.domain.AccountsTransferRecord;
import com.ruoyi.invest.domain.vo.AccountsTransferRecordVo;
import com.ruoyi.invest.domain.dto.AccountsTransferRecordDto;
import com.ruoyi.invest.service.IAccountsTransferRecordService;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 账户转账记录Controller
 *
 * @author tianyongbao
 * @date 2024-03-30
 */
@Api(tags=" 账户转账记录")
@RestController
@RequestMapping("/accountsTransferRecord")
public class AccountsTransferRecordController extends BaseController
{
    @Resource
    private IAccountsTransferRecordService accountsTransferRecordService;

    /**
     * 查询账户转账记录列表
     */
    @ApiOperation(value="查询账户转账记录列表",response = AccountsTransferRecordVo.class)
    @RequiresPermissions("invest:accountsTransferRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(AccountsTransferRecordDto accountsTransferRecordDto)
    {
        startPage();
        List<AccountsTransferRecordVo> list = accountsTransferRecordService.selectAccountsTransferRecordList(accountsTransferRecordDto);
        return getDataTable(list);
    }

    /**
     * 导出账户转账记录列表
     */
    @ApiOperation(value="导出账户转账记录列表")
    @RequiresPermissions("invest:accountsTransferRecord:export")
    @Log(title = "账户转账记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountsTransferRecordDto accountsTransferRecordDto)
    {
        List<AccountsTransferRecordVo> list = accountsTransferRecordService.selectAccountsTransferRecordList(accountsTransferRecordDto);
        ExcelUtil<AccountsTransferRecordVo> util = new ExcelUtil<AccountsTransferRecordVo>(AccountsTransferRecordVo.class);
        util.exportExcel(response, list, "账户转账记录数据");
    }

    /**
     * 获取账户转账记录详细信息
     */
    @ApiOperation(value="获取账户转账记录详细信息")
    @RequiresPermissions("invest:accountsTransferRecord:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountsTransferRecordService.selectAccountsTransferRecordById(id));
    }

    /**
     * 新增账户转账记录
     */
    @ApiOperation(value="新增账户转账记录")
    @RequiresPermissions("invest:accountsTransferRecord:add")
    @Log(title = "账户转账记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountsTransferRecord accountsTransferRecord)
    {
        return toAjax(accountsTransferRecordService.insertAccountsTransferRecord(accountsTransferRecord));
    }

    /**
     * 修改账户转账记录
     */
    @ApiOperation(value="修改账户转账记录")
    @RequiresPermissions("invest:accountsTransferRecord:edit")
    @Log(title = "账户转账记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountsTransferRecord accountsTransferRecord)
    {
        return toAjax(accountsTransferRecordService.updateAccountsTransferRecord(accountsTransferRecord));
    }

    /**
     * 删除账户转账记录
     */
    @ApiOperation(value="删除账户转账记录")
    @RequiresPermissions("invest:accountsTransferRecord:remove")
    @Log(title = "账户转账记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountsTransferRecordService.deleteAccountsTransferRecordByIds(ids));
    }
}
