✨ 小程序用户支持组织与数据权限,调度端按项目业务部门收口运单
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+8
@@ -26,6 +26,7 @@ import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.MpUser;
|
||||
import org.springblade.system.pojo.entity.MpUserInfo;
|
||||
import org.springblade.system.pojo.vo.MpUserDataScopeVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -53,6 +54,7 @@ public interface IMpUserClient {
|
||||
String UPDATE_USER = API_PREFIX + "/update-user";
|
||||
String BIND_OPENID = API_PREFIX + "/bind-openid";
|
||||
String SET_PASSWORD = API_PREFIX + "/set-password";
|
||||
String RESOLVE_DATA_SCOPE = API_PREFIX + "/resolve-data-scope";
|
||||
|
||||
/**
|
||||
* 按主键查询
|
||||
@@ -60,6 +62,12 @@ public interface IMpUserClient {
|
||||
@GetMapping(USER_BY_ID)
|
||||
R<MpUser> userById(@RequestParam("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 解析小程序用户可见组织(所属组织 + 数据权限范围 + 数据层级范围)
|
||||
*/
|
||||
@GetMapping(RESOLVE_DATA_SCOPE)
|
||||
R<MpUserDataScopeVO> resolveDataScope(@RequestParam("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 按租户 + 手机号查询
|
||||
*/
|
||||
|
||||
+19
-1
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.springblade.system.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -35,6 +36,7 @@ import org.springblade.core.tool.sensitive.SensitiveType;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序用户实体(仅用于小程序登录,与 blade_user 分离)
|
||||
@@ -113,10 +115,26 @@ public class MpUser extends TenantEntity {
|
||||
@Schema(description = "小程序身份")
|
||||
private String identities;
|
||||
/**
|
||||
* 部门id
|
||||
* 部门id(多选,逗号分隔)
|
||||
*/
|
||||
@Schema(description = "部门id")
|
||||
private String deptId;
|
||||
/**
|
||||
* 数据权限范围:1-仅所属组织,2-全部组织,3-自定义
|
||||
*/
|
||||
@Schema(description = "数据权限范围")
|
||||
private Integer dataScopeRange;
|
||||
/**
|
||||
* 数据层级范围:1-包含下级,2-仅本级
|
||||
*/
|
||||
@Schema(description = "数据层级范围")
|
||||
private Integer dataLevelRange;
|
||||
/**
|
||||
* 自定义数据权限组织ID列表(dataScopeRange=3 时生效)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "自定义数据权限组织ID")
|
||||
private List<Long> dataScopeDeptIds;
|
||||
/**
|
||||
* 岗位id
|
||||
*/
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 小程序用户组织数据权限
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_mp_user_data_scope")
|
||||
@Schema(description = "小程序用户组织数据权限")
|
||||
public class MpUserDataScope implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "小程序用户主键")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "组织主键")
|
||||
private Long deptId;
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 小程序用户数据权限解析结果
|
||||
* <p>
|
||||
* allDept=true 表示全部组织(查询不过滤);否则按 deptIds 收口,空列表表示无可见组织。
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "小程序用户数据权限")
|
||||
public class MpUserDataScopeVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 是否全部组织(不过滤)
|
||||
*/
|
||||
@Schema(description = "是否全部组织")
|
||||
private boolean allDept;
|
||||
|
||||
/**
|
||||
* 可见组织 ID;allDept=false 时生效,空表示无权限
|
||||
*/
|
||||
@Schema(description = "可见组织ID")
|
||||
private List<Long> deptIds = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 全部组织
|
||||
*/
|
||||
public static MpUserDataScopeVO all() {
|
||||
MpUserDataScopeVO scope = new MpUserDataScopeVO();
|
||||
scope.setAllDept(true);
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* 无可见组织
|
||||
*/
|
||||
public static MpUserDataScopeVO empty() {
|
||||
MpUserDataScopeVO scope = new MpUserDataScopeVO();
|
||||
scope.setAllDept(false);
|
||||
scope.setDeptIds(new ArrayList<>());
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定可见组织
|
||||
*/
|
||||
public static MpUserDataScopeVO of(List<Long> deptIds) {
|
||||
MpUserDataScopeVO scope = new MpUserDataScopeVO();
|
||||
scope.setAllDept(false);
|
||||
scope.setDeptIds(deptIds == null ? new ArrayList<>() : new ArrayList<>(deptIds));
|
||||
return scope;
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -42,6 +42,13 @@ public class MpUserVO extends MpUser {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 所属组织名称(逗号分隔)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "所属组织名称")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 身份名称(逗号分隔中文)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user