Commit 8a0760ed by guojuxing

开票回调函数代码

parent ea6b17e8
......@@ -54,6 +54,12 @@ public class MenuApiServiceImpl implements MenuApiService {
private AppTokenApiService appTokenApiService;
@Override
public ServiceResponse<List<MenuDTO>> listByMenuIdList(List<Integer> menuIdList) {
return ServiceResponse
.success(EntityUtil.changeEntityListNew(MenuDTO.class, menuService.selectByIds(menuIdList)));
}
@Override
public ServiceResponse<List<MenuDTO>> listUserMenu(Integer userId) {
TabSysUser tabSysUser = userService.getUserById(userId);
if (tabSysUser == null) {
......
......@@ -6,7 +6,9 @@ import java.util.List;
import java.util.Map;
import com.gic.auth.constant.MenuTypeEnum;
import com.gic.auth.constant.SignConstants;
import com.gic.auth.web.vo.AppMenuVO;
import com.gic.commons.util.EntityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -41,7 +43,42 @@ public class RoleController {
@RequestMapping("/get-detail")
public RestResponse getDetail(Integer id) {
return ResultControllerUtils.commonResultOne(roleApiService.getById(id), RoleDetailVO.class);
ServiceResponse<RoleDTO> roleResult = roleApiService.getById(id);
if (roleResult.isSuccess()) {
RoleDTO roleDTO = roleResult.getResult();
RoleDetailVO vo = EntityUtil.changeEntityNew(RoleDetailVO.class, roleDTO);
String menuIds = roleDTO.getMenuIds();
String[] menuIdArr = menuIds.split(SignConstants.COMMA);
List<Integer> menuIdList = new ArrayList<>(menuIdArr.length);
for (String menuId : menuIdArr) {
menuIdList.add(Integer.parseInt(menuId));
}
ServiceResponse<List<MenuDTO>> menuListResult = menuApiService.listByMenuIdList(menuIdList);
ServiceResponse<List<MenuDTO>> gicResult = menuApiService.listMenuTreeForRole(MenuProjectConstants.DEFAULT_PROJECT);
Map<Integer, Object> gicMap = new HashMap<>(16);
if (gicResult.isSuccess()) {
List<MenuDTO> gicMenuList = gicResult.getResult();
for (MenuDTO menuDTO : gicMenuList) {
gicMap.put(menuDTO.getMenuId(), 1);
}
}
vo.setGicMap(changeListToSelectTree(MenuLevelConstants.FIRST_LEVEL_PARENT_ID, menuListResult.getResult(), gicMap));
//app已购买应用
ServiceResponse<List<MenuDTO>> appResult = menuApiService.listAppPageOfHasBuy();
Map<Integer, Object> appMap = new HashMap<>(16);
if (gicResult.isSuccess()) {
List<MenuDTO> appMenuList = appResult.getResult();
for (MenuDTO menuDTO : appMenuList) {
appMap.put(menuDTO.getMenuId(), 1);
}
}
vo.setAppMap(changeListToSelectTree(MenuLevelConstants.FIRST_LEVEL_PARENT_ID, menuListResult.getResult(), appMap));
return RestResponse.success(vo);
}
return EnterpriseRestResponse.failure(roleResult);
}
@RequestMapping("/save")
......@@ -138,4 +175,33 @@ public class RoleController {
}
return result;
}
public static List<Map<String, Object>> changeListToSelectTree(int storeGroupId, List<MenuDTO> list, Map<Integer, Object> menuIdMap) {
List<Map<String, Object>> result = new ArrayList<>();
if (list != null) {
for (MenuDTO menuDTO : list) {
if (storeGroupId == menuDTO.getParentId() && menuDTO.getIsShow().intValue() == 1) {
Map<String, Object> data = new HashMap<>(16);
data.put("menuId", menuDTO.getMenuId());
data.put("menuName", menuDTO.getMenuName());
data.put("project", menuDTO.getProject());
data.put("menuType", menuDTO.getMenuType());
if (menuIdMap.containsKey(menuDTO.getMenuId())) {
//如果存在,则说明钩上了
data.put("isSelect", true);
} else {
data.put("isSelect", false);
}
List<Map<String, Object>> children = changeListToTree(menuDTO.getMenuId(), list);
if (children == null || children.size() < 1) {
data.put("children", null);
} else {
data.put("children", children);
}
result.add(data);
}
}
}
return result;
}
}
package com.gic.auth.web.vo;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 角色详情
* @ClassName: RoleDetailVO

......@@ -21,10 +24,9 @@ public class RoleDetailVO implements Serializable{
*/
private String roleName;
/**
* 菜单ID,多个时,用英文逗号隔开
*/
private String menuIds;
List<Map<String, Object>> gicMap;
List<Map<String, Object>> appMap;
public Integer getRoleId() {
......@@ -43,11 +45,19 @@ public class RoleDetailVO implements Serializable{
this.roleName = roleName;
}
public String getMenuIds() {
return menuIds;
public List<Map<String, Object>> getGicMap() {
return gicMap;
}
public void setGicMap(List<Map<String, Object>> gicMap) {
this.gicMap = gicMap;
}
public List<Map<String, Object>> getAppMap() {
return appMap;
}
public void setMenuIds(String menuIds) {
this.menuIds = menuIds;
public void setAppMap(List<Map<String, Object>> appMap) {
this.appMap = appMap;
}
}
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