Commit c0676efd authored by shiyu's avatar shiyu

微信文字内容安全识别22

parent 4241daaf
......@@ -84,7 +84,8 @@ public class QdWxAppletApi {
}
public String checkWord(WxCheckMediaRequestDto dto) {
public boolean checkWord(WxCheckMediaRequestDto dto) {
try {
String accessToken = qdWxLoginManager.getAccessToken();
String url = String.format(WORD_CHECK_URL, accessToken);
OkHttpUtil okHttpUtil = OkHttpUtil.builder().url(url);
......@@ -97,7 +98,15 @@ public class QdWxAppletApi {
okHttpUtil.post(true);
String responseStr = okHttpUtil.async();
logger.info("[checkContent] response :{}", responseStr);
return responseStr;
String result = JsonUtils.getValueByPath(responseStr, "result/suggest");
if (!"pass".equals(result)) {
return false;
}
return true;
} catch (Exception e) {
logger.error("checkContent error : {}", e);
}
return false;
}
......
......@@ -290,7 +290,12 @@ public class QdUserServiceImpl implements QdUserService {
wxCheckMediaRequestDto.setMediaUrl(dto.getAvatar());
wxCheckMediaRequestDto.setWxOpenId(user.getWxOpenid());
qdWxAppletApi.checkMedia(wxCheckMediaRequestDto);
logger.info("=========== 微信音频内容安全识别接口调用成功 ===========");
logger.info("=========== 微信图片内容安全识别接口调用成功 ===========");
}
String key = dto.getUserId() + "_updateAvatar";
if (!redisUtils.hasKey(key)) {
redisUtils.set(key, key, 30);
return Result.failed("头像安全检测有风险,请更换");
}
user.setAvatar(dto.getAvatar());
qdUserDao.updateById(user);
......
......@@ -10,6 +10,7 @@ import com.wwdz.ch.core.consts.qiandao.SignInTaskEnum;
import com.wwdz.ch.core.entity.WxCheckMediaRequestDto;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.IdUtils;
import com.wwdz.ch.core.util.RedisUtils;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.dao.qiandao.*;
import com.wwdz.ch.db.domain.User;
......@@ -65,6 +66,8 @@ public class QdUserSignInServiceImpl implements QdUserSignInService {
@Autowired
QdWxAppletApi qdWxAppletApi;
@Autowired
RedisUtils redisUtils;
@Override
public Result check(QdUserSignInRequestDto dto) {
......@@ -146,10 +149,19 @@ public class QdUserSignInServiceImpl implements QdUserSignInService {
wxCheckMediaRequestDto.setMediaUrl(dto.getImages().get(0));
qdWxAppletApi.checkMedia(wxCheckMediaRequestDto);
logger.info("=========== 微信音频内容安全识别接口调用成功 ===========");
String key = dto.getUserId() + "_signIn";
if (!redisUtils.hasKey(key)) {
redisUtils.set(key, key, 30);
return Result.failed("图片安全检测有风险,请更换");
}
}
wxCheckMediaRequestDto.setWordStr(dto.getContent());
qdWxAppletApi.checkWord(wxCheckMediaRequestDto);
wxCheckMediaRequestDto.setWordStr(dto.getContent());
boolean result = qdWxAppletApi.checkWord(wxCheckMediaRequestDto);
logger.info("=========== 微信文字内容安全识别接口调用成功 ===========");
if (!result) {
return Result.failed("发布的文字内容识别有风险,不可发布");
}
//签到记录id
Long recordId = null;
//今天尚未签到,则进行记录,先查询昨天的打卡记录,有则再连续打卡天数上+1,没有则算签到第一天
......
......@@ -71,10 +71,6 @@ public class QdUserSignInController {
String url = storageService.store(targetInput, file.getSize(), file.getContentType(), originalFilename);
Map<String, Object> map = new HashMap<>();
map.put("url", url);
logger.info("【请求结束】乾岛上传文件,响应结果:{}", JSONObject.toJSONString(map));
return Result.success(map);
} catch (Exception e) {
......
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