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

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.module.system.controller.admin.biz.vo.PriceChangeDetailRespVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.TransferChangeDetailRespVO;
import cn.iocoder.yudao.module.system.controller.admin.biz.vo.TransferSyncDataReqVO;
import cn.iocoder.yudao.module.system.service.biz.PriceChangeRecordService;
import cn.iocoder.yudao.module.system.service.biz.TransferChangeRecordService;
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.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
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;

/**
 * @Author: jinyd
 * @CreateTime: 2024/8/29  9:41
 * @Description:
 * @Version: 4.0
 */


@Tag(name = "管理后台 - 转院变更")
@RestController
@RequestMapping("/elderly/transferChangeRecord")
@Validated
public class TransferChangeRecordController {

    @Resource
    private TransferChangeRecordService transferChangeRecordService;


    @GetMapping("/getTransferDetail")
    @Operation(summary = "获得转院变更详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('changes:hospital:detail')")
    @TenantIgnore
    public CommonResult<TransferChangeDetailRespVO> getTransferDetail(@RequestParam("id") Long id) {
        TransferChangeDetailRespVO priceChangeDetail = transferChangeRecordService.getTransferDetail(id);
        return success(priceChangeDetail);
    }

    @PostMapping("/transferSyncData")
    @PreAuthorize("@ss.hasPermission('bpm:nurse-change:transferSyncData')")
    @Operation(summary = "同步数据")
    public CommonResult<Long> transferSyncData(@Valid @RequestBody TransferSyncDataReqVO createReqVO) {
        return success(transferChangeRecordService.transferSyncData(getLoginUserId(),
                SecurityFrameworkUtils.getLoginUserNickname(), createReqVO));
    }

}
