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

/**
 * 日志Controller
 *
 * @author fs
 * @date 2024-03-26
 */
@RestController
@RequestMapping("/hospital/hospitalPharmacyOrderLogs")
public class HospitalPharmacyOrderLogsController extends BaseController
{
    @Autowired
    private IHospitalPharmacyOrderLogsService hospitalPharmacyOrderLogsService;

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

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

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

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

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

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