@@ -84,10 +84,6 @@ type ShareService interface {
8484 // GetActiveNotePathsByVault 返回指定 vault 下所有有效分享的笔记路径列表
8585 GetActiveNotePathsByVault (ctx context.Context , uid int64 , vaultName string ) ([]string , error )
8686
87- // GetNoteShareChangesByVault returns share path changes since sinceMs for a vault
88- // GetNoteShareChangesByVault 返回指定 vault 下 sinceMs 之后的分享路径变更
89- GetNoteShareChangesByVault (ctx context.Context , uid int64 , vaultName string , sinceMs int64 ) (* dto.ShareChangesData , error )
90-
9187 // Shutdown shuts down the service and flushes remaining data
9288 // Shutdown 关闭服务并同步最后的数据
9389 Shutdown (ctx context.Context ) error
@@ -693,71 +689,6 @@ func (s *shareService) GetActiveNotePathsByVault(ctx context.Context, uid int64,
693689 return paths , nil
694690}
695691
696- // GetNoteShareChangesByVault 返回指定 vault 下 sinceMs 之后的分享路径变更(两步查询,避免跨库 JOIN)
697- // GetNoteShareChangesByVault returns note share path changes since sinceMs for a vault (two-step query, no cross-DB JOIN)
698- func (s * shareService ) GetNoteShareChangesByVault (ctx context.Context , uid int64 , vaultName string , sinceMs int64 ) (* dto.ShareChangesData , error ) {
699- // since=0 表示客户端无本地缓存,需要全量刷新 / since=0 means client has no cache, require full refresh
700- if sinceMs == 0 {
701- return & dto.ShareChangesData {
702- FullRefreshRequired : true ,
703- Added : []string {},
704- Removed : []string {},
705- LastTime : time .Now ().UnixMilli (),
706- }, nil
707- }
708-
709- vault , err := s .vaultRepo .GetByName (ctx , vaultName , uid )
710- if err != nil || vault == nil {
711- return nil , code .ErrorVaultNotFound
712- }
713-
714- since := time .UnixMilli (sinceMs )
715-
716- // 步骤1:查询 user_shares 中变更的 note res_id(无跨库 JOIN)
717- // Step 1: query changed note res_ids from user_shares (no cross-DB JOIN)
718- activeIDs , revokedIDs , err := s .repo .ListChangedNoteResIDs (ctx , uid , since )
719- if err != nil {
720- return nil , err
721- }
722-
723- result := & dto.ShareChangesData {
724- Added : []string {},
725- Removed : []string {},
726- LastTime : time .Now ().UnixMilli (),
727- }
728-
729- // 步骤2:合并 ID 列表,一次批量查询 notes,按 vault 过滤后按来源分拆
730- // Step 2: merge ID lists, single batch query for notes, filter by vault and split by source
731- allIDs := make ([]int64 , 0 , len (activeIDs )+ len (revokedIDs ))
732- allIDs = append (allIDs , activeIDs ... )
733- allIDs = append (allIDs , revokedIDs ... )
734-
735- if len (allIDs ) > 0 {
736- activeSet := make (map [int64 ]struct {}, len (activeIDs ))
737- for _ , id := range activeIDs {
738- activeSet [id ] = struct {}{}
739- }
740-
741- notes , err := s .noteRepo .ListByIDs (ctx , allIDs , uid )
742- if err == nil {
743- for _ , n := range notes {
744- if n .VaultID != vault .ID {
745- continue
746- }
747- if _ , ok := activeSet [n .ID ]; ok {
748- if n .Action != domain .NoteActionDelete {
749- result .Added = append (result .Added , n .Path )
750- }
751- } else {
752- result .Removed = append (result .Removed , n .Path )
753- }
754- }
755- }
756- }
757-
758- return result , nil
759- }
760-
761692// GetSharedNote retrieves specific shared note details
762693// GetSharedNote 获取分享的单条笔记详情
763694func (s * shareService ) GetSharedNote (ctx context.Context , shareToken string , noteID int64 , password string ) (* dto.NoteDTO , error ) {
0 commit comments