Skip to content

Commit 7c56774

Browse files
committed
Update Org
1 parent b6ff7c7 commit 7c56774

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

FileService/.idea/.idea.FileService/.idea/workspace.xml

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

org-service/src/main/java/com/codecampus/organization/repository/OrganizationMemberRepository.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,23 @@ Page<OrganizationMember> findByScopeTypeAndScopeIdAndIsActiveIsTrue(
3838
ScopeType scopeType, String scopeId, Pageable pageable);
3939

4040
// Đếm số membership ACTIVE cấp Organization của user
41-
@Query("select count(m) from OrganizationMember m " +
42-
"where m.userId = :userId and m.scopeType = com.codecampus.constant.ScopeType.Organization " +
43-
"and m.isActive = true")
41+
@Query("""
42+
select count(m) from OrganizationMember m, Organization o
43+
where m.userId = :userId
44+
and m.scopeType = com.codecampus.constant.ScopeType.Organization
45+
and m.isActive = true
46+
and o.id = m.scopeId
47+
""")
4448
long countActiveOrganizations(@Param("userId") String userId);
4549

4650
// Lấy tất cả membership ACTIVE của user ở cấp Organization
47-
@Query("select m from OrganizationMember m " +
48-
"where m.userId = :userId and m.scopeType = com.codecampus.constant.ScopeType.Organization " +
49-
"and m.isActive = true")
51+
@Query("""
52+
select m from OrganizationMember m, Organization o
53+
where m.userId = :userId
54+
and m.scopeType = com.codecampus.constant.ScopeType.Organization
55+
and m.isActive = true
56+
and o.id = m.scopeId
57+
""")
5058
List<OrganizationMember> findActiveOrgsOfUser(@Param("userId") String userId);
5159

5260
// Lấy tất cả member ACTIVE của 1 org

org-service/src/main/java/com/codecampus/organization/service/MembershipService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public void addToOrg(
6565
String role,
6666
boolean active) {
6767

68-
6968
auth.ensureRoleAtLeastForOrg(orgId, OrgAuthorization.OrgRole.ADMIN);
7069

7170
List<OrganizationMember> actives =

0 commit comments

Comments
 (0)