package com.ruoyi.system.controller;

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.system.domain.MarketStock;
import com.ruoyi.system.service.IMarketStockService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 市场大盘（日）Controller
 * 
 * @author ruoyi
 * @date 2024-08-20
 */
@RestController
@RequestMapping("/market/daily")
public class MarketStockController extends BaseController
{
    @Autowired
    private IMarketStockService marketStockService;

    /**
     * 查询市场大盘（日）列表
     */
    @PreAuthorize("@ss.hasPermi('market:daily:list')")
    @GetMapping("/list")
    public TableDataInfo list(MarketStock marketStock)
    {
        startPage();
        List<MarketStock> list = marketStockService.selectMarketStockList(marketStock);
        return getDataTable(list);
    }

    /**
     * 导出市场大盘（日）列表
     */
    @PreAuthorize("@ss.hasPermi('market:daily:export')")
    @Log(title = "市场大盘（日）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MarketStock marketStock)
    {
        List<MarketStock> list = marketStockService.selectMarketStockList(marketStock);
        ExcelUtil<MarketStock> util = new ExcelUtil<MarketStock>(MarketStock.class);
        util.exportExcel(response, list, "市场大盘（日）数据");
    }

    /**
     * 获取市场大盘（日）详细信息
     */
    @PreAuthorize("@ss.hasPermi('market:daily:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(marketStockService.selectMarketStockById(id));
    }

    /**
     * 新增市场大盘（日）
     */
    @PreAuthorize("@ss.hasPermi('market:daily:add')")
    @Log(title = "市场大盘（日）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MarketStock marketStock)
    {
        return toAjax(marketStockService.insertMarketStock(marketStock));
    }

    /**
     * 修改市场大盘（日）
     */
    @PreAuthorize("@ss.hasPermi('market:daily:edit')")
    @Log(title = "市场大盘（日）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MarketStock marketStock)
    {
        return toAjax(marketStockService.updateMarketStock(marketStock));
    }

    /**
     * 删除市场大盘（日）
     */
    @PreAuthorize("@ss.hasPermi('market:daily:remove')")
    @Log(title = "市场大盘（日）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(marketStockService.deleteMarketStockByIds(ids));
    }
}
