提交 a96b989b 编写于 作者: zhouweidong's avatar zhouweidong

菜单usr代码

上级 1b27b217
...@@ -14,13 +14,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,13 +14,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -48,6 +46,10 @@ public class ClientAuthenticationResource ...@@ -48,6 +46,10 @@ public class ClientAuthenticationResource
* 统一资源标识 * 统一资源标识
*/ */
private String UniResTag="UNIRES"; private String UniResTag="UNIRES";
/**
* 菜单项标识
*/
private String AppMenuTag="APPMENU";
@Autowired @Autowired
@Qualifier("IBZUSERService") @Qualifier("IBZUSERService")
...@@ -107,6 +109,7 @@ public class ClientAuthenticationResource ...@@ -107,6 +109,7 @@ public class ClientAuthenticationResource
JSONObject permissionObj=new JSONObject(); JSONObject permissionObj=new JSONObject();
//数据能力
String opprivSQL="SELECT\n" + String opprivSQL="SELECT\n" +
"\tT2.pssysmoduleid as sysmodule,\n" + "\tT2.pssysmoduleid as sysmodule,\n" +
"\tT2.psdataentityid as dataentity,\n" + "\tT2.psdataentityid as dataentity,\n" +
...@@ -128,8 +131,7 @@ public class ClientAuthenticationResource ...@@ -128,8 +131,7 @@ public class ClientAuthenticationResource
"\t)\n" + "\t)\n" +
"AND T1.PERMISSIONTYPE = #{et.param1} "; "AND T1.PERMISSIONTYPE = #{et.param1} ";
//统一资源
String uniResSQL="SELECT\n" + String uniResSQL="SELECT\n" +
"\tt2.SYS_PSSYSUNIRESID,\n" + "\tt2.SYS_PSSYSUNIRESID,\n" +
"\tt2.SYS_PSSYSUNIRESNAME,\n" + "\tt2.SYS_PSSYSUNIRESNAME,\n" +
...@@ -148,24 +150,68 @@ public class ClientAuthenticationResource ...@@ -148,24 +150,68 @@ public class ClientAuthenticationResource
"\t)\n" + "\t)\n" +
"AND T1.PERMISSIONTYPE = #{et.param1} "; "AND T1.PERMISSIONTYPE = #{et.param1} ";
//应用菜单
String appMenuSQL="SELECT\n" +
"\tt2.PSAPPPMENUITEMID as MENUITEMID,\n" +
"\tt2.SYS_PSAPPMENUITEMNAME AS MENUITEMNAME \n" +
"FROM\n" +
"\tibzrole_permission T\n" +
"INNER JOIN ibzpermission T1 ON T.SYS_PERMISSIONID = T1.SYS_PERMISSIONID\n" +
"INNER JOIN ibzpsappmenuitem T2 on T1.SYS_PERMISSIONID=t2.SYS_PSAPPMENUITEMID\n" +
"WHERE\n" +
"\tT.SYS_ROLEID IN (\n" +
"\t SELECT SYS_ROLEID\n" +
"\t FROM\n" +
"\t IBZUSER_ROLE t LEFT JOIN IBZUSER t1 ON t.SYS_USERID=T1.USERID\n" +
"\t WHERE\n" +
"\t T1.USERID = #{et.param0}\n" +
"\t)\n" +
"AND T1.PERMISSIONTYPE = #{et.param1} ";
Map opprivParam=new HashMap(); Map opprivParam=new HashMap();
opprivParam.put("param0",user.getUserid()); opprivParam.put("param0",user.getUserid());
opprivParam.put("param1",OPPriTag); opprivParam.put("param1",OPPriTag);
List<JSONObject> entitiesList= permissionService.select(opprivSQL,opprivParam); //查询用户权限下的菜单数据
Map uniresParam=new HashMap(); Map uniresParam=new HashMap();
uniresParam.put("param0",user.getUserid()); uniresParam.put("param0",user.getUserid());
uniresParam.put("param1",UniResTag); uniresParam.put("param1",UniResTag);
List<JSONObject> uniResList= permissionService.select(uniResSQL,uniresParam); //查询用户权限下的菜单数据 Map appMenuParam=new HashMap();
appMenuParam.put("param0",user.getUserid());
appMenuParam.put("param1",AppMenuTag);
List<JSONObject> entitiesList= permissionService.select(opprivSQL,opprivParam); //查询用户权限下数据能力
List<JSONObject> uniResList= permissionService.select(uniResSQL,uniresParam); //查询用户权限下的统一资源
List<JSONObject> appMenuItemList= permissionService.select(appMenuSQL,appMenuParam); //查询用户权限下的菜单项
JSONObject entities=getEntitiesList(entitiesList); JSONObject entities=getEntitiesList(entitiesList);
JSONArray uniRes=getUniRes(uniResList); JSONArray uniRes=getUniRes(uniResList);
JSONArray appMenuItem=getAppMenuItem(appMenuItemList);
permissionObj.put("entities",entities); permissionObj.put("entities",entities);
permissionObj.put("unires",uniRes); permissionObj.put("unires",uniRes);
permissionObj.put("appmenu",appMenuItem);
user.setPermissionList(permissionObj); user.setPermissionList(permissionObj);
} }
/**
* 获取应用菜单
* @param menuItemList
* @return
*/
private JSONArray getAppMenuItem(List<JSONObject> menuItemList) {
JSONArray menuItemArr=new JSONArray();
for(int a=0;a<menuItemList.size();a++){
JSONObject menuItem=menuItemList.get(a);
JSONObject newMenuItem=new JSONObject();
newMenuItem.put("menuitemid",menuItem.getString("MENUITEMID"));
newMenuItem.put("menuitemname",menuItem.getString("MENUITEMNAME"));
menuItemArr.add(newMenuItem);
}
return menuItemArr;
}
/** /**
* 获取统一资源 * 获取统一资源
* @param uniResList * @param uniResList
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册