package com.fs.hospital.controller.hospital;

import java.util.List;
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.HospitalOutpatientOrderLogs;
import com.fs.hospital.service.IHospitalOutpatientOrderLogsService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 日志Controller
 *
 * @author fs
 * @date 2024-03-26
 */
@RestController
@RequestMapping("/hospital/hospitalOutpatientOrderLogs")
public class HospitalOutpatientOrderLogsController extends BaseController
{
    @Autowired
    private IHospitalOutpatientOrderLogsService hospitalOutpatientOrderLogsService;

    /**
     * 查询日志列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalOutpatientOrderLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalOutpatientOrderLogs hospitalOutpatientOrderLogs)
    {
        startPage();
        List<HospitalOutpatientOrderLogs> list = hospitalOutpatientOrderLogsService.selectHospitalOutpatientOrderLogsList(hospitalOutpatientOrderLogs);
        return getDataTable(list);
    }

    /**
     * 导出日志列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalOutpatientOrderLogs:export')")
    @Log(title = "日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HospitalOutpatientOrderLogs hospitalOutpatientOrderLogs)
    {
        List<HospitalOutpatientOrderLogs> list = hospitalOutpatientOrderLogsService.selectHospitalOutpatientOrderLogsList(hospitalOutpatientOrderLogs);
        ExcelUtil<HospitalOutpatientOrderLogs> util = new ExcelUtil<HospitalOutpatientOrderLogs>(HospitalOutpatientOrderLogs.class);
        return util.exportExcel(list, "日志数据");
    }

    /**
     * 获取日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalOutpatientOrderLogs:query')")
    @GetMapping(value = "/{logsId}")
    public AjaxResult getInfo(@PathVariable("logsId") Long logsId)
    {
        return AjaxResult.success(hospitalOutpatientOrderLogsService.selectHospitalOutpatientOrderLogsByLogsId(logsId));
    }

    /**
     * 新增日志
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalOutpatientOrderLogs:add')")
    @Log(title = "日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HospitalOutpatientOrderLogs hospitalOutpatientOrderLogs)
    {
        return toAjax(hospitalOutpatientOrderLogsService.insertHospitalOutpatientOrderLogs(hospitalOutpatientOrderLogs));
    }

    /**
     * 修改日志
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalOutpatientOrderLogs:edit')")
    @Log(title = "日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HospitalOutpatientOrderLogs hospitalOutpatientOrderLogs)
    {
        return toAjax(hospitalOutpatientOrderLogsService.updateHospitalOutpatientOrderLogs(hospitalOutpatientOrderLogs));
    }

    /**
     * 删除日志
     */
    @PreAuthorize("@ss.hasPermi('hospital:hospitalOutpatientOrderLogs:remove')")
    @Log(title = "日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logsIds}")
    public AjaxResult remove(@PathVariable Long[] logsIds)
    {
        return toAjax(hospitalOutpatientOrderLogsService.deleteHospitalOutpatientOrderLogsByLogsIds(logsIds));
    }
}
