package com.ruoyi.os.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.os.domain.HealthcareOsComplaints;
import com.ruoyi.os.service.IHealthcareOsComplaintsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 主诉Controller
 *
 * @author 何顺
 * @date 2024-09-24
 */
@RestController
@RequestMapping("/outpatientService/healthcareOsComplaints")
public class HealthcareOsComplaintsController extends BaseController
{
    @Autowired
    private IHealthcareOsComplaintsService healthcareOsComplaintsService;

    /**
     * 查询主诉列表
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsComplaints:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthcareOsComplaints healthcareOsComplaints)
    {
        startPage();
        List<HealthcareOsComplaints> list = healthcareOsComplaintsService.selectHealthcareOsComplaintsList(healthcareOsComplaints);
        return getDataTable(list);
    }

    /**
     * 导出主诉列表
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsComplaints:export')")
    @Log(title = "主诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthcareOsComplaints healthcareOsComplaints)
    {
        List<HealthcareOsComplaints> list = healthcareOsComplaintsService.selectHealthcareOsComplaintsList(healthcareOsComplaints);
        ExcelUtil<HealthcareOsComplaints> util = new ExcelUtil<HealthcareOsComplaints>(HealthcareOsComplaints.class);
        util.exportExcel(response, list, "主诉数据");
    }

    /**
     * 获取主诉详细信息
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsComplaints:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(healthcareOsComplaintsService.selectHealthcareOsComplaintsById(id));
    }

    /**
     * 新增主诉
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsComplaints:add')")
    @Log(title = "主诉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthcareOsComplaints healthcareOsComplaints)
    {
        return toAjax(healthcareOsComplaintsService.insertHealthcareOsComplaints(healthcareOsComplaints));
    }

    /**
     * 修改主诉
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsComplaints:edit')")
    @Log(title = "主诉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthcareOsComplaints healthcareOsComplaints)
    {
        return toAjax(healthcareOsComplaintsService.updateHealthcareOsComplaints(healthcareOsComplaints));
    }

    /**
     * 删除主诉
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsComplaints:remove')")
    @Log(title = "主诉", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(healthcareOsComplaintsService.deleteHealthcareOsComplaintsByIds(ids));
    }
}
