Commit e9e0d550 by 陶光胜

init

parent 0245cc52
package com.gic.message.service.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.constant.AuthModeEnum;
import com.gic.auth.dto.UnionEnterpriseDTO;
import com.gic.auth.dto.UnionEnterpriseResourceDTO;
import com.gic.auth.service.UnionEnterpriseApiService;
import com.gic.binlog.base.entity.GicField;
import com.gic.binlog.base.entity.GicRecord;
......@@ -9,9 +12,11 @@ import com.gic.binlog.base.entity.enums.GicRecordType;
import com.gic.message.service.MessageHandler;
import com.gic.message.utils.ListToMapUtil;
import com.gic.store.constant.StoreOwnTypeEnum;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.dto.StoreWidgetDTO;
import com.gic.store.service.StoreApiService;
import com.gic.store.service.StoreAuthorizationApiService;
import com.gic.store.service.StoreWidgetApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
......@@ -31,28 +36,44 @@ public class StoreMessageHandler implements MessageHandler {
private StoreWidgetApiService storeWidgetApiService;
@Autowired
private UnionEnterpriseApiService unionEnterpriseApiService;
@Autowired
private StoreAuthorizationApiService storeAuthorizationApiService;
@Override
public void handler(ConsumerRecord<String, GicRecord> consumerRecord){
GicRecord value = consumerRecord.value();
Map<String, GicField> fieldMap = ListToMapUtil.listToMap(consumerRecord);
Integer enterpriseId = 0, storeId = 0;
Integer enterpriseId = 0, storeId = 0, storeInfoId;
if(GicRecordType.INSERT.value() == value.getRecordType().value()){
enterpriseId = Integer.valueOf(fieldMap.get("enterprise_id").getValue());
storeId = Integer.valueOf(fieldMap.get("store_id").getValue());
storeInfoId = Integer.valueOf(fieldMap.get("store_info_id").getValue());
this.storeIndexRefreshHandler.refreshStoreIndex(enterpriseId, storeId);
Integer ownType = Integer.valueOf(fieldMap.get("own_type").getValue());
if(ownType == StoreOwnTypeEnum.OWNER.getCode()){
ServiceResponse<List<Long>> resourceResponse = this.unionEnterpriseApiService.listStoreResourceByEnterpriseId(enterpriseId);
ServiceResponse<List<UnionEnterpriseResourceDTO>> resourceResponse = this.unionEnterpriseApiService.listStoreResourceByEnterpriseId(enterpriseId);
if(CollectionUtils.isNotEmpty(resourceResponse.getResult())){
for(Long resourceId : resourceResponse.getResult()){
ServiceResponse<StoreWidgetDTO> storeWidget = this.storeWidgetApiService.getStoreWidget(resourceId.intValue());
for(UnionEnterpriseResourceDTO dto : resourceResponse.getResult()){
ServiceResponse<StoreWidgetDTO> storeWidget = this.storeWidgetApiService.getStoreWidget(dto.getResource().intValue());
if(storeWidget.isSuccess()){
StoreWidgetDTO storeWidgetDTO = storeWidget.getResult();
if(storeWidgetDTO != null){
if(AuthModeEnum.YES.getCode() == storeWidgetDTO.getAuthMode()){
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setStoreInfoIds("");
storeSearchDTO.setStoreIds(String.valueOf(storeId));
storeSearchDTO.setSearchJson(storeWidgetDTO.getSearchParam());
storeSearchDTO.setEnterpriseId(enterpriseId);
ServiceResponse<Page<StoreDTO>> response = this.storeApiService.listStore(storeSearchDTO, 1, 1);
if(response.isSuccess()){
if(CollectionUtils.isNotEmpty(response.getResult().getResult())){
StoreDTO storeDTO = new StoreDTO();
storeDTO.setStoreInfoId(storeInfoId);
storeDTO.setEnterpriseId(enterpriseId);
storeDTO.setFromEnterpriseId(dto.getUnionEnterpriseId());
this.storeAuthorizationApiService.saveStore(storeDTO);
//this.storeIndexRefreshHandler.refreshStoreIndex(dto.getUnionEnterpriseId(), storeId);
}
}
}
}
}
......
......@@ -22,4 +22,5 @@
<dubbo:reference interface="com.gic.store.service.StoreApiService" id="storeApiService" timeout="6000" />
<dubbo:reference interface="com.gic.auth.service.UnionEnterpriseApiService" id="unionEnterpriseApiService" timeout="6000" />
<dubbo:reference interface="com.gic.store.service.StoreWidgetApiService" id="storeWidgetApiService" timeout="6000" />
<dubbo:reference interface="com.gic.store.service.StoreAuthorizationApiService" id="storeAuthorizationApiService" timeout="6000" />
</beans>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment