package com.ruoyi.web.modules.epidemic.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.modules.epidemic.domain.BizEpidemicReport;
import com.ruoyi.web.modules.epidemic.domain.dto.EpidemicReportRelieveRequest;
import com.ruoyi.web.modules.epidemic.service.IBizEpidemicReportService;

/**
 * 疫情上报管理
 */
@RestController
@RequestMapping("/diseaseDetection/epidemicReport")
public class BizEpidemicReportController extends BaseController
{
    @Autowired
    private IBizEpidemicReportService bizEpidemicReportService;

    @PreAuthorize("@ss.hasPermi('diseaseDetection:epidemicReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizEpidemicReport query)
    {
        startPage();
        List<BizEpidemicReport> list = bizEpidemicReportService.selectBizEpidemicReportList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:epidemicReport:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizEpidemicReportService.selectBizEpidemicReportById(id));
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:epidemicReport:add')")
    @Log(title = "疫情上报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BizEpidemicReport row)
    {
        row.setCreateBy(getUsername());
        return toAjax(bizEpidemicReportService.insertBizEpidemicReport(row));
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:epidemicReport:edit')")
    @Log(title = "疫情上报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BizEpidemicReport row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(bizEpidemicReportService.updateBizEpidemicReport(row));
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:epidemicReport:remove')")
    @Log(title = "疫情上报", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizEpidemicReportService.deleteBizEpidemicReportByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:epidemicReport:relieve')")
    @Log(title = "疫情上报解除", businessType = BusinessType.UPDATE)
    @PutMapping("/relieve")
    public AjaxResult relieve(@Validated @RequestBody EpidemicReportRelieveRequest request)
    {
        return toAjax(bizEpidemicReportService.relieve(request, getUsername()));
    }
}
