选择车队不一致修改
This commit is contained in:
@@ -196,16 +196,16 @@
|
||||
<if test="expenseAccountDO.organizationId != null">
|
||||
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||
and a.organization_id = #{expenseAccountDO.organizationId}
|
||||
and a.organization_name IS NOT NULL
|
||||
and a.organization_name != ''
|
||||
and LENGTH(TRIM(a.organization_name)) > 0
|
||||
-- and a.organization_name IS NOT NULL
|
||||
-- and a.organization_name != ''
|
||||
-- and LENGTH(TRIM(a.organization_name)) > 0
|
||||
</if>
|
||||
<if test="expenseAccountDO.topOrganizationId != null and expenseAccountDO.organizationId == null">
|
||||
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
|
||||
and a.top_organization_id = #{expenseAccountDO.topOrganizationId}
|
||||
and a.organization_name IS NOT NULL
|
||||
and a.organization_name != ''
|
||||
and LENGTH(TRIM(a.organization_name)) > 0
|
||||
-- and a.organization_name IS NOT NULL
|
||||
-- and a.organization_name != ''
|
||||
-- and LENGTH(TRIM(a.organization_name)) > 0
|
||||
</if>
|
||||
<if test="expenseAccountDO.organizationName != null and expenseAccountDO.organizationName != ''">
|
||||
and a.organization_name like concat('%', #{expenseAccountDO.organizationName}, '%')
|
||||
|
||||
+21
-21
@@ -8,36 +8,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectServiceItemsManagePo1">
|
||||
<where>
|
||||
<!-- 删除标记:0-无状态,1-正常,2-已删除,查询时只查询正常的数据 -->
|
||||
<choose>
|
||||
<when test="delFlag != null">
|
||||
and del_flag = #{delFlag}
|
||||
</when>
|
||||
<otherwise>
|
||||
and del_flag = 1
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="createByName != null and createByName != ''">
|
||||
and create_by_name like concat('%', #{createByName}, '%')
|
||||
</if>
|
||||
<if test="updateByName != null and updateByName != ''">
|
||||
and update_by_name like concat('%', #{updateByName}, '%')
|
||||
</if>
|
||||
<!-- <!– 删除标记:0-无状态,1-正常,2-已删除,查询时只查询正常的数据 –>-->
|
||||
<!-- <choose>-->
|
||||
<!-- <when test="delFlag != null">-->
|
||||
<!-- and del_flag = #{delFlag}-->
|
||||
<!-- </when>-->
|
||||
<!-- <otherwise>-->
|
||||
<!-- and del_flag = 1-->
|
||||
<!-- </otherwise>-->
|
||||
<!-- </choose>-->
|
||||
<!-- <if test="createByName != null and createByName != ''">-->
|
||||
<!-- and create_by_name like concat('%', #{createByName}, '%')-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="updateByName != null and updateByName != ''">-->
|
||||
<!-- and update_by_name like concat('%', #{updateByName}, '%')-->
|
||||
<!-- </if>-->
|
||||
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
||||
<!-- 如果 organizationId 和 topOrganizationId 都为 null,表示查询所有组织的数据(不添加组织过滤条件) -->
|
||||
<if test="organizationId != null">
|
||||
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||
and organization_id = #{organizationId}
|
||||
and organization_name IS NOT NULL
|
||||
and organization_name != ''
|
||||
and LENGTH(TRIM(organization_name)) > 0
|
||||
-- and organization_name IS NOT NULL
|
||||
-- and organization_name != ''
|
||||
-- and LENGTH(TRIM(organization_name)) > 0
|
||||
</if>
|
||||
<if test="topOrganizationId != null and organizationId == null">
|
||||
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
|
||||
and top_organization_id = #{topOrganizationId}
|
||||
and organization_name IS NOT NULL
|
||||
and organization_name != ''
|
||||
and LENGTH(TRIM(organization_name)) > 0
|
||||
-- and organization_name IS NOT NULL
|
||||
-- and organization_name != ''
|
||||
-- and LENGTH(TRIM(organization_name)) > 0
|
||||
</if>
|
||||
<if test="organizationName != null and organizationName != ''">
|
||||
and organization_name like concat('%', #{organizationName}, '%')
|
||||
|
||||
+62
-51
@@ -86,6 +86,7 @@ public class RoleApplicationService {
|
||||
|
||||
// 先保存前端传递的 organizationId(如果存在)
|
||||
Long frontendOrganizationId = roleDo.getOrganizationId();
|
||||
log.info("角色查询 - 初始 roleDo.getOrganizationId(): {}", frontendOrganizationId);
|
||||
|
||||
// 获取登录用户信息
|
||||
Long loginUserOrganizationId = null;
|
||||
@@ -94,6 +95,12 @@ public class RoleApplicationService {
|
||||
loginUserOrganizationId = userPo.getOrganizationId();
|
||||
topOrganizationId = userPo.getTopOrganizationId();
|
||||
}
|
||||
log.info("角色查询 - 当前登录用户组织ID: {}", loginUserOrganizationId);
|
||||
|
||||
// 先保存前端传递的 organizationId(如果存在)
|
||||
// 因为后续的 BeanUtils.copyProperties 可能会覆盖掉前端传递的值
|
||||
Long savedFrontendOrganizationId = frontendOrganizationId;
|
||||
log.info("角色查询 - 保存的前端 organizationId: {}", savedFrontendOrganizationId);
|
||||
|
||||
if (userPo.getUserAccountType() != null && userPo.getUserAccountType() == 5){
|
||||
roleDo.setCreateBy(userPo.getCreateBy());
|
||||
@@ -102,60 +109,62 @@ public class RoleApplicationService {
|
||||
userDataPermissionQueryDTO.setPermissionMenuId(roleDo.getPermissionMenuId());
|
||||
userDataPermissionQueryDTO = userDataPermissionApplicationService.getUserDataPermissionQueryDTO(userDataPermissionQueryDTO);
|
||||
|
||||
// 在复制属性之前,先保存前端传递的 organizationId(如果存在)
|
||||
// 因为 BeanUtils.copyProperties 可能会覆盖掉前端传递的值
|
||||
Long savedFrontendOrganizationId = frontendOrganizationId;
|
||||
|
||||
BeanUtils.copyProperties(userDataPermissionQueryDTO, roleDo, IgnoreNullUtil.getNullPropertyNames(userDataPermissionQueryDTO));
|
||||
UserPo loginUserPo = loginUser.getUserPo();
|
||||
|
||||
// 重新获取前端传递的 organizationId(优先使用前端传递的值)
|
||||
// 对于南光组织,如果前端传递了 organizationId,必须使用前端传递的值
|
||||
Long currentFrontendOrganizationId = savedFrontendOrganizationId != null ? savedFrontendOrganizationId : roleDo.getOrganizationId();
|
||||
|
||||
// 数据权限:查询权限根据 organizationId 来设置,与其他模块保持一致
|
||||
// organizationId等于2827时,为南光组织,查所有;其他组织查自己
|
||||
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId(包括2827),使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (currentFrontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId(包括2827或其他组织),使用前端传递的值进行过滤
|
||||
roleDo.setOrganizationId(currentFrontendOrganizationId);
|
||||
roleDo.setTopOrganizationId(null);
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
roleDo.setOrganizationId(null);
|
||||
roleDo.setTopOrganizationId(null);
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(loginUserPo.getRoleCode()) && RoleEnum.SUPER_ADMIN.getCode().equals(loginUserPo.getRoleCode())) {
|
||||
//角色等级:0-无状态,1-内置角色,2-组织角色
|
||||
//roleDo.setRoleGrade(1);
|
||||
} else {
|
||||
//roleDo.setRoleGrade(2);
|
||||
}
|
||||
log.info("角色查询 - BeanUtils.copyProperties 后 roleDo.getOrganizationId(): {}", roleDo.getOrganizationId());
|
||||
}
|
||||
|
||||
UserPo loginUserPo = loginUser.getUserPo();
|
||||
|
||||
// 数据权限:查询权限根据 organizationId 来设置,与其他模块保持一致
|
||||
// organizationId等于2827时,为南光组织,查所有;其他组织查自己
|
||||
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId 且不等于当前登录用户的组织ID,使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,或者传递的值等于当前登录用户的组织ID,清空组织过滤条件,查询所有组织的数据
|
||||
log.info("角色查询 - 南光组织,savedFrontendOrganizationId: {}", savedFrontendOrganizationId);
|
||||
if (savedFrontendOrganizationId != null && !savedFrontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId(不等于2827),使用前端传递的值进行过滤
|
||||
log.info("角色查询 - 南光组织:使用前端传递的其他组织 organizationId: {}", savedFrontendOrganizationId);
|
||||
roleDo.setOrganizationId(savedFrontendOrganizationId);
|
||||
roleDo.setTopOrganizationId(null);
|
||||
} else {
|
||||
// 前端没有传递 organizationId,或者传递的值等于当前登录用户的组织ID(2827),
|
||||
// 清空组织过滤条件,查询所有组织的数据
|
||||
// 注意:这里必须清空 organizationId,不能使用 roleDo.getOrganizationId(),
|
||||
// 因为 roleDo.getOrganizationId() 可能被 BeanUtils.copyProperties 从其他地方复制过来
|
||||
log.info("角色查询 - 南光组织:前端未传递 organizationId 或传递的值等于当前登录用户组织ID,清空组织过滤条件,查询所有组织的数据");
|
||||
roleDo.setOrganizationId(null);
|
||||
roleDo.setTopOrganizationId(null);
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(loginUserPo.getRoleCode()) && RoleEnum.SUPER_ADMIN.getCode().equals(loginUserPo.getRoleCode())) {
|
||||
//角色等级:0-无状态,1-内置角色,2-组织角色
|
||||
//roleDo.setRoleGrade(1);
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||
if (currentFrontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!currentFrontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
log.warn("角色查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||
currentFrontendOrganizationId, loginUserOrganizationId);
|
||||
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||
} else {
|
||||
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
roleDo.setOrganizationId(currentFrontendOrganizationId);
|
||||
}
|
||||
roleDo.setTopOrganizationId(topOrganizationId);
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||
roleDo.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
//roleDo.setRoleGrade(2);
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||
// 重新获取前端传递的 organizationId(优先使用前端传递的值)
|
||||
Long currentFrontendOrganizationId = savedFrontendOrganizationId != null ? savedFrontendOrganizationId : roleDo.getOrganizationId();
|
||||
if (currentFrontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!currentFrontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
log.warn("角色查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||
currentFrontendOrganizationId, loginUserOrganizationId);
|
||||
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||
} else {
|
||||
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
roleDo.setOrganizationId(currentFrontendOrganizationId);
|
||||
}
|
||||
roleDo.setTopOrganizationId(topOrganizationId);
|
||||
} else {
|
||||
// 前端没有传递 organizationId,使用当前登录用户的组织ID
|
||||
roleDo.setOrganizationId(loginUserOrganizationId);
|
||||
roleDo.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
//roleDo.setRoleGrade(2);
|
||||
}
|
||||
return roleDomainService.selecRolePoList(roleDo);
|
||||
}
|
||||
@@ -167,7 +176,9 @@ public class RoleApplicationService {
|
||||
*/
|
||||
@DataPermissions(cacheName = "wlhyRole_createBy")
|
||||
public List<RolePO> getUserRolelist(RoleDo roleDo) {//获取登录人信息
|
||||
return roleDomainService.selecRolePoList(roleDo);
|
||||
// 调用应用服务层的方法,包含数据权限控制逻辑
|
||||
// 当前登录用户组织ID为2827时查询全部组织信息,其他组织只查自己
|
||||
return selecRolePoList(roleDo);
|
||||
}
|
||||
|
||||
public List<RolePO> queryList(RoleDo roleDo) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -57,9 +58,20 @@ public class RoleAPI extends BaseController {
|
||||
@Log(title = "职务/角色管理-查询", description ="查询角色列表",businessType = BusinessType.INQUIRE)
|
||||
@ApiOperation("查询角色列表-分页")
|
||||
@GetMapping("/getUserRolelist")
|
||||
public TableDataInfo getUserRolelist(RoleDTO roleDTO) {
|
||||
public TableDataInfo getUserRolelist(RoleDTO roleDTO, HttpServletRequest request) {
|
||||
// 检查前端是否明确传递了 organizationId 参数
|
||||
// 如果前端没有传递,清空 roleDTO 中的 organizationId,避免从其他地方自动设置的值影响查询
|
||||
String organizationIdParam = request.getParameter("organizationId");
|
||||
log.info("角色查询接口 - 前端传递的 organizationId 参数: {}", organizationIdParam);
|
||||
if (organizationIdParam == null || organizationIdParam.isEmpty()) {
|
||||
log.info("角色查询接口 - 前端未传递 organizationId,清空 roleDTO.organizationId");
|
||||
roleDTO.setOrganizationId(null);
|
||||
} else {
|
||||
log.info("角色查询接口 - 前端传递了 organizationId: {}", organizationIdParam);
|
||||
}
|
||||
//转换实体
|
||||
RoleDo roleDo = roleAssember.toRoleDo(roleDTO);
|
||||
log.info("角色查询接口 - 转换后 roleDo.getOrganizationId(): {}", roleDo.getOrganizationId());
|
||||
startPage();
|
||||
List<RolePO> list = roleApplicationService.getUserRolelist(roleDo);
|
||||
return getDataTable(list);
|
||||
|
||||
@@ -17,4 +17,10 @@ public class NonePagingListVO {
|
||||
@ApiModelProperty(value = "车队名称")
|
||||
private String motorcadeName;
|
||||
|
||||
@ApiModelProperty(value = "组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
@ApiModelProperty(value = "组织名称")
|
||||
private String organizationName;
|
||||
|
||||
}
|
||||
|
||||
@@ -380,31 +380,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
group by u.user_id
|
||||
</select>
|
||||
<select id="queryNonePagingList" resultType="com.mhd.user.domain.motorcade.repository.po.MotorcadePo">
|
||||
SELECT
|
||||
SELECT DISTINCT
|
||||
m.motorcade_id,
|
||||
m.motorcade_name
|
||||
m.motorcade_name,
|
||||
m.organization_id,
|
||||
m.organization_name
|
||||
FROM
|
||||
motorcade m
|
||||
LEFT JOIN
|
||||
INNER JOIN
|
||||
motorcade_driver d
|
||||
ON m.motorcade_id = d.motorcade_id and d.del_flag = 1
|
||||
INNER JOIN
|
||||
user_driver ud
|
||||
ON d.user_id = ud.user_id and ud.del_flag = 1
|
||||
LEFT JOIN
|
||||
user_driver_enterprise ude
|
||||
ON ud.user_id = ude.user_id and ude.del_flag = 1
|
||||
<where>
|
||||
m.del_flag = 1
|
||||
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
|
||||
<if test="organizationId != null">
|
||||
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
|
||||
and m.organization_id = #{organizationId}
|
||||
and m.organization_name IS NOT NULL
|
||||
</if>
|
||||
<if test="topOrganizationId != null">
|
||||
<!-- 如果设置了 topOrganizationId,添加 top_organization_id 条件 -->
|
||||
and m.top_organization_id = #{topOrganizationId}
|
||||
<if test="organizationId == null">
|
||||
<!-- 如果没有设置 organizationId,添加 organization_name IS NOT NULL 条件 -->
|
||||
and m.organization_name IS NOT NULL
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY m.motorcade_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -122,13 +122,13 @@
|
||||
</if>
|
||||
<if test="organizationId !=null">
|
||||
and a.organization_id = #{organizationId}
|
||||
and a.organization_name IS NOT NULL
|
||||
-- and a.organization_name IS NOT NULL
|
||||
</if>
|
||||
<if test="topOrganizationId !=null">
|
||||
and a.top_organization_id = #{topOrganizationId}
|
||||
<if test="organizationId == null">
|
||||
and a.organization_name IS NOT NULL
|
||||
</if>
|
||||
<!-- <if test="organizationId == null">-->
|
||||
<!-- and a.organization_name IS NOT NULL-->
|
||||
<!-- </if>-->
|
||||
</if>
|
||||
<if test="organizationName != null and organizationName != ''">
|
||||
and a.organization_name like concat('%' , #{organizationName} , '%')
|
||||
|
||||
@@ -185,27 +185,13 @@
|
||||
ude.driver_corp_legal_name,
|
||||
ude.driver_corp_name,
|
||||
ude.driver_corp_idcard_number,
|
||||
r.roleName,
|
||||
b.role_name AS roleName,
|
||||
dvb.vehicle_id,
|
||||
wlhydriver.id as wlhydriverId,
|
||||
WM_CONCAT(DISTINCT dvb.vehicle_license_plate_number ) AS vehicleLicensePlateNumber,
|
||||
WM_CONCAT(DISTINCT m.motorcade_name ) AS driverTeamName
|
||||
FROM
|
||||
"USER" b
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
user_id,
|
||||
LISTAGG(DISTINCT r.role_name, '&') WITHIN GROUP(ORDER BY r.role_name) AS roleName
|
||||
FROM
|
||||
role r
|
||||
LEFT JOIN user_role ur ON r.role_id = ur.role_id
|
||||
AND ur.del_flag = 1
|
||||
WHERE
|
||||
r.del_flag = 1
|
||||
AND role_code IN ( 'driver', 'carrier', 'captain' )
|
||||
GROUP BY
|
||||
user_id
|
||||
) r ON r.user_id = b.user_id
|
||||
LEFT JOIN user_driver a ON a.user_id = b.user_id
|
||||
LEFT JOIN NGWL_TEST_WLHY.sys_user wlhyuser ON wlhyuser.szwl_user_id = b.user_id
|
||||
LEFT JOIN NGWL_TEST_WLHY.tms_driver wlhydriver ON wlhydriver.driver_id = wlhyuser.id
|
||||
@@ -220,7 +206,7 @@
|
||||
left join motorcade m on md.motorcade_id = m.motorcade_id and m.del_flag = 1
|
||||
|
||||
LEFT JOIN motorcade mo ON a.driver_id = mo.motorcade_header_id
|
||||
AND m.del_flag = 1
|
||||
AND mo.del_flag = 1
|
||||
left join motorcade_driver mdr on mo.motorcade_id = mdr.motorcade_id and mdr.del_flag = 1
|
||||
WHERE
|
||||
b.del_flag = 1
|
||||
@@ -353,12 +339,6 @@
|
||||
select count(1)
|
||||
from ( select b.user_id
|
||||
from "USER" b
|
||||
left join (select user_id, WM_CONCAT(r.role_name separator '&') roleName
|
||||
from role r
|
||||
left join user_role ur on r.role_id = ur.role_id and ur.del_flag = 1
|
||||
where r.del_flag = 1
|
||||
and role_code in ('driver', 'carrier', 'captain', 'must')
|
||||
group by user_id) r on r.user_id = b.user_id
|
||||
left join user_driver a on a.user_id = b.user_id
|
||||
left join user_driver_enterprise ude on b.user_id = ude.user_id and ude.driver_type = 1
|
||||
left join user_driver_enterprise ud on b.user_id = ud.user_id and ud.driver_type = 2
|
||||
@@ -558,7 +538,7 @@
|
||||
</if>
|
||||
/*角色*/
|
||||
<if test="userDriverDO.roleName != null and userDriverDO.roleName != ''">
|
||||
AND r.roleName like concat('%', #{userDriverDO.roleName}, '%')
|
||||
AND b.role_name like concat('%', #{userDriverDO.roleName}, '%')
|
||||
</if>
|
||||
/*车牌号*/
|
||||
<if test="userDriverDO.vehicleLicensePlateNumber != null and userDriverDO.vehicleLicensePlateNumber != ''">
|
||||
|
||||
Reference in New Issue
Block a user