fix: 移动端搜索出不存在的目录

This commit is contained in:
fit2cloud-chenyw 2022-01-29 09:06:31 +08:00
parent 6f7345e859
commit eec895b8c8
2 changed files with 11 additions and 9 deletions

View File

@ -12,16 +12,18 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class DirService {
private static final String[] filterDirNames = { "i18n_panel_list", "i18n_default_panel" };
@Resource
private MobileDirMapper mobileDirMapper;
public List<String> permissions() {
CurrentUserDto user = AuthUtils.getUser();
Long userId = user.getUserId();
@ -43,13 +45,14 @@ public class DirService {
String userId = String.valueOf(AuthUtils.getUser().getUserId());
List<PanelEntity> panelEntities = new ArrayList<>();
if (StringUtils.isNotBlank(request.getName())) {
panelEntities = mobileDirMapper.queryWithName(request.getName(),userId);
}else {
panelEntities = mobileDirMapper.query(request.getPid(),userId);
panelEntities = mobileDirMapper.queryWithName(request.getName(), userId);
} else {
panelEntities = mobileDirMapper.query(request.getPid(), userId);
}
if (CollectionUtils.isEmpty(panelEntities)) return null;
List<DirItemDTO> dtos = panelEntities.stream().map(data -> {
if (CollectionUtils.isEmpty(panelEntities))
return null;
List<String> filterLists = Arrays.asList(filterDirNames);
List<DirItemDTO> dtos = panelEntities.stream().filter(dto -> !filterLists.contains(dto.getText())).map(data -> {
DirItemDTO dirItemDTO = new DirItemDTO();
dirItemDTO.setId(data.getId());
dirItemDTO.setText(data.getText());
@ -63,5 +66,4 @@ public class DirService {
return CommonBeanFactory.getBean(DirService.class);
}
}

View File

@ -89,7 +89,7 @@ export default {
const param = {name: val}
requestDir(param).then(res => {
let dataObj = res.data
dataObj.map(item => {
dataObj && dataObj.map(item => {
item.name = item.text
return util.dataHandle(item, val);
});