fix(governance): exclude hidden skills from owner list

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
XiaoSeS 2026-09-08 11:19:06 +08:00
parent 5c5634dd22
commit 927780db46
5 changed files with 12 additions and 12 deletions

View file

@ -84,7 +84,7 @@ public class MySkillAppService {
} else if (normalizedFilter == MySkillFilter.ALL
&& (keyword == null || keyword.isBlank())
&& (namespace == null || namespace.isBlank())) {
skillPage = skillRepository.findByOwnerId(userId, PageRequest.of(page, size));
skillPage = skillRepository.findVisibleByOwnerId(userId, PageRequest.of(page, size));
} else {
skillPage = filterSkills(userId, page, size, normalizedFilter, keyword, namespace, platformRoles);
}

View file

@ -132,7 +132,7 @@ class MySkillAppServiceTest {
ReflectionTestUtils.setField(pendingVersion, "id", 11L);
ReflectionTestUtils.setField(pendingVersion, "createdAt", Instant.parse("2026-03-15T09:30:00Z"));
given(skillRepository.findByOwnerId("user-1", PageRequest.of(0, 10)))
given(skillRepository.findVisibleByOwnerId("user-1", PageRequest.of(0, 10)))
.willReturn(new PageImpl<>(List.of(skill), PageRequest.of(0, 10), 1));
given(skillVersionRepository.findBySkillIdAndStatus(1L, SkillVersionStatus.PUBLISHED)).willReturn(List.of());
given(skillVersionRepository.findBySkillId(1L)).willReturn(List.of(pendingVersion));
@ -165,7 +165,7 @@ class MySkillAppServiceTest {
Namespace namespace = new Namespace("team-ai", "Team AI", "user-1");
ReflectionTestUtils.setField(namespace, "id", 101L);
given(skillRepository.findByOwnerId("user-1", PageRequest.of(0, 10)))
given(skillRepository.findVisibleByOwnerId("user-1", PageRequest.of(0, 10)))
.willReturn(new PageImpl<>(List.of(skill), PageRequest.of(0, 10), 1));
given(skillVersionRepository.findBySkillIdAndStatus(2L, SkillVersionStatus.PUBLISHED)).willReturn(List.of(publishedVersion));
given(skillVersionRepository.findBySkillId(2L)).willReturn(List.of(publishedVersion));
@ -197,7 +197,7 @@ class MySkillAppServiceTest {
Namespace namespace = new Namespace("team-ai", "Team AI", "user-1");
ReflectionTestUtils.setField(namespace, "id", 101L);
given(skillRepository.findByOwnerId("user-1", PageRequest.of(0, 10)))
given(skillRepository.findVisibleByOwnerId("user-1", PageRequest.of(0, 10)))
.willReturn(new PageImpl<>(List.of(skill), PageRequest.of(0, 10), 1));
given(skillVersionRepository.findBySkillIdAndStatus(2L, SkillVersionStatus.PUBLISHED)).willReturn(List.of(publishedVersion));
given(skillVersionRepository.findBySkillId(2L)).willReturn(List.of(publishedVersion));
@ -259,7 +259,7 @@ class MySkillAppServiceTest {
Skill skill = createSkill(5L, 101L, "rejected-skill", "user-1");
SkillVersion rejectedVersion = createVersion(5L, 55L, "1.1.0", SkillVersionStatus.REJECTED, "2026-03-15T09:30:00Z");
given(skillRepository.findByOwnerId("user-1", PageRequest.of(0, 10)))
given(skillRepository.findVisibleByOwnerId("user-1", PageRequest.of(0, 10)))
.willReturn(new PageImpl<>(List.of(skill), PageRequest.of(0, 10), 1));
given(skillVersionRepository.findBySkillId(5L)).willReturn(List.of(rejectedVersion));
given(namespaceRepository.findByIdIn(List.of(101L))).willReturn(List.of(namespace(101L, "team-ai")));
@ -278,7 +278,7 @@ class MySkillAppServiceTest {
SkillVersion rejectedVersion = createVersion(6L, 60L, "1.0.0", SkillVersionStatus.REJECTED, "2026-03-15T09:30:00Z");
SkillVersion publishedVersion = createVersion(6L, 61L, "2.0.0", SkillVersionStatus.PUBLISHED, "2026-03-16T09:30:00Z");
given(skillRepository.findByOwnerId("user-1", PageRequest.of(0, 10)))
given(skillRepository.findVisibleByOwnerId("user-1", PageRequest.of(0, 10)))
.willReturn(new PageImpl<>(List.of(skill), PageRequest.of(0, 10), 1));
given(skillVersionRepository.findBySkillIdAndStatus(6L, SkillVersionStatus.PUBLISHED)).willReturn(List.of(publishedVersion));
given(skillVersionRepository.findBySkillId(6L)).willReturn(List.of(rejectedVersion, publishedVersion));

View file

@ -21,7 +21,7 @@ public interface SkillRepository {
void flush();
void delete(Skill skill);
List<Skill> findByOwnerId(String ownerId);
Page<Skill> findByOwnerId(String ownerId, Pageable pageable);
Page<Skill> findVisibleByOwnerId(String ownerId, Pageable pageable);
List<Skill> findByHiddenTrue();
Page<Skill> findByHiddenTrue(Pageable pageable);
void incrementDownloadCount(Long skillId);

View file

@ -83,8 +83,8 @@ public class JpaSkillRepositoryAdapter implements SkillRepository {
}
@Override
public Page<Skill> findByOwnerId(String ownerId, Pageable pageable) {
return delegate.findByOwnerId(ownerId, pageable);
public Page<Skill> findVisibleByOwnerId(String ownerId, Pageable pageable) {
return delegate.findVisibleByOwnerId(ownerId, pageable);
}
@Override

View file

@ -33,13 +33,13 @@ public interface SkillJpaRepository extends JpaRepository<Skill, Long>, SkillRep
List<Skill> findByNamespaceIdAndStatusOrderByCreatedAtDesc(Long namespaceId, SkillStatus status);
Page<Skill> findByNamespaceIdAndStatus(Long namespaceId, SkillStatus status, Pageable pageable);
List<Skill> findByOwnerId(String ownerId);
Page<Skill> findByOwnerIdOrderByUpdatedAtDesc(String ownerId, Pageable pageable);
Page<Skill> findByOwnerIdAndHiddenFalseOrderByUpdatedAtDesc(String ownerId, Pageable pageable);
List<Skill> findByHiddenTrueOrderByUpdatedAtDesc();
Page<Skill> findByHiddenTrueOrderByUpdatedAtDesc(Pageable pageable);
@Override
default Page<Skill> findByOwnerId(String ownerId, Pageable pageable) {
return findByOwnerIdOrderByUpdatedAtDesc(ownerId, pageable);
default Page<Skill> findVisibleByOwnerId(String ownerId, Pageable pageable) {
return findByOwnerIdAndHiddenFalseOrderByUpdatedAtDesc(ownerId, pageable);
}
@Override