bug 6708 h5中去除notice内容的html标签

This commit is contained in:
sxu 2025-07-10 10:01:08 +08:00
parent 86c53aff0a
commit 2608079db1
1 changed files with 6 additions and 2 deletions

View File

@ -16,6 +16,8 @@ import com.bonus.system.service.ISysNoticeService;
@Service
public class SysNoticeServiceImpl implements ISysNoticeService
{
private static final String HTML_REGEX = "(?s)<[^>]*>(\\s*<[^>]*>)*";
@Autowired
private SysNoticeMapper noticeMapper;
@ -28,7 +30,9 @@ public class SysNoticeServiceImpl implements ISysNoticeService
@Override
public SysNotice selectNoticeById(Long noticeId)
{
return noticeMapper.selectNoticeById(noticeId);
SysNotice sysNotice = noticeMapper.selectNoticeById(noticeId);
sysNotice.setNoticeContentNoHtml(sysNotice.getNoticeContent().replaceAll(HTML_REGEX, ""));
return sysNotice;
}
/**
@ -41,7 +45,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService
public List<SysNotice> selectNoticeList(SysNotice notice)
{
List<SysNotice> list = noticeMapper.selectNoticeList(notice);
list.stream().forEach(o -> o.setNoticeContentNoHtml(o.getNoticeContent().replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", "")));
list.stream().forEach(o -> o.setNoticeContentNoHtml(o.getNoticeContent().replaceAll(HTML_REGEX, "")));
return list;
}