From b2996ca9c030f89df2dde2f5975cb6c443237d10 Mon Sep 17 00:00:00 2001 From: xusd Date: Sat, 11 May 2024 16:59:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AD=A6=E4=B9=A0=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5=E5=92=8C=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E6=85=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../develop/LearningPathInfoController.java | 14 +++++++++++ .../service/ILearningPathInfoService.java | 10 ++++++++ .../impl/LearningPathInfoServiceImpl.java | 24 +++++++++++++++---- inspur-ui/src/api/develop/learningPath.js | 8 +++++++ .../src/views/develop/learningPath/index.vue | 15 ++++++++++-- 5 files changed, 65 insertions(+), 6 deletions(-) diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/develop/LearningPathInfoController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/develop/LearningPathInfoController.java index 855b56b..96765bb 100644 --- a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/develop/LearningPathInfoController.java +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/develop/LearningPathInfoController.java @@ -102,4 +102,18 @@ public class LearningPathInfoController extends BaseController return toAjax(learningPathInfoService.deleteLearningPathInfoByIds(ids)); } + /** + * 获取图片base64 + * + * @Author xusd + * @Date 16:44 2024/5/11 + * @param id 学习路径id + * @return java.lang.String + */ + @PreAuthorize("@ss.hasPermi('develop:learningPath:query')") + @GetMapping("/getPhotoBase64ById/{id}") + public String getPhotoBase64ById(@PathVariable("id") String id){ + return learningPathInfoService.getPhotoBase64ById(id); + } + } diff --git a/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/ILearningPathInfoService.java b/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/ILearningPathInfoService.java index d3b88b0..f60462a 100644 --- a/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/ILearningPathInfoService.java +++ b/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/ILearningPathInfoService.java @@ -58,4 +58,14 @@ public interface ILearningPathInfoService * @return 结果 */ public int deleteLearningPathInfoById(String id); + + /** + * 获取图片base64 + * + * @Author xusd + * @Date 16:44 2024/5/11 + * @param id 学习路径id + * @return java.lang.String + */ + String getPhotoBase64ById(String id); } diff --git a/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/impl/LearningPathInfoServiceImpl.java b/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/impl/LearningPathInfoServiceImpl.java index e60ece6..f773a89 100644 --- a/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/impl/LearningPathInfoServiceImpl.java +++ b/inspur-service/inspur-develop/src/main/java/com/inspur/develop/service/impl/LearningPathInfoServiceImpl.java @@ -50,10 +50,6 @@ public class LearningPathInfoServiceImpl implements ILearningPathInfoService LearningPathInfo learningPathInfo = learningPathInfoMapper.selectLearningPathInfoById(id); if (Objects.nonNull(learningPathInfo)){ learningPathInfo.setLearningPathCourseList(learningPathCourseService.selectLearningPathCourseByPathId(id)); - if (StringUtils.isNotEmpty(learningPathInfo.getFileName())){ - byte[] bytes = sftpServices.downLoadFile(learningPathInfo.getFileName()); - learningPathInfo.setPhotoBase("data:image/png;base64,"+Base64.getEncoder().encodeToString(bytes)); - } } return learningPathInfo; } @@ -145,4 +141,24 @@ public class LearningPathInfoServiceImpl implements ILearningPathInfoService { return learningPathInfoMapper.deleteLearningPathInfoById(id); } + + /** + * 获取图片base64 + * + * @Author xusd + * @Date 16:44 2024/5/11 + * @param id 学习路径id + * @return java.lang.String + */ + @Override + public String getPhotoBase64ById(String id) { + LearningPathInfo learningPathInfo = learningPathInfoMapper.selectLearningPathInfoById(id); + if (Objects.nonNull(learningPathInfo)){ + if (StringUtils.isNotEmpty(learningPathInfo.getFileName())){ + byte[] bytes = sftpServices.downLoadFile(learningPathInfo.getFileName()); + return "data:image/png;base64," + Base64.getEncoder().encodeToString(bytes); + } + } + return ""; + } } diff --git a/inspur-ui/src/api/develop/learningPath.js b/inspur-ui/src/api/develop/learningPath.js index ba0ce21..6824d15 100644 --- a/inspur-ui/src/api/develop/learningPath.js +++ b/inspur-ui/src/api/develop/learningPath.js @@ -42,3 +42,11 @@ export function delLearningPath(id) { method: 'delete' }) } + +// 查询学习路径信息详细 +export function getPhotoBase64ById(id) { + return request({ + url: '/develop/learningPath/getPhotoBase64ById/' + id, + method: 'get' + }) +} diff --git a/inspur-ui/src/views/develop/learningPath/index.vue b/inspur-ui/src/views/develop/learningPath/index.vue index e451ed7..499bc72 100644 --- a/inspur-ui/src/views/develop/learningPath/index.vue +++ b/inspur-ui/src/views/develop/learningPath/index.vue @@ -361,7 +361,9 @@
学习路径
- learningPathForm.fileName +
+ learningPathForm.fileName +
@@ -393,7 +395,8 @@ import { delLearningPath, getLearningPath, listLearningPath, - updateLearningPath + updateLearningPath, + getPhotoBase64ById } from '@/api/develop/learningPath' import { getToken } from '@/utils/auth' @@ -408,6 +411,8 @@ export default { dicts: ['class_type','sys_normal_disable','train_doc_type'], data() { return { + photoBase64Loading: false, + photoBase64: "", learningPathForm: {}, loadingLearningPath: false, onLineDiaLogSelectList: [], @@ -579,6 +584,7 @@ export default { cancelShowLearningPath(){ this.loadingLearningPath = false; this.learningPathForm = {}; + this.photoBase64 = ""; }, //确认选择课程框 submitSelectCourseForm(){ @@ -780,6 +786,7 @@ export default { }, handleGetLearningPath(row){ this.reset(); + this.photoBase64Loading = true; const id = row.id || this.ids getLearningPath(id).then(response => { this.learningPathForm = response.data; @@ -792,6 +799,10 @@ export default { this.allDiaLogSelectList = this.learningPathForm.learningPathCourseList; this.loadingLearningPath = true; }); + getPhotoBase64ById(id).then(res=>{ + this.photoBase64 = res; + this.photoBase64Loading = false; + }); }, /** 提交按钮 */ submitForm() {