| @@ -10,7 +10,7 @@ import com.iformall.enums.EnumMouldSendType; | |||||
| import com.iformall.enums.EnumaMouldPatchStatus; | import com.iformall.enums.EnumaMouldPatchStatus; | ||||
| import com.iformall.service.sm.MouldPatchSignService; | import com.iformall.service.sm.MouldPatchSignService; | ||||
| import com.iformall.service.sm.PersonPhotoService; | import com.iformall.service.sm.PersonPhotoService; | ||||
| import com.iformall.utils.BaiduImageCheckUtil; | |||||
| import com.iformall.utils.BaiduCheckUtil; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -45,7 +45,18 @@ public class BaiduController extends BaseController { | |||||
| if (size > length) { | if (size > length) { | ||||
| return new ResultData(ErrorCode.PICTURE_FOUR_SIZE_EXCEED); | return new ResultData(ErrorCode.PICTURE_FOUR_SIZE_EXCEED); | ||||
| } | } | ||||
| return BaiduImageCheckUtil.photoCheck(file); | |||||
| return BaiduCheckUtil.photoCheck(file); | |||||
| } | |||||
| @AuthIgnore | |||||
| @ApiOperation("百度文字审核接口") | |||||
| @PostMapping(value = "checkText") | |||||
| @ApiImplicitParam(name = "text", value = "text", dataType = "String", paramType = "query", required = true) | |||||
| public ResultData baiduCheckPhoto(@RequestBody String text) { | |||||
| if (StringUtils.isBlank(text)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "内容为空"); | |||||
| } | |||||
| return BaiduCheckUtil.textCheck(text); | |||||
| } | } | ||||
| } | } | ||||
| @@ -11,7 +11,7 @@ import com.iformall.enums.EnumaMouldPatchStatus; | |||||
| import com.iformall.service.sm.MouldPatchSignService; | import com.iformall.service.sm.MouldPatchSignService; | ||||
| import com.iformall.service.sm.PersonPhotoService; | import com.iformall.service.sm.PersonPhotoService; | ||||
| import com.iformall.sm.AiBaiduCheckResult; | import com.iformall.sm.AiBaiduCheckResult; | ||||
| import com.iformall.utils.BaiduImageCheckUtil; | |||||
| import com.iformall.utils.BaiduCheckUtil; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -109,7 +109,7 @@ public class PersonPhotoController extends BaseController { | |||||
| if (size > length) { | if (size > length) { | ||||
| return new ResultData(ErrorCode.PICTURE_FOUR_SIZE_EXCEED); | return new ResultData(ErrorCode.PICTURE_FOUR_SIZE_EXCEED); | ||||
| } | } | ||||
| return BaiduImageCheckUtil.photoCheck(file); | |||||
| return BaiduCheckUtil.photoCheck(file); | |||||
| } | } | ||||
| @@ -14,7 +14,7 @@ import com.iformall.enums.EnumaMouldPatchStatus; | |||||
| import com.iformall.service.ProductService; | import com.iformall.service.ProductService; | ||||
| import com.iformall.service.sm.MouldPatchSignService; | import com.iformall.service.sm.MouldPatchSignService; | ||||
| import com.iformall.service.sm.PersonPhotoService; | import com.iformall.service.sm.PersonPhotoService; | ||||
| import com.iformall.utils.BaiduImageCheckUtil; | |||||
| import com.iformall.utils.BaiduCheckUtil; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -24,6 +24,7 @@ import com.iformall.service.sm.VoiceInfoService; | |||||
| import com.iformall.smsdk.SmGenerateVideoDTO; | import com.iformall.smsdk.SmGenerateVideoDTO; | ||||
| import com.iformall.smsdk.SmPreviewVideoDTO; | import com.iformall.smsdk.SmPreviewVideoDTO; | ||||
| import com.iformall.smsdk.SmSdkUtils; | import com.iformall.smsdk.SmSdkUtils; | ||||
| import com.iformall.utils.BaiduCheckUtil; | |||||
| import com.iformall.video.VideoFactory; | import com.iformall.video.VideoFactory; | ||||
| import com.iformall.video.entity.VideUploadResult; | import com.iformall.video.entity.VideUploadResult; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -228,9 +229,8 @@ public class UserMouldVideoController extends BaseController { | |||||
| if(mouldVideo == null){ | if(mouldVideo == null){ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"id无效"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"id无效"); | ||||
| } | } | ||||
| //TODO 校验 | |||||
| //return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"校验失败"); | |||||
| return new ResultData(); | |||||
| //校验文本 | |||||
| return BaiduCheckUtil.textCheck(mouldVideo.getPaperwork()); | |||||
| } | } | ||||
| // @AuthIgnore | // @AuthIgnore | ||||
| @@ -22,9 +22,10 @@ import java.util.HashMap; | |||||
| */ | */ | ||||
| @Slf4j | @Slf4j | ||||
| @Component | @Component | ||||
| public class BaiduImageCheckUtil { | |||||
| public class BaiduCheckUtil { | |||||
| // 百度图片审核接口地址 | // 百度图片审核接口地址 | ||||
| private final static String photo_check_url = "https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined"; | private final static String photo_check_url = "https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined"; | ||||
| private final static String text_check_url = "https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined"; | |||||
| // 获取token | // 获取token | ||||
| private final static String auth_url = "https://aip.baidubce.com/oauth/2.0/token?"; | private final static String auth_url = "https://aip.baidubce.com/oauth/2.0/token?"; | ||||
| // 百度API Key | // 百度API Key | ||||
| @@ -33,6 +34,32 @@ public class BaiduImageCheckUtil { | |||||
| // 百度Secret Key | // 百度Secret Key | ||||
| private final static String secretKey = "eGmeQkP3Opzph0GB4Y2voiOkGOlwbeWd"; | private final static String secretKey = "eGmeQkP3Opzph0GB4Y2voiOkGOlwbeWd"; | ||||
| public static ResultData textCheck(String text) { | |||||
| try { | |||||
| String param = "text=" + URLEncoder.encode(text, "utf-8");; | |||||
| String accessToken = getAuth(); | |||||
| String result = BaiDuHttpUtil.post(text_check_url, accessToken, param); | |||||
| log.info("图片检测"+result); | |||||
| JSONObject jsonObject = JSON.parseObject(result); | |||||
| //1:合规,2:不合规,3:疑似,4:审核失败 | |||||
| Integer type = jsonObject.getInteger("conclusionType"); | |||||
| if (type == 1) { | |||||
| return new ResultData(); | |||||
| } else if (type == 2 || type == 3) { | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"文字内容不合规"); | |||||
| } else if (type == 4) { | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"文字内容审核失败"); | |||||
| } else { | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"文字内容不合规"); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"文字内容审核失败"); | |||||
| } | |||||
| } | |||||
| public static ResultData photoCheck(MultipartFile file) { | public static ResultData photoCheck(MultipartFile file) { | ||||
| try { | try { | ||||
| byte[] fileBytes = file.getBytes(); | byte[] fileBytes = file.getBytes(); | ||||