Skip to content

Commit

Permalink
fix-数据字典-因缓存导致的新增数据不能及时展示
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Oct 29, 2024
1 parent 5c600dd commit e350fdb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public class DictCategoryController extends ScaffoldForPlatform implements ITree
.expireAfterWrite(1, TimeUnit.MINUTES)
.build(this::loadCategory);

@Override
protected void afterInit() {
super.afterInit();
String address = dictController.getDataChangeChannel().getAddress();
getEventBus().consumer(address).handler(it -> {
categoryCache.invalidateAll();
});
}

@Override
public String getMainTable() {
return "app_dictcategory";
Expand Down Expand Up @@ -71,9 +80,6 @@ private List<DictTreeNode> loadCategory(String id) {
@GET
@Path("/tree/{id}")
public List<DictTreeNode> tree(@PathParam("id") String id) {
if (getConfig().isTestMode()) {
categoryCache.invalidateAll();
}
return categoryCache.get(id);
}

Expand Down Expand Up @@ -126,7 +132,9 @@ public Integer sort(String id, String prevId, String nextId, String parentId) {
if (parentId == null) {
parentId = dict.get("id_at_app_dictcategory").toString();
}
return dictController.sort(id, prevId, nextId, parentId);
Integer sorted = dictController.sort(id, prevId, nextId, parentId);
categoryCache.invalidate(parentId);
return sorted;
}

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jakarta.enterprise.context.ApplicationScoped;
import net.ximatai.muyun.ability.IChildAbility;
import net.ximatai.muyun.ability.IDataBroadcastAbility;
import net.ximatai.muyun.ability.IReferableAbility;
import net.ximatai.muyun.ability.ITreeAbility;
import net.ximatai.muyun.ability.curd.std.IDataCheckAbility;
Expand All @@ -23,7 +24,7 @@

//@Path(BASE_PATH + "/dict")
@ApplicationScoped
public class DictController extends ScaffoldForPlatform implements ITreeAbility, IChildAbility, IReferableAbility, IDataCheckAbility, IQueryAbility {
public class DictController extends ScaffoldForPlatform implements ITreeAbility, IChildAbility, IReferableAbility, IDataCheckAbility, IQueryAbility, IDataBroadcastAbility {

@Override
public String getMainTable() {
Expand Down

0 comments on commit e350fdb

Please sign in to comment.