|
|
package com.yoho.datasync.consumer.handler.listener;
|
|
|
|
|
|
import com.yoho.datasync.consumer.common.EventEnum;
|
|
|
import com.yoho.datasync.consumer.common.ServiceConstant;
|
|
|
import com.yoho.datasync.consumer.handler.helper.AnnotationClassFactory;
|
|
|
import com.yoho.datasync.consumer.handler.mqcomponent.AbstractMqListener;
|
|
|
import com.yoho.datasync.consumer.service.PublicVirtualUserService;
|
|
|
import com.yoho.datasync.core.base.annotation.MqConsumerListerner;
|
|
|
import com.yoho.datasync.core.base.model.yh_grass.GrassVirtualUser;
|
|
|
import com.yoho.datasync.core.base.model.yh_pcms.PublicVirtualUser;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@Component
|
|
|
@MqConsumerListerner(dbName = "yh_grass",tableName = "grass_virtual_user")
|
|
|
public class GrassVirtualUserListener extends AbstractMqListener<GrassVirtualUser> {
|
|
|
|
|
|
@Resource
|
|
|
PublicVirtualUserService publicVirtualUserService;
|
|
|
|
|
|
@Resource
|
|
|
AnnotationClassFactory annotationClassFactory;
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(GrassVirtualUserListener.class);
|
|
|
|
|
|
@Override
|
|
|
protected void deleteData(GrassVirtualUser sourceObject , Object checkResult) throws Exception {
|
|
|
PublicVirtualUser publicVirtualUser = annotationClassFactory.convertTargetObjectFromSource(sourceObject,
|
|
|
PublicVirtualUser.class);
|
|
|
if(publicVirtualUser == null){
|
|
|
logger.error("deleteData failed , publicVirtualUser is null");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
publicVirtualUser.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
|
|
|
publicVirtualUserService.deletePbulicVirtualUser(publicVirtualUser);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void updateData(GrassVirtualUser sourceObject , Object checkResult) throws Exception {
|
|
|
PublicVirtualUser publicVirtualUser = annotationClassFactory.convertTargetObjectFromSource(sourceObject,
|
|
|
PublicVirtualUser.class);
|
|
|
if(publicVirtualUser == null){
|
|
|
logger.error("updateData failed , publicVirtualUser is null");
|
|
|
return;
|
|
|
}
|
|
|
publicVirtualUser.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
|
|
|
publicVirtualUserService.saveOrUpdatePbulicVirtualUser(publicVirtualUser);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
protected EventEnum getEventReportEnum() {
|
|
|
return EventEnum.GRASS_VIRTUAL_USER_UPDATE;
|
|
|
}
|
|
|
} |
...
|
...
|
|