From f050644f656c0e906fec7cd262a3dbed4135ed3f Mon Sep 17 00:00:00 2001 From: xxzuo <1293378490@qq.com> Date: Tue, 26 Dec 2023 21:01:50 +0800 Subject: [PATCH] [Fix-320][UI] Fix Error data management list Updater field shows ID instead of name --- .../ErrorDataStorageController.java | 8 +++ .../bo/storage/ErrorDataStoragePageParam.java | 40 ++++++++++++++ .../server/api/dto/vo/ErrorDataStorageVO.java | 49 +++++++++++++++++ .../mapper/ErrorDataStorageMapper.java | 13 ++++- .../service/ErrorDataStorageService.java | 5 ++ .../impl/ErrorDataStorageServiceImpl.java | 20 +++++++ .../mapper/ErrorDataStorageMapper.xml | 53 +++++++++++++++++++ .../src/view/Main/ErrorDataManage/index.tsx | 20 ++++--- 8 files changed, 200 insertions(+), 8 deletions(-) create mode 100644 datavines-server/src/main/java/io/datavines/server/api/dto/bo/storage/ErrorDataStoragePageParam.java create mode 100644 datavines-server/src/main/java/io/datavines/server/api/dto/vo/ErrorDataStorageVO.java create mode 100644 datavines-server/src/main/resources/mapper/ErrorDataStorageMapper.xml diff --git a/datavines-server/src/main/java/io/datavines/server/api/controller/ErrorDataStorageController.java b/datavines-server/src/main/java/io/datavines/server/api/controller/ErrorDataStorageController.java index 8ce0835e3..1aaa31e89 100644 --- a/datavines-server/src/main/java/io/datavines/server/api/controller/ErrorDataStorageController.java +++ b/datavines-server/src/main/java/io/datavines/server/api/controller/ErrorDataStorageController.java @@ -21,7 +21,9 @@ import io.datavines.core.aop.RefreshToken; import io.datavines.core.constant.DataVinesConstants; import io.datavines.server.api.dto.bo.storage.ErrorDataStorageCreate; +import io.datavines.server.api.dto.bo.storage.ErrorDataStoragePageParam; import io.datavines.server.api.dto.bo.storage.ErrorDataStorageUpdate; +import io.datavines.server.api.dto.vo.ErrorDataStorageVO; import io.datavines.server.api.dto.vo.Item; import io.datavines.server.repository.service.ErrorDataStorageService; import io.datavines.spi.PluginLoader; @@ -77,6 +79,12 @@ public Object listByUserId(@PathVariable Long workspaceId) { return errorDataStorageService.listByWorkspaceId(workspaceId); } + @ApiOperation(value = "get error data storage page", response = ErrorDataStorageVO.class, responseContainer = "page") + @PostMapping(value = "page") + public Object page(@Valid @RequestBody ErrorDataStoragePageParam errorDataStoragePageParam) { + return errorDataStorageService.getErrorDataStoragePage(errorDataStoragePageParam); + } + @ApiOperation(value = "get storage config json") @GetMapping(value = "/config/{type}") public Object getConfigJson(@PathVariable String type){ diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/bo/storage/ErrorDataStoragePageParam.java b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/storage/ErrorDataStoragePageParam.java new file mode 100644 index 000000000..d9fd710f1 --- /dev/null +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/bo/storage/ErrorDataStoragePageParam.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.server.api.dto.bo.storage; + +import lombok.Data; +import javax.validation.constraints.NotNull; + +@Data +@NotNull(message = "ErrorDataStoragePageParam cannot be null") +public class ErrorDataStoragePageParam { + + private Long workspaceId; + + private String searchVal; + + private String type; + + private String startTime; + + private String endTime; + + private Integer pageNumber; + + private Integer pageSize; + +} diff --git a/datavines-server/src/main/java/io/datavines/server/api/dto/vo/ErrorDataStorageVO.java b/datavines-server/src/main/java/io/datavines/server/api/dto/vo/ErrorDataStorageVO.java new file mode 100644 index 000000000..eea93e959 --- /dev/null +++ b/datavines-server/src/main/java/io/datavines/server/api/dto/vo/ErrorDataStorageVO.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.datavines.server.api.dto.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import java.io.Serializable; +import java.time.LocalDateTime; + +@Data +public class ErrorDataStorageVO implements Serializable { + + private static final long serialVersionUID = 1L; + + private Long id; + + private String name; + + private String type; + + private String param; + + private Long workspaceId; + + private String creator; + + private String updater; + + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime startTime; + + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime updateTime; + +} diff --git a/datavines-server/src/main/java/io/datavines/server/repository/mapper/ErrorDataStorageMapper.java b/datavines-server/src/main/java/io/datavines/server/repository/mapper/ErrorDataStorageMapper.java index b60bda7a3..cccf55950 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/mapper/ErrorDataStorageMapper.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/mapper/ErrorDataStorageMapper.java @@ -14,13 +14,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.datavines.server.repository.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.datavines.server.api.dto.vo.ErrorDataStorageVO; import io.datavines.server.repository.entity.ErrorDataStorage; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface ErrorDataStorageMapper extends BaseMapper { + + IPage getErrorDataStoragePage(Page page, + @Param("workspaceId") Long workspaceId, + @Param("searchVal") String searchVal, + @Param("type") String type, + @Param("startTime") String startTime, + @Param("endTime") String endTime); + } diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/ErrorDataStorageService.java b/datavines-server/src/main/java/io/datavines/server/repository/service/ErrorDataStorageService.java index 069753110..ea55d0a4b 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/ErrorDataStorageService.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/ErrorDataStorageService.java @@ -17,11 +17,14 @@ package io.datavines.server.repository.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import io.datavines.common.param.TestConnectionRequestParam; import io.datavines.core.exception.DataVinesServerException; import io.datavines.server.api.dto.bo.storage.ErrorDataStorageCreate; +import io.datavines.server.api.dto.bo.storage.ErrorDataStoragePageParam; import io.datavines.server.api.dto.bo.storage.ErrorDataStorageUpdate; +import io.datavines.server.api.dto.vo.ErrorDataStorageVO; import io.datavines.server.repository.entity.ErrorDataStorage; import java.util.List; @@ -40,5 +43,7 @@ public interface ErrorDataStorageService extends IService { List listByWorkspaceId(long workspaceId); + IPage getErrorDataStoragePage(ErrorDataStoragePageParam errorDataStoragePageParam); + String getConfigJson(String type); } diff --git a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/ErrorDataStorageServiceImpl.java b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/ErrorDataStorageServiceImpl.java index d489ab837..46a59b89e 100644 --- a/datavines-server/src/main/java/io/datavines/server/repository/service/impl/ErrorDataStorageServiceImpl.java +++ b/datavines-server/src/main/java/io/datavines/server/repository/service/impl/ErrorDataStorageServiceImpl.java @@ -17,6 +17,8 @@ package io.datavines.server.repository.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import io.datavines.common.param.ConnectorResponse; import io.datavines.common.param.TestConnectionRequestParam; @@ -26,7 +28,9 @@ import io.datavines.core.exception.DataVinesServerException; import io.datavines.core.utils.LanguageUtils; import io.datavines.server.api.dto.bo.storage.ErrorDataStorageCreate; +import io.datavines.server.api.dto.bo.storage.ErrorDataStoragePageParam; import io.datavines.server.api.dto.bo.storage.ErrorDataStorageUpdate; +import io.datavines.server.api.dto.vo.ErrorDataStorageVO; import io.datavines.server.repository.entity.ErrorDataStorage; import io.datavines.server.repository.mapper.ErrorDataStorageMapper; import io.datavines.server.repository.service.ErrorDataStorageService; @@ -110,6 +114,22 @@ public List listByWorkspaceId(long workspaceId) { return list; } + @Override + public IPage getErrorDataStoragePage(ErrorDataStoragePageParam errorDataStoragePageParam) { + Page page = new Page<>(errorDataStoragePageParam.getPageNumber(), errorDataStoragePageParam.getPageSize()); + IPage errorDataStoragePage = baseMapper.getErrorDataStoragePage(page, + errorDataStoragePageParam.getWorkspaceId(), + errorDataStoragePageParam.getSearchVal(), + errorDataStoragePageParam.getType(), + errorDataStoragePageParam.getStartTime(), + errorDataStoragePageParam.getEndTime()); + List errorDataStoragePageRecordList = errorDataStoragePage.getRecords(); + for (ErrorDataStorageVO errorDataStorageVO : errorDataStoragePageRecordList) { + errorDataStorageVO.setParam(PasswordFilterUtils.convertPasswordToNULL(PWD_PATTERN_1, errorDataStorageVO.getParam())); + } + return errorDataStoragePage; + } + @Override public int deleteById(long id) { return baseMapper.deleteById(id); diff --git a/datavines-server/src/main/resources/mapper/ErrorDataStorageMapper.xml b/datavines-server/src/main/resources/mapper/ErrorDataStorageMapper.xml new file mode 100644 index 000000000..eecabf55d --- /dev/null +++ b/datavines-server/src/main/resources/mapper/ErrorDataStorageMapper.xml @@ -0,0 +1,53 @@ + + + + + + select * from dv_error_data_storage + + + and type = #{type} + + + and workspace_id = #{workspaceId} + + + and update_time >= #{startTime} + + + and update_time <= #{endTime} + + + + + + + + + \ No newline at end of file diff --git a/datavines-ui/src/view/Main/ErrorDataManage/index.tsx b/datavines-ui/src/view/Main/ErrorDataManage/index.tsx index f9cf90c77..7a68b0b52 100644 --- a/datavines-ui/src/view/Main/ErrorDataManage/index.tsx +++ b/datavines-ui/src/view/Main/ErrorDataManage/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, {useEffect, useState} from 'react'; import { Table, Button, message, } from 'antd'; @@ -35,10 +35,13 @@ const Index = () => { const getData = async () => { try { setLoading(true); - const res = (await $http.get(`/errorDataStorage/list/${workspaceId}`)) || []; + const res = (await $http.post(`/errorDataStorage/page`, { + workspaceId: workspaceId, + ...pageParams + })) || []; setTableData({ - list: res || [], - total: (res || []).length, + list: res?.records || [], + total: res?.total || 0, }); } catch (error) { } finally { @@ -48,13 +51,16 @@ const Index = () => { useMount(() => { getData(); }); + useEffect(() => { + getData(); + }, [pageParams]); const onEdit = (record: TWarnTableItem) => { show(record); }; const onDelete = async (id: any) => { try { setLoading(true); - const res = await $http.delete(`sla/sender/${id}`); + const res = await $http.delete(`errorDataStorage/${id}`); if (res) { getData(); message.success(intl.formatMessage({ id: 'common_success' })); @@ -81,8 +87,8 @@ const Index = () => { }, { title: intl.formatMessage({ id: 'common_updater' }), - dataIndex: 'updateBy', - key: 'updateBy', + dataIndex: 'updater', + key: 'updater', render: (text: string) =>
{text || '--'}
, }, {