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.BizLabDetection;
import com.ruoyi.web.modules.epidemic.service.IBizLabDetectionService;

/**
 * 实验室检测管理
 */
@RestController
@RequestMapping("/diseaseDetection/labDetection")
public class BizLabDetectionController extends BaseController
{
    @Autowired
    private IBizLabDetectionService bizLabDetectionService;

    @PreAuthorize("@ss.hasPermi('diseaseDetection:labDetection:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizLabDetection query)
    {
        startPage();
        List<BizLabDetection> list = bizLabDetectionService.selectBizLabDetectionList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:labDetection:query')")
    @GetMapping("/quarantineStationOptions")
    public AjaxResult quarantineStationOptions()
    {
        return success(bizLabDetectionService.listQuarantineStationOptions());
    }

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

    @PreAuthorize("@ss.hasPermi('diseaseDetection:labDetection:add')")
    @Log(title = "实验室检测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BizLabDetection row)
    {
        row.setCreateBy(getUsername());
        return toAjax(bizLabDetectionService.insertBizLabDetection(row));
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:labDetection:edit')")
    @Log(title = "实验室检测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BizLabDetection row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(bizLabDetectionService.updateBizLabDetection(row));
    }

    @PreAuthorize("@ss.hasPermi('diseaseDetection:labDetection:remove')")
    @Log(title = "实验室检测", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizLabDetectionService.deleteBizLabDetectionByIds(ids));
    }
}
