package com.ruoyi.web.modules.architecture.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.architecture.domain.BizEpidemicTreatmentStandard;
import com.ruoyi.web.modules.architecture.service.IBizEpidemicTreatmentStandardService;

/**
 * 疫病诊疗标准管理
 */
@RestController
@RequestMapping("/epidemicTreatment/standard")
public class BizEpidemicTreatmentStandardController extends BaseController
{
    @Autowired
    private IBizEpidemicTreatmentStandardService bizEpidemicTreatmentStandardService;

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizEpidemicTreatmentStandard query)
    {
        startPage();
        List<BizEpidemicTreatmentStandard> list = bizEpidemicTreatmentStandardService.selectBizEpidemicTreatmentStandardList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizEpidemicTreatmentStandardService.selectBizEpidemicTreatmentStandardById(id));
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:add')")
    @Log(title = "疫病诊疗标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BizEpidemicTreatmentStandard row)
    {
        row.setCreateBy(getUsername());
        return toAjax(bizEpidemicTreatmentStandardService.insertBizEpidemicTreatmentStandard(row));
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:edit')")
    @Log(title = "疫病诊疗标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BizEpidemicTreatmentStandard row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(bizEpidemicTreatmentStandardService.updateBizEpidemicTreatmentStandard(row));
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:remove')")
    @Log(title = "疫病诊疗标准", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizEpidemicTreatmentStandardService.deleteBizEpidemicTreatmentStandardByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:syncKb')")
    @Log(title = "疫病诊疗标准同步知识库", businessType = BusinessType.UPDATE)
    @PostMapping("/syncKb/{id}")
    public AjaxResult syncKb(@PathVariable Long id)
    {
        return toAjax(bizEpidemicTreatmentStandardService.syncKb(id));
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:removeKb')")
    @Log(title = "疫病诊疗标准移出知识库", businessType = BusinessType.UPDATE)
    @PostMapping("/removeKb/{id}")
    public AjaxResult removeKb(@PathVariable Long id)
    {
        return toAjax(bizEpidemicTreatmentStandardService.removeKb(id));
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:publish')")
    @Log(title = "疫病诊疗标准发布", businessType = BusinessType.UPDATE)
    @PostMapping("/publish/{id}")
    public AjaxResult publish(@PathVariable Long id)
    {
        return toAjax(bizEpidemicTreatmentStandardService.publish(id));
    }

    @PreAuthorize("@ss.hasPermi('epidemicTreatment:standard:offline')")
    @Log(title = "疫病诊疗标准下架", businessType = BusinessType.UPDATE)
    @PostMapping("/offline/{id}")
    public AjaxResult offline(@PathVariable Long id)
    {
        return toAjax(bizEpidemicTreatmentStandardService.offline(id));
    }
}
