Commit 551bd9ea authored by 刘基明's avatar 刘基明

查重

parent 8d2a8dcb
...@@ -5,6 +5,7 @@ import com.tanpu.common.constant.BizStatus; ...@@ -5,6 +5,7 @@ import com.tanpu.common.constant.BizStatus;
import com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity; import com.tanpu.community.dao.entity.community.ThemeCheckDuplicateEntity;
import com.tanpu.community.dao.mapper.community.ThemeCheckDuplicateMapper; import com.tanpu.community.dao.mapper.community.ThemeCheckDuplicateMapper;
import com.tanpu.community.util.TimeUtils; import com.tanpu.community.util.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -14,6 +15,7 @@ import java.util.ArrayList; ...@@ -14,6 +15,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@Service @Service
@Slf4j
public class ThemeTextCheckService { public class ThemeTextCheckService {
@Resource @Resource
...@@ -23,16 +25,21 @@ public class ThemeTextCheckService { ...@@ -23,16 +25,21 @@ public class ThemeTextCheckService {
// 插入 // 插入
public void insert(String content, String themeId, String userId, Integer themeType, String editThemeId) { public void insert(String content, String themeId, String userId, Integer themeType, String editThemeId) {
if (StringUtils.isNotBlank(editThemeId)){ try{
themeCheckDuplicateMapper.deleteByThemeId(editThemeId); if (StringUtils.isNotBlank(editThemeId)){
themeCheckDuplicateMapper.deleteByThemeId(editThemeId);
}
content = content.replaceAll(regex, "。");
String[] split = content.split("。");
for (int i = 0; i < split.length; i++) {
String trim = StringUtils.trim(split[i]);
insert(themeId, trim, getHash(trim), i + 1, split.length, userId,themeType);
}
}catch (Exception e){
log.error("文本查重insert失败,themeId:"+themeId);
} }
content = content.replaceAll(regex, "。");
String[] split = content.split("。");
for (int i = 0; i < split.length; i++) {
String trim = StringUtils.trim(split[i]);
insert(themeId, trim, getHash(trim), i + 1, split.length, userId,themeType);
}
} }
// 删除 // 删除
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment