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.HospitalOrderLogs;
import com.fs.hospital.service.IHospitalOrderLogsService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 日志Controller
 *
 * @author fs
 * @date 2024-03-22
 */
@RestController
@RequestMapping("/hospital/hospitalOrderLogs")
public class HospitalOrderLogsController extends BaseController
{
    @Autowired
    private IHospitalOrderLogsService hospitalOrderLogsService;

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

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

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

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

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

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