com.zyy.common.service.impl.RabbitHandle Maven / Gradle / Ivy
package com.zyy.common.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zyy.common.model.RabbitModel;
import com.zyy.common.model.TemplateModel;
import com.zyy.common.producer.BaseSendProducer;
import com.zyy.common.service.HandleService;
import com.zyy.common.util.RegUtil;
import com.zyy.common.util.TokenModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Data
@AllArgsConstructor
public class RabbitHandle implements HandleService {
private BaseSendProducer baseSendProducer;
private ObjectMapper objectMapper;
/**
* 处理handle
*
* @param model 处理模板
* @param proceed 数据对象
* @param tokenModel 用户对象
*/
@Override
public void handleRun(TemplateModel model, Object proceed, TokenModel tokenModel) {
try {
String template = model.getContext();
String parse = RegUtil.parse("\\{\\{(.+?)\\}\\}", template, proceed, tokenModel);
baseSendProducer.producerSocketSend(objectMapper.readValue(parse, RabbitModel.class));
} catch (JsonProcessingException e) {
log.info("", e);
}
}
}