package com.cusc.nirvana.user.rnr.fp.controller;

import com.alibaba.fastjson.JSONObject;
import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.fp.dto.AgainUploadDTO;
import com.cusc.nirvana.user.rnr.fp.dto.T1CallbackResultDTO;
import com.cusc.nirvana.user.rnr.fp.dto.T1CommonResponseDTO;
import com.cusc.nirvana.user.rnr.fp.service.IT1UploadService;
import com.cusc.nirvana.user.rnr.mg.dto.MgCardNoticeDTO;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * T1数据上报
 */
@RestController
@RequestMapping("/t1/data")
@Slf4j
public class T1DataUploadController {

    @Resource
    private IT1UploadService t1UploadService;

    /**
     * Description: T1上传用户信息和文件信息
     * <br />
     * CreateDate 2022-06-07 20:08:03
     *
     * @author yuyi
     **/
    @PostMapping("/uploadUserInfoAndFile")
    public Response uploadUserInfoAndFile(@RequestBody MgCardNoticeDTO cardNoticeDTO) {
        log.info("uploadUserInfoAndFile+++++++++++++++++入参{}", JSONObject.toJSONString(cardNoticeDTO));
        return t1UploadService.uploadUserInfoAndFile(cardNoticeDTO);
    }

    @PostMapping("/test")
    public Response test(@RequestBody MgCardNoticeDTO cardNoticeDTO) {
        log.info("这是用来测试得{}", JSONObject.toJSONString(cardNoticeDTO));
        return Response.createSuccess();
    }

    /**
     * 报竣
     * @param t1CallbackResultDTO
     * @return
     */
    @PostMapping("/callbackResult")
    public T1CommonResponseDTO t1CallbackResult(@RequestBody @Validated T1CallbackResultDTO t1CallbackResultDTO) {
        log.info("t1CallbackResult{}", JSONObject.toJSONString(t1CallbackResultDTO));
        return t1UploadService.t1CallbackResult(t1CallbackResultDTO);
    }

    /**
     * T1重试
     * @param againUploadDTO
     * @return
     */
    @PostMapping("/againUploadUserInfoAndFile")
    public Response againUploadUserInfoAndFile(@RequestBody AgainUploadDTO againUploadDTO) {
        log.info("againUploadUserInfoAndFile{}", JSONObject.toJSONString(againUploadDTO));
        return t1UploadService.againUploadUserInfoAndFile(againUploadDTO);
    }

}
