package com.ruoyi.web.controller.care;

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.care.domain.CareNurseRecords;
import com.ruoyi.care.service.ICareNurseRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 护理任务记录Controller
 * 
 * @author qy
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/care/records")
public class CareNurseRecordsController extends BaseController
{
    @Autowired
    private ICareNurseRecordsService careNurseRecordsService;

    /**
     * 查询护理任务记录列表
     */
    @PreAuthorize("@ss.hasPermi('care:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(CareNurseRecords careNurseRecords)
    {
        startPage();
        List<CareNurseRecords> list = careNurseRecordsService.selectCareNurseRecordsList(careNurseRecords);
        return getDataTable(list);
    }

    /**
     * 导出护理任务记录列表
     */
    @PreAuthorize("@ss.hasPermi('care:records:export')")
    @Log(title = "护理任务记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CareNurseRecords careNurseRecords)
    {
        List<CareNurseRecords> list = careNurseRecordsService.selectCareNurseRecordsList(careNurseRecords);
        ExcelUtil<CareNurseRecords> util = new ExcelUtil<CareNurseRecords>(CareNurseRecords.class);
        util.exportExcel(response, list, "护理任务记录数据");
    }

    /**
     * 获取护理任务记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('care:records:query')")
    @GetMapping(value = "/{nursingRecordId}")
    public AjaxResult getInfo(@PathVariable("nursingRecordId") Long nursingRecordId)
    {
        return success(careNurseRecordsService.selectCareNurseRecordsByNursingRecordId(nursingRecordId));
    }

    /**
     * 新增护理任务记录
     */
    @PreAuthorize("@ss.hasPermi('care:records:add')")
    @Log(title = "护理任务记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CareNurseRecords careNurseRecords)
    {
        return toAjax(careNurseRecordsService.insertCareNurseRecords(careNurseRecords));
    }

    /**
     * 修改护理任务记录
     */
    @PreAuthorize("@ss.hasPermi('care:records:edit')")
    @Log(title = "护理任务记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CareNurseRecords careNurseRecords)
    {
        return toAjax(careNurseRecordsService.updateCareNurseRecords(careNurseRecords));
    }

    /**
     * 删除护理任务记录
     */
    @PreAuthorize("@ss.hasPermi('care:records:remove')")
    @Log(title = "护理任务记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nursingRecordIds}")
    public AjaxResult remove(@PathVariable Long[] nursingRecordIds)
    {
        return toAjax(careNurseRecordsService.deleteCareNurseRecordsByNursingRecordIds(nursingRecordIds));
    }
}
