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

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.system.controller.admin.nursing.vo.SpecialNursingPlanItemExecuteReqVO;
import cn.iocoder.yudao.module.system.controller.admin.nursing.vo.SpecialNursingPlanItemUnfinishedByFloorRespVO;
import cn.iocoder.yudao.module.system.service.nursing.SpecialNursingPlanItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import java.util.List;

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

@Tag(name = "管理后台 - 特殊照护计划明细")
@RestController
@RequestMapping("/nursing/special-plan-item")
@Validated
public class SpecialNursingPlanItemController {

    @Resource
    private SpecialNursingPlanItemService specialNursingPlanItemService;

    @PostMapping("/execute")
    @Operation(summary = "执行特殊照护计划")
    @TenantIgnore
    @PermitAll
    public CommonResult<Boolean> execute(@Valid @RequestBody SpecialNursingPlanItemExecuteReqVO executeReqVO) {
        specialNursingPlanItemService.executePlan(executeReqVO);
        return success(true);
    }

    @GetMapping("/getUnfinishedByFloorId")
    @Operation(summary = "根据楼层ID获取长者未完成的特殊照护计划明细")
    @Parameter(name = "floorId", description = "楼层ID", required = true, example = "1024")
    @TenantIgnore
    @PermitAll
    public CommonResult<List<SpecialNursingPlanItemUnfinishedByFloorRespVO>> getUnfinishedByFloorId(@RequestParam("floorId") Long floorId) {
        return success(specialNursingPlanItemService.getUnfinishedByFloorId(floorId));
    }
}
