package com.diagbot.web;

import com.diagbot.annotation.SysLogger;
import com.diagbot.dto.RespDTO;
import com.diagbot.dto.StrAdmissionNoteDTO;
import com.diagbot.facade.DataEditFacade;
import com.diagbot.vo.DataEditVO;
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 wangsy
 * @since 2020-04-27
 */
@RestController
@RequestMapping("/qc/dataEdit")
@SuppressWarnings("unchecked")
@Api(value = "数据编辑API", tags = {"数据编辑API"})
public class DataEditController {

    @Autowired
    DataEditFacade dateEditFacade;

    @ApiOperation(value = "获取入院记录结构化json数据")
    @PostMapping("/getDataEdit")
    @SysLogger("getDataEdit")
    public RespDTO<StrAdmissionNoteDTO>getDataEdit() {
        return RespDTO.onSuc(dateEditFacade.dataSearch());
    }

    @ApiOperation(value = "更新数据", notes = "recId: id\n" +
            "wholeData: json字符串")
    @PostMapping("/saveDataEdit")
    @SysLogger("saveDataEdit")
    @Transactional
    public RespDTO<Boolean> saveDataEdit(@RequestBody @Valid DataEditVO dataEditVO) {
        Boolean data = dateEditFacade.saveDataEditFacade(dataEditVO);
        return RespDTO.onSuc(data);
    }


}
