package com.persagy.calendar.controller;

import java.util.Map;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.persagy.calendar.utils.NTPClientUtil;
import com.persagy.common.enums.ResponseCode;
import com.persagy.common.utils.ResponseResult;
import com.persagy.common.utils.ResponseUtil;
import com.persagy.common.utils.StringUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @version 
 * @description 
 * @company persagy
 * @author zhangqiankun
 * @since 2020年10月3日:	下午2:32:36
 */
@Api(tags = "NTP服务时间")
@RestController
@RequestMapping(value = "/v2.0/ntp", method = RequestMethod.POST)
public class WorkTimeEngineController {
	
	/**
     * 获取NTP服务时间
     */
    @ApiOperation(value = "获取NTP服务时间")
    @RequestMapping(value = "getNTPServerTime")
    public ResponseResult queryWorkCalendarDateList(@RequestBody @Validated Map<String, String> map) {
    	String ntpServerTime = NTPClientUtil.getNTPServerTime();
		if (StringUtil.isNotBlank(ntpServerTime)) {
			return ResponseUtil.successResult(null, ntpServerTime);
		}
		return ResponseUtil.errorResult(ResponseCode.Z9999.getCode(), ResponseCode.Z9999.getDesc());
	}
	
}
