| 
				
				
					
				
				
				 | 
			
			 | 
			@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import com.alibaba.fastjson.JSONObject; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import com.iformall.common.ErrorCode; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import com.iformall.common.ResultData; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import lombok.extern.slf4j.Slf4j; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import org.springframework.stereotype.Component; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import org.springframework.web.multipart.MultipartFile; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import java.io.*; | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -18,6 +20,8 @@ import java.util.HashMap; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			/** | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			 * 图片质量检查方法 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			 */ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			@Slf4j | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			@Component | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			public class BaiduImageCheckUtil { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 百度图片审核接口地址 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    private final static String photo_check_url = "https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined"; | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -43,7 +47,7 @@ public class BaiduImageCheckUtil { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            //这里暂时写死 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            String result = BaiDuHttpUtil.post(photo_check_url, accessToken, param); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            System.out.println(result); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            log.info("图片检测"+result); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            JSONObject jsonObject = JSON.parseObject(result); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            //1:合规,2:不合规,3:疑似,4:审核失败 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            Integer type = jsonObject.getInteger("conclusionType"); | 
		
		
	
	
		
			
				| 
				
					
				
				
					
				
				
				 | 
			
			 | 
			@@ -104,6 +108,7 @@ public class BaiduImageCheckUtil { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        map.put("client_secret", secretKey); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        map.put("grant_type", "client_credentials"); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        String doPost = HttpUtil.doPost(auth_url, map); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        log.info("获取token"+doPost); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        JSONObject json = JSONObject.parseObject(doPost); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        String access_token = (String) json.get("access_token"); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        Integer expires_in = (Integer) json.get("expires_in"); | 
		
		
	
	
		
			
				| 
				
					
				
				
				
				 | 
			
			 | 
			
  |