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.BizDrugIncompatibilityStandard;
import com.ruoyi.web.modules.architecture.service.IBizDrugIncompatibilityStandardService;

/**
 * 药物禁配标准管理
 */
@RestController
@RequestMapping("/drugIncompatibility/standard")
public class BizDrugIncompatibilityStandardController extends BaseController
{
    @Autowired
    private IBizDrugIncompatibilityStandardService bizDrugIncompatibilityStandardService;

    @PreAuthorize("@ss.hasPermi('drugIncompatibility:standard:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizDrugIncompatibilityStandard query)
    {
        startPage();
        List<BizDrugIncompatibilityStandard> list = bizDrugIncompatibilityStandardService.selectBizDrugIncompatibilityStandardList(query);
        return getDataTable(list);
    }

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

    @PreAuthorize("@ss.hasPermi('drugIncompatibility:standard:add')")
    @Log(title = "药物禁配标准", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BizDrugIncompatibilityStandard row)
    {
        row.setCreateBy(getUsername());
        return toAjax(bizDrugIncompatibilityStandardService.insertBizDrugIncompatibilityStandard(row));
    }

    @PreAuthorize("@ss.hasPermi('drugIncompatibility:standard:edit')")
    @Log(title = "药物禁配标准", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BizDrugIncompatibilityStandard row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(bizDrugIncompatibilityStandardService.updateBizDrugIncompatibilityStandard(row));
    }

    @PreAuthorize("@ss.hasPermi('drugIncompatibility:standard:remove')")
    @Log(title = "药物禁配标准", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizDrugIncompatibilityStandardService.deleteBizDrugIncompatibilityStandardByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('drugIncompatibility:standard:syncKb')")
    @Log(title = "药物禁配标准同步知识库", businessType = BusinessType.UPDATE)
    @PostMapping("/syncKb/{id}")
    public AjaxResult syncKb(@PathVariable Long id)
    {
        return toAjax(bizDrugIncompatibilityStandardService.syncKb(id));
    }

    @PreAuthorize("@ss.hasPermi('drugIncompatibility:standard:removeKb')")
    @Log(title = "药物禁配标准移出知识库", businessType = BusinessType.UPDATE)
    @PostMapping("/removeKb/{id}")
    public AjaxResult removeKb(@PathVariable Long id)
    {
        return toAjax(bizDrugIncompatibilityStandardService.removeKb(id));
    }
}
