-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
312 additions
and
30 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...on-common-flyway/src/main/resources/db/migration/V32__240208_ADD_alarm_history_COLUMN.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. | ||
*/ | ||
|
||
-- ---------------------------- | ||
-- Table structure for alarm_history | ||
-- ---------------------------- | ||
ALTER TABLE `alarm_history` | ||
ADD COLUMN `deleted` TINYINT(4) NULL COMMENT '软删除标记'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,4 +117,6 @@ public class AlarmHistory { | |
*/ | ||
@Column(name = "app") | ||
private String app; | ||
|
||
private boolean deleted; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,6 @@ public class AlarmHistoryDTO { | |
private String envType; | ||
|
||
private List<String> app; | ||
|
||
private boolean deleted; | ||
} |
52 changes: 52 additions & 0 deletions
52
...src/main/java/io/holoinsight/server/home/biz/listener/AlarmRuleHistoryUpdateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. | ||
*/ | ||
|
||
package io.holoinsight.server.home.biz.listener; | ||
|
||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
import com.google.common.eventbus.AllowConcurrentEvents; | ||
import com.google.common.eventbus.Subscribe; | ||
import io.holoinsight.server.home.common.util.EventBusHolder; | ||
import io.holoinsight.server.home.dal.mapper.AlarmHistoryDetailMapper; | ||
import io.holoinsight.server.home.dal.model.AlarmHistoryDetail; | ||
import io.holoinsight.server.home.facade.AlarmHistoryDTO; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.annotation.Resource; | ||
|
||
/** | ||
* @author jsy1001de | ||
* @version 1.0: AlarmRuleUpdateListener.java, Date: 2023-06-09 Time: 09:57 | ||
*/ | ||
@Component | ||
@Slf4j | ||
public class AlarmRuleHistoryUpdateListener { | ||
|
||
@Resource | ||
private AlarmHistoryDetailMapper detailMapper; | ||
|
||
@PostConstruct | ||
void register() { | ||
EventBusHolder.register(this); | ||
} | ||
|
||
@Subscribe | ||
@AllowConcurrentEvents | ||
public void onEvent(AlarmHistoryDTO alarmHistoryDTO) { | ||
|
||
if (alarmHistoryDTO.isDeleted()) { | ||
deleteAlarmHistoryDetail(alarmHistoryDTO.getId(), alarmHistoryDTO.getUniqueId()); | ||
} | ||
} | ||
|
||
private void deleteAlarmHistoryDetail(Long alarmHistoryId, String uniqueId) { | ||
QueryWrapper<AlarmHistoryDetail> queryWrapper = new QueryWrapper<>(); | ||
queryWrapper.eq("unique_id", uniqueId); | ||
queryWrapper.eq("history_id", alarmHistoryId); | ||
int count = this.detailMapper.delete(queryWrapper); | ||
log.info("delete alarm history detail size {}", count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...src/main/java/io/holoinsight/server/home/web/security/custom/AbstractResourceChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. | ||
*/ | ||
package io.holoinsight.server.home.web.security.custom; | ||
|
||
import io.holoinsight.server.home.web.security.LevelAuthorizationCheck; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author masaimu | ||
* @version 2024-02-07 17:29:00 | ||
*/ | ||
@Slf4j | ||
public abstract class AbstractResourceChecker implements LevelAuthorizationCheck { | ||
|
||
protected boolean checkIdNotNull(List<String> parameters) { | ||
if (CollectionUtils.isEmpty(parameters) || !StringUtils.isNumeric(parameters.get(0))) { | ||
log.error("parameters {} is empty or is not numeric.", parameters); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
protected boolean checkIdExists(List<String> parameters, String tenant, String workspace) { | ||
if (!checkIdNotNull(parameters)) { | ||
return false; | ||
} | ||
Long id = Long.parseLong(parameters.get(0)); | ||
return checkIdExists(id, tenant, workspace); | ||
} | ||
|
||
abstract boolean checkIdExists(Long id, String tenant, String workspace); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.