|
|
@ -1,15 +1,23 @@ |
|
|
|
package com.zc.business.service.impl; |
|
|
|
|
|
|
|
import java.net.URLDecoder; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult; |
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.zc.business.mapper.DcInfoBoardVocabularyMapper; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.common.utils.bean.BeanValidators; |
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
|
import com.zc.business.domain.DcInfoBoardVocabulary; |
|
|
|
import com.zc.business.mapper.DcInfoBoardVocabularyMapper; |
|
|
|
import com.zc.business.service.IDcInfoBoardVocabularyService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.validation.Validator; |
|
|
|
import java.net.URLDecoder; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 情报板敏感字管理Service业务层处理 |
|
|
@ -18,11 +26,13 @@ import com.zc.business.service.IDcInfoBoardVocabularyService; |
|
|
|
* @date 2024-01-05 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyService |
|
|
|
{ |
|
|
|
public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyService { |
|
|
|
@Autowired |
|
|
|
private DcInfoBoardVocabularyMapper dcInfoBoardVocabularyMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
protected Validator validator; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询情报板敏感字管理 |
|
|
|
* |
|
|
@ -30,8 +40,7 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
* @return 情报板敏感字管理 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public DcInfoBoardVocabulary selectDcInfoBoardVocabularyById(Long id) |
|
|
|
{ |
|
|
|
public DcInfoBoardVocabulary selectDcInfoBoardVocabularyById(Long id) { |
|
|
|
return dcInfoBoardVocabularyMapper.selectDcInfoBoardVocabularyById(id); |
|
|
|
} |
|
|
|
|
|
|
@ -42,11 +51,36 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
* @return 情报板敏感字管理 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<DcInfoBoardVocabulary> selectDcInfoBoardVocabularyList(DcInfoBoardVocabulary dcInfoBoardVocabulary) |
|
|
|
{ |
|
|
|
public List<DcInfoBoardVocabulary> selectDcInfoBoardVocabularyList(DcInfoBoardVocabulary dcInfoBoardVocabulary) { |
|
|
|
return dcInfoBoardVocabularyMapper.selectDcInfoBoardVocabularyList(dcInfoBoardVocabulary); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导入敏感字 |
|
|
|
* |
|
|
|
* @param file |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult importVocabulary(MultipartFile file) throws Exception { |
|
|
|
ExcelUtil<DcInfoBoardVocabulary> util = new ExcelUtil<>(DcInfoBoardVocabulary.class); |
|
|
|
List<DcInfoBoardVocabulary> vocabularyList = util.importExcel(file.getInputStream()); |
|
|
|
BeanValidators.validateWithException(validator, vocabularyList);//对象属性验证
|
|
|
|
Date nowDate = DateUtils.getNowDate(); |
|
|
|
List<DcInfoBoardVocabulary> dcInfoBoardVocabularies = dcInfoBoardVocabularyMapper.selectDcInfoBoardVocabularyList(new DcInfoBoardVocabulary()); |
|
|
|
List<DcInfoBoardVocabulary> wordsNotInDcInfoBoard = vocabularyList.stream() |
|
|
|
.filter(dcInfoBoardVocabulary -> StringUtils.isNotEmpty(dcInfoBoardVocabulary.getWord())) |
|
|
|
.filter(v -> dcInfoBoardVocabularies.stream().noneMatch(d -> d.getWord().equals(v.getWord()))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
wordsNotInDcInfoBoard.forEach(dcInfoBoardVocabulary -> { |
|
|
|
dcInfoBoardVocabulary.setCreateTime(nowDate); |
|
|
|
}); |
|
|
|
if (wordsNotInDcInfoBoard.size() > 0) { |
|
|
|
return AjaxResult.success(dcInfoBoardVocabularyMapper.importVocabulary(wordsNotInDcInfoBoard)); |
|
|
|
} |
|
|
|
return AjaxResult.success().put("msg", "请检查数据是否重复,或存在空值"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增情报板敏感字管理 |
|
|
|
* |
|
|
@ -54,11 +88,10 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult insertDcInfoBoardVocabulary(DcInfoBoardVocabulary dcInfoBoardVocabulary) |
|
|
|
{ |
|
|
|
public AjaxResult insertDcInfoBoardVocabulary(DcInfoBoardVocabulary dcInfoBoardVocabulary) { |
|
|
|
dcInfoBoardVocabulary.setCreateTime(DateUtils.getNowDate()); |
|
|
|
int oldNum = dcInfoBoardVocabularyMapper.selectWordNum(dcInfoBoardVocabulary); |
|
|
|
if (oldNum > 0){ |
|
|
|
if (oldNum > 0) { |
|
|
|
return AjaxResult.error("该关键词已存在!"); |
|
|
|
} |
|
|
|
dcInfoBoardVocabularyMapper.insertDcInfoBoardVocabulary(dcInfoBoardVocabulary); |
|
|
@ -72,10 +105,9 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult updateDcInfoBoardVocabulary(DcInfoBoardVocabulary dcInfoBoardVocabulary) |
|
|
|
{ |
|
|
|
public AjaxResult updateDcInfoBoardVocabulary(DcInfoBoardVocabulary dcInfoBoardVocabulary) { |
|
|
|
int oldNum = dcInfoBoardVocabularyMapper.selectWordNum(dcInfoBoardVocabulary); |
|
|
|
if (oldNum > 0){ |
|
|
|
if (oldNum > 0) { |
|
|
|
return AjaxResult.error("该关键词已存在!"); |
|
|
|
} |
|
|
|
dcInfoBoardVocabularyMapper.updateDcInfoBoardVocabulary(dcInfoBoardVocabulary); |
|
|
@ -89,8 +121,7 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int deleteDcInfoBoardVocabularyByIds(Long[] ids) |
|
|
|
{ |
|
|
|
public int deleteDcInfoBoardVocabularyByIds(Long[] ids) { |
|
|
|
return dcInfoBoardVocabularyMapper.deleteDcInfoBoardVocabularyByIds(ids); |
|
|
|
} |
|
|
|
|
|
|
@ -101,8 +132,7 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public int deleteDcInfoBoardVocabularyById(Long id) |
|
|
|
{ |
|
|
|
public int deleteDcInfoBoardVocabularyById(Long id) { |
|
|
|
return dcInfoBoardVocabularyMapper.deleteDcInfoBoardVocabularyById(id); |
|
|
|
} |
|
|
|
|
|
|
@ -113,7 +143,7 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public AjaxResult checkBoardContent(String content){ |
|
|
|
public AjaxResult checkBoardContent(String content) { |
|
|
|
if (content == null || content.equals("")) { |
|
|
|
return AjaxResult.error("情报板内容为空"); |
|
|
|
} else { |
|
|
@ -125,7 +155,7 @@ public class DcInfoBoardVocabularyServiceImpl implements IDcInfoBoardVocabularyS |
|
|
|
e.printStackTrace(); |
|
|
|
return AjaxResult.error(); |
|
|
|
} |
|
|
|
for (int i = 0;i < boardVocabularies.size();i++) { |
|
|
|
for (int i = 0; i < boardVocabularies.size(); i++) { |
|
|
|
String word = boardVocabularies.get(i).getWord(); |
|
|
|
if (content.contains(word)) { |
|
|
|
return AjaxResult.error("当前发布内容包含敏感字段'" + word + "',请修改"); |
|
|
|