package cn.iocoder.yudao.module.bpm.controller.admin.business;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.module.bpm.controller.admin.business.vo.BpmCheckInWaitCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.business.vo.BpmCheckInWaitSupplementReqVO;
import cn.iocoder.yudao.module.bpm.service.business.BpmElderlApplyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

@Tag(name = "管理后台 - 长者轮候入住流程")
@RestController
@RequestMapping("/bpm/check-in-wait")
@Validated
public class BpmCheckInWaitController {

    @Resource
    private BpmElderlApplyService elderlApplyService;

    @PostMapping("/create")
    @Operation(summary = "创建轮候入住申请")
    @TenantIgnore
    @PermitAll
    public CommonResult<Long> create(@Valid @RequestBody BpmCheckInWaitCreateReqVO createReqVO) {
        createReqVO.setTenantId(createReqVO.getTenantId() == null ? TenantContextHolder.getTenantId() : createReqVO.getTenantId());
        return success(elderlApplyService.checkInWaitCreate(getLoginUserId(),
                SecurityFrameworkUtils.getLoginUserNickname(), createReqVO));
    }
}

