package com.fs.company.controller.company;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.his.domain.FsFirstDiagnosis;
import com.fs.his.service.IFsFirstDiagnosisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 初诊单Controller
 */
@RestController
@RequestMapping("/his/diagnosis")
public class FsFirstDiagnosisController extends BaseController {

    @Autowired
    private IFsFirstDiagnosisService fsFirstDiagnosisService;

    /**
     * 获取初诊单详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(fsFirstDiagnosisService.getByUserId(userId));
    }

    /**
     * 新增初诊单
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:add')")
    @Log(title = "初诊单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsFirstDiagnosis fsFirstDiagnosis)
    {
        return toAjax(fsFirstDiagnosisService.insertFsFirstDiagnosis(fsFirstDiagnosis));
    }

    /**
     * 修改初诊单
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:edit')")
    @Log(title = "初诊单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsFirstDiagnosis fsFirstDiagnosis)
    {
        return toAjax(fsFirstDiagnosisService.updateFsFirstDiagnosis(fsFirstDiagnosis));
    }
}
