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.
106 lines
2.7 KiB
106 lines
2.7 KiB
3 years ago
|
package com.fr.plugin.sso.utils;
|
||
|
|
||
|
import com.fr.decision.authority.data.User;
|
||
|
import com.fr.decision.webservice.bean.user.UserBean;
|
||
|
import com.fr.decision.webservice.bean.user.UserUpdateBean;
|
||
|
import com.fr.decision.webservice.v10.login.LoginService;
|
||
|
import com.fr.decision.webservice.v10.user.UserService;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
||
|
public class FRUserUtils {
|
||
|
|
||
|
/**
|
||
|
* 获取用户Service
|
||
|
* @return
|
||
|
*/
|
||
|
public static UserService getUserService(){
|
||
|
return UserService.getInstance();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 添加用户
|
||
|
* @param userBean
|
||
|
*/
|
||
|
public static void addUser(UserBean userBean){
|
||
|
try {
|
||
|
getUserService().addUser(userBean);
|
||
|
} catch (Exception e) {
|
||
|
FRUtils.FRLogInfo("addUser:exception:"+e.getMessage());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 删除用户
|
||
|
* @param userBean
|
||
|
*/
|
||
|
public static void updateUser(UserBean userBean){
|
||
|
try {
|
||
|
getUserService().editUser(userBean);
|
||
|
} catch (Exception e) {
|
||
|
FRUtils.FRLogInfo("updateUser:exception:"+e.getMessage());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 删除用户
|
||
|
* @param user
|
||
|
* @return
|
||
|
*/
|
||
|
public static int deleteUser(User user){
|
||
|
String userId = user.getId();
|
||
|
|
||
|
UserUpdateBean userUpdateBean = new UserUpdateBean();
|
||
|
userUpdateBean.setRemoveUserIds(new String[]{userId});
|
||
|
|
||
|
try {
|
||
|
return getUserService().deleteUsers(userUpdateBean);
|
||
|
} catch (Exception e) {
|
||
|
FRUtils.FRLogInfo("deleteUser:exception:"+e.getMessage());
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据用户名获取用户实体
|
||
|
* @param userName
|
||
|
* @return
|
||
|
*/
|
||
|
public static User getUserByUserName(String userName){
|
||
|
try {
|
||
|
return getUserService().getUserByUserName(userName);
|
||
|
} catch (Exception e) {
|
||
|
FRUtils.FRLogInfo("获取用户信息异常:"+e.getMessage());
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 判断是否是管理员
|
||
|
* @param userId
|
||
|
* @return
|
||
|
*/
|
||
|
public static boolean isAdmin(String userId){
|
||
|
return UserService.getInstance().isAdmin(userId);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 验证密码是否正确
|
||
|
* @param psd 明文密码
|
||
|
* @param user 根据用户名获取得用户对象
|
||
|
* @return
|
||
|
*/
|
||
|
// public static boolean checkPsd(String psd,User user){
|
||
|
// String shaPsd = CipherUtils.jdksha256(psd);
|
||
|
//
|
||
|
// return shaPsd.equals(user.getPassword());
|
||
|
// }
|
||
|
|
||
|
public static void getCurrentUser(HttpServletRequest httpServletRequest){
|
||
|
// LoginService.getInstance().getCurrentUserNameFromRequest(user)
|
||
|
// UserService.getInstance().getC
|
||
|
}
|
||
|
}
|