@@ -9,13 +9,13 @@ export class WordsService {
99 /**
1010 * 내부용: 전체 낱말 카드 목록 생성 (categoryId 없이)
1111 */
12- async _getAllWordCards ( userId , onlyFavorite = false ) {
12+ async _getAllWordCards ( userId , accountType , onlyFavorite = false ) {
1313 const wordCards = [ ] ;
1414 let categoryNameToUserCategoryIdMap = new Map ( ) ;
1515 let categoryNameToCategoryIdMap = new Map ( ) ;
1616 let hasUserCategories = false ;
1717
18- if ( userId ) {
18+ if ( userId && accountType !== 'GUEST' ) {
1919 const userCategories = await wordsRepository . findAllUserCategories ( userId ) ;
2020 if ( userCategories . length > 0 ) {
2121 hasUserCategories = true ;
@@ -34,7 +34,7 @@ export class WordsService {
3434 let userWords = [ ] ;
3535 const userWordMap = new Map ( ) ;
3636 const deletedWordIds = new Set ( ) ;
37- if ( userId ) {
37+ if ( userId && accountType !== 'GUEST' ) {
3838 userWords = await wordsRepository . findUserWords ( userId , null , onlyFavorite , true ) ;
3939 userWords . forEach ( uw => {
4040 if ( uw . wordId ) userWordMap . set ( uw . wordId , uw ) ;
@@ -45,8 +45,8 @@ export class WordsService {
4545 }
4646
4747 // 소셜 로그인(유저가 존재) 시에는 기본 Word를 반환하지 않고 UserWord만 반환
48- // 게스트(유저 없음)일 때만 기본 Word 반환
49- if ( ! onlyFavorite && ! userId ) {
48+ // 게스트(유저 없음 또는 accountType이 GUEST )일 때 기본 Word 반환
49+ if ( ! onlyFavorite && ( ! userId || accountType === 'GUEST' ) ) {
5050 const words = await wordsRepository . findWords ( null , userId ) ;
5151 words . forEach ( ( word , index ) => {
5252 const wordCategoryName = word . category ?. categoryName ;
@@ -101,20 +101,20 @@ export class WordsService {
101101 /**
102102 * 다음 displayOrder 계산 (기본 Word + UserWord 모두 고려)
103103 * @param {string } userId
104+ * @param {string } accountType
104105 * @param {string } categoryId
105106 * @returns {Promise<number> }
106107 */
107- async getNextDisplayOrder ( userId , categoryId ) {
108+ async getNextDisplayOrder ( userId , accountType , categoryId ) {
108109 // 1. UserWord 조회 (삭제된 것 제외)
109- const userWords = await wordsRepository . findUserWords ( userId , categoryId , false , false ) ;
110-
111- // 2. UserWord가 있으면 최대값 + 1 반환
112- if ( userWords . length > 0 ) {
113- const maxOrder = Math . max ( ... userWords . map ( w => w . displayOrder ) ) ;
114- return maxOrder + 1 ;
110+ if ( accountType !== 'GUEST' ) {
111+ const userWords = await wordsRepository . findUserWords ( userId , categoryId , false , false ) ;
112+ if ( userWords . length > 0 ) {
113+ const maxOrder = Math . max ( ... userWords . map ( w => w . displayOrder ) ) ;
114+ return maxOrder + 1 ;
115+ }
115116 }
116-
117- // 3. UserWord가 없으면 기본 Word 개수 반환
117+ // 게스트이거나 UserWord가 없으면 기본 Word 개수 반환
118118 const words = await wordsRepository . findWords ( categoryId , userId ) ;
119119 return words . length ;
120120 }
@@ -124,13 +124,14 @@ export class WordsService {
124124 * 기본 낱말(Word) + 개인 낱말(UserWord) 통합 반환
125125 *
126126 * @param {string } userId
127+ * @param {string } accountType
127128 * @param {string|null } categoryId - Category.id 또는 UserCategory.id
128129 * @param {boolean } onlyFavorite
129130 * @returns {Promise<Object> } { category, words }
130131 */
131- async getWords ( userId , categoryId = null , onlyFavorite = false ) {
132+ async getWords ( userId , accountType , categoryId = null , onlyFavorite = false ) {
132133 // 1. 전체 낱말 목록 생성 (categoryId 없이)
133- const allWords = await this . _getAllWordCards ( userId , onlyFavorite ) ;
134+ const allWords = await this . _getAllWordCards ( userId , accountType , onlyFavorite ) ;
134135
135136 // 2. categoryId가 없으면 전체 반환
136137 if ( ! categoryId ) {
0 commit comments