| | |
| | | |
| | | private ColumnMapper columnMapper = SpringContextHolder.getBean(ColumnMapper.class); |
| | | private ArticleMapper articleMapper = SpringContextHolder.getBean(ArticleMapper.class); |
| | | private CmsProperties cmsProperties = SpringContextHolder.getBean(CmsProperties.class); |
| | | |
| | | private String baseUrl = ""; |
| | | @Override |
| | | public void dataParser(AttrNode node) { |
| | | log.info("导航栏解析"); |
| | | Long companyId = (Long) node.getSystemDataValue("companyId"); |
| | | baseUrl = (String) node.getSystemDataValue("baseUrl"); |
| | | |
| | | List<ColumnEntity> columns = columnMapper.selectColumnByParentId(0L, companyId); |
| | | List<ColumnEntity> columns = columnMapper.selectColumnByParentId(0L, companyId, 1); |
| | | |
| | | if (CollUtil.isEmpty(columns)) { |
| | | return; |
| | |
| | | |
| | | NavData index = new NavData(); |
| | | index.setTitle("首页"); |
| | | index.setUrl(cmsProperties.getBaseUrl()); |
| | | index.setUrl(baseUrl); |
| | | index.setCode("index"); |
| | | list.add(index); |
| | | |
| | | for (ColumnEntity column : columns) { |
| | | NavData navData = columnToNav(column); |
| | | |
| | | List<ColumnEntity> child = columnMapper.selectColumnByParentId(column.getId(), companyId); |
| | | List<ColumnEntity> child = columnMapper.selectColumnByParentId(column.getId(), companyId, 1); |
| | | if (CollUtil.isNotEmpty(child)) { |
| | | List<NavData> childNavData = columnsToNavs(child); |
| | | navData.setChildren(childNavData); |
| | |
| | | public NavData columnToNav(ColumnEntity column) { |
| | | NavData navData = ColumnConversion.INSTANCE.columnToNav(column); |
| | | |
| | | navData.setUrl(cmsProperties.getBaseUrl() + column.getPath()); |
| | | navData.setUrl(baseUrl + column.getPath()); |
| | | if (column.getType() == 2) { |
| | | if (column.getTargetType() == 1) { |
| | | ArticleEntity article = this.articleMapper.selectArticleById(Long.parseLong(column.getTargetUrl())); |
| | | navData.setUrl(cmsProperties.getBaseUrl() + article.getPath() + "/" + article.getId() + ".html"); |
| | | navData.setUrl(baseUrl + article.getPath() + "/" + article.getId() + ".html"); |
| | | } else if (column.getTargetType() == 2) { |
| | | ColumnEntity columnEntity = this.columnMapper.selectByCodeAndCompanyId(column.getTargetUrl(), column.getCompanyId()); |
| | | navData.setUrl(cmsProperties.getBaseUrl() + columnEntity.getPath()); |
| | | navData.setUrl(baseUrl + columnEntity.getPath()); |
| | | } else { |
| | | navData.setUrl(column.getTargetUrl()); |
| | | } |