package com.diagbot.web;

import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.RespDTO;
import com.diagbot.facade.MedExamineInfoFacade;
import com.diagbot.util.SysUserUtils;
import com.diagbot.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
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.validation.Valid;

/**
 * <p>
 * 审核 前端控制器
 * </p>
 *
 * @author dsYun
 * @time: 2024-07-06
 */
@RestController
@RequestMapping("/qc/medExamineInfo")
@Api(value = "审核相关接口API", tags = { "审核相关接口API" })
@SuppressWarnings("unchecked")
public class MedExamineInfoController {

    @Autowired
    MedExamineInfoFacade medExamineInfoFacade;

    @ApiOperation(value = "通过审核[by:dsYun]")
    @PostMapping("/passAudit")
    @SysLogger("passAudit")
    @Transactional
    public RespDTO<Boolean> passAudit(@RequestBody BehospitalcodeVO behospitalcodeVO) {
        Boolean res = medExamineInfoFacade.passAudit(behospitalcodeVO);
        return RespDTO.onSuc(res);
    }

    @ApiOperation(value = "驳回[by:dsYun]",
            notes = "驳回")
    @PostMapping("/rejected")
    @Transactional
    public RespDTO<Boolean> rejected(@RequestBody RejectedVo rejectedVo) {
        String userId = SysUserUtils.getCurrentPrincipleID();
        String hospitalId = SysUserUtils.getCurrentHospitalID();
        rejectedVo.setHospitalId(Long.valueOf(hospitalId));
        rejectedVo.setExamineId(Long.valueOf(userId));
        return RespDTO.onSuc(medExamineInfoFacade.rejected(rejectedVo));
    }

    @ApiOperation(value = "申诉[by:dsYun]",
            notes = "申诉")
    @PostMapping("/addAppealInfo")
    @Transactional
    public RespDTO<Boolean> addAppealInfo(@RequestBody @Valid MedAppealInfoVO medAppealInfoVO) {
        medAppealInfoVO.setHospitalId(Long.parseLong(SysUserUtils.getCurrentHospitalID()));
        medAppealInfoVO.setClaimantId(SysUserUtils.getCurrentPrincipleID());
        return RespDTO.onSuc(medExamineInfoFacade.addAppealInfo(medAppealInfoVO));
    }

}
