|
|
@ -21,21 +21,44 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
|
import com.epmet.modules.notice.dao.NoticeCommentDao; |
|
|
|
import com.epmet.modules.notice.entity.NoticeCommentEntity; |
|
|
|
import com.epmet.modules.notice.entity.NoticeEntity; |
|
|
|
import com.epmet.modules.notice.redis.NoticeCommentRedis; |
|
|
|
import com.epmet.modules.notice.service.NoticeCommentService; |
|
|
|
import com.epmet.modules.notice.service.NoticeService; |
|
|
|
import com.epmet.modules.topic.service.ResiTopicService; |
|
|
|
import com.epmet.modules.utils.ModuleConstant; |
|
|
|
import com.epmet.resi.group.constant.MemberStateConstant; |
|
|
|
import com.epmet.resi.group.constant.TopicConstant; |
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.NoticeCommentDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.NoticeDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.form.NoticeCommentFormDTO; |
|
|
|
import com.epmet.resi.group.dto.topic.ResiTopicDTO; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
/** |
|
|
|
* 小组通知评论表 |
|
|
@ -45,9 +68,18 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class NoticeCommentServiceImpl extends BaseServiceImpl<NoticeCommentDao, NoticeCommentEntity> implements NoticeCommentService { |
|
|
|
|
|
|
|
private final Log logger = LogFactory.getLog(getClass()); |
|
|
|
@Autowired |
|
|
|
private NoticeCommentRedis noticeCommentRedis; |
|
|
|
@Autowired |
|
|
|
private NoticeService noticeService; |
|
|
|
@Autowired |
|
|
|
private ResiGroupMemberService resiGroupMemberService; |
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
|
private String scanApiUrl; |
|
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
|
private String textSyncScanMethod; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<NoticeCommentDTO> page(Map<String, Object> params) { |
|
|
@ -65,8 +97,8 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl<NoticeCommentDao, |
|
|
|
return ConvertUtils.sourceToTarget(entityList, NoticeCommentDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<NoticeCommentEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<NoticeCommentEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<NoticeCommentEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -101,4 +133,67 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl<NoticeCommentDao, |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 发布通知评论 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void noticeComment(TokenDto tokenDto, NoticeCommentFormDTO formDTO) { |
|
|
|
//1.内容安全校验
|
|
|
|
String commentContent = formDTO.getCommentContent(); |
|
|
|
if (StringUtils.isNotBlank(commentContent)) { |
|
|
|
//评论话题内容审核
|
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
taskDTO.setContent(commentContent); |
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
logger.error(String.format(TopicConstant.REVIEW_TOPIC, commentContent)); |
|
|
|
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//2.判断当前用户是否被禁言、移除、非本组成员
|
|
|
|
NoticeDTO notice = noticeService.get(formDTO.getNoticeId()); |
|
|
|
if (null == notice) { |
|
|
|
logger.error(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
throw new RenException(ModuleConstant.NO_SUCH_TOPIC); |
|
|
|
} |
|
|
|
|
|
|
|
ResiGroupMemberDTO resiGroupMemberDTO = |
|
|
|
resiGroupMemberService.getResiGroupMember(notice.getGroupId(), tokenDto.getUserId()); |
|
|
|
//查看当前用户是否被禁言或者被移除
|
|
|
|
if (null != resiGroupMemberDTO) { |
|
|
|
if (MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())) { |
|
|
|
//当前用户被禁言
|
|
|
|
logger.error(ModuleConstant.SLIENT_MEMBER); |
|
|
|
throw new RenException(ModuleConstant.SLIENT_MEMBER); |
|
|
|
} else if (MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())) { |
|
|
|
//当前用户已被移出群
|
|
|
|
logger.error(ModuleConstant.REMOVED_MEMBER); |
|
|
|
throw new RenException(ModuleConstant.REMOVED_MEMBER); |
|
|
|
} |
|
|
|
} else { |
|
|
|
//当前用户非组内成员
|
|
|
|
logger.error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
throw new RenException(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); |
|
|
|
} |
|
|
|
|
|
|
|
//3.通知评论表新增数据
|
|
|
|
NoticeCommentEntity entity = new NoticeCommentEntity(); |
|
|
|
entity.setCustomerId(notice.getCustomerId()); |
|
|
|
entity.setNoticeId(formDTO.getNoticeId()); |
|
|
|
entity.setCommentContent(formDTO.getCommentContent()); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
} |