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.
111 lines
2.9 KiB
111 lines
2.9 KiB
package com.fr.plugin.sso.utils; |
|
|
|
import com.fr.decision.authority.data.User; |
|
import com.fr.decision.privilege.TransmissionTool; |
|
import com.fr.decision.webservice.bean.user.UserBean; |
|
import com.fr.decision.webservice.bean.user.UserUpdateBean; |
|
import com.fr.decision.webservice.v10.user.UserService; |
|
|
|
public class FRUserUtils { |
|
|
|
/** |
|
* 获取用户Service |
|
* @return |
|
*/ |
|
public static UserService getUserService(){ |
|
return UserService.getInstance(); |
|
} |
|
|
|
/** |
|
* 添加用户 |
|
* @param userBean |
|
*/ |
|
public static void addUser(UserBean userBean) throws Exception { |
|
userBean.setPassword(TransmissionTool.defaultEncrypt(userBean.getPassword())); |
|
getUserService().addUser(userBean); |
|
} |
|
|
|
/** |
|
* 删除用户 |
|
* @param userBean |
|
*/ |
|
public static void updateUser(UserBean userBean) throws Exception { |
|
getUserService().editUser(userBean); |
|
} |
|
|
|
/** |
|
* 删除用户 |
|
* @param user |
|
* @return |
|
*/ |
|
public static int deleteUser(User user) throws Exception { |
|
String userId = user.getId(); |
|
|
|
UserUpdateBean userUpdateBean = new UserUpdateBean(); |
|
userUpdateBean.setRemoveUserIds(new String[]{userId}); |
|
|
|
return getUserService().deleteUsers(userUpdateBean); |
|
} |
|
|
|
/** |
|
* 根据用户名获取用户实体 |
|
* @param userName |
|
* @return |
|
*/ |
|
public static User getUserByUserName(String userName) throws Exception { |
|
return getUserService().getUserByUserName(userName); |
|
} |
|
|
|
/** |
|
* 根据id获取用户 |
|
* @param id |
|
* @return |
|
* @throws Exception |
|
*/ |
|
public static UserBean getUser(String id) throws Exception { |
|
return getUserService().getUser(id); |
|
} |
|
|
|
/** |
|
* 判断是否是管理员 |
|
* @param userId |
|
* @return |
|
*/ |
|
public static boolean isAdmin(String userId){ |
|
return getUserService().isAdmin(userId); |
|
} |
|
|
|
/** |
|
* 禁用启用用户 |
|
* @param userId |
|
* @param state false 禁用 true 启用 |
|
* @throws Exception 异常说明失败 |
|
*/ |
|
public static void forbidUser(String userId,boolean state) throws Exception { |
|
getUserService().forbidUser(userId,state); |
|
} |
|
|
|
/** |
|
* 修改用户部门 |
|
* @param departmentId |
|
* @param postId |
|
* @param ud |
|
* @throws Exception |
|
*/ |
|
public static void updateDepartmentPostUsers(String departmentId, String postId, UserUpdateBean ud) throws Exception { |
|
getUserService().updateDepartmentPostUsers(departmentId,postId,ud); |
|
} |
|
|
|
|
|
// /** |
|
// * 验证密码是否正确 |
|
// * @param psd 明文密码 |
|
// * @param user 根据用户名获取得用户对象 |
|
// * @return |
|
// */ |
|
// public static boolean checkPsd(String psd,User user){ |
|
// String shaPsd = CipherUtils.jdksha256(psd); |
|
// |
|
// return shaPsd.equals(user.getPassword()); |
|
// } |
|
}
|
|
|