forked from fanruan/finekit
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.
39 lines
1.3 KiB
39 lines
1.3 KiB
package com.fanruan.api.decision; |
|
|
|
import com.fanruan.api.decision.middle.ReadOnlyUser; |
|
import com.fr.decision.authority.data.User; |
|
import com.fr.decision.webservice.utils.UserSourceFactory; |
|
import com.fr.decision.webservice.utils.user.source.UserSource; |
|
import com.fr.decision.webservice.v10.user.UserService; |
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-09-19 |
|
*/ |
|
public class UserKit { |
|
|
|
/** |
|
* 根据用户名获取这个用户的来源 |
|
* |
|
* @param username 用户名 |
|
* @return 用户来源 |
|
* @throws Exception 如果在获取用户的过程中出错了,则抛出此异常 |
|
*/ |
|
public static UserSource fetchUserSource(String username) throws Exception { |
|
User user = UserService.getInstance().getUserByUserName(username); |
|
return UserSourceFactory.getInstance().getUserSource(user); |
|
} |
|
|
|
/** |
|
* 根据用户名获取用户信息 |
|
* |
|
* @param username 用户名 |
|
* @return 用户信息 |
|
* @throws Exception 如果获取用户出错,则抛出此异常 |
|
*/ |
|
public static ReadOnlyUser getReadOnlyUser(String username) throws Exception { |
|
User user = UserService.getInstance().getUserByUserName(username); |
|
return ReadOnlyUser.build(user.getUserName(), user.getPassword(), user.getRealName()); |
|
} |
|
}
|
|
|