Authored by 胡古飞

销售类目有变更,更新到缓存中

... ... @@ -29,7 +29,7 @@ public class SalesCategoryMqListener extends AbstractMqListener implements Chann
private IYohoIndexService indexService;
@Autowired
private SalesCategoryLogicService salesCategoryLogicService;
@Override
public void onMessage(Message message, Channel channel) throws Exception {
try {
... ... @@ -61,13 +61,15 @@ public class SalesCategoryMqListener extends AbstractMqListener implements Chann
return;
}
salesCategoryLogicService.saveOrUpdate(salesCategory);
salesCategoryLogicService.doReload();
}
public void deleteData(final String id) throws Exception {
if (StringUtils.isBlank(id)) {
return;
}
salesCategoryLogicService.deleteById(Integer.valueOf(id));
salesCategoryLogicService.doReload();
}
}
... ...
... ... @@ -23,7 +23,7 @@ public class SalesCategoryLogicService {
// 一级销售类目和物理小分类之间的关系
private Map<String, Set<Integer>> physicalChannelToSortIds;
public void init() {
public void doReload() {
Map<String, Set<Integer>> temps = new ConcurrentHashMap<String, Set<Integer>>();
List<SalesCategory> allSalesCategory = salesCategoryService.selectAll();
for (SalesCategory salesCategory : allSalesCategory) {
... ... @@ -81,7 +81,7 @@ public class SalesCategoryLogicService {
return new ArrayList<String>();
}
if (physicalChannelToSortIds == null || physicalChannelToSortIds.isEmpty()) {
init();
doReload();
}
List<String> channels = new ArrayList<String>();
for (Map.Entry<String, Set<Integer>> entry : physicalChannelToSortIds.entrySet()) {
... ...