This is an automated email from the ASF dual-hosted git repository.
kirs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 38b1441 [Fix-6941][API] Fix the failure of querying details of alert
group (#6942)
38b1441 is described below
commit 38b14410ab622685b961cc8fc6728963b8552779
Author: Kerwin <[email protected]>
AuthorDate: Tue Nov 23 09:28:27 2021 +0800
[Fix-6941][API] Fix the failure of querying details of alert group (#6942)
* Fix the failure of querying details of alert group
* code cleanup
---
.../api/service/impl/AlertGroupServiceImpl.java | 13 ++--
.../api/service/AlertGroupServiceTest.java | 28 +------
.../dao/mapper/AlertGroupMapper.java | 9 ---
.../dolphinscheduler/dao/vo/AlertGroupVo.java | 87 ----------------------
.../dao/mapper/AlertGroupMapper.xml | 10 +--
5 files changed, 11 insertions(+), 136 deletions(-)
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java
index 887b911..1cad66a 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java
@@ -25,7 +25,6 @@ import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
-import org.apache.dolphinscheduler.dao.vo.AlertGroupVo;
import org.apache.commons.lang.StringUtils;
@@ -116,12 +115,12 @@ public class AlertGroupServiceImpl extends
BaseServiceImpl implements AlertGroup
return result;
}
- Page<AlertGroupVo> page = new Page<>(pageNo, pageSize);
- IPage<AlertGroupVo> alertGroupVoIPage =
alertGroupMapper.queryAlertGroupVo(page, searchVal);
- PageInfo<AlertGroupVo> pageInfo = new PageInfo<>(pageNo, pageSize);
-
- pageInfo.setTotal((int) alertGroupVoIPage.getTotal());
- pageInfo.setTotalList(alertGroupVoIPage.getRecords());
+ Page<AlertGroup> page = new Page<>(pageNo, pageSize);
+ IPage<AlertGroup> alertGroupIPage =
alertGroupMapper.queryAlertGroupPage(
+ page, searchVal);
+ PageInfo<AlertGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
+ pageInfo.setTotal((int) alertGroupIPage.getTotal());
+ pageInfo.setTotalList(alertGroupIPage.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java
index ec03018..443b68e 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java
@@ -29,7 +29,6 @@ import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
-import org.apache.dolphinscheduler.dao.vo.AlertGroupVo;
import org.apache.commons.collections.CollectionUtils;
@@ -79,10 +78,10 @@ public class AlertGroupServiceTest {
@Test
public void testListPaging() {
- IPage<AlertGroupVo> page = new Page<>(1, 10);
+ IPage<AlertGroup> page = new Page<>(1, 10);
page.setTotal(1L);
- page.setRecords(getAlertGroupVoList());
- Mockito.when(alertGroupMapper.queryAlertGroupVo(any(Page.class),
eq(groupName))).thenReturn(page);
+ page.setRecords(getList());
+ Mockito.when(alertGroupMapper.queryAlertGroupPage(any(Page.class),
eq(groupName))).thenReturn(page);
User user = new User();
// no operate
Result result = alertGroupService.listPaging(user, groupName, 1, 10);
@@ -92,7 +91,7 @@ public class AlertGroupServiceTest {
user.setUserType(UserType.ADMIN_USER);
result = alertGroupService.listPaging(user, groupName, 1, 10);
logger.info(result.toString());
- PageInfo<AlertGroupVo> pageInfo = (PageInfo<AlertGroupVo>)
result.getData();
+ PageInfo<AlertGroup> pageInfo = (PageInfo<AlertGroup>)
result.getData();
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));
}
@@ -218,23 +217,4 @@ public class AlertGroupServiceTest {
return alertGroup;
}
- /**
- * get AlertGroupVo list
- */
- private List<AlertGroupVo> getAlertGroupVoList() {
- List<AlertGroupVo> alertGroupVos = new ArrayList<>();
- alertGroupVos.add(getAlertGroupVoEntity());
- return alertGroupVos;
- }
-
- /**
- * get AlertGroupVo entity
- */
- private AlertGroupVo getAlertGroupVoEntity() {
- AlertGroupVo alertGroupVo = new AlertGroupVo();
- alertGroupVo.setId(1);
- alertGroupVo.setGroupName(groupName);
- return alertGroupVo;
- }
-
}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java
index 72eac71..0e090f4 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java
@@ -18,7 +18,6 @@
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
-import org.apache.dolphinscheduler.dao.vo.AlertGroupVo;
import org.apache.ibatis.annotations.Param;
@@ -84,12 +83,4 @@ public interface AlertGroupMapper extends
BaseMapper<AlertGroup> {
*/
String queryAlertGroupInstanceIdsById(@Param("alertGroupId") int
alertGroupId);
- /**
- * query alertGroupVo page list
- * @param page page
- * @param groupName groupName
- * @return IPage<AlertGroupVo>: include alert group id and group_name
- */
- IPage<AlertGroupVo> queryAlertGroupVo(Page<AlertGroupVo> page,
- @Param("groupName") String
groupName);
}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/vo/AlertGroupVo.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/vo/AlertGroupVo.java
deleted file mode 100644
index db9c9f5..0000000
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/vo/AlertGroupVo.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 org.apache.dolphinscheduler.dao.vo;
-
-import java.util.Date;
-
-/**
- * AlertGroupVo
- */
-public class AlertGroupVo {
-
- /**
- * primary key
- */
- private int id;
- /**
- * group_name
- */
- private String groupName;
- /**
- * description
- */
- private String description;
- /**
- * create_time
- */
- private Date createTime;
- /**
- * update_time
- */
- private Date updateTime;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getGroupName() {
- return groupName;
- }
-
- public void setGroupName(String groupName) {
- this.groupName = groupName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Date getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-}
diff --git
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml
index efdacb1..521fdce 100644
---
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml
+++
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml
@@ -32,15 +32,7 @@
</if>
order by update_time desc
</select>
- <select id="queryAlertGroupVo"
resultType="org.apache.dolphinscheduler.dao.vo.AlertGroupVo">
- select id, group_name, description, create_time, update_time
- from t_ds_alertgroup
- where 1 = 1
- <if test="groupName != null and groupName != ''">
- and group_name like concat('%', #{groupName}, '%')
- </if>
- order by update_time desc
- </select>
+
<select id="queryByGroupName"
resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select
<include refid="baseSql"/>