|
|
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.PublicLabelGroupService;
|
|
|
import com.yoho.datasync.core.base.annotation.MqConsumerListerner;
|
|
|
import com.yoho.datasync.core.base.model.yh_grass.GrassLabelGroup;
|
|
|
import com.yoho.datasync.core.base.model.yh_pcms.PublicLabelGroup;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@Component
|
|
|
@MqConsumerListerner(dbName = "yh_grass",tableName = "grass_lable_group")
|
|
|
public class GrassLableGroupListener extends AbstractMqListener<GrassLabelGroup> {
|
|
|
|
|
|
@Resource
|
|
|
PublicLabelGroupService publicLabelGroupService;
|
|
|
|
|
|
@Resource
|
|
|
AnnotationClassFactory annotationClassFactory;
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(GrassLableGroupListener.class);
|
|
|
|
|
|
@Override
|
|
|
protected void deleteData(GrassLabelGroup sourceObject , Object checkResult) throws Exception {
|
|
|
PublicLabelGroup publicLabelGroup = annotationClassFactory.convertTargetObjectFromSource(sourceObject,
|
|
|
PublicLabelGroup.class);
|
|
|
if(publicLabelGroup == null){
|
|
|
logger.error("deleteData failed , publicLabelGroup is null");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
publicLabelGroup.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
|
|
|
publicLabelGroupService.deletePublicLabelGroup(publicLabelGroup);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void updateData(GrassLabelGroup sourceObject , Object checkResult) throws Exception {
|
|
|
PublicLabelGroup publicLabelGroup = annotationClassFactory.convertTargetObjectFromSource(sourceObject,PublicLabelGroup.class);
|
|
|
if(publicLabelGroup == null){
|
|
|
logger.error("updateData failed , publicLabelGroup is null");
|
|
|
return;
|
|
|
}
|
|
|
if(sourceObject.getStatus() != null){
|
|
|
switch (sourceObject.getStatus()){
|
|
|
case ServiceConstant.Grass_Label_Group.CLOSE_STATUS:
|
|
|
publicLabelGroup.setStatus(ServiceConstant.Public_Label_Group.CLOSE_STATUS);
|
|
|
break;
|
|
|
case ServiceConstant.Grass_Label_Group.OPEN_STATUS:
|
|
|
publicLabelGroup.setStatus(ServiceConstant.Public_Label_Group.OPEN_STATUS);
|
|
|
}
|
|
|
}
|
|
|
publicLabelGroup.setSrcChannel(ServiceConstant.SRCCHANNEL_TYPE.YOHO_GRASS);
|
|
|
publicLabelGroupService.saveOrUpdatePublicUserAttention(publicLabelGroup);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
protected EventEnum getEventReportEnum() {
|
|
|
return EventEnum.GRASSLABELGROUPLISTENER_UPDATEDATA;
|
|
|
}
|
|
|
} |
...
|
...
|
|