package com.xxl.job.executor.service.jobhandler;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import com.xxl.job.core.util.ConstantVar;
import com.xxl.job.core.util.HttpClientUtil;

@JobHandler(value = "SendReadAlarmJobHandler")
@Component
public class SendReadAlarmJobHandler extends IJobHandler {

	@Override
	public ReturnT<String> execute(String param) throws Exception {

		XxlJobLogger.log(" start -推送阅读提醒消息接口调用启动;time:" + new Date());

		String responseMessage = HttpClientUtil.postTaskJob(ConstantVar.DEVELOP_URL, "taskJob_sendReadAlarm");
		XxlJobLogger.log(" responseMessage: " + responseMessage);

		JSONObject retJson = JSONObject.parseObject(responseMessage).getJSONObject("ret");
		if (retJson == null || retJson.getString("code") != "200") {
			return FAIL;
		}

		XxlJobLogger.log(" end - 推送阅读提醒消息接口调用结束;time:" + new Date());
		return SUCCESS;
	}

}