Commit 054afc56 by 宋祥

1.修复admin查询时userId错误问题

parent 60422ff2
......@@ -33,6 +33,10 @@ public class CommonConstant {
// 否
public static final Integer NO_0 = 0;
// 是
public static final String YES_S1 = "1";
// 否
public static final String NO_S0 = "0";
// 是
public static final String YES = "Y";
// 否
public static final String NO = "N";
......@@ -88,6 +92,8 @@ public class CommonConstant {
public static final String PROJ_ID = "projId";
// 企业管理员
public static final String COMPANY_MANAGE = "companyManage";
// ADMIN
public static final String ADMIN = "ADMIN";
}
/**
......
......@@ -40,9 +40,9 @@ public class UserSessionUtils extends UserSession {
*/
public static User getUser() {
EiInfo eiInfo = new EiInfo();
eiInfo.set("userId", UserSession.getUserId());
eiInfo.set("loginName", UserSession.getLoginName());
eiInfo.set(EiConstant.serviceName, "HGXSUser");
eiInfo.set(EiConstant.methodName, "getUser");
eiInfo.set(EiConstant.methodName, "getUserByLogin");
EiInfo outInfo = XLocalManager.call(eiInfo);
// -1表示报错
if (outInfo.getStatus() == -1) {
......
......@@ -6,7 +6,6 @@
A.ID as "id",
A.ACCOUNT_CODE as "accountCode", <!-- 企业编码 -->
A.DEP_CODE as "depCode", <!-- 部门编码 -->
A.DELETE_FLAG as "deleteFlag", <!-- 0-未删除,1-已删除 -->
A.COMPANY_CODE as "companyCode", <!-- 公司编码 -->
A.COMPANY_NAME as "companyName", <!-- 公司名称 -->
A.PROJ_CODE as "projCode", <!-- 项目编码 -->
......@@ -24,15 +23,11 @@
<sql id="condition">
AND A.DELETE_FLAG = 0
AND B.BIZ_TYPE = 'WD'
<include refid="HGXSDataAuth.authConditionA"/>
<isNotEmpty prepend=" AND " property="id">
A.ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
A.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="depCode">
A.DEP_CODE = #depCode#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="companyName">
A.COMPANY_NAME LIKE CONCAT('%', #companyName#, '%')
</isNotEmpty>
......
......@@ -60,6 +60,40 @@ public class ServiceHGXSUser extends ServiceBase {
}
/**
* 获取用户信息
*
* @param eiInfo
* @return
*/
public EiInfo getUserByLogin(EiInfo eiInfo) {
EiInfo outInfo = new EiInfo();
int status = 0;
String msg = "";
try {
String loginName = eiInfo.getString("loginName");
if (StringUtils.isNotEmpty(loginName)) {
Map map = new HashMap();
map.put("loginName", loginName);
List<User> users = dao.query("HGXSUser.query", map);
if (users != null && users.size() > 0) {
status = 1;
msg = "用户存在!";
outInfo.set("result", users.get(0));
} else {
msg = "用户信息不存在!";
}
} else {
msg = "传入用户名不能为空!";
}
outInfo.setStatus(status);
outInfo.setMsg(msg);
} catch (Exception e) {
LogUtils.setDetailMsg(outInfo, e, "平台调用用户信息异常");
}
return outInfo;
}
/**
* 查询用户下拉框
*
* @param inInfo
......
......@@ -3,6 +3,9 @@
<sqlMap namespace="HGXSDataAuth">
<sql id="authCondition">
<isNotEmpty prepend=" AND " property="accountCode">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<!-- 无权限时使用 -->
<isNotEmpty prepend=" AND " property="authDepCode">
DEP_CODE = #authDepCode#
......@@ -24,4 +27,29 @@
</isNotEqual>
</sql>
<sql id="authConditionA">
<isNotEmpty prepend=" AND " property="accountCode">
A.ACCOUNT_CODE = #accountCode#
</isNotEmpty>
<!-- 无权限时使用 -->
<isNotEmpty prepend=" AND " property="authDepCode">
A.DEP_CODE = #authDepCode#
</isNotEmpty>
<!-- 仅本人和部门组合 -->
<isEqual prepend=" AND " property="authCombination" compareValue="1">
(A.CREATED_BY = #authOnlyPeople# OR A.DEP_CODE IN <iterate close=")" open="(" conjunction=","
property="authDepCodes">#authDepCodes[]#</iterate>)
</isEqual>
<!-- 仅本人或部门 -->
<isNotEqual prepend=" AND " property="authCombination" compareValue="1">
<isNotEmpty property="authOnlyPeople">
A.CREATED_BY = #authOnlyPeople#
</isNotEmpty>
<isNotEmpty property="authDepCodes">
A.DEP_CODE IN
<iterate close=")" open="(" conjunction="," property="authDepCodes">#authDepCodes[]#</iterate>
</isNotEmpty>
</isNotEqual>
</sql>
</sqlMap>
......@@ -4,9 +4,9 @@
<sql id="condition">
AND IS_DELETED = '0'
<isNotEmpty prepend=" AND " property="accountCode">
<isNotEqual prepend=" AND " property="accountCode" compareValue="ADMIN">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
</isNotEqual>
<isNotEmpty prepend=" AND " property="orgEname">
ORG_ENAME = #orgEname#
</isNotEmpty>
......
......@@ -190,7 +190,9 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
if (StringUtils.startsWithAny(name, serviceFilter)) {
return;
}
((Map) parameters).put("accountCode", UserSessionUtils.getAccountCode());
// 本来是BUG,避免业务代码改动依然保持原逻辑ADMIN时依然置空
String accountCode = UserSessionUtils.getAccountCode();
((Map) parameters).put("accountCode", CommonConstant.Field.ADMIN.equals(accountCode) ? "" : accountCode);
}
/**
......@@ -211,7 +213,7 @@ public class SqlMapDaoLogProxy extends SqlMapDao {
return;
}
String authEnable = PlatApplicationContext.getProperty("iplat4j.page.auth.enable");
if (StringUtils.isNotBlank(authEnable) && CommonConstant.YesNo.NO_0.equals(authEnable)) {
if (StringUtils.isNotBlank(authEnable) && CommonConstant.YesNo.NO_S0.equals(authEnable)) {
return;
}
// 当前用户所有角色
......
package com.baosight.xservices.xs.og.service;
import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
......@@ -36,7 +37,7 @@ public class ServiceXSOG0800 extends TreeService {
HashMap<String, String> map = new HashMap();
List<HashMap> list = new ArrayList();
String accountCode = UserSessionUtils.getAccountCode();
if (StringUtils.isEmpty(accountCode)) {
if (StringUtils.isEmpty(accountCode) || CommonConstant.Field.ADMIN.equals(accountCode)) {
map.put("label", "root");
map.put("text", "组织机构");
} else {
......@@ -57,9 +58,8 @@ public class ServiceXSOG0800 extends TreeService {
Map queryMap = new HashMap();
queryMap.put("node", parentLabel);
// 非管理员仅查询所属企业用户 added by songx at 2024-01-16
if (!LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())) {
queryMap.put("accountCode", UserSessionUtils.getAccountCode());
}
queryMap.put("accountCode", LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())
? CommonConstant.Field.ADMIN : UserSessionUtils.getAccountCode());
List<Map> ret = this.dao.query("XSOG01.queryOrganiation", queryMap, 0, -999999);
Map parentOrgMap = new HashMap();
......
......@@ -4,11 +4,8 @@ import com.baosight.hggp.core.constant.CommonConstant;
import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGConstant;
import com.baosight.hggp.hg.pz.domain.HGPZ009;
import com.baosight.hggp.hg.pz.tools.HGPZTools;
import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.AssertUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.StringUtils;
......@@ -412,9 +409,8 @@ public class ServiceXSOG0801 extends ServiceBase {
inInfo.set("inqu_status-0-orgType", inInfo.get("inqu_status2-0-orgType"));
}
// 非管理员仅查询所属企业用户 added by songx at 2024-01-16
if (!LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())) {
inInfo.set("inqu_status-0-accountCode", UserSessionUtils.getAccountCode());
}
inInfo.set("inqu_status-0-accountCode", LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())
? CommonConstant.Field.ADMIN : UserSessionUtils.getAccountCode());
EiInfo outInfo = super.query(inInfo, "XSOG01.query", new XSOG01());
r2Block.setRows(outInfo.getBlock(EiConstant.resultBlock).getRows());
outInfo.addBlock(r2Block);
......
......@@ -85,15 +85,14 @@ public class ServiceXSOG0801A extends ServiceEPBase {
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
String parentOrgId = MapUtils.getString(queryRow, "parentOrgId");
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String parentOrgId = MapUtils.getString(queryMap, "parentOrgId");
if ("".equals(parentOrgId)) {
return inInfo;
}
// 非管理员仅查询所属企业用户 added by songx at 2024-01-16
if (!LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())) {
queryRow.put("accountCode", UserSessionUtils.getAccountCode());
}
queryMap.put("accountCode", LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())
? CommonConstant.Field.ADMIN : UserSessionUtils.getAccountCode());
inInfo = super.query(inInfo, "XSOG01.query", new XSOG01());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
......
......@@ -17,6 +17,7 @@ import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import com.baosight.iplat4j.core.service.soa.XServiceManager;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import com.baosight.xservices.xs.og.domain.XSOG01;
import com.baosight.xservices.xs.util.LoginUserDetails;
import java.util.List;
import java.util.Map;
......@@ -76,12 +77,14 @@ public class ServiceXSOG0801B extends ServiceEPBase {
@Override
public EiInfo query(EiInfo inInfo) {
try {
Map queryRow = EiInfoUtils.getFirstRow(inInfo);
String orgId = MapUtils.getString(queryRow, "orgId");
Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String orgId = MapUtils.getString(queryMap, "orgId");
if ("".equals(orgId)) {
return inInfo;
}
queryRow.put("accountCode", UserSessionUtils.getAccountCode());
// 非管理员仅查询所属企业用户 added by songx at 2024-01-16
queryMap.put("accountCode", LoginUserDetails.isUserAdmin(UserSessionUtils.getLoginName())
? CommonConstant.Field.ADMIN : UserSessionUtils.getAccountCode());
inInfo = super.query(inInfo, "XSOG01.query", new XSOG01());
} catch (Exception e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败");
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="XSOG01">
<select id="queryOrgInfo" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
<select id="queryOrgInfo" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT
ORG_ID as "orgId", <!-- 组织ID -->
ORG_ENAME as "orgEname", <!-- 组织编码 -->
......@@ -125,9 +123,8 @@
ORDER BY ORG_ENAME,SORT_INDEX ASC
</select>
<!--条件查询组织机构-->
<select id="query" parameterClass="java.util.HashMap"
resultClass="java.util.HashMap">
<!-- 条件查询组织机构 -->
<select id="query" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
SELECT
ORG_ID as "orgId", <!-- 组织ID -->
ORG_ENAME as "orgEname", <!-- 组织编码 -->
......@@ -161,13 +158,13 @@
<isNotEmpty prepend=" AND " property="orgType">
ORG_TYPE like ('%$orgType$%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
<isNotEqual prepend=" AND " property="accountCode" compareValue="ADMIN">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
</isNotEqual>
ORDER BY SORT_INDEX ASC
</select>
<!--条件查询组织机构-->
<!-- 条件查询组织机构 -->
<select id="count" parameterClass="java.util.HashMap" resultClass="int">
SELECT COUNT(1)
FROM ${platSchema}.TXSOG01
......@@ -188,9 +185,9 @@
<isNotEmpty prepend=" AND " property="orgType">
ORG_TYPE like ('%$orgType$%')
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
<isNotEqual prepend=" AND " property="accountCode" compareValue="ADMIN">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
</isNotEqual>
</select>
<!-- 根据id查询组织机构 -->
......@@ -265,7 +262,7 @@
</isNotEmpty>
</select>
<!--组织机构子节点树查询-->
<!-- 组织机构子节点树查询 -->
<select id="queryOrganiation" resultClass="java.util.HashMap">
SELECT
ORG_ID as "label",
......@@ -282,9 +279,9 @@
<isNotEmpty prepend=" AND " property="node">
PARENT_ORG_ID = #node#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="accountCode">
<isNotEqual prepend=" AND " property="accountCode" compareValue="ADMIN">
ACCOUNT_CODE = #accountCode#
</isNotEmpty>
</isNotEqual>
order by SORT_INDEX asc
</select>
......
......@@ -20,6 +20,7 @@ import org.apache.commons.lang.StringUtils;
* @date:2024/1/26,11:26
*/
public class ServiceXS0710 extends MenuTreeService {
private EiBlockMeta eiMetadata = null;
public ServiceXS0710() {
......
......@@ -36,6 +36,7 @@ import java.util.Map;
public class ServiceXS3002 extends ServiceEPBase {
private static final Logger logger = LoggerFactory.getLogger(ServiceXS3002.class);
private String USER_TYPE = "USER";
public ServiceXS3002() {
......
......@@ -92,5 +92,6 @@
<!-- 文档库 -->
<sqlMap resource="com/baosight/hggp/hg/wd/sql/HGWD001.xml"/>
<sqlMap resource="com/baosight/hggp/hg/wd/sql/HGWD002.xml"/>
</sqlMapConfig>
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