package cn.axzo.msg.center.notices.client.task.process;

import cn.axzo.msg.center.notices.client.task.LoggerJobHandler;
import cn.azxo.framework.common.model.JobPageRequest;
import cn.azxo.framework.common.utils.LogUtil;
import com.alibaba.fastjson.JSON;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * BatchMessageRequest 短信拆分批次
 *
 * @author szg
 * @see BatchMessageRequestSplitJobHandler
 * @since 2021-08-11 15:44
 */
@Slf4j
@Component
public class BatchMessageRequestSplitJobHandler extends LoggerJobHandler {

    @Override
    @XxlJob(value = "batchMessageRequestSplitHandle")
    public ReturnT<String> execute(String param) {
        return jobLoggerTemplate.execute(() -> {
            log.info("BatchMessageRequestSplitJobHandler.execute task Start ......");
            try {
                JobPageRequest request = jobParamResolver.resolver(param);
                log.info("BatchMessageRequestSplitJobHandler.execute task request is {}", JSON.toJSONString(request));
                taskService.batchMessageRequestSplitHandle(request);
            } catch (Exception e) {
                LogUtil.error("BatchMessageRequestSplitJobHandler.execute is error", e);
                return ReturnT.FAIL;
            }
            log.info("BatchMessageRequestSplitJobHandler.execute task End ......");
            return ReturnT.SUCCESS;
        });
    }

}
