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.FutureStocks;
import com.ruoyi.invest.domain.vo.FutureStocksVo;
import com.ruoyi.invest.domain.dto.FutureStocksDto;
import com.ruoyi.invest.service.IFutureStocksService;
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-19
 */
@Api(tags=" 期货股票基本信息")
@RestController
@RequestMapping("/futureStocks")
public class FutureStocksController extends BaseController
{
    @Resource
    private IFutureStocksService futureStocksService;

    /**
     * 查询期货股票基本信息列表
     */
    @ApiOperation(value="查询期货股票基本信息列表",response = FutureStocksVo.class)
    @RequiresPermissions("invest:futureStocks:list")
    @GetMapping("/list")
    public TableDataInfo list(FutureStocksDto futureStocksDto)
    {
        startPage();
        List<FutureStocksVo> list = futureStocksService.selectFutureStocksList(futureStocksDto);
        return getDataTable(list);
    }

    /**
     * 导出期货股票基本信息列表
     */
    @ApiOperation(value="导出期货股票基本信息列表")
    @RequiresPermissions("invest:futureStocks:export")
    @Log(title = "期货股票基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FutureStocksDto futureStocksDto)
    {
        List<FutureStocksVo> list = futureStocksService.selectFutureStocksList(futureStocksDto);
        ExcelUtil<FutureStocksVo> util = new ExcelUtil<FutureStocksVo>(FutureStocksVo.class);
        util.exportExcel(response, list, "期货股票基本信息数据");
    }

    /**
     * 获取期货股票基本信息详细信息
     */
    @ApiOperation(value="获取期货股票基本信息详细信息")
    @RequiresPermissions("invest:futureStocks:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(futureStocksService.selectFutureStocksById(id));
    }

    /**
     * 新增期货股票基本信息
     */
    @ApiOperation(value="新增期货股票基本信息")
    @RequiresPermissions("invest:futureStocks:add")
    @Log(title = "期货股票基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FutureStocks futureStocks)
    {
        return toAjax(futureStocksService.insertFutureStocks(futureStocks));
    }

    /**
     * 修改期货股票基本信息
     */
    @ApiOperation(value="修改期货股票基本信息")
    @RequiresPermissions("invest:futureStocks:edit")
    @Log(title = "期货股票基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FutureStocks futureStocks)
    {
        return toAjax(futureStocksService.updateFutureStocks(futureStocks));
    }

    /**
     * 删除期货股票基本信息
     */
    @ApiOperation(value="删除期货股票基本信息")
    @RequiresPermissions("invest:futureStocks:remove")
    @Log(title = "期货股票基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(futureStocksService.deleteFutureStocksByIds(ids));
    }
}
