Commit 1b0dbadc by 徐高华

好办小程序权限

parent 2de8f46b
......@@ -258,15 +258,9 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
Long superRoleId = superRoleBO.getRoleId() ;
List<String> superMenuCodeList = this.listRoleMenuCode(allMenuList,wxEnterpriseId, superRoleId);
// 查询gic配置的权限
if(StringUtils.isNotBlank(enterpriseId) && !"-1".equals(enterpriseId)) {
EnterpriseSuperAdminRightMenuQDTO qdto = new EnterpriseSuperAdminRightMenuQDTO() ;
qdto.setEnterpriseId(enterpriseId);
qdto.setNamespace("haoban-wxa");
List<RightMenuDTO> list = this.rightService.listSuperAdminRightMenu(qdto) ;
if(CollectionUtils.isNotEmpty(list)) {
List<String> subGicList = list.stream().map(o->o.getMenuCode()).collect(Collectors.toList());
superMenuCodeList.addAll(subGicList) ;
}
List<String> gicBuyCodes = this.haobanMenuService.getGicBuyCodes(enterpriseId) ;
if(CollectionUtils.isNotEmpty(gicBuyCodes)) {
superMenuCodeList.addAll(gicBuyCodes) ;
}
logger.info("超管的权限={}",superMenuCodeList);
// 如果查询的后台的子管理员权限
......@@ -280,7 +274,7 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
Long subRoleId = subRoleBO.getRoleId() ;
subMenuCodes = this.listRoleMenuCode(allMenuList,wxEnterpriseId,subRoleId) ;
}
HaobanRoleBO retBO = new HaobanRoleBO();
HaobanRoleBO retBO = null ;
if(systemFlag==0) {
retBO = superRoleBO ;
retBO.setMenuCodes(superMenuCodeList);
......
package com.gic.haoban.manage.service.service.role;
import com.gic.clerk.api.dto.right.RightMenuDTO;
import com.gic.haoban.manage.service.entity.role.TabHaobanMenu;
import com.gic.haoban.manage.service.pojo.bo.role.HaobanMenuBO;
......@@ -65,6 +66,9 @@ public interface HaobanMenuService {
*/
List<HaobanMenuBO> getHaobanMenuTreeList(String wxEnterpriseId, String enterpriseId, Integer clerkType);
public List<RightMenuDTO> getGicBuyMenus(String enterpriseId) ;
public List<String> getGicBuyCodes(String enterpriseId) ;
/**
* 得到haoban菜单列表
......
......@@ -21,6 +21,7 @@ import com.gic.haoban.manage.service.entity.role.TabHaobanRoleMenu;
import com.gic.haoban.manage.service.pojo.bo.role.HaobanMenuBO;
import com.gic.haoban.manage.service.service.MemberQueryService;
import com.gic.haoban.manage.service.service.role.HaobanMenuService;
import com.gic.haoban.manage.service.util.Constant;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -116,27 +117,45 @@ public class HaobanMenuServiceImpl implements HaobanMenuService {
}
@Override
public List<RightMenuDTO> getGicBuyMenus(String enterpriseId) {
if(StringUtils.isBlank(enterpriseId) || "-1".equals(enterpriseId)) {
return null ;
}
// 查询gic购买的好办小程序权限
EnterpriseSuperAdminRightMenuQDTO qdto = new EnterpriseSuperAdminRightMenuQDTO() ;
qdto.setEnterpriseId(enterpriseId);
qdto.setNamespace(Constant.hb_wxa_namespace);
List<RightMenuDTO> list = this.rightService.listSuperAdminRightMenu(qdto) ;
logger.info("查询gic购买的好办小程序权限={}",enterpriseId,JSONObject.toJSONString(list));
return list ;
}
@Override
public List<String> getGicBuyCodes(String enterpriseId) {
List<RightMenuDTO> list = this.getGicBuyMenus(enterpriseId) ;
if(CollectionUtils.isNotEmpty(list)) {
return list.stream().map(o->o.getMenuCode()).collect(Collectors.toList());
}
return null ;
}
@Override
public List<HaobanMenuBO> getHaobanMenuTreeList(String wxEnterpriseId, String enterpriseId ,Integer clerkType) {
List<TabHaobanMenu> pidMenuList = tabHaobanMenuMapper.getHaobanPidMenuList(wxEnterpriseId, clerkType, 0);
List<TabHaobanMenu> notPidMenuList = tabHaobanMenuMapper.getHaobanNotPidMenuList(wxEnterpriseId, clerkType, 0);
List<HaobanMenuBO> pidMenuBOList = EntityUtil.changeEntityListNew(HaobanMenuBO.class, pidMenuList);
List<HaobanMenuBO> notPidMenuBOList = EntityUtil.changeEntityListNew(HaobanMenuBO.class, notPidMenuList);
// 查询gic默认带的
// this.rightService.listSuperAdminRightMenu()
EnterpriseSuperAdminRightMenuQDTO qdto = new EnterpriseSuperAdminRightMenuQDTO() ;
qdto.setEnterpriseId(enterpriseId);
qdto.setNamespace("haoban-wxa");
List<RightMenuDTO> list = this.rightService.listSuperAdminRightMenu(qdto) ;
if(CollectionUtils.isNotEmpty(list)) {
List<String> gicMenulist = this.getGicBuyCodes(enterpriseId) ;
if(CollectionUtils.isNotEmpty(gicMenulist)) {
List<HaobanMenuBO> allMenuList = this.getAllMenuList();
Map<String,HaobanMenuBO> map = allMenuList.stream().collect(Collectors.toMap(HaobanMenuBO::getMenuCode,o->o,(k1,k2)->k1)) ;
for(RightMenuDTO gicMenu : list) {
String menuCode = gicMenu.getMenuCode() ;
if(null != map.get(menuCode)) {
if (menuCode.equals(map.get(menuCode).getParentCode())) {
notPidMenuBOList.add(map.get(menuCode)) ;
for(String menuCode : gicMenulist) {
HaobanMenuBO bo = map.get(menuCode) ;
if(null != bo) {
if (menuCode.equals(bo.getParentCode())) {
notPidMenuBOList.add(bo) ;
}else {
pidMenuBOList.add(map.get(menuCode)) ;
pidMenuBOList.add(bo) ;
}
}
}
......@@ -227,50 +246,51 @@ public class HaobanMenuServiceImpl implements HaobanMenuService {
logger.info("取消不处理");
return ;
}
List<TabHaobanWxEnterpriseRelated> wxEnterpriseList = this.wxEnterpriseRelatedMapper.listByEnterpriseId(enterpriseId) ;
if(CollectionUtils.isEmpty(wxEnterpriseList)) {
logger.info("无好办={}",enterpriseId);
return ;
}
MenuListQDTO qdto = new MenuListQDTO() ;
qdto.setNamespace("haoban-wxa");
qdto.setNamespace(Constant.hb_wxa_namespace);
qdto.setServiceCode(serviceCode);
qdto.setPackageCode(packageCode);
ServiceResponse<List<MenuDTO>> resp = this.menuApiService.listMenu(qdto) ;
logger.info("查询gic权限={},{}",JSONObject.toJSONString(qdto),JSONObject.toJSONString(resp));
if(!resp.isSuccess()) {
if(!resp.isSuccess() || CollectionUtils.isEmpty(resp.getResult())) {
logger.info("无相关菜单,不处理");
return;
}
List<TabHaobanWxEnterpriseRelated> wxEnterpriseList = this.wxEnterpriseRelatedMapper.listByEnterpriseId(enterpriseId) ;
if(CollectionUtils.isEmpty(wxEnterpriseList)) {
logger.info("未关联企微={}",enterpriseId);
return ;
}
logger.info("gic关联的企微={}", JSONObject.toJSONString(wxEnterpriseList));
List<MenuDTO> menuDTOList = resp.getResult() ;
if(CollectionUtils.isEmpty(menuDTOList)) {
logger.info("无相关菜单");
return ;
}
for(MenuDTO gicMenu : menuDTOList) {
// 授权方式,是否自动授权给子管理员 0,不做处理 1:自动授权子管理员
Integer authType = gicMenu.getAuthType() ;
String gicMenuCode = gicMenu.getMenuCode();
String haobanRoles = gicMenu.getHaobanRoles() ;
if(null == authType || authType == 0) {
logger.info("authType=0 {}",gicMenuCode);
continue;
}
List<String> menuCodeList = Arrays.asList(gicMenuCode) ;
String haobanRoles = gicMenu.getHaobanRoles() ;
if(StringUtils.isBlank(haobanRoles)) {
logger.info("haobanRoles null {}",gicMenuCode);
continue;
}
List<String> menuCodeList = Arrays.asList(gicMenuCode) ;
String[] arr = haobanRoles.split(",") ;
List<Integer> addRoleTypeList = Arrays.stream(arr).map(o->Integer.valueOf(o)).collect(Collectors.toList());
List<Integer> addRoleTypeList = Arrays.stream(arr).filter(o->StringUtils.isNotBlank(o)).map(o->Integer.valueOf(o)).collect(Collectors.toList());
if(CollectionUtils.isEmpty(addRoleTypeList)) {
logger.info("haobanRoles null {} , {}",gicMenuCode , haobanRoles);
continue;
}
Date now = new Date() ;
for(int i=0;i<wxEnterpriseList.size();i++) {
TabHaobanWxEnterpriseRelated item = wxEnterpriseList.get(i) ;
String wxEnterpriseId = item.getWxEnterpriseId() ;
List<TabHaobanRoleMenu> insertMenuList = new ArrayList<>() ;
List<TabHaobanRole> list = this.roleMapper.getListByWxEnterpriseId(wxEnterpriseId,1) ;
List<TabHaobanRole> hbRoleList = this.roleMapper.getListByWxEnterpriseId(wxEnterpriseId,1) ;
TabHaobanRoleMenu menu = null ;
for(TabHaobanRole role : list) {
for(TabHaobanRole role : hbRoleList) {
int roleType = role.getClerkType() ;
if(!addRoleTypeList.contains(roleType)) {
continue;
......
package com.gic.haoban.manage.service.util;
public class Constant {
public static final String hb_wxa_namespace = "haoban-wxa";
}
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