forked from fanruan/finekit
6 changed files with 189 additions and 2 deletions
@ -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; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fanruan.api.decision; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.lang.reflect.Method; |
||||
|
||||
/** |
||||
* @author Zed |
||||
* @version 10.0 |
||||
* Created by Zed on 2020/4/30 |
||||
*/ |
||||
public class AuthorityKitTest { |
||||
|
||||
@Test |
||||
public void setAuth() throws Exception { |
||||
|
||||
Class<?> classBook = Class.forName("com.fanruan.api.decision.AuthorityKit"); |
||||
Assert.assertNotNull(classBook); |
||||
|
||||
Method method1 = classBook.getDeclaredMethod("setCustomRoleAuth", String.class, int.class, String.class, int.class); |
||||
Assert.assertNotNull(method1); |
||||
|
||||
Method method2 = classBook.getDeclaredMethod("setUserAuth", String.class, int.class, String.class, int.class); |
||||
Assert.assertNotNull(method2); |
||||
|
||||
Method method3 = classBook.getDeclaredMethod("setDepAuth", String.class, int.class, String.class, int.class); |
||||
Assert.assertNotNull(method3); |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fanruan.api.decision.role; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.lang.reflect.Method; |
||||
|
||||
/** |
||||
* @author Zed |
||||
* @version 10.0 |
||||
* Created by Zed on 2020/4/30 |
||||
*/ |
||||
public class CustomRoleKitTest { |
||||
|
||||
@Test |
||||
public void getCustomRoleIds() throws Exception { |
||||
|
||||
Class<?> classBook = Class.forName("com.fanruan.api.decision.role.CustomRoleKit"); |
||||
Assert.assertNotNull(classBook); |
||||
|
||||
Method method1 = classBook.getDeclaredMethod("getCustomRoleIds", String.class, String.class); |
||||
Assert.assertNotNull(method1); |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fanruan.api.decision.user; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.lang.reflect.Method; |
||||
|
||||
/** |
||||
* @author Zed |
||||
* @version 10.0 |
||||
* Created by Zed on 2020/4/30 |
||||
*/ |
||||
public class UserKitTest { |
||||
|
||||
@Test |
||||
public void getCurrentUserId() throws Exception { |
||||
|
||||
Class<?> classBook = Class.forName("com.fanruan.api.decision.user.UserKit"); |
||||
Assert.assertNotNull(classBook); |
||||
|
||||
Method method1 = classBook.getDeclaredMethod("getCurrentUserId", HttpServletRequest.class); |
||||
Assert.assertNotNull(method1); |
||||
} |
||||
} |
Loading…
Reference in new issue