From 927780db46c1b2b33eaa5f931b659fc5c48fb3bc Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Tue, 8 Sep 2026 11:19:06 +0800 Subject: [PATCH] fix(governance): exclude hidden skills from owner list Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- .../iflytek/skillhub/service/MySkillAppService.java | 2 +- .../skillhub/service/MySkillAppServiceTest.java | 10 +++++----- .../iflytek/skillhub/domain/skill/SkillRepository.java | 2 +- .../skillhub/infra/jpa/JpaSkillRepositoryAdapter.java | 4 ++-- .../iflytek/skillhub/infra/jpa/SkillJpaRepository.java | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/MySkillAppService.java b/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/MySkillAppService.java index 5d69b9d9..5541ace7 100644 --- a/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/MySkillAppService.java +++ b/server/skillhub-app/src/main/java/com/iflytek/skillhub/service/MySkillAppService.java @@ -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); } diff --git a/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/MySkillAppServiceTest.java b/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/MySkillAppServiceTest.java index acd58494..8316af4b 100644 --- a/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/MySkillAppServiceTest.java +++ b/server/skillhub-app/src/test/java/com/iflytek/skillhub/service/MySkillAppServiceTest.java @@ -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)); diff --git a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill/SkillRepository.java b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill/SkillRepository.java index a6d4c760..a22a5371 100644 --- a/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill/SkillRepository.java +++ b/server/skillhub-domain/src/main/java/com/iflytek/skillhub/domain/skill/SkillRepository.java @@ -21,7 +21,7 @@ public interface SkillRepository { void flush(); void delete(Skill skill); List findByOwnerId(String ownerId); - Page findByOwnerId(String ownerId, Pageable pageable); + Page findVisibleByOwnerId(String ownerId, Pageable pageable); List findByHiddenTrue(); Page findByHiddenTrue(Pageable pageable); void incrementDownloadCount(Long skillId); diff --git a/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/JpaSkillRepositoryAdapter.java b/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/JpaSkillRepositoryAdapter.java index f1502007..1452d89b 100644 --- a/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/JpaSkillRepositoryAdapter.java +++ b/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/JpaSkillRepositoryAdapter.java @@ -83,8 +83,8 @@ public class JpaSkillRepositoryAdapter implements SkillRepository { } @Override - public Page findByOwnerId(String ownerId, Pageable pageable) { - return delegate.findByOwnerId(ownerId, pageable); + public Page findVisibleByOwnerId(String ownerId, Pageable pageable) { + return delegate.findVisibleByOwnerId(ownerId, pageable); } @Override diff --git a/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillJpaRepository.java b/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillJpaRepository.java index 18e97fa0..33e7aa49 100644 --- a/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillJpaRepository.java +++ b/server/skillhub-infra/src/main/java/com/iflytek/skillhub/infra/jpa/SkillJpaRepository.java @@ -33,13 +33,13 @@ public interface SkillJpaRepository extends JpaRepository, SkillRep List findByNamespaceIdAndStatusOrderByCreatedAtDesc(Long namespaceId, SkillStatus status); Page findByNamespaceIdAndStatus(Long namespaceId, SkillStatus status, Pageable pageable); List findByOwnerId(String ownerId); - Page findByOwnerIdOrderByUpdatedAtDesc(String ownerId, Pageable pageable); + Page findByOwnerIdAndHiddenFalseOrderByUpdatedAtDesc(String ownerId, Pageable pageable); List findByHiddenTrueOrderByUpdatedAtDesc(); Page findByHiddenTrueOrderByUpdatedAtDesc(Pageable pageable); @Override - default Page findByOwnerId(String ownerId, Pageable pageable) { - return findByOwnerIdOrderByUpdatedAtDesc(ownerId, pageable); + default Page findVisibleByOwnerId(String ownerId, Pageable pageable) { + return findByOwnerIdAndHiddenFalseOrderByUpdatedAtDesc(ownerId, pageable); } @Override