Browse Source

新增接口获取用户所在分部,如果是管理员,获取所有分部

zouxuan 4 years ago
parent
commit
94ef7eff20

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OrganizationService.java

@@ -25,6 +25,12 @@ public interface OrganizationService extends BaseService<Integer, Organization>
     List<Organization> queryEmployeeOrgan() throws Exception;
     List<Organization> queryEmployeeOrgan() throws Exception;
 
 
     /**
     /**
+     * 获取员工坐在分部列表
+     * @return
+     */
+    List<Organization> queryEmployeeOrganByUser() throws Exception;
+
+    /**
      * 获取分部名称
      * 获取分部名称
      * @return
      * @return
      */
      */

+ 14 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrganizationServiceImpl.java

@@ -42,7 +42,7 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 	}
 	}
 
 
 	@Override
 	@Override
-	public List<Organization> queryEmployeeOrgan() throws Exception {
+	public List<Organization> queryEmployeeOrgan(){
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		if(sysUser == null){
 		if(sysUser == null){
 			throw new BizException("获取用户信息失败");
 			throw new BizException("获取用户信息失败");
@@ -52,6 +52,19 @@ public class OrganizationServiceImpl extends BaseServiceImpl<Integer, Organizati
 	}
 	}
 
 
 	@Override
 	@Override
+	public List<Organization> queryEmployeeOrganByUser(){
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if(sysUser == null){
+			throw new BizException("获取用户信息失败");
+		}
+		Integer userId = sysUser.getId();
+		if(sysUser.getIsSuperAdmin()){
+			userId = null;
+		}
+		return organizationDao.queryEmployeeOrgan(userId);
+	}
+
+	@Override
 	public String getOrganName(String organId) {
 	public String getOrganName(String organId) {
 		return organizationDao.getOrganName(organId);
 		return organizationDao.getOrganName(organId);
 	}
 	}

+ 7 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OrganizationController.java

@@ -45,6 +45,13 @@ public class OrganizationController extends BaseController {
         return succeed(organizationService.queryEmployeeOrgan());
         return succeed(organizationService.queryEmployeeOrgan());
     }
     }
 
 
+    @ApiOperation(value = "获取员工所在分部列表(管理员查看所有的分部)")
+    @GetMapping("/queryEmployeeOrganByUser")
+    @PreAuthorize("@pcs.hasPermissions('organization/queryEmployeeOrganByUser')")
+    public Object queryEmployeeOrganByUser() throws Exception {
+        return succeed(organizationService.queryEmployeeOrganByUser());
+    }
+
     @ApiOperation(value = "新增分部")
     @ApiOperation(value = "新增分部")
     @PostMapping("/add")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('organization/add')")
     @PreAuthorize("@pcs.hasPermissions('organization/add')")