Browse Source
* [Feature-#3828][server] Delete recipients and CCs in the process definition and select the associated alert group instead * The specific alarm instance associated with the alert group * The process definition only associates the alert group, and does not care about the specific alarm instance. this closes #3828 * remove test cc * remove test cc * fix test error * add sql upgrade script delete alert column(show_type、alert_type、re、cc) * code style * update test Note the statement to delete the column, and provide related instructions * delete AlertGroup field(alert_type) * fix ut error * fix ut error * fix ut error * code style * delete api-doc receiverCC * delete UserAlertGroupMapper * delete UserAlertGroup * delete UserAlertGroupApi * alert group add coulmn user_id * alter user_id to create_user_id * userinfo remove alert group infopull/3/MERGE
Kirs
4 years ago
committed by
GitHub
45 changed files with 1189 additions and 2140 deletions
@ -1,38 +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.api.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.apache.dolphinscheduler.dao.entity.UserAlertGroup; |
||||
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@Service |
||||
public class UserAlertGroupService extends ServiceImpl<UserAlertGroupMapper, UserAlertGroup> { |
||||
|
||||
@Autowired |
||||
private UserAlertGroupMapper userAlertGroupMapper; |
||||
|
||||
boolean deleteByAlertGroupId(Integer groupId) { |
||||
return userAlertGroupMapper.deleteByAlertgroupId(groupId) >= 1; |
||||
} |
||||
|
||||
} |
@ -1,53 +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.api.service; |
||||
|
||||
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper; |
||||
import static org.junit.Assert.assertEquals; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.mockito.ArgumentCaptor; |
||||
import org.mockito.InjectMocks; |
||||
import org.mockito.Mock; |
||||
import org.mockito.Mockito; |
||||
import org.mockito.junit.MockitoJUnitRunner; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@RunWith(MockitoJUnitRunner.class) |
||||
public class UserAlertGroupServiceTest { |
||||
|
||||
@InjectMocks |
||||
UserAlertGroupService userAlertGroupService; |
||||
|
||||
@Mock |
||||
UserAlertGroupMapper userAlertGroupMapper; |
||||
|
||||
@Test |
||||
public void deleteByAlertGroupId() { |
||||
|
||||
Integer groupId = 1; |
||||
userAlertGroupService.deleteByAlertGroupId(groupId); |
||||
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class); |
||||
|
||||
Mockito.verify(userAlertGroupMapper).deleteByAlertgroupId(argumentCaptor.capture()); |
||||
assertEquals(argumentCaptor.getValue(), groupId); |
||||
|
||||
} |
||||
|
||||
} |
@ -1,142 +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.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* user alert group |
||||
*/ |
||||
@TableName("t_ds_relation_user_alertgroup") |
||||
public class UserAlertGroup { |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableId(value="id", type=IdType.AUTO) |
||||
private int id; |
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
@TableField("alertgroup_id") |
||||
private int alertgroupId; |
||||
|
||||
/** |
||||
* alert group name |
||||
*/ |
||||
@TableField(exist = false) |
||||
private String alertgroupName; |
||||
|
||||
/** |
||||
* user id |
||||
*/ |
||||
private int userId; |
||||
|
||||
/** |
||||
* user name |
||||
*/ |
||||
@TableField(exist = false) |
||||
private String userName; |
||||
|
||||
/** |
||||
* create time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* update time |
||||
*/ |
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") |
||||
private Date updateTime; |
||||
|
||||
public int getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setId(int id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public int getAlertgroupId() { |
||||
return alertgroupId; |
||||
} |
||||
|
||||
public void setAlertgroupId(int alertgroupId) { |
||||
this.alertgroupId = alertgroupId; |
||||
} |
||||
|
||||
public int getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(int userId) { |
||||
this.userId = userId; |
||||
} |
||||
|
||||
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; |
||||
} |
||||
|
||||
public String getAlertgroupName() { |
||||
return alertgroupName; |
||||
} |
||||
|
||||
public void setAlertgroupName(String alertgroupName) { |
||||
this.alertgroupName = alertgroupName; |
||||
} |
||||
|
||||
public String getUserName() { |
||||
return userName; |
||||
} |
||||
|
||||
public void setUserName(String userName) { |
||||
this.userName = userName; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "UserAlertGroup{" + |
||||
"id=" + id + |
||||
", alertgroupId=" + alertgroupId + |
||||
", alertgroupName='" + alertgroupName + '\'' + |
||||
", userId=" + userId + |
||||
", userName='" + userName + '\'' + |
||||
", createTime=" + createTime + |
||||
", updateTime=" + updateTime + |
||||
'}'; |
||||
} |
||||
} |
@ -1,45 +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.mapper; |
||||
|
||||
import org.apache.dolphinscheduler.dao.entity.User; |
||||
import org.apache.dolphinscheduler.dao.entity.UserAlertGroup; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* user alertgroup relation mapper interface
|
||||
*/ |
||||
public interface UserAlertGroupMapper extends BaseMapper<UserAlertGroup> { |
||||
|
||||
/** |
||||
* delete user alertgroup relation by alertgroupId |
||||
* @param alertgroupId alertgroupId |
||||
* @return delete result |
||||
*/ |
||||
int deleteByAlertgroupId(@Param("alertgroupId") int alertgroupId); |
||||
|
||||
/** |
||||
* list user by alertgroupId |
||||
* @param alertgroupId alertgroupId |
||||
* @return user list |
||||
*/ |
||||
List<User> listUserByAlertgroupId(@Param("alertgroupId") int alertgroupId); |
||||
|
||||
} |
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper"> |
||||
<delete id="deleteByAlertgroupId"> |
||||
delete from t_ds_relation_user_alertgroup |
||||
where alertgroup_id = #{alertgroupId} |
||||
</delete> |
||||
<select id="listUserByAlertgroupId" resultType="org.apache.dolphinscheduler.dao.entity.User"> |
||||
SELECT u.* |
||||
FROM t_ds_relation_user_alertgroup g_u |
||||
JOIN t_ds_user u on g_u.user_id = u.id |
||||
WHERE g_u.alertgroup_id = #{alertgroupId} |
||||
</select> |
||||
</mapper> |
@ -1,196 +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.mapper; |
||||
|
||||
|
||||
import org.apache.dolphinscheduler.common.enums.AlertType; |
||||
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.entity.UserAlertGroup; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.annotation.Rollback; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest |
||||
@Transactional |
||||
@Rollback(true) |
||||
public class UserAlertGroupMapperTest { |
||||
|
||||
@Autowired |
||||
private UserMapper userMapper; |
||||
|
||||
@Autowired |
||||
AlertGroupMapper alertGroupMapper; |
||||
|
||||
@Autowired |
||||
private UserAlertGroupMapper userAlertGroupMapper; |
||||
|
||||
/** |
||||
* insert one UserAlertGroup |
||||
* @param user user |
||||
* @param alertGroup alertGroup |
||||
* @return UserAlertGroup |
||||
*/ |
||||
private UserAlertGroup insertOne(User user,AlertGroup alertGroup){ |
||||
UserAlertGroup userAlertGroup = new UserAlertGroup(); |
||||
userAlertGroup.setAlertgroupName(alertGroup.getGroupName()); |
||||
userAlertGroup.setAlertgroupId(alertGroup.getId()); |
||||
userAlertGroup.setUserId(user.getId()); |
||||
userAlertGroup.setCreateTime(new Date()); |
||||
userAlertGroup.setUpdateTime(new Date()); |
||||
userAlertGroupMapper.insert(userAlertGroup); |
||||
return userAlertGroup; |
||||
} |
||||
|
||||
/** |
||||
* insert one UserAlertGroup |
||||
* @return UserAlertGroup |
||||
*/ |
||||
private UserAlertGroup insertOne(){ |
||||
UserAlertGroup userAlertGroup = new UserAlertGroup(); |
||||
userAlertGroup.setAlertgroupName("dolphin_alert_group"); |
||||
userAlertGroup.setAlertgroupId(10); |
||||
userAlertGroup.setUserId(4); |
||||
userAlertGroup.setCreateTime(new Date()); |
||||
userAlertGroup.setUpdateTime(new Date()); |
||||
userAlertGroupMapper.insert(userAlertGroup); |
||||
return userAlertGroup; |
||||
} |
||||
|
||||
/** |
||||
* insert one user |
||||
* @return User |
||||
*/ |
||||
private User insertOneUser(){ |
||||
User user = new User(); |
||||
user.setUserName("user1"); |
||||
user.setUserPassword("1"); |
||||
user.setEmail("xx@123.com"); |
||||
user.setUserType(UserType.GENERAL_USER); |
||||
user.setCreateTime(new Date()); |
||||
user.setTenantId(1); |
||||
user.setQueue("dolphin"); |
||||
user.setUpdateTime(new Date()); |
||||
userMapper.insert(user); |
||||
return user; |
||||
} |
||||
|
||||
/** |
||||
* insert one AlertGroup |
||||
* @return AlertGroup |
||||
*/ |
||||
private AlertGroup insertOneAlertGroup(){ |
||||
//insertOne
|
||||
AlertGroup alertGroup = new AlertGroup(); |
||||
alertGroup.setGroupName("alert group 1"); |
||||
alertGroup.setDescription("alert test1"); |
||||
alertGroup.setGroupType(AlertType.EMAIL); |
||||
|
||||
alertGroup.setCreateTime(new Date()); |
||||
alertGroup.setUpdateTime(new Date()); |
||||
alertGroupMapper.insert(alertGroup); |
||||
return alertGroup; |
||||
} |
||||
|
||||
/** |
||||
* test update |
||||
*/ |
||||
@Test |
||||
public void testUpdate(){ |
||||
//insertOneUser
|
||||
User user = insertOneUser(); |
||||
//insertOneAlertGroup
|
||||
AlertGroup alertGroup = insertOneAlertGroup(); |
||||
|
||||
//insertOne
|
||||
UserAlertGroup userAlertGroup = insertOne(); |
||||
//update
|
||||
userAlertGroup.setUserId(user.getId()); |
||||
userAlertGroup.setAlertgroupId(alertGroup.getId()); |
||||
userAlertGroup.setUpdateTime(new Date()); |
||||
|
||||
int update = userAlertGroupMapper.updateById(userAlertGroup); |
||||
Assert.assertEquals(update, 1); |
||||
} |
||||
|
||||
/** |
||||
* test delete |
||||
*/ |
||||
@Test |
||||
public void testDelete(){ |
||||
//insertOne
|
||||
UserAlertGroup userAlertGroup = insertOne(); |
||||
//delete
|
||||
int delete = userAlertGroupMapper.deleteById(userAlertGroup.getId()); |
||||
Assert.assertEquals(delete, 1); |
||||
} |
||||
|
||||
/** |
||||
* test query |
||||
*/ |
||||
@Test |
||||
public void testQuery() { |
||||
//insertOne
|
||||
UserAlertGroup userAlertGroup = insertOne(); |
||||
//query
|
||||
List<UserAlertGroup> userAlertGroupList = userAlertGroupMapper.selectList(null); |
||||
Assert.assertNotEquals(userAlertGroupList.size(), 0); |
||||
} |
||||
|
||||
/** |
||||
* test delete by alertgroupId |
||||
*/ |
||||
@Test |
||||
public void testDeleteByAlertgroupId() { |
||||
//insertOneUser
|
||||
User user = insertOneUser(); |
||||
//insertOneAlertGroup
|
||||
AlertGroup alertGroup = insertOneAlertGroup(); |
||||
|
||||
//insertOne
|
||||
UserAlertGroup userAlertGroup = insertOne(user,alertGroup); |
||||
int delete = userAlertGroupMapper.deleteByAlertgroupId(alertGroup.getId()); |
||||
Assert.assertEquals(delete, 1); |
||||
} |
||||
|
||||
/** |
||||
* test list user by alertgroupId |
||||
*/ |
||||
@Test |
||||
public void testListUserByAlertgroupId() { |
||||
//insertOneUser
|
||||
User user = insertOneUser(); |
||||
//insertOneAlertGroup
|
||||
AlertGroup alertGroup = insertOneAlertGroup(); |
||||
|
||||
//insertOne
|
||||
UserAlertGroup userAlertGroup = insertOne(user,alertGroup); |
||||
List<User> userList = userAlertGroupMapper.listUserByAlertgroupId(alertGroup.getId()); |
||||
Assert.assertNotEquals(userList.size(), 0); |
||||
|
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue