🔨 修改终端逻辑.
This commit is contained in:
@@ -28,7 +28,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.visor.framework.mybatis.core.mapper.IMapper;
|
||||
import org.dromara.visor.framework.mybatis.core.query.Conditions;
|
||||
import org.dromara.visor.module.asset.entity.domain.HostConfigDO;
|
||||
import org.dromara.visor.module.asset.entity.po.HostTypeCountPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -134,11 +133,4 @@ public interface HostConfigDAO extends IMapper<HostConfigDO> {
|
||||
*/
|
||||
int setIdentityIdWithNull(@Param("identityIdList") List<Long> identityIdList);
|
||||
|
||||
/**
|
||||
* 查询启用的主机类型数量
|
||||
*
|
||||
* @return count
|
||||
*/
|
||||
List<HostTypeCountPO> selectEnabledTypeCount();
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ public class HostKeyCreateRequest implements Serializable {
|
||||
@Schema(description = "私钥文本")
|
||||
private String privateKey;
|
||||
|
||||
@NotBlank
|
||||
@ParamDecrypt
|
||||
@Schema(description = "密码")
|
||||
private String password;
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 - present Dromara, All rights reserved.
|
||||
*
|
||||
* https://visor.dromara.org
|
||||
* https://visor.dromara.org.cn
|
||||
* https://visor.orionsec.cn
|
||||
*
|
||||
* Members:
|
||||
* Jiahang Li - ljh1553488six@139.com - author
|
||||
*
|
||||
* Licensed 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.dromara.visor.module.asset.service.impl;
|
||||
|
||||
import cn.orionsec.kit.lang.utils.Objects1;
|
||||
import cn.orionsec.kit.lang.utils.collect.Maps;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.dromara.visor.common.entity.chart.PieChartData;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisStrings;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import org.dromara.visor.module.asset.dao.HostConfigDAO;
|
||||
import org.dromara.visor.module.asset.define.cache.AssetStatisticsCacheKeyDefine;
|
||||
import org.dromara.visor.module.asset.entity.po.HostTypeCountPO;
|
||||
import org.dromara.visor.module.asset.enums.HostTypeEnum;
|
||||
import org.dromara.visor.module.asset.service.AssetStatisticsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 资产模块统计服务实现
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2025/3/7 16:26
|
||||
*/
|
||||
@Service
|
||||
public class AssetStatisticsServiceImpl implements AssetStatisticsService {
|
||||
|
||||
@Resource
|
||||
private HostConfigDAO hostConfigDAO;
|
||||
|
||||
@Override
|
||||
public PieChartData getHostTypeChart() {
|
||||
// 查询缓存
|
||||
JSONObject cache = RedisStrings.getJson(AssetStatisticsCacheKeyDefine.HOST_TYPE_COUNT);
|
||||
if (Maps.isEmpty(cache)) {
|
||||
cache = new JSONObject();
|
||||
// 查询数据库
|
||||
List<HostTypeCountPO> typeCountList = hostConfigDAO.selectEnabledTypeCount();
|
||||
for (HostTypeCountPO typeCount : typeCountList) {
|
||||
cache.put(typeCount.getType(), typeCount.getCount());
|
||||
}
|
||||
// 设置屏障 防止穿透
|
||||
CacheBarriers.STRING_MAP.check(cache);
|
||||
// 设置缓存
|
||||
RedisStrings.set(AssetStatisticsCacheKeyDefine.HOST_TYPE_COUNT, cache);
|
||||
}
|
||||
// 删除屏障
|
||||
CacheBarriers.STRING_MAP.remove(cache);
|
||||
// 查询类型数量
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
for (HostTypeEnum value : HostTypeEnum.values()) {
|
||||
data.put(value.name(), Objects1.def(cache.getInteger(value.name()), 0));
|
||||
}
|
||||
return new PieChartData(data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,12 +37,10 @@ import org.dromara.visor.common.enums.EnableStatus;
|
||||
import org.dromara.visor.common.utils.Valid;
|
||||
import org.dromara.visor.framework.biz.operator.log.core.utils.OperatorLogs;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisMaps;
|
||||
import org.dromara.visor.framework.redis.core.utils.RedisStrings;
|
||||
import org.dromara.visor.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import org.dromara.visor.module.asset.convert.HostConvert;
|
||||
import org.dromara.visor.module.asset.dao.HostConfigDAO;
|
||||
import org.dromara.visor.module.asset.dao.HostDAO;
|
||||
import org.dromara.visor.module.asset.define.cache.AssetStatisticsCacheKeyDefine;
|
||||
import org.dromara.visor.module.asset.define.cache.HostCacheKeyDefine;
|
||||
import org.dromara.visor.module.asset.entity.domain.HostDO;
|
||||
import org.dromara.visor.module.asset.entity.dto.HostCacheDTO;
|
||||
@@ -346,7 +344,6 @@ public class HostServiceImpl implements HostService {
|
||||
@Override
|
||||
public void clearCache() {
|
||||
RedisMaps.scanKeysDelete(HostCacheKeyDefine.HOST_INFO.format("*"));
|
||||
RedisStrings.delete(AssetStatisticsCacheKeyDefine.HOST_TYPE_COUNT.getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,12 +16,6 @@
|
||||
<result column="deleted" property="deleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 类型数量结果映射 -->
|
||||
<resultMap id="TypeCountResultMap" type="org.dromara.visor.module.asset.entity.po.HostTypeCountPO">
|
||||
<result column="type" property="type"/>
|
||||
<result column="total_count" property="count"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, host_id, type, status, config, create_time, update_time, creator, updater, deleted
|
||||
@@ -45,12 +39,4 @@
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectEnabledTypeCount" resultMap="TypeCountResultMap">
|
||||
SELECT type, COUNT(1) total_count
|
||||
FROM host_config
|
||||
WHERE deleted = 0
|
||||
AND status = 'ENABLED'
|
||||
GROUP BY type
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user