文档库--菜单中英文

This commit is contained in:
zhn
2022-03-03 11:06:34 +08:00
parent 265cb484fc
commit 0b5d8d38f0
3 changed files with 67 additions and 48 deletions
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.constant.enums.CutEnum;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresRoles; import org.apache.shiro.authz.annotation.RequiresRoles;
@@ -199,7 +200,7 @@ public class SysPermissionController {
* @return * @return
*/ */
@RequestMapping(value = "/getUserPermissionByToken", method = RequestMethod.GET) @RequestMapping(value = "/getUserPermissionByToken", method = RequestMethod.GET)
public Result<?> getUserPermissionByToken() { public Result<?> getUserPermissionByToken(String cut) {
Result<JSONObject> result = new Result<JSONObject>(); Result<JSONObject> result = new Result<JSONObject>();
try { try {
//直接获取当前用户不适用前端token //直接获取当前用户不适用前端token
@@ -217,7 +218,7 @@ public class SysPermissionController {
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存 //update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
JSONArray menujsonArray = new JSONArray(); JSONArray menujsonArray = new JSONArray();
this.getPermissionJsonArray(menujsonArray, metaList, null); this.getPermissionJsonArray(menujsonArray, metaList, null,cut);
JSONArray authjsonArray = new JSONArray(); JSONArray authjsonArray = new JSONArray();
this.getAuthJsonArray(authjsonArray, metaList); this.getAuthJsonArray(authjsonArray, metaList);
//查询所有的权限 //查询所有的权限
@@ -505,20 +506,20 @@ public class SysPermissionController {
* @param metaList * @param metaList
* @param parentJson * @param parentJson
*/ */
private void getPermissionJsonArray(JSONArray jsonArray, List<SysPermission> metaList, JSONObject parentJson) { private void getPermissionJsonArray(JSONArray jsonArray, List<SysPermission> metaList, JSONObject parentJson,String cut) {
for (SysPermission permission : metaList) { for (SysPermission permission : metaList) {
if (permission.getMenuType() == null) { if (permission.getMenuType() == null) {
continue; continue;
} }
String tempPid = permission.getParentId(); String tempPid = permission.getParentId();
JSONObject json = getPermissionJsonObject(permission); JSONObject json = getPermissionJsonObject(permission,cut);
if(json==null) { if(json==null) {
continue; continue;
} }
if (parentJson == null && oConvertUtils.isEmpty(tempPid)) { if (parentJson == null && oConvertUtils.isEmpty(tempPid)) {
jsonArray.add(json); jsonArray.add(json);
if (!permission.isLeaf()) { if (!permission.isLeaf()) {
getPermissionJsonArray(jsonArray, metaList, json); getPermissionJsonArray(jsonArray, metaList, json,cut);
} }
} else if (parentJson != null && oConvertUtils.isNotEmpty(tempPid) && tempPid.equals(parentJson.getString("id"))) { } else if (parentJson != null && oConvertUtils.isNotEmpty(tempPid) && tempPid.equals(parentJson.getString("id"))) {
// 类型( 0:一级菜单 1:子菜单 2:按钮 ) // 类型( 0:一级菜单 1:子菜单 2:按钮 )
@@ -542,7 +543,7 @@ public class SysPermissionController {
} }
if (!permission.isLeaf()) { if (!permission.isLeaf()) {
getPermissionJsonArray(jsonArray, metaList, json); getPermissionJsonArray(jsonArray, metaList, json,cut);
} }
} }
} }
@@ -555,7 +556,7 @@ public class SysPermissionController {
* @param permission * @param permission
* @return * @return
*/ */
private JSONObject getPermissionJsonObject(SysPermission permission) { private JSONObject getPermissionJsonObject(SysPermission permission,String cut) {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
// 类型(0:一级菜单 1:子菜单 2:按钮) // 类型(0:一级菜单 1:子菜单 2:按钮)
if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) { if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
@@ -610,7 +611,11 @@ public class SysPermissionController {
} }
/* update_end author:wuxianquan date:20190908 for: 往菜单信息里添加外链菜单打开方式*/ /* update_end author:wuxianquan date:20190908 for: 往菜单信息里添加外链菜单打开方式*/
meta.put("title", permission.getName()); if(CutEnum.CN.getValue().equals(cut)){
meta.put("title", permission.getName());
}else{
meta.put("title", permission.getMenuEn());
}
//update-begin--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842 //update-begin--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
String component = permission.getComponent(); String component = permission.getComponent();
@@ -42,6 +42,8 @@ public class SysPermission implements Serializable {
*/ */
private String name; private String name;
private String menuEn;
/** /**
* 菜单权限编码,例如:“sys:schedule:list,sys:schedule:info”,多个逗号隔开 * 菜单权限编码,例如:“sys:schedule:list,sys:schedule:info”,多个逗号隔开
*/ */
@@ -25,6 +25,8 @@ public class TreeModel implements Serializable {
private String icon; private String icon;
private String menuEn;
private Integer ruleFlag; private Integer ruleFlag;
private Map<String,String> scopedSlots; private Map<String,String> scopedSlots;
@@ -37,6 +39,14 @@ public class TreeModel implements Serializable {
this.scopedSlots = scopedSlots; this.scopedSlots = scopedSlots;
} }
public String getMenuEn() {
return menuEn;
}
public void setMenuEn(String menuEn) {
this.menuEn = menuEn;
}
public String getKey() { public String getKey() {
return key; return key;
} }
@@ -92,6 +102,7 @@ public class TreeModel implements Serializable {
this.value = permission.getId(); this.value = permission.getId();
this.isLeaf = permission.isLeaf(); this.isLeaf = permission.isLeaf();
this.label = permission.getName(); this.label = permission.getName();
this.menuEn = permission.getMenuEn();
if(!permission.isLeaf()) { if(!permission.isLeaf()) {
this.children = new ArrayList<TreeModel>(); this.children = new ArrayList<TreeModel>();
} }
@@ -99,6 +110,7 @@ public class TreeModel implements Serializable {
public TreeModel(String key,String parentId,String slotTitle,Integer ruleFlag,boolean isLeaf) { public TreeModel(String key,String parentId,String slotTitle,Integer ruleFlag,boolean isLeaf) {
this.key = key; this.key = key;
this.menuEn = getMenuEn();
this.parentId = parentId; this.parentId = parentId;
this.ruleFlag=ruleFlag; this.ruleFlag=ruleFlag;
this.slotTitle = slotTitle; this.slotTitle = slotTitle;