Browse Source

DEC-13003 角色批量设置插件finekit适配

master
zed 5 years ago
parent
commit
a308409036
  1. 6
      src/main/java/com/fanruan/api/cluster/state/BaseRedisCollectionConfig.java
  2. 62
      src/main/java/com/fanruan/api/decision/AuthorityKit.java
  3. 35
      src/main/java/com/fanruan/api/decision/role/CustomRoleKit.java
  4. 11
      src/main/java/com/fanruan/api/decision/user/UserKit.java

6
src/main/java/com/fanruan/api/cluster/state/BaseRedisCollectionConfig.java

@ -13,12 +13,12 @@ public class BaseRedisCollectionConfig extends RedisCollectionConfig {
public BaseRedisCollectionConfig(Codec codec, String host, int port) {
super(codec, host, port);
//super(codec, host, port);
}
public BaseRedisCollectionConfig(String host, int port, String password) {
super(host, port, password);
//super(host, port, password);
}
public BaseRedisCollectionConfig() {
@ -28,6 +28,6 @@ public class BaseRedisCollectionConfig extends RedisCollectionConfig {
public BaseRedisCollectionConfig(String host, int port) {
super(host, port);
//super(host, port);
}
}

62
src/main/java/com/fanruan/api/decision/AuthorityKit.java

@ -1,6 +1,12 @@
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
@ -42,4 +48,60 @@ public class AuthorityKit {
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));
}
}

35
src/main/java/com/fanruan/api/decision/role/CustomRoleKit.java

@ -0,0 +1,35 @@
package com.fanruan.api.decision.role;
import com.fr.decision.authority.data.CustomRole;
import com.fr.decision.webservice.utils.ControllerFactory;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* @author Zed
* @version 10.0
* Created by Zed on 2020/4/30
*/
public class CustomRoleKit {
/**
* 获取角色id
*
* @param userId 用户id
* @param keyword 搜索关键字
* @return 角色id
* @throws Exception 异常
*/
public static List<String> getCustomRoleIds(@NotNull String userId, String keyword) throws Exception {
List<String> result = new ArrayList<>();
CustomRole[] roles = ControllerFactory.getInstance().getCustomRoleController(userId).getAllCustomRoles(userId, keyword);
for (CustomRole role : roles) {
result.add(role.getId());
}
return result;
}
}

11
src/main/java/com/fanruan/api/decision/user/UserKit.java

@ -75,4 +75,15 @@ public class UserKit {
public static List<String> getUserNamesFromEmail(String email) throws Exception {
return UserService.getInstance().getUserNamesFromEmail(email);
}
/**
* 获取当前用户id
*
* @param request 请求体
* @return 用户id
* @throws Exception 异常
*/
public static String getCurrentUserId(HttpServletRequest request) throws Exception {
return UserService.getInstance().getCurrentUserId(request);
}
}

Loading…
Cancel
Save