package com.ruoyi.web.controller.care;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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.enums.BusinessType;

import com.ruoyi.care.domain.CareRecords;
import com.ruoyi.care.service.ICareRecordsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流程记录Controller
 * 
 * @author qy
 * @date 2025-01-07
 */
@RestController
@RequestMapping("/care/careRecords")
public class CareRecordsController extends BaseController
{
    @Autowired
    private ICareRecordsService careRecordsService;

    /**
     * 查询流程记录列表
     */
    @PreAuthorize("@ss.hasPermi('care:careRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(CareRecords careRecords)
    {
        startPage();
        List<CareRecords> list = careRecordsService.selectCareRecordsList(careRecords);
        return getDataTable(list);
    }

    /**
     * 导出流程记录列表
     */
    @PreAuthorize("@ss.hasPermi('care:careRecords:export')")
    @Log(title = "流程记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CareRecords careRecords)
    {
        List<CareRecords> list = careRecordsService.selectCareRecordsList(careRecords);
        ExcelUtil<CareRecords> util = new ExcelUtil<CareRecords>(CareRecords.class);
        util.exportExcel(response, list, "流程记录数据");
    }

    /**
     * 获取流程记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('care:careRecords:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(careRecordsService.selectCareRecordsByRecordId(recordId));
    }

    /**
     * 新增流程记录
     */
    @PreAuthorize("@ss.hasPermi('care:careRecords:add')")
    @Log(title = "流程记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CareRecords careRecords)
    {
        return toAjax(careRecordsService.insertCareRecords(careRecords));
    }

    /**
     * 修改流程记录
     */
    @PreAuthorize("@ss.hasPermi('care:careRecords:edit')")
    @Log(title = "流程记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CareRecords careRecords)
    {
        return toAjax(careRecordsService.updateCareRecords(careRecords));
    }

    /**
     * 删除流程记录
     */
    @PreAuthorize("@ss.hasPermi('care:careRecords:remove')")
    @Log(title = "流程记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(careRecordsService.deleteCareRecordsByRecordIds(recordIds));
    }
}
