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.
67 lines
2.0 KiB
67 lines
2.0 KiB
6 years ago
|
package com.fanruan.api.decision.user;
|
||
6 years ago
|
|
||
6 years ago
|
import com.fr.decision.authority.AuthorityContext;
|
||
6 years ago
|
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;
|
||
|
|
||
6 years ago
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
||
6 years ago
|
/**
|
||
|
* @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);
|
||
|
}
|
||
|
|
||
6 years ago
|
public static OpenUser getUserByRequest(HttpServletRequest req) throws Exception {
|
||
|
User user = UserService.getInstance().getUserByRequest(req);
|
||
|
return OpenUser.wrap(user);
|
||
|
}
|
||
|
|
||
6 years ago
|
/**
|
||
|
* 根据用户名获取用户信息
|
||
|
*
|
||
|
* @param username 用户名
|
||
|
* @return 用户信息
|
||
|
* @throws Exception 如果获取用户出错,则抛出此异常
|
||
|
*/
|
||
6 years ago
|
public static OpenUser getUser(String username) throws Exception {
|
||
6 years ago
|
User user = UserService.getInstance().getUserByUserName(username);
|
||
6 years ago
|
return OpenUser.wrap(user);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 更新一个用户信息
|
||
|
*
|
||
|
* @param user 用户
|
||
|
* @throws Exception 更新用户信息失败则抛出此异常
|
||
|
*/
|
||
|
public static void update(OpenUser user) throws Exception {
|
||
|
AuthorityContext.getInstance().getUserController().update(user.select());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 添加一个用户
|
||
|
*
|
||
|
* @param user 用户
|
||
|
* @throws Exception 添加用户失败则抛出此异常
|
||
|
*/
|
||
|
public static void add(OpenUser user) throws Exception {
|
||
|
AuthorityContext.getInstance().getUserController().update(user.select());
|
||
6 years ago
|
}
|
||
|
}
|