修改资源文件查看接口

master
xiaoCJ 5 months ago
parent 9967ad25e8
commit 14e34a8957

@ -1,7 +1,7 @@
package com.sztzjy.financial_bigdata.controller.tea; package com.sztzjy.financial_bigdata.controller.tea;
import com.sztzjy.financial_bigdata.annotation.AnonymousAccess; 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.entity.resource_entity.SysResource;
import com.sztzjy.financial_bigdata.resourceCenterAPI.ResourceCenterApi; import com.sztzjy.financial_bigdata.resourceCenterAPI.ResourceCenterApi;
import com.sztzjy.financial_bigdata.service.tea.ITeaResourceCenterService; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; 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.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
//资源中心 //资源中心
@ -49,9 +55,15 @@ public class TeaResourceCenterController {
@AnonymousAccess @AnonymousAccess
@GetMapping("selectResourceByChapterId") @GetMapping("selectResourceByChapterId")
@ApiOperation("**根据章节查看资源文件列表,图片资源使用默认图片") @ApiOperation("**根据章节查看资源文件列表,图片资源使用默认图片")
public ResultEntity<List<TeaResourceCenter>> selectResourceByChapterId(@ApiParam("章节Id") @RequestParam String chapterId, @RequestParam String systemOwner) { public ResultEntity<List<TeaResourceCenter>> selectResourceByChapterId(@ApiParam("章节Id") @RequestParam(required = false) String chapterId,
@RequestParam String systemOwner) {
try { try {
List<SysResource> resourceList = ResourceCenterApi.selectResourceByChapterId(chapterId, systemOwner); List<SysResource> resourceList = new ArrayList<>();
if (StringUtils.isBlank(chapterId)) {
resourceList = ResourceCenterApi.selectResourceByChapterId(systemOwner);
} else {
resourceList = ResourceCenterApi.selectResourceByChapterId(chapterId, systemOwner);
}
return new ResultEntity(HttpStatus.OK, "根据章节查看资源文件列表,展示成功", resourceList); return new ResultEntity(HttpStatus.OK, "根据章节查看资源文件列表,展示成功", resourceList);
} catch (IOException e) { } catch (IOException e) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "资源中心接口异常");

@ -79,6 +79,20 @@ public class ResourceCenterApi {
} }
public static List<SysResource> 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<List<SysResource>>() {
}.getType();
List<SysResource> resourceList = gson.fromJson(object.get("respString").toString(), listType);
return resourceList;
}
/** /**
* local: * local:
* rsapi: * rsapi:

Loading…
Cancel
Save