wangwei 7 years ago
parent
commit
f98354db5e

+ 24 - 0
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/OrgController.java

@@ -36,6 +36,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
+import com.google.common.collect.Lists;
+
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
 import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
@@ -275,4 +277,26 @@ public class OrgController extends ControllerSupport {
 		return list;
 	}
 
+	/**
+	 * 修改请通知作者
+	 *
+	 * @author WANGWEI
+	 * @param parentId
+	 * @param orgName
+	 * @return
+	 */
+	@ApiOperation(value = "按机构名称模糊查询子机构列表")
+	@PostMapping("getSubOrgListByNameLike/{parentId}")
+	public List<Org> getSubOrgListByNameLike(@PathVariable Long parentId,
+			@RequestParam String orgName) {
+		List<Org> list = null;
+		if (StringUtils.isBlank(orgName)) {
+			list = Lists.newArrayList();
+			return list;
+		}
+		orgName = "%" + orgName + "%";
+		list = orgRepo.findByParentIdAndNameLikeAndEnable(parentId, orgName, true);
+		return list;
+	}
+
 }

+ 2 - 1
examcloud-core-basic-api-provider/src/main/java/cn/com/qmth/examcloud/core/basic/api/controller/UserController.java

@@ -113,6 +113,7 @@ public class UserController extends ControllerSupport {
 			bean.setLoginName(next.getLoginName());
 			bean.setName(next.getName());
 			bean.setRootOrgId(next.getRootOrgId());
+			bean.setOrgId(next.getOrgId());
 			bean.setEnable(next.getEnable());
 
 			List<UserRole> userRoles = next.getUserRoles();
@@ -235,7 +236,7 @@ public class UserController extends ControllerSupport {
 		userEntity.setLoginName(userForm.getLoginName());
 		userEntity.setMobile(userForm.getMobile());
 		userEntity.setName(userForm.getName());
-		userEntity.setOrgId(rootOrgId);
+		userEntity.setOrgId(userForm.getOrgId());
 		userEntity.setRootOrgId(rootOrgId);
 		userEntity.setPassword(userForm.getPassword());
 		userEntity.setScope(UserScope.ORG);

+ 24 - 19
examcloud-core-basic-dao/src/main/java/cn/com/qmth/examcloud/core/basic/dao/OrgRepo.java

@@ -13,30 +13,35 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
 /**
  * Created by songyue on 17/1/13.
  */
-public interface OrgRepo extends JpaRepository<Org,Long>,QueryByExampleExecutor<Org> , JpaSpecificationExecutor<Org>{
+public interface OrgRepo
+		extends
+			JpaRepository<Org, Long>,
+			QueryByExampleExecutor<Org>,
+			JpaSpecificationExecutor<Org> {
+
+	List<Org> findByRootId(Long rootId);
 
-    List<Org> findByRootId(Long rootId);
-    
 	List<Org> findByRootIdAndNameLike(long rootId, String name);
 
-    List<Org> findById(Long id);
+	List<Org> findByParentIdAndNameLikeAndEnable(long parentId, String name, Boolean enable);
 
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId")
-    List<Org> findBothByParentId(@Param("parentId") long parentId);
+	List<Org> findById(Long id);
 
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and enable = 1")
-    List<Org> findByParentId(@Param("parentId") Long parentId);
+	@Query(nativeQuery = true, value = "select *from ecs_core_org where parent_id=:parentId")
+	List<Org> findBothByParentId(@Param("parentId") long parentId);
 
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type = \"SCHOOL\"")
-    List<Org> findAllSchoolByParentId(@Param("parentId") long parentId);
-    
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type in (\"PRINT_QMTH\",\"PRINT_SUPPLIER\")")
-    List<Org> findAllPrintByParentId(@Param("parentId") long parentId);
+	@Query(nativeQuery = true, value = "select *from ecs_core_org where parent_id=:parentId and enable = 1")
+	List<Org> findByParentId(@Param("parentId") Long parentId);
 
-    @Query(nativeQuery = true,value = "select *from ecs_core_org where parent_id=:parentId and code=:code and enable = 1")
-	Org findFirstByParentIdAndCode(@Param("parentId") Long parentId, @Param("code")String code);
-    
-    @Query(nativeQuery = true,value = "select * from ecs_core_org t where t.parent_id = 0 and t.enable = 1 order by t.id")
-    List<Org> findAllParentOrg();
-}
+	@Query(nativeQuery = true, value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type = \"SCHOOL\"")
+	List<Org> findAllSchoolByParentId(@Param("parentId") long parentId);
+
+	@Query(nativeQuery = true, value = "select *from ecs_core_org where (id=:parentId or parent_id=:parentId) and enable = 1 and type in (\"PRINT_QMTH\",\"PRINT_SUPPLIER\")")
+	List<Org> findAllPrintByParentId(@Param("parentId") long parentId);
 
+	@Query(nativeQuery = true, value = "select *from ecs_core_org where parent_id=:parentId and code=:code and enable = 1")
+	Org findFirstByParentIdAndCode(@Param("parentId") Long parentId, @Param("code") String code);
+
+	@Query(nativeQuery = true, value = "select * from ecs_core_org t where t.parent_id = 0 and t.enable = 1 order by t.id")
+	List<Org> findAllParentOrg();
+}