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

/**
 * 护理任务打卡Controller
 * 
 * @author qy
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/care/clocks")
public class CareNurseClocksController extends BaseController
{
    @Autowired
    private ICareNurseClocksService careNurseClocksService;

    /**
     * 查询护理任务打卡列表
     */
    @PreAuthorize("@ss.hasPermi('care:clocks:list')")
    @GetMapping("/list")
    public TableDataInfo list(CareNurseClocks careNurseClocks)
    {
        startPage();
        List<CareNurseClocks> list = careNurseClocksService.selectCareNurseClocksList(careNurseClocks);
        return getDataTable(list);
    }

    /**
     * 导出护理任务打卡列表
     */
    @PreAuthorize("@ss.hasPermi('care:clocks:export')")
    @Log(title = "护理任务打卡", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CareNurseClocks careNurseClocks)
    {
        List<CareNurseClocks> list = careNurseClocksService.selectCareNurseClocksList(careNurseClocks);
        ExcelUtil<CareNurseClocks> util = new ExcelUtil<CareNurseClocks>(CareNurseClocks.class);
        util.exportExcel(response, list, "护理任务打卡数据");
    }

    /**
     * 获取护理任务打卡详细信息
     */
    @PreAuthorize("@ss.hasPermi('care:clocks:query')")
    @GetMapping(value = "/{clockId}")
    public AjaxResult getInfo(@PathVariable("clockId") Long clockId)
    {
        return success(careNurseClocksService.selectCareNurseClocksByClockId(clockId));
    }

    /**
     * 新增护理任务打卡
     */
    @PreAuthorize("@ss.hasPermi('care:clocks:add')")
    @Log(title = "护理任务打卡", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CareNurseClocks careNurseClocks)
    {
        return toAjax(careNurseClocksService.insertCareNurseClocks(careNurseClocks));
    }

    /**
     * 修改护理任务打卡
     */
    @PreAuthorize("@ss.hasPermi('care:clocks:edit')")
    @Log(title = "护理任务打卡", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CareNurseClocks careNurseClocks)
    {
        return toAjax(careNurseClocksService.updateCareNurseClocks(careNurseClocks));
    }

    /**
     * 删除护理任务打卡
     */
    @PreAuthorize("@ss.hasPermi('care:clocks:remove')")
    @Log(title = "护理任务打卡", businessType = BusinessType.DELETE)
	@DeleteMapping("/{clockIds}")
    public AjaxResult remove(@PathVariable Long[] clockIds)
    {
        return toAjax(careNurseClocksService.deleteCareNurseClocksByClockIds(clockIds));
    }
}
