插件开发工具库,推荐依赖该工具库。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
4.0 KiB

package com.fanruan.api.decision;
import com.fr.decision.authority.AuthorityContext;
import com.fr.decision.authority.base.constant.AuthorityStaticItemId;
import com.fr.decision.authority.base.constant.AuthorityValue;
import com.fr.decision.authority.base.constant.type.authority.AuthorityType;
import com.fr.decision.authority.controller.GradeAuthorityController;
import com.fr.decision.authority.data.personnel.DepRole;
import com.fr.decision.webservice.utils.WebServiceUtils;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-09-19
* 权限相关的工具类
*/
public class AuthorityKit {
/**
* 内置管理系统节点id
*/
public static class Management {
public static final String USER = AuthorityStaticItemId.DEC_MANAGEMENT_USER_ID;
public static final String AUTHORITY = AuthorityStaticItemId.DEC_MANAGEMENT_AUTHORITY_ID;
public static final String DIRECTORY = AuthorityStaticItemId.DEC_MANAGEMENT_DIRECTORY_ID;
public static final String APPEARANCE = AuthorityStaticItemId.DEC_MANAGEMENT_APPEARANCE_ID;
public static final String CONNECTION = AuthorityStaticItemId.DEC_MANAGEMENT_CONNECTION_ID;
public static final String SYSTEM = AuthorityStaticItemId.DEC_MANAGEMENT_SYSTEM_ID;
public static final String SCHEDULE = AuthorityStaticItemId.DEC_MANAGEMENT_SCHEDULE_ID;
public static final String MOBILE = AuthorityStaticItemId.DEC_MANAGEMENT_MOBILE_ID;
public static final String REGISTER = AuthorityStaticItemId.DEC_MANAGEMENT_REGISTER_ID;
public static final String PLUGIN = AuthorityStaticItemId.DEC_MANAGEMENT_PLUGIN_ID;
public static final String SECURITY = AuthorityStaticItemId.DEC_MANAGEMENT_SECURITY_ID;
public static final String TEMPLATE = AuthorityStaticItemId.DEC_MANAGEMENT_TEMPLATE_ID;
public static final String MAP = AuthorityStaticItemId.DEC_MANAGEMENT_MAP_ID;
public static final String MAINTENANCE = AuthorityStaticItemId.DEC_MANAGEMENT_MAINTENANCE_ID;
}
/**
* 给部门职位设置人员管理权限
*
* @param depostId 部门职位id
* @param authValue 接受/拒绝
* @param authId 实体id
* @param authType 权限类型
* @throws Exception 异常
*/
public static void setDepAuth(String depostId, int authValue, String authId, int authType) throws Exception {
DepRole depRole = WebServiceUtils.parseUniqueDepartmentPostId(depostId);
AuthorityContext.getInstance().getAuthorityController(GradeAuthorityController.class).setDepAuthorityValue(
depRole.getDepartmentId(),
depRole.getPostId(),
AuthorityValue.fromInteger(authValue),
authId,
AuthorityType.fromInteger(authType));
}
/**
* 给用户设置人员管理权限
*
* @param userId 用户id
* @param authValue 接受/拒绝
* @param authId 实体id
* @param authType 权限类型
* @throws Exception 异常
*/
public static void setUserAuth(String userId, int authValue, String authId, int authType) throws Exception {
AuthorityContext.getInstance().getAuthorityController(GradeAuthorityController.class).setUserAuthorityValue(
userId,
AuthorityValue.fromInteger(authValue),
authId,
AuthorityType.fromInteger(authType));
}
/**
* 给角色设置人员管理权限
*
* @param roleId 角色id
* @param authValue 接受/拒绝
* @param authId 实体id
* @param authType 权限类型
* @throws Exception 异常
*/
public static void setCustomRoleAuth(String roleId, int authValue, String authId, int authType) throws Exception {
AuthorityContext.getInstance().getAuthorityController(GradeAuthorityController.class).setCustomAuthorityValue(
roleId,
AuthorityValue.fromInteger(authValue),
authId,
AuthorityType.fromInteger(authType));
}
}