帮助服务
| 35 | * 帮助服务 |
| 36 | */ |
| 37 | @Service |
| 38 | public class HelpServiceImpl implements HelpService { |
| 39 | private static final Logger logger = LogManager.getLogger(HelpServiceImpl.class); |
| 40 | |
| 41 | |
| 42 | @Resource HelpRepository helpRepository; |
| 43 | @Resource |
| 44 | SettingRepository settingRepository; |
| 45 | @Resource |
| 46 | JsonComponent jsonComponent; |
| 47 | @Resource |
| 48 | TextFilterComponent textFilterComponent; |
| 49 | @Resource |
| 50 | FileComponent fileComponent; |
| 51 | @Resource HelpTypeRepository helpTypeRepository; |
| 52 | |
| 53 | //Html过滤结果 |
| 54 | private record HtmlFilterResult(HtmlProcessingResult htmlProcessingResult, String formatterMarkdown,String content) { |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * 获取帮助 |
| 59 | * @param helpId 帮助Id |
| 60 | * @param host 域名 |
| 61 | * @param serverAddressList 文件服务器地址集合 |
| 62 | * @return |
| 63 | */ |
| 64 | public Help getHelp(Long helpId, String host,List<String> serverAddressList){ |
| 65 | if (helpId == null || helpId < 0L) { |
| 66 | throw new BusinessException(Map.of("helpId", "帮助Id不存在")); |
| 67 | } |
| 68 | Help help = helpRepository.findById(helpId); |
| 69 | if(help == null){ |
| 70 | throw new BusinessException(Map.of("helpId", "帮助不存在")); |
| 71 | } |
| 72 | HelpType helpType = helpTypeRepository.findById(help.getHelpTypeId()); |
| 73 | if(helpType != null){ |
| 74 | help.setHelpTypeName(helpType.getName()); |
| 75 | } |
| 76 | SystemSetting systemSetting = settingRepository.findSystemSetting_cache(); |
| 77 | |
| 78 | //处理富文本路径 |
| 79 | help.setContent(fileComponent.processRichTextFilePath(help.getContent(),"help")); |
| 80 | |
| 81 | if(help.getContent() != null && !help.getContent().trim().isEmpty() && systemSetting.getFileSecureLinkSecret() != null && !systemSetting.getFileSecureLinkSecret().trim().isEmpty()){ |
| 82 | |
| 83 | //解析上传的文件完整路径名称 |
| 84 | Map<String,String> analysisFullFileNameMap = textFilterComponent.analysisFullFileName(help.getContent(),"help",serverAddressList); |
| 85 | if(analysisFullFileNameMap != null && analysisFullFileNameMap.size() >0){ |
| 86 | |
| 87 | |
| 88 | Map<String,String> newFullFileNameMap = new HashMap<String,String>();//新的完整路径名称 key: 完整路径名称 value: 重定向接口 |
| 89 | for (Map.Entry<String,String> entry : analysisFullFileNameMap.entrySet()) { |
| 90 | |
| 91 | newFullFileNameMap.put(entry.getKey(), host+ SecureLink.createDownloadRedirectLink(entry.getKey(),entry.getValue(),-1L,systemSetting.getFileSecureLinkSecret())); |
| 92 | } |
| 93 | |
| 94 | help.setContent(textFilterComponent.processFullFileName(help.getContent(),"help",newFullFileNameMap,serverAddressList)); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…