package com.fs.hospital.controller.hospital;

import java.util.List;

import com.fs.common.annotation.RepeatSubmit;
import com.fs.hospital.vo.HospitalTreatOrderLogsHVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.hospital.domain.HospitalTreatOrderLogs;
import com.fs.hospital.service.IHospitalTreatOrderLogsService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 治疗记录Controller
 *
 * @author fs
 * @date 2024-03-26
 */
@RestController
@RequestMapping("/hospital/hospitalTreatOrderLogs")
public class HospitalTreatOrderLogsController extends BaseController
{
    @Autowired
    private IHospitalTreatOrderLogsService hospitalTreatOrderLogsService;

    /**
     * 查询治疗记录列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalTreatOrderLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalTreatOrderLogs hospitalTreatOrderLogs)
    {
        startPage();
        List<HospitalTreatOrderLogsHVO> list = hospitalTreatOrderLogsService.selectHospitalTreatOrderLogsListVO(hospitalTreatOrderLogs);
        return getDataTable(list);
    }

    /**
     * 导出治疗记录列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalTreatOrderLogs:export')")
    @Log(title = "治疗记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HospitalTreatOrderLogs hospitalTreatOrderLogs)
    {
        List<HospitalTreatOrderLogs> list = hospitalTreatOrderLogsService.selectHospitalTreatOrderLogsList(hospitalTreatOrderLogs);
        ExcelUtil<HospitalTreatOrderLogs> util = new ExcelUtil<HospitalTreatOrderLogs>(HospitalTreatOrderLogs.class);
        return util.exportExcel(list, "治疗记录数据");
    }

    /**
     * 获取治疗记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalTreatOrderLogs:query')")
    @GetMapping(value = "/{logsId}")
    public AjaxResult getInfo(@PathVariable("logsId") Long logsId)
    {
        return AjaxResult.success(hospitalTreatOrderLogsService.selectHospitalTreatOrderLogsByLogsId(logsId));
    }

    /**
     * 新增治疗记录
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalTreatOrderLogs:add')")
    @Log(title = "治疗记录", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@RequestBody HospitalTreatOrderLogs hospitalTreatOrderLogs)
    {
        return toAjax(hospitalTreatOrderLogsService.insertHospitalTreatOrderLogs(hospitalTreatOrderLogs));
    }

    /**
     * 修改治疗记录
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalTreatOrderLogs:edit')")
    @Log(title = "治疗记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalTreatOrderLogs hospitalTreatOrderLogs)
    {
        return toAjax(hospitalTreatOrderLogsService.updateHospitalTreatOrderLogs(hospitalTreatOrderLogs));
    }

    /**
     * 删除治疗记录
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalTreatOrderLogs:remove')")
    @Log(title = "治疗记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logsIds}")
    public AjaxResult remove(@PathVariable Long[] logsIds)
    {
        return toAjax(hospitalTreatOrderLogsService.deleteHospitalTreatOrderLogsByLogsIds(logsIds));
    }
}
