package com.lantone.daqe.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lantone.common.api.CommonResult;
import com.lantone.common.vo.BlockLossTypeGatherVO;
import com.lantone.common.vo.DataCompareVO;
import com.lantone.common.vo.DataRepariVO;
import com.lantone.daqe.dto.BlockLossTypeGatherDTO;
import com.lantone.daqe.dto.GetBlockLossPageDTO;
import com.lantone.daqe.dto.UpBlockLossByIdVO;
import com.lantone.daqe.facade.BlockLossManagementFacade;
import com.lantone.daqe.vo.GetBlockLossPageVO;
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;

/**
 * @Description: 病历数据丢失明细API
 * @author: songxl
 * @time: 2022/3/4 10:39
 */
@RestController
@Api(value = "病历数据丢失明细API", tags = { "病历数据丢失明细API" })
@RequestMapping("/blockLossManage")
public class BlockLossManagementController {

    @Autowired
    private BlockLossManagementFacade blockLossManagementFacade;

    @ApiOperation(value = "获取病历数据丢失明细分页列表 [by:songxl]", notes = "获取病历数据丢失明细分页列表")
    @PostMapping("/getBlockLossPage")
    public CommonResult<IPage<GetBlockLossPageDTO>> getBlockLossPage(@RequestBody GetBlockLossPageVO getBlockLossPageVO) {
        return CommonResult.success(blockLossManagementFacade.getBlockLossPage(getBlockLossPageVO));
    }

    @ApiOperation(value = "通过id修改病历数据块丢失明细 [by:songxl]", notes = "通过id修改病历数据块丢失明细")
    @PostMapping("/upBlockLossById")
    @Transactional
    public CommonResult<Boolean> upBlockLossById(@RequestBody @Valid UpBlockLossByIdVO upBlockLossByIdVO) {
        return CommonResult.success(blockLossManagementFacade.upBlockLossById(upBlockLossByIdVO));
    }

    @ApiOperation(value = "数据对比 [by:songxl]", notes = "数据对比")
    @PostMapping("/dataCompare")
    @Transactional
    public CommonResult<Boolean> dataCompare(@RequestBody @Valid DataCompareVO dataCompareVO) {
        return CommonResult.success(blockLossManagementFacade.dataCompare(dataCompareVO));
    }


    @ApiOperation(value = "丢失量分类汇总 [by:songxl]", notes = "丢失量分类汇总")
    @PostMapping("/blockLossTypeGather")
    public CommonResult<BlockLossTypeGatherDTO> blockLossTypeGather(@RequestBody @Valid BlockLossTypeGatherVO blockLossTypeGatherVO) {
        return CommonResult.success(blockLossManagementFacade.blockLossTypeGather(blockLossTypeGatherVO));
    }


    @ApiOperation(value = "数据补录 [by:songxl]", notes = "数据补录")
    @PostMapping("/dataRepari")
    @Transactional
    public CommonResult<Boolean> dataRepari(@RequestBody @Valid DataRepariVO dataRepariVO) {
        return CommonResult.success(blockLossManagementFacade.dataRepari(dataRepariVO));
    }
}