1. 画像表示データ
{
"SubCompanyID":"285","DepartmentID":"3382","UserName":"运维组02","Loginid":"lzt","UserID":"16630","UserType":"0","Language":"7","Message":"true"}
2. データセットを取得するフロントエンドコード
var userInfor = getCurrentUserInfor();
var currentUserID = userInfor.UserID;
function getCurrentUserInfor() {
var dataMap = {
};
jQuery.ajax({
url: "/fuli/getSysInforForCurrentUser.jsp?t=" + new Date().getTime(),
data: "",
async: false,
dataType: "json",
contentType: "application/json",
success: function(data) {
dataMap = data;
}
});
return dataMap;
}
3. バックエンドの getSysInforForCurrentUser.jsp ファイル
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="weaver.hrm.*"%>
<%@ page import="weaver.general.*"%>
<%@ page import="net.sf.json.JSONObject"%>
<%@ page import="weaver.conn.RecordSet"%>
<%
RecordSet rs = new RecordSet();
JSONObject json = new JSONObject();
User user = HrmUserVarify.getUser(request , response);
String Message = "flase";
if(user != null){
Message = "true";
json.put( "SubCompanyID" , "" + user.getUserSubCompany1() );
json.put( "DepartmentID" , ""+ user.getUserDepartment() );
json.put( "UserName" , ""+ user.getLastname() );
json.put( "Loginid" , ""+ user.getLoginid() );
json.put( "UserID" , ""+ user.getUID() );
json.put( "UserType" , ""+ user.getType() );
json.put( "Language" , ""+ user.getLanguage() );
}
json.put( "Message" , Message );
out.println(json.toString());
%>
getUser() メソッドを呼び出す
package weaver.hrm;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import weaver.conn.RecordSet;
import weaver.general.StaticObj;
import weaver.general.Util;
import weaver.hrm.online.HrmUserOnlineMap;
import weaver.login.LicenseCheckLogin;
import weaver.systeminfo.setting.HrmUserSettingComInfo;
import weaver.systeminfo.systemright.CheckUserRight;
public class HrmUserVarify
{
public static User getUserOld(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
{
User localUser = (User)paramHttpServletRequest.getSession(true).getAttribute("weaver_user@bean");
if (localUser == null)
{
String str = Util.getCookie(paramHttpServletRequest, "loginfileweaver");
try
{
if ((Util.null2String(str).equals("")) || (Util.null2String(str).toLowerCase().equals("null"))) {
paramHttpServletResponse.sendRedirect("/login/Login.jsp");
} else {
paramHttpServletResponse.sendRedirect("/Refresh.jsp?loginfile=" + str + "&message=19");
}
}
catch (Exception localException) {
}
}
return localUser;
}
public static User getUser(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
{
User localUser = (User)paramHttpServletRequest.getSession(true).getAttribute("weaver_user@bean");
if (localUser == null) {
String str1 = Util.getCookie(paramHttpServletRequest, "loginfileweaver");
try {
if ((Util.null2String(str1).equals("")) || (Util.null2String(str1).toLowerCase().equals("null"))) {
paramHttpServletResponse.sendRedirect("/login/Login.jsp");
return null;
}
paramHttpServletResponse.sendRedirect("/Refresh.jsp?loginfile=" + str1 + "&message=19");
return null;
}
catch (Exception localException) {
}
}
int i = Util.getIntValue(paramHttpServletRequest.getParameter("f_weaver_belongto_userid"), 0);
int j = Util.getIntValue(paramHttpServletRequest.getParameter("f_weaver_belongto_usertype"), 0);
RecordSet localRecordSet = new RecordSet();
if ((localUser != null) && (i != localUser.getUID()) && (i > 0))
{
int k = 0;
String str2 = " SELECT belongto FROM HrmResource WHERE id= " + localUser.getUID();
localRecordSet.executeSql(str2);
int m; while (localRecordSet.next()) {
m = localRecordSet.getInt("belongto");
if (m == i) {
k = 1;
break;
}
}
str2 = " SELECT id FROM HrmResource WHERE belongto= " + localUser.getUID();
localRecordSet.executeSql(str2);
while (localRecordSet.next()) {
m = localRecordSet.getInt("id");
if (m == i) {
k = 1;
break;
}
}
if (k != 0) {
localUser = User.getUser(i, j);
}
}
return localUser;
}
public static User getUser(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, String paramString1, String paramString2)
{
return getUser(paramHttpServletRequest, paramHttpServletResponse, Util.getIntValue(paramString1, 0), Util.getIntValue(paramString2, 0));
}
public static User getUser(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, int paramInt1, int paramInt2)
{
User localUser = (User)paramHttpServletRequest.getSession(true).getAttribute("weaver_user@bean");
if (localUser == null) {
localObject = Util.getCookie(paramHttpServletRequest, "loginfileweaver");
try {
if ((Util.null2String((String)localObject).equals("")) || (Util.null2String((String)localObject).toLowerCase().equals("null"))) {
paramHttpServletResponse.sendRedirect("/login/Login.jsp");
return null;
}
paramHttpServletResponse.sendRedirect("/Refresh.jsp?loginfile=" + (String)localObject + "&message=19");
return null;
}
catch (Exception localException) {
}
}
Object localObject = new RecordSet();
if ((localUser != null) && (paramInt1 != localUser.getUID()) && (paramInt1 > 0))
{
int i = 0;
String str = " SELECT belongto FROM HrmResource WHERE id= " + localUser.getUID();
((RecordSet)localObject).executeSql(str);
int j; while (((RecordSet)localObject).next()) {
j = ((RecordSet)localObject).getInt("belongto");
if (j == paramInt1) {
i = 1;
break;
}
}
str = " SELECT id FROM HrmResource WHERE belongto= " + localUser.getUID();
((RecordSet)localObject).executeSql(str);
while (((RecordSet)localObject).next()) {
j = ((RecordSet)localObject).getInt("id");
if (j == paramInt1) {
i = 1;
break;
}
}
if (i != 0) {
localUser = User.getUser(paramInt1, paramInt2);
}
}
return localUser;
}
public static User checkUser(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse)
{
User localUser = (User)paramHttpServletRequest.getSession(true).getAttribute("weaver_user@bean");
return localUser;
}
public static boolean checkUserRight(String paramString, User paramUser)
{
if (paramUser.getLoginid().equalsIgnoreCase("sysadmin")) return true;
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString, paramUser);
if (!bool) {
String str = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRight(paramString, (User)localObject);
if (bool) {
break;
}
}
}
}
}
return bool;
}
public static String getcheckUserRightUserId(String paramString, User paramUser)
{
return getcheckUserRightUserId(paramString, paramUser, true);
}
private static String getcheckUserRightUserId(String paramString, User paramUser, boolean paramBoolean)
{
if ((paramBoolean) && (paramUser.getLoginid().equalsIgnoreCase("sysadmin"))) return "1";
String str1 = "";
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString, paramUser);
if (bool) {
return "" + paramUser.getUID();
}
String str2 = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str2 = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str2.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRight(paramString, (User)localObject);
if (bool) {
str1 = "" + ((User)localObject).getUID();
break;
}
}
}
}
return str1;
}
public static boolean checkUserRightSystemadmin(String paramString, User paramUser)
{
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString, paramUser);
if (!bool) {
String str = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRight(paramString, (User)localObject);
if (bool) {
break;
}
}
}
}
}
return bool;
}
public static String getcheckUserRightSystemadminUserId(String paramString, User paramUser)
{
return getcheckUserRightUserId(paramString, paramUser, false);
}
public static boolean checkUserRight(String paramString1, User paramUser, String paramString2)
{
if (paramUser.getLoginid().equalsIgnoreCase("sysadmin")) return true;
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString1, paramUser, paramString2);
if (!bool) {
String str = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRight(paramString1, (User)localObject, paramString2);
if (bool) {
break;
}
}
}
}
}
return bool;
}
public static String getcheckUserRightUserId(String paramString1, User paramUser, String paramString2)
{
String str1 = "";
if (paramUser.getLoginid().equalsIgnoreCase("sysadmin")) return "1";
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString1, paramUser, paramString2);
if (bool) {
return "" + paramUser.getUID();
}
String str2 = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str2 = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str2.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRight(paramString1, (User)localObject, paramString2);
if (bool) {
str1 = "" + ((User)localObject).getUID();
break;
}
}
}
}
return str1;
}
public static boolean checkUserRight(String paramString, User paramUser, int paramInt)
{
return checkUserRight(paramString, paramUser, "" + paramInt);
}
public static String getcheckUserRightUserId(String paramString, User paramUser, int paramInt) {
return getcheckUserRightUserId(paramString, paramUser, "" + paramInt);
}
public static String getRightLevel(String paramString, User paramUser)
{
if (paramUser.getLoginid().equalsIgnoreCase("sysadmin")) return "2";
CheckUserRight localCheckUserRight = new CheckUserRight();
String str1 = localCheckUserRight.getRightLevel(paramString, paramUser);
int i = Util.getIntValue(str1, -1);
String str2 = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str2 = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str2.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
str1 = localCheckUserRight.getRightLevel(paramString, (User)localObject);
if (!str1.equals("-1")) {
int j = Util.getIntValue(str1, -1);
if (j > i) {
i = j;
}
}
}
}
}
return "" + i;
}
public String getRightLevel(String paramString1, String paramString2)
{
CheckUserRight localCheckUserRight = new CheckUserRight();
String str1 = localCheckUserRight.getRightLevel(paramString1, paramString2);
int i = Util.getIntValue(str1, -1);
String str2 = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str2 = localHrmUserSettingComInfo.getBelongtoshowByUserId(paramString1);
}
catch (Exception localException) {
}
if (str2.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramString1);
if (localList != null) {
for (Object localObject : localList) {
str1 = localCheckUserRight.getRightLevel(paramString1, (User)localObject);
if (!str1.equals("-1")) {
int j = Util.getIntValue(str1, -1);
if (j > i) {
i = j;
}
}
}
}
}
return "" + i;
}
public boolean checkUserRight(String paramString1, String paramString2, String paramString3)
{
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString1, paramString2, paramString3);
if (!bool) {
String str = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str = localHrmUserSettingComInfo.getBelongtoshowByUserId(paramString1);
}
catch (Exception localException) {
}
if (str.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramString1);
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRight("" + ((User)localObject).getUID(), paramString2, paramString3);
if (bool) {
break;
}
}
}
}
}
return bool;
}
public static String getcheckUserRightUserId(String paramString1, String paramString2, String paramString3)
{
String str1 = "";
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString1, paramString2, paramString3);
if (bool) {
return "" + paramString1;
}
String str2 = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str2 = localHrmUserSettingComInfo.getBelongtoshowByUserId(paramString1);
} catch (Exception localException) {
}
if (str2.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramString1);
if (localList != null) {
for (Object localObject : localList) {
bool = new CheckUserRight().checkUserRight("" + ((User)localObject).getUID(), paramString2, paramString3);
if (bool) {
str1 = "" + ((User)localObject).getUID();
break;
}
}
}
}
return str1;
}
public boolean checkUserRole(String paramString1, User paramUser, String paramString2)
{
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRole(paramString1, paramUser, paramString2);
if (!bool) {
String str = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRole(paramString1, (User)localObject, paramString2);
if (bool) {
break;
}
}
}
}
}
return bool;
}
public static String getcheckUserRoleUserId(String paramString1, User paramUser, String paramString2)
{
String str1 = "";
CheckUserRight localCheckUserRight = new CheckUserRight();
boolean bool = localCheckUserRight.checkUserRight(paramString1, paramUser, paramString2);
if (bool) {
return "" + paramUser.getUID();
}
String str2 = "";
try {
HrmUserSettingComInfo localHrmUserSettingComInfo = new HrmUserSettingComInfo();
str2 = localHrmUserSettingComInfo.getBelongtoshowByUserId("" + paramUser.getUID());
}
catch (Exception localException) {
}
if (str2.equals("1")) {
List localList = User.getBelongtoUsersByUserId(paramUser.getUID());
if (localList != null) {
for (Object localObject : localList) {
bool = localCheckUserRight.checkUserRight(paramString1, (User)localObject, paramString2);
if (bool) {
str1 = "" + ((User)localObject).getUID();
break;
}
}
}
}
return str1;
}
public static boolean isUserOnline(String paramString)
{
LicenseCheckLogin localLicenseCheckLogin = new LicenseCheckLogin();
localLicenseCheckLogin.checkOnlineUser();
StaticObj localStaticObj = StaticObj.getInstance();
ArrayList localArrayList = (ArrayList)localStaticObj.getObject("onlineuserids");
if (localArrayList == null) return false;
int i = localArrayList.indexOf(paramString);
if (i == -1) return false;
return true;
}
public static String getOnlineUserIp(String paramString) {
return HrmUserOnlineMap.getInstance().getClientIpByUidFromClusterMap(paramString); }
private static User getUserfromDB(String paramString) {
RecordSet localRecordSet = new RecordSet();
User localUser = new User();
localRecordSet.execute("SELECT id,firstname,lastname,systemlanguage,seclevel FROM HrmResourceManager WHERE loginid='" + paramString + "'");
if (localRecordSet.next()) {
localUser.setUid(localRecordSet.getInt("id"));
localUser.setLoginid(paramString);
localUser.setFirstname(localRecordSet.getString("firstname"));
localUser.setLastname(localRecordSet.getString("lastname"));
localUser.setLanguage(Util.getIntValue(localRecordSet.getString("systemlanguage"), 0));
localUser.setSeclevel(localRecordSet.getString("seclevel"));
localUser.setLogintype("1");
}
localRecordSet.execute("HrmResource_SelectByLoginID", paramString);
if (localRecordSet.next()) {
localUser.setUid(localRecordSet.getInt("id"));
localUser.setLoginid(paramString);
localUser.setFirstname(localRecordSet.getString("firstname"));
localUser.setLastname(localRecordSet.getString("lastname"));
localUser.setAliasname(localRecordSet.getString("aliasname"));
localUser.setTitle(localRecordSet.getString("title"));
localUser.setTitlelocation(localRecordSet.getString("titlelocation"));
localUser.setSex(localRecordSet.getString("sex"));
localUser.setLanguage(Util.getIntValue(localRecordSet.getString("systemlanguage"), 0));
localUser.setTelephone(localRecordSet.getString("telephone"));
localUser.setMobile(localRecordSet.getString("mobile"));
localUser.setMobilecall(localRecordSet.getString("mobilecall"));
localUser.setEmail(localRecordSet.getString("email"));
localUser.setCountryid(localRecordSet.getString("countryid"));
localUser.setLocationid(localRecordSet.getString("locationid"));
localUser.setResourcetype(localRecordSet.getString("resourcetype"));
localUser.setStartdate(localRecordSet.getString("startdate"));
localUser.setEnddate(localRecordSet.getString("enddate"));
localUser.setContractdate(localRecordSet.getString("contractdate"));
localUser.setJobtitle(localRecordSet.getString("jobtitle"));
localUser.setJobgroup(localRecordSet.getString("jobgroup"));
localUser.setJobactivity(localRecordSet.getString("jobactivity"));
localUser.setJoblevel(localRecordSet.getString("joblevel"));
localUser.setSeclevel(localRecordSet.getString("seclevel"));
localUser.setUserDepartment(Util.getIntValue(localRecordSet.getString("departmentid"), 0));
localUser.setUserSubCompany1(Util.getIntValue(localRecordSet.getString("subcompanyid1"), 0));
localUser.setUserSubCompany2(Util.getIntValue(localRecordSet.getString("subcompanyid2"), 0));
localUser.setUserSubCompany3(Util.getIntValue(localRecordSet.getString("subcompanyid3"), 0));
localUser.setUserSubCompany4(Util.getIntValue(localRecordSet.getString("subcompanyid4"), 0));
localUser.setManagerid(localRecordSet.getString("managerid"));
localUser.setAssistantid(localRecordSet.getString("assistantid"));
localUser.setPurchaselimit(localRecordSet.getString("purchaselimit"));
localUser.setCurrencyid(localRecordSet.getString("currencyid"));
localUser.setLastlogindate(localRecordSet.getString("lastlogindate"));
localUser.setLogintype("1");
}
return localUser;
}
}