Browse Source

懒加载接口新增返回所需字段

test
smallchill 5 years ago
parent
commit
606f1a8379
  1. 13
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java
  2. 11
      blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java

13
blade-service/blade-system/src/main/java/org/springblade/system/controller/DeptController.java

@ -29,12 +29,13 @@ import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.node.INode;
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictCache;
import org.springblade.system.entity.Dept;
import org.springblade.system.service.IDeptService;
import org.springblade.system.vo.DeptVO;
import org.springblade.system.wrapper.DeptWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -131,8 +132,14 @@ public class DeptController extends BladeController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入dept")
public R submit(@Valid @RequestBody Dept dept) {
CacheUtil.clear(SYS_CACHE);
return R.status(deptService.submit(dept));
if (deptService.submit(dept)) {
CacheUtil.clear(SYS_CACHE);
// 返回懒加载树更新节点所需字段
Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId())
.set("deptCategoryName", DictCache.getValue("org_category", dept.getDeptCategory()));
return R.data(kv);
}
return R.fail("操作失败");
}
/**

11
blade-service/blade-system/src/main/java/org/springblade/system/controller/MenuController.java

@ -36,7 +36,6 @@ import org.springblade.system.vo.CheckedTreeVO;
import org.springblade.system.vo.GrantTreeVO;
import org.springblade.system.vo.MenuVO;
import org.springblade.system.wrapper.MenuWrapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -45,7 +44,6 @@ import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.MENU_CACHE;
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE;
/**
@ -146,8 +144,13 @@ public class MenuController extends BladeController {
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入menu")
public R submit(@Valid @RequestBody Menu menu) {
CacheUtil.clear(MENU_CACHE);
return R.status(menuService.submit(menu));
if (menuService.submit(menu)) {
CacheUtil.clear(MENU_CACHE);
// 返回懒加载树更新节点所需字段
Kv kv = Kv.create().set("id", String.valueOf(menu.getId()));
return R.data(kv);
}
return R.fail("操作失败");
}

Loading…
Cancel
Save