فهرست منبع

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-2/examcloud-core-basic

chenken 7 سال پیش
والد
کامیت
f46f39eac2

+ 10 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/service/core/api/OrgApi.java

@@ -36,6 +36,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
 import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
 import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
+import cn.com.qmth.examcloud.commons.web.security.bean.User;
 import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
@@ -296,4 +297,13 @@ public class OrgApi extends ControllerSupport{
 		}
 	}
 	
+	@ApiOperation(value = "按机构名称模糊查询机构列表", notes = "")
+	@PostMapping("getOrgListByNameLike")
+	public List<Org> getOrgListByNameLike(@RequestParam String orgName) {
+		User accessUser = getAccessUser();
+		orgName = "%" + orgName + "%";
+		List<Org> list = orgRepo.findByRootIdAndNameLike(accessUser.getRootOrgId(), orgName);
+		return list;
+	}
+	
 }

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/App.java

@@ -5,7 +5,7 @@ import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
  * 应用
@@ -16,7 +16,7 @@ import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
  */
 @Entity
 @Table(name = "EC_B_APP")
-public class App extends JpaEntitySupport {
+public class App extends JpaEntity {
 
 	private static final long serialVersionUID = -6288949236298877031L;
 

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/Privilege.java

@@ -7,7 +7,7 @@ import javax.persistence.Id;
 import javax.persistence.Table;
 
 import cn.com.qmth.examcloud.commons.web.helpers.tree.TreeNode;
-import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
  * 权限
@@ -18,7 +18,7 @@ import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
  */
 @Entity
 @Table(name = "EC_B_PRIVILEGE")
-public class Privilege extends JpaEntitySupport implements TreeNode {
+public class Privilege extends JpaEntity implements TreeNode {
 
 	private static final long serialVersionUID = -6288949236298877031L;
 

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/PrivilegeGroup.java

@@ -6,7 +6,7 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
  * 权限组
@@ -17,7 +17,7 @@ import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
  */
 @Entity
 @Table(name = "EC_B_PRIVILEGE_GROUP")
-public class PrivilegeGroup extends JpaEntitySupport {
+public class PrivilegeGroup extends JpaEntity {
 
 	private static final long serialVersionUID = -3654724059677675683L;
 

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/Role.java

@@ -6,7 +6,7 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
  * 角色
@@ -17,7 +17,7 @@ import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
  */
 @Entity
 @Table(name = "EC_B_ROLE")
-public class Role extends JpaEntitySupport {
+public class Role extends JpaEntity {
 
 	private static final long serialVersionUID = -2167420238674588632L;
 

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/RolePrivilegeRelation.java

@@ -5,7 +5,7 @@ import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.Table;
 
-import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
  * 角色权限关联
@@ -17,7 +17,7 @@ import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
 @Entity
 @Table(name = "EC_B_ROLE_PRIV_RELATION")
 @IdClass(RolePrivilegeRelationPK.class)
-public class RolePrivilegeRelation extends JpaEntitySupport {
+public class RolePrivilegeRelation extends JpaEntity {
 
 	private static final long serialVersionUID = 8849214483955278647L;
 

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/UserPrivilegeRelation.java

@@ -5,7 +5,7 @@ import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.Table;
 
-import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
  * 权限
@@ -17,7 +17,7 @@ import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
 @Entity
 @Table(name = "EC_B_USER_PRIV_RELATION")
 @IdClass(UserPrivilegeRelationPK.class)
-public class UserPrivilegeRelation extends JpaEntitySupport {
+public class UserPrivilegeRelation extends JpaEntity {
 
 	private static final long serialVersionUID = -2673489395106849624L;
 

+ 2 - 2
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/entity/UserRoleRelation.java

@@ -5,7 +5,7 @@ import javax.persistence.Id;
 import javax.persistence.IdClass;
 import javax.persistence.Table;
 
-import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
+import cn.com.qmth.examcloud.commons.web.jpa.JpaEntity;
 
 /**
  * 角色
@@ -17,7 +17,7 @@ import cn.com.qmth.examcloud.commons.web.support.JpaEntitySupport;
 @Entity
 @Table(name = "EC_B_USER_ROLE_RELATION")
 @IdClass(UserRoleRelationPK.class)
-public class UserRoleRelation extends JpaEntitySupport {
+public class UserRoleRelation extends JpaEntity {
 
 	private static final long serialVersionUID = 5623631699393069659L;
 

+ 28 - 19
examcloud-core-basic-service/src/main/java/cn/com/qmth/examcloud/core/basic/service/impl/UserServiceImpl.java

@@ -29,6 +29,7 @@ import cn.com.qmth.examcloud.commons.web.security.AccessUserOps;
 import cn.com.qmth.examcloud.commons.web.security.AccessUserOpsForRedis;
 import cn.com.qmth.examcloud.commons.web.security.entity.AccessUser;
 import cn.com.qmth.examcloud.commons.web.security.enums.RoleMeta;
+import cn.com.qmth.examcloud.core.basic.base.enums.AccountType;
 import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
 import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
 import cn.com.qmth.examcloud.core.basic.dao.ThirdPartyAccessDao;
@@ -47,7 +48,9 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.UserOpsLog;
 import cn.com.qmth.examcloud.core.basic.dao.entity.UserRole;
 import cn.com.qmth.examcloud.core.basic.dao.enums.UserScope;
 import cn.com.qmth.examcloud.core.basic.dao.enums.UserType;
+import cn.com.qmth.examcloud.core.basic.service.AuthService;
 import cn.com.qmth.examcloud.core.basic.service.UserService;
+import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
 import cn.com.qmth.examcloud.core.basic.service.bean.UserInfo;
 
 /**
@@ -82,6 +85,9 @@ public class UserServiceImpl  implements UserService{
     ThirdPartyAccessDao thirdPartyAccessDao;
 
     RedisTemplate redisTemplate;
+    
+	@Autowired
+	AuthService authService;
 
     AccessUserOps accessUserOps;
 
@@ -247,13 +253,11 @@ public class UserServiceImpl  implements UserService{
      */
     public UserInfo login(String loginName,
                           String password)throws Exception{
-        User user = userRepo.findByLoginName(loginName);
-        if(user == null){
-        	throw new RuntimeException("该用户不存在");
-        }else if(!user.getPassword().equals(password)){
-        	throw new RuntimeException("密码错误");
-        }else if(!user.getEnable()){
-            throw new RuntimeException("该用户被禁用");
+		User user = userRepo.findByLoginName(loginName);
+		if (user == null) {
+			throw new RuntimeException("该用户不存在");
+		} else if (!user.getEnable()) {
+			throw new RuntimeException("该用户被禁用");
 		}
 		return loginProcess(user);
 
@@ -270,27 +274,29 @@ public class UserServiceImpl  implements UserService{
                           String loginName,
                           String password)throws Exception{
         User user = userRepo.findByRootOrgIdAndLoginName(orgId,loginName);
-        if(user == null){
-        	throw new RuntimeException("该用户不存在");
-        }else if(!user.getPassword().equals(password)){
-        	throw new RuntimeException("密码错误");
-        }else if(!user.getEnable()){
-            throw new RuntimeException("该用户被禁用");
-        }
+		if (user == null) {
+			throw new RuntimeException("该用户不存在");
+		} else if (!user.getEnable()) {
+			throw new RuntimeException("该用户被禁用");
+		}
 		return loginProcess(user);
     }
 
     /**
      * 登录处理
+     * 重新定义 by wangwei 
      * @param user
      * @return
      */
 	public UserInfo loginProcess(User user) throws Exception {
-		String token = AccessCtrlUtil.buildToken();
-		initUserLogin(user);
-		createAccessUser(token, user, null);
-		createUserLogin(token, user);
-		return getUserInfo(user, token);
+		LoginInfo loginInfo=new LoginInfo();
+		loginInfo.setAccountType(AccountType.COMMON_LOGIN_NAME.getCode());
+		loginInfo.setAccountValue(user.getLoginName());
+		loginInfo.setPassword(user.getPassword());
+		loginInfo.setRootOrgId(String.valueOf(user.getRootOrgId()));
+		cn.com.qmth.examcloud.commons.web.security.bean.User loginUser = authService.login(loginInfo);
+		String userToken = loginUser.getUserToken();
+		return getUserInfo(user, userToken);
 	}
     
 	/**
@@ -345,6 +351,7 @@ public class UserServiceImpl  implements UserService{
      * 初始化用户登录
      * @param user
      */
+	@Deprecated
     public void initUserLogin(User user){
         //判断是否已登录,若已登录则强制已登录用户退出
         UserLogin userLogin= userLoginRepo.findFirstByUserId(user.getId());
@@ -369,6 +376,7 @@ public class UserServiceImpl  implements UserService{
      * @param token
      * @param user
      */
+    @Deprecated
     public void createUserLogin(String token,User user){
         UserLogin userLogin = new UserLogin();
         userLogin.setLoginTime(new Date());
@@ -382,6 +390,7 @@ public class UserServiceImpl  implements UserService{
      * @param token
      * @param user
      */
+    @Deprecated
     public void createAccessUser(String token,User user,Long studentId)throws Exception{
         AccessUser accessUser = new AccessUser();
         Set<UserRole> userRoleSet = new HashSet<UserRole>(user.getUserRoles());