Browse Source

控制数据权限

wangyangyang 4 years ago
parent
commit
3bea5f32ed

+ 4 - 0
user_center/src/main/java/com/huaxu/entity/UserEntity.java

@@ -121,4 +121,8 @@ public class UserEntity implements Serializable {
     @ApiModelProperty(value ="权限",hidden = true)
     @TableField(exist = false)
     private List<ProgramItem> programItems;
+
+    @ApiModelProperty(value="用户权限类型")
+    @TableField(exist = false)
+    private Integer permissonType;
 }

+ 2 - 0
user_center/src/main/java/com/huaxu/service/UserService.java

@@ -49,6 +49,8 @@ public class UserService extends ServiceImpl<UserMapper,UserEntity> {
 		userEntity.setTenantId(currentUser.getTenantId());
 		userEntity.setProgramItems(currentUser.getProgramItemList());
 		userEntity.setUserType(currentUser.getType());
+		//1是公司,2是公司及以下,3部门,4部门及以下,5自定义
+		userEntity.setPermissonType(currentUser.getPermissonType());
 		Page<UserEntity> userPage = userMapper.findPage(page, userEntity);
 		return userPage;
 	}

+ 15 - 0
user_center/src/main/resources/mapper/UserMapper.xml

@@ -98,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                   )
             </if>
             <if test="user.userType!=null and user.userType!=-999 and user.userType!=-9999 and  user.programItems != null and user.programItems.size() > 0">
+               <if test="user.permissonType == 5 or user.permissonType == 2">
                 and ( a.DEPT_ORG_ID in
                        <foreach collection="user.programItems" item="item" open="(" close=")" separator=",">
                            #{item.orgId}
@@ -108,6 +109,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                             #{item.orgId}
                         </foreach>
                 )
+               </if>
+                <if test="user.permissonType == 4 or user.permissonType == 3">
+                    and a.DEPT_ORG_ID in
+                    <foreach collection="user.programItems" item="item" open="(" close=")" separator=",">
+                        #{item.orgId}
+                    </foreach>
+                </if>
+                <if test="user.permissonType == 1">
+                    and a.COMPANY_ORG_ID in
+                    <foreach collection="user.programItems" item="item" open="(" close=")" separator=",">
+                        #{item.orgId}
+                    </foreach>
+                    and (a.DEPT_ORG_ID is null or a.DEPT_ORG_ID =0)
+                </if>
            </if>
 		</where>
         order by a.date_create desc