🔨 修改基础查询.
This commit is contained in:
@@ -90,6 +90,8 @@ public interface ErrorMessage {
|
||||
|
||||
String HOST_NOT_ENABLED = "主机未启用";
|
||||
|
||||
String CONFIG_NOT_ENABLED = "配置未启用";
|
||||
|
||||
String UNABLE_OPERATE_ADMIN_ROLE = "无法操作管理员账号";
|
||||
|
||||
String UNSUPPORTED_CHARSET = "不支持的编码 [{}]";
|
||||
|
||||
@@ -24,11 +24,18 @@ package org.dromara.visor.module.asset.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.dromara.visor.common.constant.Const;
|
||||
import org.dromara.visor.common.handler.data.GenericsStrategyDefinition;
|
||||
import org.dromara.visor.common.handler.data.model.GenericsDataModel;
|
||||
import org.dromara.visor.common.handler.data.strategy.GenericsDataStrategy;
|
||||
import org.dromara.visor.module.asset.handler.host.config.strategy.HostSshConfigStrategy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 主机配置类型枚举
|
||||
*
|
||||
@@ -61,4 +68,15 @@ public enum HostTypeEnum implements GenericsStrategyDefinition {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<String> split(String types) {
|
||||
if (types == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return Arrays.stream(types.split(Const.COMMA))
|
||||
.map(HostTypeEnum::of)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Enum::name)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +58,14 @@ public interface DataExtraApi {
|
||||
*/
|
||||
Long addExtraItem(DataExtraSetDTO dto, DataExtraTypeEnum type);
|
||||
|
||||
/**
|
||||
* 新增数据拓展信息
|
||||
*
|
||||
* @param rows rows
|
||||
* @param type type
|
||||
*/
|
||||
void addExtraItems(List<DataExtraSetDTO> rows, DataExtraTypeEnum type);
|
||||
|
||||
/**
|
||||
* 更新数据拓展信息
|
||||
*
|
||||
|
||||
@@ -100,6 +100,15 @@ public interface DataGroupRelApi {
|
||||
*/
|
||||
Future<Set<Long>> getGroupIdByRelIdAsync(DataGroupTypeEnum type, Long relId);
|
||||
|
||||
/**
|
||||
* 通过 relIdList 查询 groupRel
|
||||
*
|
||||
* @param type type
|
||||
* @param relIdList relIdList
|
||||
* @return rows
|
||||
*/
|
||||
Map<Long, Set<Long>> getGroupRelByRelIdList(DataGroupTypeEnum type, List<Long> relIdList);
|
||||
|
||||
/**
|
||||
* 删除数据分组关联
|
||||
*
|
||||
|
||||
@@ -62,7 +62,7 @@ public class DataExtraSetDTO implements Serializable {
|
||||
@Schema(description = "配置项")
|
||||
private String item;
|
||||
|
||||
@NotBlank
|
||||
@NotNull
|
||||
@Schema(description = "配置值")
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -79,6 +79,18 @@ public class DataExtraApiImpl implements DataExtraApi {
|
||||
return dataExtraService.addExtraItem(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraItems(List<DataExtraSetDTO> rows, DataExtraTypeEnum type) {
|
||||
for (DataExtraSetDTO row : rows) {
|
||||
Valid.valid(row);
|
||||
}
|
||||
List<DataExtraSetRequest> extras = rows.stream()
|
||||
.map(DataExtraProviderConvert.MAPPER::to)
|
||||
.peek(s -> s.setType(type.name()))
|
||||
.collect(Collectors.toList());
|
||||
dataExtraService.addExtraItems(extras);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateExtraValue(Long id, String value) {
|
||||
return dataExtraService.updateExtraValue(id, value);
|
||||
|
||||
@@ -107,6 +107,14 @@ public class DataGroupRelApiImpl implements DataGroupRelApi {
|
||||
return CompletableFuture.completedFuture(groupIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Set<Long>> getGroupRelByRelIdList(DataGroupTypeEnum type, List<Long> relIdList) {
|
||||
return dataGroupRelService.getGroupRelByRelIdList(type.name(), Const.SYSTEM_USER_ID, relIdList)
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(DataGroupRelDO::getRelId,
|
||||
Collectors.mapping(DataGroupRelDO::getGroupId, Collectors.toSet())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteByRelId(DataGroupTypeEnum type, Long relId) {
|
||||
return dataGroupRelService.deleteByRelId(type.name(), Const.SYSTEM_USER_ID, relId);
|
||||
|
||||
@@ -95,8 +95,6 @@ public class SystemUserController {
|
||||
return systemUserService.updateSystemUserById(request);
|
||||
}
|
||||
|
||||
// TODO 修改头像 最后再说 可有可无的功能 要是有 http 文件需求就写
|
||||
|
||||
@DemoDisableApi
|
||||
@OperatorLog(SystemUserOperatorType.UPDATE_STATUS)
|
||||
@PutMapping("/update-status")
|
||||
|
||||
@@ -54,6 +54,13 @@ public interface DataExtraService {
|
||||
*/
|
||||
Long addExtraItem(DataExtraSetRequest request);
|
||||
|
||||
/**
|
||||
* 批量新增数据拓展信息
|
||||
*
|
||||
* @param rows rows
|
||||
*/
|
||||
void addExtraItems(List<DataExtraSetRequest> rows);
|
||||
|
||||
/**
|
||||
* 更新数据拓展信息
|
||||
*
|
||||
|
||||
@@ -102,6 +102,16 @@ public interface DataGroupRelService {
|
||||
*/
|
||||
List<DataGroupRelDO> getGroupRelByRelId(String type, Long userId, Long relId);
|
||||
|
||||
/**
|
||||
* 通过 relId 查询 groupRel
|
||||
*
|
||||
* @param type type
|
||||
* @param userId userId
|
||||
* @param relIdList relIdList
|
||||
* @return rows
|
||||
*/
|
||||
List<DataGroupRelDO> getGroupRelByRelIdList(String type, Long userId, List<Long> relIdList);
|
||||
|
||||
/**
|
||||
* 删除数据分组关联
|
||||
*
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -95,6 +96,27 @@ public class DataExtraServiceImpl implements DataExtraService {
|
||||
return insert.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraItems(List<DataExtraSetRequest> rows) {
|
||||
// 插入
|
||||
List<DataExtraDO> list = rows.stream()
|
||||
.map(s -> {
|
||||
DataExtraDO row = new DataExtraDO();
|
||||
row.setUserId(s.getUserId());
|
||||
row.setRelId(s.getRelId());
|
||||
row.setType(s.getType());
|
||||
row.setItem(s.getItem());
|
||||
row.setValue(s.getValue());
|
||||
return row;
|
||||
}).collect(Collectors.toList());
|
||||
dataExtraDAO.insertBatch(list);
|
||||
// 删除缓存
|
||||
Set<String> keys = rows.stream()
|
||||
.map(s -> DataExtraCacheKeyDefine.DATA_EXTRA.format(s.getUserId(), s.getType(), s.getItem()))
|
||||
.collect(Collectors.toSet());
|
||||
RedisMaps.delete(keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateExtraValue(Long id, String value) {
|
||||
// 查询数据
|
||||
|
||||
@@ -228,6 +228,17 @@ public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataGroupRelDO> getGroupRelByRelIdList(String type, Long userId, List<Long> relIdList) {
|
||||
return dataGroupRelDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataGroupRelDO::getType, type)
|
||||
.eq(DataGroupRelDO::getUserId, userId)
|
||||
.in(DataGroupRelDO::getRelId, relIdList)
|
||||
.then()
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer deleteByRelId(String type, Long userId, Long relId) {
|
||||
|
||||
Reference in New Issue
Block a user