package com.brilliance.isc.common.api.oit.controller;

import com.brilliance.isc.common.api.oit.OitApiService;
import com.brilliance.isc.common.api.oit.vo.OitRequest;
import com.brilliance.isc.common.api.oit.vo.OitResponse;
import com.brilliance.isc.common.converter.DtoMapper;
import com.brilliance.isc.common.oit.vo.NoticeVo;
import com.brilliance.isc.vo.ResponseSet;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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;

@RestController
@RequestMapping("/oit")
public class OitController {

    @Autowired(required = false)
    private OitApiService oitApiService;

    @PostMapping("/oitcheck")
    @ApiOperation("oit消息提示")
    public ResponseSet<OitResponse> oitCheck(@RequestBody OitRequest oitRequest) {
        try {
            NoticeVo noticeVo=new NoticeVo();
            DtoMapper.INSTANCE.updateVoToBo(oitRequest,noticeVo);
            oitApiService.registOit(noticeVo);
            OitResponse oitResponse=new OitResponse(noticeVo);
            return ResponseSet.simpleSuccess(oitResponse);
        } catch (Exception e) {
            throw e;
        }
    }
}
