Commit 2a223ab3 authored by 赵啸非's avatar 赵啸非

添加菜单资源配置

parent c5a16c5f
...@@ -147,7 +147,7 @@ public class MenuController extends BaseCRUDJsonBodyMappingController<MenuServic ...@@ -147,7 +147,7 @@ public class MenuController extends BaseCRUDJsonBodyMappingController<MenuServic
String busiDesc = "查询" + this.getModuleDesc() + "子节点"; String busiDesc = "查询" + this.getModuleDesc() + "子节点";
try { try {
List<MenuTreeSelect> treeList = this.service.getListByParentId(parentId, getContext()); List<MenuTreeSelect> treeList = this.service.getListByParentId(parentId, getContext());
model.put(RESULT_KEY, treeList); model.put(KEY_RESULT_DATA, treeList);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_DATA, model); ret.put(KEY_RESULT_DATA, model);
recordSysLog(request, busiDesc + "【成功】"); recordSysLog(request, busiDesc + "【成功】");
......
...@@ -19,5 +19,9 @@ public class ResourceVo extends BaseEntityLong { ...@@ -19,5 +19,9 @@ public class ResourceVo extends BaseEntityLong {
/** 菜单ID,主键,自增长列表 */ /** 菜单ID,主键,自增长列表 */
private List <Long> idList; private List <Long> idList;
private Integer checked=0;
private Long roleId;
} }
\ No newline at end of file
...@@ -10,20 +10,27 @@ import com.mortals.framework.exception.AppException; ...@@ -10,20 +10,27 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.menu.model.MenuTreeSelect;
import com.mortals.xhx.base.system.resource.model.ResourceEntity; import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.model.ResourceQuery;
import com.mortals.xhx.base.system.resource.service.ResourceService; import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import com.mortals.xhx.common.code.AuthType; import com.mortals.xhx.common.code.AuthType;
import com.mortals.xhx.common.code.SourceType; import com.mortals.xhx.common.code.SourceType;
import com.mortals.xhx.common.code.YesNoEnum;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping; import org.checkerframework.checker.units.qual.A;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.Map;
import static com.mortals.framework.ap.SysConstains.RESULT_KEY;
/** /**
* 资源信息 * 资源信息
...@@ -36,6 +43,9 @@ import java.util.Map; ...@@ -36,6 +43,9 @@ import java.util.Map;
@RequestMapping("resource") @RequestMapping("resource")
public class ResourceController extends BaseCRUDJsonBodyMappingController<ResourceService, ResourceEntity, Long> { public class ResourceController extends BaseCRUDJsonBodyMappingController<ResourceService, ResourceEntity, Long> {
@Autowired
private RoleAuthService roleAuthService;
public ResourceController() { public ResourceController() {
super.setModuleDesc("资源信息"); super.setModuleDesc("资源信息");
} }
...@@ -79,4 +89,48 @@ public class ResourceController extends BaseCRUDJsonBodyMappingController<Resour ...@@ -79,4 +89,48 @@ public class ResourceController extends BaseCRUDJsonBodyMappingController<Resour
return rest; return rest;
} }
/**
* 分组显示
*/
@ApiOperation(value = "分组列表")
@PostMapping(value = "group")
@UnAuth
public String group(@RequestBody ResourceQuery query) {
JSONObject ret = new JSONObject();
Map<String, Object> model = new HashMap<>();
String busiDesc = "查询" + this.getModuleDesc() + "子节点";
try {
if (!ObjectUtils.isEmpty(query.getRoleId())) {
List<RoleAuthEntity> roleAuthEntities = roleAuthService.find(new RoleAuthQuery().roleId(query.getRoleId()));
Set<Long> collect = roleAuthEntities.stream()
.filter(f -> f.getMenuId() == null)
.map(m -> m.getResourceId())
.collect(Collectors.toSet());
Map<String, List<ResourceEntity>> group = this.service.find(new ResourceQuery(), getContext()).stream()
.map(m -> {
if (collect.contains(m.getId())) {
m.setChecked(YesNoEnum.YES.getValue());
}
return m;
})
.collect(Collectors.groupingBy(x -> x.getGroupName()));
model.put(KEY_RESULT_DATA, group);
}else{
Map<String, List<ResourceEntity>> group = this.service.find(new ResourceQuery(), getContext()).stream()
.collect(Collectors.groupingBy(x -> x.getGroupName()));
model.put(KEY_RESULT_DATA, group);
}
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_DATA, model);
recordSysLog(request, busiDesc + "【成功】");
} catch (Exception e) {
log.error("分组列表错误", e);
this.doException(request, busiDesc, model, e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
return ret.toJSONString();
}
} }
\ No newline at end of file
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