diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java index 4ddc3c9d2a2431a65d4e360c7cf3cf1383b9d2fb..5f6b58adf4e71461fc3bb650487b2464fef77125 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java @@ -21,6 +21,7 @@ import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ALERT_GROUP_ER import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ALERT_GROUP_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.LIST_PAGING_ALERT_GROUP_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_ALERTGROUP_ERROR; +import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALERT_GROUP_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ALERT_GROUP_ERROR; import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation; @@ -141,6 +142,28 @@ public class AlertGroupController extends BaseController { result = alertGroupService.listPaging(loginUser, searchVal, pageNo, pageSize); return returnDataListPaging(result); } + /** + * check alarm group detail by Id + * + * @param loginUser login user + * @param id alert group id + * @return one alert group + */ + @ApiOperation(value = "queryAlertGroupById", notes = "QUERY_ALERT_GROUP_BY_ID_NOTES") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", dataType = "Int", example = "1") + }) + @GetMapping(value = "/query") + @ResponseStatus(HttpStatus.OK) + @ApiException(QUERY_ALERT_GROUP_ERROR) + @AccessLogAnnotation(ignoreRequestArgs = "loginUser") + public Result queryAlertGroupById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @RequestParam("id") Integer id) { + + Map result = alertGroupService.queryAlertGroupById(loginUser, id); + return returnDataList(result); + } + /** * updateProcessInstance alert group diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java index 8372a69355d6c08cd572ce293c8014677c85bb3c..4c7d25efca48770c1f5fb1e497d405243b734f52 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java @@ -211,6 +211,7 @@ public enum Status { WORKER_ADDRESS_INVALID(10177, "worker address {0} invalid", "worker地址[{0}]无效"), QUERY_WORKER_ADDRESS_LIST_FAIL(10178, "query worker address list fail ", "查询worker地址列表失败"), TRANSFORM_PROJECT_OWNERSHIP(10179, "Please transform project ownership [{0}]", "请先转移项目所有权[{0}]"), + QUERY_ALERT_GROUP_ERROR(10180, "query alert group error", "查询告警组错误"), UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"), UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"), diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java index 71e09cab6dd9c266882e4c17fd485cee2f52e64d..810bb80ddd6a292a9618aeee27dbe68a749378cd 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java @@ -33,6 +33,15 @@ public interface AlertGroupService { */ Map queryAlertgroup(); + /** + * query alert group by id + * + * @param loginUser login user + * @param id alert group id + * @return one alert group + */ + Map queryAlertGroupById(User loginUser, Integer id); + /** * paging query alarm group list * 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 02a564a75fbe3e7c409572323e61127afe18883f..8b62bbb80545215b03e1ea258da448ebed2b37ed 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 @@ -69,6 +69,33 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup return result; } + /** + * query alert group by id + * + * @param loginUser login user + * @param id alert group id + * @return one alert group + */ + @Override + public Map queryAlertGroupById(User loginUser, Integer id) { + Map result = new HashMap<>(); + result.put(Constants.STATUS, false); + + //only admin can operate + if (isNotAdmin(loginUser, result)) { + return result; + } + //check exist + AlertGroup alertGroup = alertGroupMapper.selectById(id); + if (alertGroup == null) { + putMsg(result, Status.ALERT_GROUP_NOT_EXIST); + return result; + } + result.put("data", alertGroup); + putMsg(result, Status.SUCCESS); + return result; + } + /** * paging query alarm group list * @@ -85,11 +112,10 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup if (isNotAdmin(loginUser, result)) { return result; } - - Page page = new Page<>(pageNo, pageSize); - IPage alertGroupIPage = alertGroupMapper.queryAlertGroupPage( + Page> page = new Page<>(pageNo, pageSize); + IPage> alertGroupIPage = alertGroupMapper.queryAlertGroup( page, searchVal); - PageInfo pageInfo = new PageInfo<>(pageNo, pageSize); + PageInfo> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotalCount((int) alertGroupIPage.getTotal()); pageInfo.setLists(alertGroupIPage.getRecords()); result.put(Constants.DATA_LIST, pageInfo); 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 b8f4188fc7542e1ab2834ff7daa982a3be67ef59..e478f4db2de8b2dd1a34743a147bd9bce436a2a3 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 @@ -22,6 +22,7 @@ import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -82,4 +83,13 @@ public interface AlertGroupMapper extends BaseMapper { * @return */ String queryAlertGroupInstanceIdsById(@Param("alertGroupId") int alertGroupId); + + /** + * alert group page + * @param page page + * @param groupName groupName + * @return map IPage + */ + IPage> queryAlertGroup(Page> page, + @Param("groupName") String groupName); } 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 8a7d3a57e8bfd2d896447e12d6a660ecec16190d..1dead3298d955d763dfeb28dedc55a8759fee1ec 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,6 +32,15 @@ order by update_time desc + - \ No newline at end of file +