package cn.iocoder.yudao.module.system.controller.admin.nursing;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.admin.nursing.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.NursingInspectionDO;
import cn.iocoder.yudao.module.system.service.nursing.NursingInspectionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;

import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 - 长者护理巡检")
@RestController
@RequestMapping("/elderly/nursingInspection")
@Validated
public class NursingInspectionController {

    @Resource
    private NursingInspectionService nursingInspectionService;


    @PostMapping("/create")
    @Operation(summary = "创建长者护理巡检")
    public CommonResult<Boolean> createNursingInspection(@Valid @RequestBody NursingInspectionSaveReqVO createReqVO) {
        nursingInspectionService.createNursingInspection(createReqVO);
        return success(true);
    }
//
//    @PutMapping("/update")
//    @Operation(summary = "更新长者护理巡检")
//    @PreAuthorize("@ss.hasPermission('elderly:nursing-inspection:update')")
//    public CommonResult<Boolean> updateNursingInspection(@Valid @RequestBody NursingInspectionSaveReqVO updateReqVO) {
//        nursingInspectionService.updateNursingInspection(updateReqVO);
//        return success(true);
//    }
//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除长者护理巡检")
//    @Parameter(name = "id", description = "编号", required = true)
//    @PreAuthorize("@ss.hasPermission('elderly:nursing-inspection:delete')")
//    public CommonResult<Boolean> deleteNursingInspection(@RequestParam("id") Long id) {
//        nursingInspectionService.deleteNursingInspection(id);
//        return success(true);
//    }
//
    @GetMapping("/get")
    @Operation(summary = "获得长者护理巡检详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<NursingInspectionRespVO> getNursingInspection(@RequestParam("id") Long id) {
        NursingInspectionDO nursingInspection = nursingInspectionService.getNursingInspection(id);
        return success(BeanUtils.toBean(nursingInspection, NursingInspectionRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得长者护理巡检分页")
    public CommonResult<PageResult<NursingInspectionRespVO>> getNursingInspectionPage(@Valid NursingInspectionPageReqVO pageReqVO) {
        PageResult<NursingInspectionDO> pageResult = nursingInspectionService.getNursingInspectionPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, NursingInspectionRespVO.class));
    }

    @GetMapping("/mobile/getMobileNursingInspectionList")
    @Operation(summary = "移动端-获取巡检记录详情列表")
    public CommonResult<List<NursingInspectionDO>>  getMobileNursingInspectionList(@RequestParam("nursingLogId") Long nursingLogId){
        return  success(nursingInspectionService.getMobileNursingInspectionList(nursingLogId));
    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出长者护理巡检 Excel")
//    @PreAuthorize("@ss.hasPermission('elderly:nursing-inspection:export')")
//    @ApiAccessLog(operateType = EXPORT)
//    public void exportNursingInspectionExcel(@Valid NursingInspectionPageReqVO pageReqVO,
//              HttpServletResponse response) throws IOException {
//        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
//        List<NursingInspectionDO> list = nursingInspectionService.getNursingInspectionPage(pageReqVO).getList();
//        // 导出 Excel
//        ExcelUtils.write(response, "长者护理巡检.xls", "数据", NursingInspectionRespVO.class,
//                        BeanUtils.toBean(list, NursingInspectionRespVO.class));
//    }




}