package com.dcsoft.system.consume.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dcsoft.system.consume.domain.ConsumeReport;
import com.dcsoft.system.consume.service.IConsumeReportService;
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.dcsoft.common.log.annotation.Log;
import com.dcsoft.common.log.enums.BusinessType;
import com.dcsoft.common.security.annotation.RequiresPermissions;
import com.dcsoft.common.core.web.controller.BaseController;
import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.common.core.utils.poi.ExcelUtil;
import com.dcsoft.common.core.web.page.TableDataInfo;

/**
 * 三方上报餐补信息Controller
 *
 * @author dcsoft
 * @date 2024-10-24
 */
@RestController
@RequestMapping("/consumeReport")
public class ConsumeReportController extends BaseController
{
    @Autowired
    private IConsumeReportService consumeReportService;

    /**
     * 查询三方上报餐补信息列表
     */
    @RequiresPermissions("consume:consumeReport:list")
    @GetMapping("/list")
    public TableDataInfo list(ConsumeReport consumeReport)
    {
        startPage();
        List<ConsumeReport> list = consumeReportService.selectConsumeReportList(consumeReport);
        return getDataTable(list);
    }

    /**
     * 导出三方上报餐补信息列表
     */
    @RequiresPermissions("consume:consumeReport:export")
    @Log(title = "三方上报餐补信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConsumeReport consumeReport)
    {
        List<ConsumeReport> list = consumeReportService.selectConsumeReportList(consumeReport);
        ExcelUtil<ConsumeReport> util = new ExcelUtil<ConsumeReport>(ConsumeReport.class);
        util.exportExcel(response, list, "三方上报餐补信息数据");
    }

    /**
     * 获取三方上报餐补信息详细信息
     */
    @RequiresPermissions("consume:consumeReport:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(consumeReportService.selectConsumeReportById(id));
    }

    /**
     * 新增三方上报餐补信息
     */
    @RequiresPermissions("consume:consumeReport:add")
    @Log(title = "三方上报餐补信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConsumeReport consumeReport)
    {
        return toAjax(consumeReportService.insertConsumeReport(consumeReport));
    }

    /**
     * 修改三方上报餐补信息
     */
    @RequiresPermissions("consume:consumeReport:edit")
    @Log(title = "三方上报餐补信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConsumeReport consumeReport)
    {
        return toAjax(consumeReportService.updateConsumeReport(consumeReport));
    }

    /**
     * 删除三方上报餐补信息
     */
    @RequiresPermissions("consume:consumeReport:remove")
    @Log(title = "三方上报餐补信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(consumeReportService.deleteConsumeReportByIds(ids));
    }
}
