Эх сурвалжийг харах

在线学习 - 查看当前登录用户每个课件的累计学习时长

wangggziwen 1 жил өмнө
parent
commit
39094bd4d4

+ 13 - 0
master/src/main/java/com/ruoyi/project/training/elearn/controller/TElResourceController.java

@@ -2,6 +2,9 @@ package com.ruoyi.project.training.elearn.controller;
 
 import java.util.List;
 
+import com.ruoyi.project.training.elearn.domain.TElLearn;
+import com.ruoyi.project.training.elearn.mapper.TElLearnMapper;
+import com.ruoyi.project.training.elearn.service.ITElLearnService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -34,6 +37,9 @@ public class TElResourceController extends BaseController
     @Autowired
     private ITElResourceService tElResourceService;
 
+    @Autowired
+    private ITElLearnService itElLearnService;
+
     /**
      * 查询课件列表
      */
@@ -43,6 +49,13 @@ public class TElResourceController extends BaseController
     {
         startPage();
         List<TElResource> list = tElResourceService.selectFileList(tElResource);
+        Long userId = getUserId();
+        for (TElResource elResource : list) {
+            TElLearn learn = new TElLearn();
+            learn.setUserId(userId);
+            learn.setResourceId(elResource.getId());
+            elResource.setLearnTime(itElLearnService.selectLearnByUserIdAndResourceId(learn).getLearnTime());
+        }
         return getDataTable(list);
     }
 

+ 11 - 0
master/src/main/java/com/ruoyi/project/training/elearn/domain/TElResource.java

@@ -42,6 +42,17 @@ public class TElResource extends BaseEntity
     /** 路径 */
     private String fileUrl;
 
+    /** 累计学习时长 */
+    private String learnTime;
+
+    public String getLearnTime() {
+        return learnTime;
+    }
+
+    public void setLearnTime(String learnTime) {
+        this.learnTime = learnTime;
+    }
+
     public Long getFileId() {
         return fileId;
     }

+ 2 - 2
master/src/main/resources/mybatis/training/elearn/TElLearnMapper.xml

@@ -43,8 +43,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLearnByUserIdAndResourceId" parameterType="TElLearn" resultMap="TElLearnResult">
         <include refid="selectTElLearnVo"/>
         <where>
-            <if test="resourceId != null  and resourceId != ''"> and resource_id = #{resourceId}</if>
-            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
+            <if test="resourceId != null  and resourceId != ''"> and d.resource_id = #{resourceId}</if>
+            <if test="userId != null  and userId != ''"> and d.user_id = #{userId}</if>
             and d.del_flag = 0
         </where>
         <!-- 数据范围过滤 -->

+ 6 - 3
ui/src/views/training/elearn/learn/index.vue

@@ -25,6 +25,11 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="主题" align="center" prop="title" :show-overflow-tooltip="true"/>
       <el-table-column label="文件名" align="center" prop="fileName" :show-overflow-tooltip="true"/>
+      <el-table-column label="累计学习时长" align="center" prop="learnTime" :show-overflow-tooltip="true">
+        <template slot-scope="scope">
+          <span>{{ scope.row.learnTime }}</span> min
+        </template>
+      </el-table-column>
       <el-table-column label="操作" align="center" fixed="right" width="240" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
@@ -32,14 +37,12 @@
             type="text"
             @click="handleStudy(scope.row)"
             icon="el-icon-video-play"
-            v-hasPermi="['elearn:resource:edit']"
           >开始学习</el-button>
           <el-button
             size="mini"
             type="text"
             @click="handleHistory(scope.row)"
             icon="el-icon-document"
-            v-hasPermi="['elearn:resource:remove']"
           >学习记录</el-button>
         </template>
       </el-table-column>
@@ -298,7 +301,7 @@
       handleHistory(row) {
         this.history.title = row.fileName + " 学习记录";
         this.history.open = true;
-        listLearn({"resourceId": row.resourceId}).then(response => {
+        listLearn({"resourceId": row.id}).then(response => {
           this.historyList = response.data;
           this.historyLoading = false;
         });