|
@@ -42,7 +42,7 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Student;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccess;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.ThirdPartyAccessPK;
|
|
|
-import cn.com.qmth.examcloud.core.basic.dao.entity.User;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserLogin;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserOpsLog;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
|
|
@@ -103,8 +103,8 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param pageable
|
|
|
* @return
|
|
|
*/
|
|
|
- public Page<User> findAll(User userCriteria, Pageable pageable){
|
|
|
- Specification<User> userSpecification = (root, query, cb) -> {
|
|
|
+ public Page<UserEntity> findAll(UserEntity userCriteria, Pageable pageable){
|
|
|
+ Specification<UserEntity> userSpecification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
if(userCriteria.getType() != null){
|
|
|
predicates.add(cb.equal(root.get("type"),userCriteria.getType()));
|
|
@@ -124,7 +124,7 @@ public class UserServiceImpl implements UserService{
|
|
|
}
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
};
|
|
|
- List<User> users = userRepo.findAll(userSpecification);
|
|
|
+ List<UserEntity> users = userRepo.findAll(userSpecification);
|
|
|
int pageNumber = pageable.getPageNumber();
|
|
|
int pageSize = pageable.getPageSize();
|
|
|
users = users.stream()
|
|
@@ -135,7 +135,7 @@ public class UserServiceImpl implements UserService{
|
|
|
.skip(pageNumber * pageSize)
|
|
|
.limit(pageSize)
|
|
|
.collect(Collectors.toList());
|
|
|
- Page<User> userPage = new PageImpl<User>(users,pageable,total);
|
|
|
+ Page<UserEntity> userPage = new PageImpl<UserEntity>(users,pageable,total);
|
|
|
return userPage;
|
|
|
}
|
|
|
|
|
@@ -144,7 +144,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param user
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean filterNonMarkerUser(User user){
|
|
|
+ private boolean filterNonMarkerUser(UserEntity user){
|
|
|
List<UserRole> userRoles = user.getUserRoles();
|
|
|
if(userRoles != null){
|
|
|
if(userRoles.size() == 1 && userRoles.get(0).getRoleCode().equals(RoleMeta.MARKER.name())){
|
|
@@ -161,7 +161,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param user
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean filterAdminUser(User user){
|
|
|
+ private boolean filterAdminUser(UserEntity user){
|
|
|
List<UserRole> userRoles = user.getUserRoles();
|
|
|
if(userRoles != null){
|
|
|
for(UserRole userRole:userRoles){
|
|
@@ -183,8 +183,8 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param pageable
|
|
|
* @return
|
|
|
*/
|
|
|
- public Page<User> findOrgUser(User userCriteria,Pageable pageable){
|
|
|
- Specification<User> userSpecification = (root, query, cb) -> {
|
|
|
+ public Page<UserEntity> findOrgUser(UserEntity userCriteria,Pageable pageable){
|
|
|
+ Specification<UserEntity> userSpecification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
predicates.add(cb.equal(root.get("rootOrgId"),root.get("orgId")));
|
|
|
if(userCriteria.getType() != null){
|
|
@@ -204,7 +204,7 @@ public class UserServiceImpl implements UserService{
|
|
|
}
|
|
|
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
};
|
|
|
- List<User> users = userRepo.findAll(userSpecification);
|
|
|
+ List<UserEntity> users = userRepo.findAll(userSpecification);
|
|
|
int pageNumber = pageable.getPageNumber();
|
|
|
int pageSize = pageable.getPageSize();
|
|
|
users = users.stream()
|
|
@@ -215,7 +215,7 @@ public class UserServiceImpl implements UserService{
|
|
|
.skip(pageNumber * pageSize)
|
|
|
.limit(pageSize)
|
|
|
.collect(Collectors.toList());
|
|
|
- Page<User> userPage = new PageImpl<User>(users,pageable,total);
|
|
|
+ Page<UserEntity> userPage = new PageImpl<UserEntity>(users,pageable,total);
|
|
|
return userPage;
|
|
|
}
|
|
|
|
|
@@ -224,7 +224,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param userId
|
|
|
*/
|
|
|
public void initPassword(long userId){
|
|
|
- User user = userRepo.findOne(userId);
|
|
|
+ UserEntity user = userRepo.findOne(userId);
|
|
|
//根据用户类型采用不同的初始化策略
|
|
|
if(user.getType() == UserType.NOT_STUDENT){
|
|
|
//初始化为默认密码
|
|
@@ -253,7 +253,7 @@ public class UserServiceImpl implements UserService{
|
|
|
*/
|
|
|
public UserInfo login(String loginName,
|
|
|
String password)throws Exception{
|
|
|
- User user = userRepo.findByLoginName(loginName);
|
|
|
+ UserEntity user = userRepo.findByLoginName(loginName);
|
|
|
if (user == null) {
|
|
|
throw new RuntimeException("该用户不存在");
|
|
|
} else if (!user.getEnable()) {
|
|
@@ -273,7 +273,7 @@ public class UserServiceImpl implements UserService{
|
|
|
public UserInfo login(long orgId,
|
|
|
String loginName,
|
|
|
String password)throws Exception{
|
|
|
- User user = userRepo.findByRootOrgIdAndLoginName(orgId,loginName);
|
|
|
+ UserEntity user = userRepo.findByRootOrgIdAndLoginName(orgId,loginName);
|
|
|
if (user == null) {
|
|
|
throw new RuntimeException("该用户不存在");
|
|
|
} else if (!user.getEnable()) {
|
|
@@ -288,7 +288,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param user
|
|
|
* @return
|
|
|
*/
|
|
|
- public UserInfo loginProcess(User user) throws Exception {
|
|
|
+ public UserInfo loginProcess(UserEntity user) throws Exception {
|
|
|
LoginInfo loginInfo=new LoginInfo();
|
|
|
loginInfo.setAccountType(AccountType.COMMON_LOGIN_NAME.getCode());
|
|
|
loginInfo.setAccountValue(user.getLoginName());
|
|
@@ -339,7 +339,7 @@ public class UserServiceImpl implements UserService{
|
|
|
throw new RuntimeException("第三方系统接入鉴权失败: token校验失败!");
|
|
|
}
|
|
|
|
|
|
- User user = userRepo.findByRootOrgIdAndLoginName(orgId, userid);
|
|
|
+ UserEntity user = userRepo.findByRootOrgIdAndLoginName(orgId, userid);
|
|
|
if (user == null) {
|
|
|
throw new RuntimeException("该用户不存在!");
|
|
|
}
|
|
@@ -352,7 +352,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param user
|
|
|
*/
|
|
|
@Deprecated
|
|
|
- public void initUserLogin(User user){
|
|
|
+ public void initUserLogin(UserEntity user){
|
|
|
//判断是否已登录,若已登录则强制已登录用户退出
|
|
|
UserLogin userLogin= userLoginRepo.findFirstByUserId(user.getId());
|
|
|
if(userLogin != null){
|
|
@@ -366,7 +366,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param user
|
|
|
* @param action
|
|
|
*/
|
|
|
- public void createUserOpsLog(User user,String action){
|
|
|
+ public void createUserOpsLog(UserEntity user,String action){
|
|
|
UserOpsLog userOpsLog = new UserOpsLog(action,user.getId(),user.getName(),new Date());
|
|
|
userOpsLogRepo.save(userOpsLog);
|
|
|
}
|
|
@@ -377,7 +377,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param user
|
|
|
*/
|
|
|
@Deprecated
|
|
|
- public void createUserLogin(String token,User user){
|
|
|
+ public void createUserLogin(String token,UserEntity user){
|
|
|
UserLogin userLogin = new UserLogin();
|
|
|
userLogin.setLoginTime(new Date());
|
|
|
userLogin.setUserId(user.getId());
|
|
@@ -391,7 +391,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param user
|
|
|
*/
|
|
|
@Deprecated
|
|
|
- public void createAccessUser(String token,User user,Long studentId)throws Exception{
|
|
|
+ public void createAccessUser(String token,UserEntity user,Long studentId)throws Exception{
|
|
|
AccessUser accessUser = new AccessUser();
|
|
|
Set<UserRole> userRoleSet = new HashSet<UserRole>(user.getUserRoles());
|
|
|
Org org = orgService.findOne(user.getRootOrgId());
|
|
@@ -418,7 +418,7 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param token
|
|
|
* @return
|
|
|
*/
|
|
|
- public UserInfo getUserInfo(User user,String token)throws Exception{
|
|
|
+ public UserInfo getUserInfo(UserEntity user,String token)throws Exception{
|
|
|
UserInfo userInfo = new UserInfo();
|
|
|
Org org = orgService.findOne(user.getOrgId());
|
|
|
Org rootOrg = orgService.findOne(user.getRootOrgId());
|
|
@@ -465,7 +465,7 @@ public class UserServiceImpl implements UserService{
|
|
|
userLoginRepo.deleteByUserId(accessUser.getUserId());
|
|
|
}
|
|
|
|
|
|
- public List<User> getMarker(Long rootOrgId) {
|
|
|
+ public List<UserEntity> getMarker(Long rootOrgId) {
|
|
|
return userRepo.findMarkerByRootOrgId(rootOrgId);
|
|
|
}
|
|
|
|
|
@@ -475,13 +475,13 @@ public class UserServiceImpl implements UserService{
|
|
|
* @param pageable
|
|
|
* @return
|
|
|
*/
|
|
|
- public Page<User> getAllMaker(User user,Pageable pageable){
|
|
|
- Specification<User> specification = getSpecification(user);
|
|
|
+ public Page<UserEntity> getAllMaker(UserEntity user,Pageable pageable){
|
|
|
+ Specification<UserEntity> specification = getSpecification(user);
|
|
|
return userRepo.findAll(specification,pageable);
|
|
|
}
|
|
|
|
|
|
- public Specification<User> getSpecification(User user){
|
|
|
- Specification<User> specification = (root, query, cb) -> {
|
|
|
+ public Specification<UserEntity> getSpecification(UserEntity user){
|
|
|
+ Specification<UserEntity> specification = (root, query, cb) -> {
|
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
|
predicates.add(cb.equal(root.get("type"),UserType.NOT_STUDENT));
|
|
|
predicates.add(cb.equal(root.get("rootOrgId"),user.getRootOrgId()));
|
|
@@ -501,7 +501,7 @@ public class UserServiceImpl implements UserService{
|
|
|
return specification;
|
|
|
}
|
|
|
|
|
|
- public User save(User user) throws Exception{
|
|
|
+ public UserEntity save(UserEntity user) throws Exception{
|
|
|
user.setScope(UserScope.ORG);
|
|
|
user.setCreateTime(new Date());
|
|
|
checkLoginName(user.getRootOrgId(), user.getLoginName());
|
|
@@ -509,7 +509,7 @@ public class UserServiceImpl implements UserService{
|
|
|
}
|
|
|
|
|
|
private void checkLoginName(Long rootOrgId,String loginName) {
|
|
|
- User old = userRepo.findByRootOrgIdAndLoginName(rootOrgId,loginName);
|
|
|
+ UserEntity old = userRepo.findByRootOrgIdAndLoginName(rootOrgId,loginName);
|
|
|
if(old!=null){
|
|
|
throw new RuntimeException("用户名已存在");
|
|
|
}else if("admin".equalsIgnoreCase(loginName)){
|
|
@@ -517,8 +517,8 @@ public class UserServiceImpl implements UserService{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public User update(Long id, User user) {
|
|
|
- User old = userRepo.findOne(id);
|
|
|
+ public UserEntity update(Long id, UserEntity user) {
|
|
|
+ UserEntity old = userRepo.findOne(id);
|
|
|
if(!old.getLoginName().equals(user.getLoginName())){
|
|
|
checkLoginName(user.getRootOrgId(), user.getLoginName());
|
|
|
}
|
|
@@ -526,12 +526,12 @@ public class UserServiceImpl implements UserService{
|
|
|
return userRepo.save(user);
|
|
|
}
|
|
|
|
|
|
- public User saveMarker(Long rootOrgId, String loginName,String name) {
|
|
|
- User old = userRepo.findByRootOrgIdAndLoginName(rootOrgId,loginName);
|
|
|
+ public UserEntity saveMarker(Long rootOrgId, String loginName,String name) {
|
|
|
+ UserEntity old = userRepo.findByRootOrgIdAndLoginName(rootOrgId,loginName);
|
|
|
if(old!=null){
|
|
|
return old;
|
|
|
}
|
|
|
- User user = new User();
|
|
|
+ UserEntity user = new UserEntity();
|
|
|
user.setName(name);
|
|
|
user.setLoginName(loginName);
|
|
|
user.setEnable(true);
|
|
@@ -549,8 +549,8 @@ public class UserServiceImpl implements UserService{
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public User getUser(Long rootOrgId, String loginName) {
|
|
|
- User user = userRepo.findByRootOrgIdAndLoginName(rootOrgId,loginName);
|
|
|
+ public UserEntity getUser(Long rootOrgId, String loginName) {
|
|
|
+ UserEntity user = userRepo.findByRootOrgIdAndLoginName(rootOrgId,loginName);
|
|
|
return user;
|
|
|
}
|
|
|
|