|
|
@ -17,15 +17,24 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
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.ImgScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
|
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.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
|
import com.epmet.constant.UserAdviceConstant; |
|
|
|
import com.epmet.dao.UserAdviceDao; |
|
|
|
import com.epmet.dto.UserAdviceDTO; |
|
|
@ -40,15 +49,15 @@ import com.epmet.service.UserAdviceImgService; |
|
|
|
import com.epmet.service.UserAdviceService; |
|
|
|
import io.jsonwebtoken.lang.Collections; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.logging.log4j.LogManager; |
|
|
|
import org.apache.logging.log4j.Logger; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
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.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* user_advice |
|
|
@ -59,12 +68,20 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAdviceEntity> implements UserAdviceService { |
|
|
|
|
|
|
|
private Logger logger = LogManager.getLogger(UserAdviceServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private UserAdviceRedis userAdviceRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserAdviceImgService userAdviceImgService; |
|
|
|
|
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
|
private String scanApiUrl; |
|
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
|
private String textSyncScanMethod; |
|
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
|
private String imgSyncScanMethod; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<UserAdviceDTO> page(Map<String, Object> params) { |
|
|
|
IPage<UserAdviceEntity> page = baseDao.selectPage( |
|
|
@ -132,6 +149,10 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
if (StringUtils.isNotBlank(userAdviceEntity.getReplyContent()) || StringUtils.isNotBlank(userAdviceEntity.getReplyUserId())) { |
|
|
|
throw new RenException("该建议已被回复,不能再次回复"); |
|
|
|
} |
|
|
|
//审核图片
|
|
|
|
auditPic(dto.getGovImgList()); |
|
|
|
//审核文字
|
|
|
|
auditText(dto.getReplyContent()); |
|
|
|
//更新advice表
|
|
|
|
baseDao.replyAdvice(dto.getAdviceId(), dto.getReplyContent(), dto.getGovContent(), loginUserId); |
|
|
|
//如果govImg不为空,插入advice_img表
|
|
|
@ -256,4 +277,50 @@ public class UserAdviceServiceImpl extends BaseServiceImpl<UserAdviceDao, UserAd |
|
|
|
|
|
|
|
return getPageData(result, AdviceListResultDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private void auditText(String text) { |
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
taskDTO.setContent(text); |
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
logger.info("用户建议文字审核入参:"+JSON.toJSONString(textScanParamDTO)); |
|
|
|
logger.info("用户建议文字审核返参:"+JSON.toJSONString(textSyncScanResult)); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
logger.warn("用户建议文字审核接口返回失败,返参:", JSON.toJSONString(textSyncScanResult)); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
logger.warn("用户建议文字审核失败,文字:",text); |
|
|
|
throw new RenException(EpmetErrorCode.ACT_REQ_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("用户建议文字审核成功"); |
|
|
|
} |
|
|
|
|
|
|
|
private void auditPic(List<String> imgList) { |
|
|
|
if (null != imgList && imgList.size() > 0) { |
|
|
|
//审核活动详情中的图片
|
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
imgList.forEach(url -> { |
|
|
|
ImgTaskDTO task = new ImgTaskDTO(); |
|
|
|
task.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
task.setUrl(url); |
|
|
|
imgScanParamDTO.getTasks().add(task); |
|
|
|
}); |
|
|
|
Result<SyncScanResult> imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); |
|
|
|
logger.info("图片审核入参:" + JSON.toJSONString(imgScanParamDTO)); |
|
|
|
logger.info("图片审核返参:" + JSON.toJSONString(imgScanResult)); |
|
|
|
if (!imgScanResult.success()) { |
|
|
|
logger.warn("图片审核接口失败,返参:", JSON.toJSONString(imgScanResult)); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!imgScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.ACT_CONTENT_IMG_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
logger.info("图片审核成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|