From 14e34a89577e40e4fa7b8d7b3ee46d9dce4d4dec Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Tue, 22 Oct 2024 17:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=9F=A5=E7=9C=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tea/TeaResourceCenterController.java | 22 ++++++++++++++----- .../resourceCenterAPI/ResourceCenterApi.java | 14 ++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java index a9ada94..decda79 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/tea/TeaResourceCenterController.java @@ -1,7 +1,7 @@ package com.sztzjy.financial_bigdata.controller.tea; import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; -import com.sztzjy.financial_bigdata.entity.*; +import com.sztzjy.financial_bigdata.entity.TeaResourceCenter; import com.sztzjy.financial_bigdata.entity.resource_entity.SysResource; import com.sztzjy.financial_bigdata.resourceCenterAPI.ResourceCenterApi; import com.sztzjy.financial_bigdata.service.tea.ITeaResourceCenterService; @@ -10,11 +10,17 @@ import com.sztzjy.financial_bigdata.util.file.IFileUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + import java.io.IOException; +import java.util.ArrayList; import java.util.List; //资源中心 @@ -35,7 +41,7 @@ public class TeaResourceCenterController { @GetMapping("selectResource") @ApiOperation("**查看资源文件列表,图片资源使用默认图片") public ResultEntity> selectResource(@ApiParam("学校id") @RequestParam String schoolId, - @ApiParam("课程Id") @RequestParam String courseId, @RequestParam String systemOwner) { + @ApiParam("课程Id") @RequestParam String courseId, @RequestParam String systemOwner) { List resourceList = null; try { resourceList = ResourceCenterApi.selectResource(schoolId, courseId, systemOwner); @@ -49,9 +55,15 @@ public class TeaResourceCenterController { @AnonymousAccess @GetMapping("selectResourceByChapterId") @ApiOperation("**根据章节查看资源文件列表,图片资源使用默认图片") - public ResultEntity> selectResourceByChapterId(@ApiParam("章节Id") @RequestParam String chapterId, @RequestParam String systemOwner) { + public ResultEntity> selectResourceByChapterId(@ApiParam("章节Id") @RequestParam(required = false) String chapterId, + @RequestParam String systemOwner) { try { - List resourceList = ResourceCenterApi.selectResourceByChapterId(chapterId, systemOwner); + List resourceList = new ArrayList<>(); + if (StringUtils.isBlank(chapterId)) { + resourceList = ResourceCenterApi.selectResourceByChapterId(systemOwner); + } else { + resourceList = ResourceCenterApi.selectResourceByChapterId(chapterId, systemOwner); + } return new ResultEntity(HttpStatus.OK, "根据章节查看资源文件列表,展示成功", resourceList); } catch (IOException e) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); diff --git a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java index a1f3da0..2cb8886 100644 --- a/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java +++ b/src/main/java/com/sztzjy/financial_bigdata/resourceCenterAPI/ResourceCenterApi.java @@ -79,6 +79,20 @@ public class ResourceCenterApi { } + public static List selectResourceByChapterId(String systemOwner) throws IOException { + String requestBody = "oneId=" + systemOwner; + JSONObject object = HttpUtils.sendPost( + selectResourceByChapterId, + requestBody); + Gson gson = new GsonBuilder() + .registerTypeAdapter(Date.class, new DateTypeAdapter()) + .create(); + Type listType = new TypeToken>() { + }.getType(); + List resourceList = gson.fromJson(object.get("respString").toString(), listType); + return resourceList; + } + /** * local:资源文件下载 * rsapi:资源文件下载