diff --git a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java index 49522ae2..2fa90cad 100644 --- a/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java +++ b/renren-admin/src/main/java/io/renren/common/domain/Tsingtao_xhaProperties.java @@ -20,4 +20,5 @@ public class Tsingtao_xhaProperties { private String localcam; private String resourcecount; private String resourceapplyinfo; + private String sjzy; } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java index f33b1f53..858d4988 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/controller/ResourceController.java @@ -10,6 +10,9 @@ import io.renren.common.utils.Result; import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; +import io.renren.modules.resource.dataResource.AbstractDataResourceService; +import io.renren.modules.resource.dataResource.DataResourceFactory; +import io.renren.modules.resource.dto.GetDataResourceListDto; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.excel.ResourceExcelImportListener; import io.renren.modules.resource.service.ResourceService; @@ -336,8 +339,6 @@ public class ResourceController { HashMap result = JSONObject.parseObject(json, HashMap.class); List rows = (List) result.get("data"); - - List objects = rows.stream() .filter(item -> item.get("main") != null) .map(item -> item.get("main")) @@ -415,7 +416,7 @@ public class ResourceController { */ @GetMapping("getHls") - @ApiOperation("对接知识库数据") + @ApiOperation("获取hls地址") public Result getHls(String key) { Optional factory = VideoPreviewFactory.build(); if (factory.isPresent()) { @@ -425,4 +426,15 @@ public class ResourceController { return null; } + + @PostMapping("/getDataResource") + @ApiOperation("获取数据资源") + public Result getDataResource(@RequestBody GetDataResourceListDto dto) { + Optional factory = DataResourceFactory.build(); + if (factory.isPresent()) { + Object dataResource = factory.get().getDataResource(dto); + return new Result().ok(dataResource); + } + return null; + } } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/AbstractDataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/AbstractDataResourceService.java new file mode 100644 index 00000000..ad82cc20 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/AbstractDataResourceService.java @@ -0,0 +1,20 @@ +package io.renren.modules.resource.dataResource; + + +import io.renren.modules.resource.dto.GetDataResourceListDto; + +import java.util.Map; + +/** + * 视频预览抽象类 + */ +public abstract class AbstractDataResourceService { + + /** + * 获取数据资源列表 + * + * @param Map 查询参数集合 + * @return + */ + public abstract Object getDataResource(GetDataResourceListDto dto); +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/DataResourceFactory.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/DataResourceFactory.java new file mode 100644 index 00000000..3f39b02c --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/DataResourceFactory.java @@ -0,0 +1,59 @@ +package io.renren.modules.resource.dataResource; + +import io.renren.common.constant.Constant; +import io.renren.common.domain.BaoTouProperties; +import io.renren.common.domain.TsingtaoProperties; +import io.renren.common.domain.Tsingtao_xhaProperties; +import io.renren.common.utils.SpringContextUtils; +import io.renren.modules.resource.dataResource.domain.TsingtaoXHADataResourceService; +import io.renren.modules.resource.service.ResourceService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Optional; + +/** + * 数据资源工厂类 + */ +public final class DataResourceFactory { + + private static final Logger logger = LoggerFactory.getLogger(DataResourceFactory.class); + + private static ResourceService resourceService; + + private static int projectPlace; + + private static TsingtaoProperties tsingtaoProperties; // 青岛市区配置 + + private static Tsingtao_xhaProperties tsingtao_xhaProperties; // 青岛西海岸配置 + + static { + DataResourceFactory.resourceService = SpringContextUtils.getBean(ResourceService.class); + DataResourceFactory.projectPlace = resourceService.getProjectPlace(); + DataResourceFactory.tsingtaoProperties = SpringContextUtils.getBean(TsingtaoProperties.class); + DataResourceFactory.tsingtao_xhaProperties = SpringContextUtils.getBean(Tsingtao_xhaProperties.class); + } + + /** + * 获取数据资源服务实现 + * + * @return + */ + public static Optional build() { + AbstractDataResourceService abstractDataResourceService = null; + switch (Constant.ProjectPlace.getByFlag(projectPlace)) { + case TSINGTAO: { // 青岛市局 + } + break; + case TSINGTAO_XHA: { // 青岛西海岸 + abstractDataResourceService = new TsingtaoXHADataResourceService(tsingtao_xhaProperties); + } + break; + case UNKNOWN: { // 未知区域 + logger.error("区域未知"); + } + break; + } + return Optional.ofNullable(abstractDataResourceService); + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java new file mode 100644 index 00000000..e265c351 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java @@ -0,0 +1,18 @@ +package io.renren.modules.resource.dataResource.domain; + +import io.renren.modules.resource.dataResource.AbstractDataResourceService; +import io.renren.modules.resource.dto.GetDataResourceListDto; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 青岛市局数据资源 + */ +public class TsingtaoDataResourceService extends AbstractDataResourceService { + + private static final Logger logger = LoggerFactory.getLogger(TsingtaoDataResourceService.class); + @Override + public Object getDataResource(GetDataResourceListDto dto) { + return null; + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoXHADataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoXHADataResourceService.java new file mode 100644 index 00000000..14ca10a3 --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoXHADataResourceService.java @@ -0,0 +1,46 @@ +package io.renren.modules.resource.dataResource.domain; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import io.renren.common.domain.Tsingtao_xhaProperties; +import io.renren.modules.resource.dataResource.AbstractDataResourceService; +import io.renren.modules.resource.dto.GetDataResourceListDto; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * 青岛西海岸数据资源 + */ +public class TsingtaoXHADataResourceService extends AbstractDataResourceService { + private static final Logger logger = LoggerFactory.getLogger(TsingtaoXHADataResourceService.class); + Tsingtao_xhaProperties tsingtao_xhaProperties; + + public TsingtaoXHADataResourceService(Tsingtao_xhaProperties tsingtao_xhaProperties) { + this.tsingtao_xhaProperties = tsingtao_xhaProperties; + } + + @Override + public Object getDataResource(GetDataResourceListDto dto){ + JSONObject result = null; + OkHttpClient client = new OkHttpClient(); + Request request = new Request.Builder().url(String.format(tsingtao_xhaProperties.getSjzy(), + dto.getServiceName(), dto.getOrderField(), dto.getOrderType(), dto.getPageNum(), dto.getPageSize())).build(); + try (Response response = client.newCall(request).execute()) { + if (response.isSuccessful()) { + JSONObject jsonObject = JSON.parseObject(response.body().string()); + if (jsonObject.containsKey("data")) { + result = jsonObject.getJSONObject("data"); + } + } else { + logger.error("西海岸数据资源列表获取失败"); + } + } catch (Exception exception) { + logger.error("西海岸数据资源列表获取失败", exception); + } + return result; + } +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dto/GetDataResourceListDto.java b/renren-admin/src/main/java/io/renren/modules/resource/dto/GetDataResourceListDto.java new file mode 100644 index 00000000..660df80d --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/resource/dto/GetDataResourceListDto.java @@ -0,0 +1,21 @@ +package io.renren.modules.resource.dto; + +import lombok.Data; + +/** + * 数据资源查询参数对象 + */ +@Data +public class GetDataResourceListDto { + + //名称,模糊查询 + private String serviceName; + //排序字段 + private String orderField; + //排序方式:desc,asc + private String orderType; + //分页页数 + private Integer pageNum; + //分页大小 + private Integer pageSize; +} diff --git a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java index fdf3fcef..7aa5c114 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/videoPreview/VideoPreviewFactory.java @@ -1,6 +1,5 @@ package io.renren.modules.resource.videoPreview; - import io.renren.common.constant.Constant; import io.renren.common.domain.BaoTouProperties; import io.renren.common.domain.TsingtaoProperties; diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java index def96eb7..434e4cec 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/controller/ResourceBrowseController.java @@ -10,6 +10,7 @@ import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO; import io.renren.modules.resourceBrowse.excel.ResourceBrowseExcel; import io.renren.modules.resourceBrowse.service.ResourceBrowseService; @@ -38,6 +39,8 @@ import java.util.Map; public class ResourceBrowseController { @Autowired private ResourceBrowseService resourceBrowseService; + @Autowired + private ResourceService resourceService; @GetMapping("/page") @ApiOperation("分页") @@ -45,12 +48,12 @@ public class ResourceBrowseController { @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") + @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String"), }) //@RequiresPermissions("resourceBrowse:resourcebrowse:page") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = resourceBrowseService.page(params); - + page.getList().forEach(item -> item.setResourceDTO(resourceService.get(item.getResourceId()))); return new Result>().ok(page); } diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dto/ResourceBrowseDTO.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dto/ResourceBrowseDTO.java index 86a51551..978a0b26 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dto/ResourceBrowseDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/dto/ResourceBrowseDTO.java @@ -1,5 +1,6 @@ package io.renren.modules.resourceBrowse.dto; +import io.renren.modules.resource.dto.ResourceDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -41,4 +42,9 @@ public class ResourceBrowseDTO implements Serializable { @ApiModelProperty(value = "备用字段3") private String note3; + @ApiModelProperty(value = "能力信息") + private ResourceDTO resourceDTO; + + + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java index 00205120..8c67dab8 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceBrowse/service/impl/ResourceBrowseServiceImpl.java @@ -25,6 +25,7 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl