jichoi / lms_front star
woals 2024-08-23
240823 권민수 단어장 나머지 유형 페이지들 api 데이터 연결
@dc9188c205ae43a5ed655b1f3cd909d29ac9db13
client/views/pages/main/Chapter/Chapter2_4.vue
--- client/views/pages/main/Chapter/Chapter2_4.vue
+++ client/views/pages/main/Chapter/Chapter2_4.vue
@@ -47,7 +47,7 @@
                 />
                 <div class="textbox">
                   <div style="height: 80%; line-height: 200px">
-                    <img :src="item.imgSrc" alt="" />
+                    <img :src="item.imgSrc" alt="" style="width: 120px;" />
                   </div>
                   <p class="subtitle3" style="height: 20%">{{ item.title }}</p>
                 </div>
@@ -82,32 +82,33 @@
 export default {
   data() {
     return {
-      items: [
-        {
-          imgSrc1: "client/resources/img/img61_36s.png",
-          imgSrc2: "client/resources/img/img62_36s.png",
-          imgSrc: "client/resources/img/img59_36s.png",
-          title: "apple",
-        },
-        {
-          imgSrc1: "client/resources/img/img61_36s.png",
-          imgSrc2: "client/resources/img/img62_36s.png",
-          imgSrc: "client/resources/img/img2_4.png",
-          title: "bank",
-        },
-        {
-          imgSrc1: "client/resources/img/img61_36s.png",
-          imgSrc2: "client/resources/img/img62_36s.png",
-          imgSrc: "client/resources/img/img57_36s.png",
-          title: "car",
-        },
-        {
-          imgSrc1: "client/resources/img/img61_36s.png",
-          imgSrc2: "client/resources/img/img62_36s.png",
-          imgSrc: "client/resources/img/img56_36s.png",
-          title: "guitar",
-        },
-      ],
+      // items: [
+      //   {
+      //     imgSrc1: "client/resources/img/img61_36s.png",
+      //     imgSrc2: "client/resources/img/img62_36s.png",
+      //     imgSrc: "client/resources/img/img59_36s.png",
+      //     title: "apple",
+      //   },
+      //   {
+      //     imgSrc1: "client/resources/img/img61_36s.png",
+      //     imgSrc2: "client/resources/img/img62_36s.png",
+      //     imgSrc: "client/resources/img/img2_4.png",
+      //     title: "bank",
+      //   },
+      //   {
+      //     imgSrc1: "client/resources/img/img61_36s.png",
+      //     imgSrc2: "client/resources/img/img62_36s.png",
+      //     imgSrc: "client/resources/img/img57_36s.png",
+      //     title: "car",
+      //   },
+      //   {
+      //     imgSrc1: "client/resources/img/img61_36s.png",
+      //     imgSrc2: "client/resources/img/img62_36s.png",
+      //     imgSrc: "client/resources/img/img56_36s.png",
+      //     title: "guitar",
+      //   },
+      // ],
+      items: [],
       selectedIndex: 0,
 
       wdBookIdList: [], // 단어 컨텐츠의 단어장 id 리스트
@@ -123,11 +124,41 @@
       this.wdBookIdList = this.$store.getters.getWdBookIdList; // 단어컨텐츠의 단어장 id 리스트
       this.wdBookId = this.$store.getters.getWdBookIdList[this.currentWdBkIndex] // 현재 단어장 콘텐츠 인덱스에 대한 단어장 id
 
-      // this.fetchWordList();
+      this.fetchWordList();
     },
     
     async fetchWordList() {
+      try {
+        const response = await axios.post('/word/getWordsByBookId.json', {
+          wdBookId: this.wdBookId,
+        });
 
+        const wordList = response.data;
+
+        // 각 word 객체에 대해 fileRpath를 받아오는 요청 처리
+        const requests = wordList.map(async (word) => {
+          const fileResponse = await axios.post("/file/find.json", {
+            file_mng_id: word.fileMngId,
+          });
+
+          const fileRpath = fileResponse.data.list.length > 0 ? fileResponse.data.list[0].fileRpath : null;
+          console.log("각 단어의 fileRpath: ", fileRpath);
+
+          // items 배열에 새로운 항목 추가
+          this.items.push({
+            imgSrc1: "client/resources/img/img61_36s.png",
+            imgSrc2: "client/resources/img/img62_36s.png",
+            imgSrc: "http://165.229.169.113:9080/" + fileRpath, // 받아온 fileRpath로 이미지 설정
+            title: word.wdNm,
+          });
+        });
+
+        // 모든 요청이 완료될 때까지 대기
+        await Promise.all(requests);
+
+      } catch (error) {
+        console.error('단어 목록을 불러오는 중 오류 발생:', error);
+      }
     },
 
     async goToPrevPage() {
client/views/pages/main/Chapter/Chapter2_9.vue
--- client/views/pages/main/Chapter/Chapter2_9.vue
+++ client/views/pages/main/Chapter/Chapter2_9.vue
@@ -44,73 +44,25 @@
                 style="width: 93%"
               />
               <div class="vocaGroup">
-                <div class="flex justify-between mb80">
+                <div
+                  v-for="(word) in wordList"
+                  :key="word.wdId"
+                  class="flex justify-between mb80 word-item"
+                >
                   <article class="flex align-center">
                     <div class="imgGroup mr30">
                       <img
-                        src="../../../../resources/img/img74_41s.png"
+                        :src= word.fileRpath
                         data-num="1"
                         class="ink"
+                        style="width: 150px"
                       />
                     </div>
                     <div class="flex align-start">
                       <div>
-                        <h3>mountain</h3>
+                        <h3>{{ word.wdNm }}</h3>
                         <div class="flex align-center mt10">
-                          <span class="title1">산</span>
-                        </div>
-                      </div>
-                    </div>
-                  </article>
-                  <article class="flex align-center">
-                    <div class="imgGroup mr30">
-                      <img
-                        src="../../../../resources/img/img75_41s.png"
-                        data-num="2"
-                        class="ink"
-                      />
-                    </div>
-                    <div class="flex align-start">
-                      <div>
-                        <h3>cat</h3>
-                        <div class="flex align-center mt10">
-                          <span class="title1">고양이</span>
-                        </div>
-                      </div>
-                    </div>
-                  </article>
-                </div>
-                <div class="flex justify-between">
-                  <article class="flex align-center">
-                    <div class="imgGroup mr30">
-                      <img
-                        src="../../../../resources/img/img76_41s.png"
-                        data-num="3"
-                        class="ink"
-                      />
-                    </div>
-                    <div class="flex align-start">
-                      <div>
-                        <h3>watermelon</h3>
-                        <div class="flex align-center mt10">
-                          <span class="title1">수박</span>
-                        </div>
-                      </div>
-                    </div>
-                  </article>
-                  <article class="flex align-center">
-                    <div class="imgGroup mr30">
-                      <img
-                        src="../../../../resources/img/img77_41s.png"
-                        data-num="4"
-                        class="ink"
-                      />
-                    </div>
-                    <div class="flex align-start">
-                      <div>
-                        <h3>america</h3>
-                        <div class="flex align-center mt10">
-                          <span class="title1">보도</span>
+                          <span class="title1">{{ word.wdMnng }}</span>
                         </div>
                       </div>
                     </div>
@@ -178,6 +130,7 @@
   data() {
     return {
       draggedElementId: null, // 드래그한 요소의 ID를 저장
+      wordList: [],
 
       wdBookIdList: [], // 단어 컨텐츠의 단어장 id 리스트
       wdBookId: "", // 현재 단어장 id
@@ -192,12 +145,40 @@
       this.wdBookIdList = this.$store.getters.getWdBookIdList; // 단어컨텐츠의 단어장 id 리스트
       this.wdBookId = this.$store.getters.getWdBookIdList[this.currentWdBkIndex] // 현재 단어장 콘텐츠 인덱스에 대한 단어장 id
 
-      // this.fetchWordList();
+      this.fetchWordList();
     },
     
     async fetchWordList() {
+      try {
+        const response = await axios.post("/word/getWordsByBookId.json", {
+          wdBookId: this.wdBookId,
+        });
 
+        const wordList = response.data;
+
+        // 각 word 객체에 대해 fileRpath를 받아오는 요청 처리
+        const requests = wordList.map(async (word) => {
+          const fileResponse = await axios.post("/file/find.json", {
+            file_mng_id: word.fileMngId,
+          });
+
+          const fileRpath = fileResponse.data.list.length > 0 ? fileResponse.data.list[0].fileRpath : null;
+          console.log("각 단어의 fileRpath: ", fileRpath);
+
+          word.fileRpath = "http://165.229.169.113:9080/" + fileRpath; // fileRpath 값을 해당 객체에 추가
+        });
+
+        // 모든 요청이 완료될 때까지 대기
+        await Promise.all(requests);
+
+        // 최종적으로 wordList를 설정
+        this.wordList = wordList;
+        console.log("단어 리스트 -> ", this.wordList);
+      } catch (error) {
+        console.error("단어 목록을 불러오는 중 오류 발생:", error);
+      }
     },
+
 
     async goToPrevPage() {
       if (this.currentWdBkIndex - 1 < 0) {
@@ -338,6 +319,12 @@
   position: absolute;
   top: 90px;
   left: 120px;
+  display: flex;
+  flex-wrap: wrap;
+}
+
+.word-item {
+  width: 49%;
 }
 
 .ink {
Add a comment
List