| | |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.plugin.*; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.constant.EsTableConstant; |
| | | import org.springblade.common.utils.SQLParseUtils; |
| | | import org.springblade.es.service.ElasticsearchDocumentService; |
| | |
| | | import org.springblade.modules.article.entity.Article; |
| | | import org.springblade.modules.house.entity.HouseEntity; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.vo.HouseVO; |
| | | import org.springblade.modules.house.vo.HouseholdVO; |
| | | import org.springblade.modules.place.entity.PlaceEntity; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Properties; |
| | | |
| | | @Component |
| | |
| | | }) |
| | | public class DataSyncInterceptor implements Interceptor { |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(DataSyncInterceptor.class); |
| | | @Lazy |
| | | @Autowired |
| | | private ElasticsearchDocumentService elasticsearchDocumentService; |
| | |
| | | if (sqlType.equals("UPDATE")) { |
| | | //update 方法需要特殊处理 |
| | | if (tableName.equals("jczz_article")) { |
| | | Article entity = (Article) ((MapperMethod.ParamMap) parameter).get("param1"); |
| | | if (entity != null && entity.getId() != null) { |
| | | esParam.setTableId(entity.getId().toString()); |
| | | elasticsearchDocumentService.update(esParam, entity, EsTableConstant.articleList); |
| | | try { |
| | | Article entity = (Article) ((MapperMethod.ParamMap) parameter).get("param1"); |
| | | if (entity != null && entity.getId() != null) { |
| | | esParam.setTableId(entity.getId().toString()); |
| | | elasticsearchDocumentService.update(esParam, entity, EsTableConstant.articleList); |
| | | } |
| | | } catch (Exception e) { |
| | | logger.error("jczz_article 更新失败!", e); |
| | | } |
| | | } |
| | | if (tableName.equals("jczz_place")) { |