|
@ -5,7 +5,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.editor.entity.SystemDictItem;
|
|
|
import com.yihu.editor.entity.YdfHealthEduArticle;
|
|
|
import com.yihu.editor.service.ArticleService;
|
|
|
import com.yihu.editor.util.Upload;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@ -95,56 +97,13 @@ public class ArticleController extends BaseController{
|
|
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String save(@ModelAttribute @Valid YdfHealthEduArticle article,HttpServletRequest request,MultipartHttpServletRequest multiReq){
|
|
|
List<MultipartFile> files = multiReq
|
|
|
.getFiles("file");
|
|
|
List<MultipartFile> files = multiReq.getFiles("file");
|
|
|
|
|
|
|
|
|
//---------------------------------------cyx
|
|
|
String url="http://172.19.103.31:10001/ydf17-6-10/upload/image?callback=call";
|
|
|
|
|
|
/*HttpClient httpClient = null;
|
|
|
HttpPost httpPost;
|
|
|
String result = null;
|
|
|
try {
|
|
|
httpClient = new DefaultHttpClient();
|
|
|
httpPost = new HttpPost(url);
|
|
|
|
|
|
String[] filenames=fileNames.split(";");
|
|
|
MultipartEntity reqEntity = new MultipartEntity();
|
|
|
for(int i=0;i<filenames.length;i++) {
|
|
|
String fileName=filenames[i];
|
|
|
FileBody file = new FileBody(new File(fileName));
|
|
|
|
|
|
reqEntity.addPart("file"+i, file);// file1为请求后台的File upload;属性
|
|
|
|
|
|
}
|
|
|
httpPost.setEntity(reqEntity);
|
|
|
HttpResponse response = httpClient.execute(httpPost);
|
|
|
if (null != response && response.getStatusLine().getStatusCode() == 200) {
|
|
|
HttpEntity resEntity = response.getEntity();
|
|
|
if (null != resEntity) {
|
|
|
result = EntityUtils.toString(resEntity, HTTP.UTF_8);
|
|
|
System.out.println(result);
|
|
|
}
|
|
|
}
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (ClientProtocolException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|
|
|
// 关闭连接,释放资源
|
|
|
httpClient.getConnectionManager().shutdown();
|
|
|
}
|
|
|
return result;
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
String url="http://172.19.103.31:10001/ydf/upload/image";
|
|
|
String result = Upload.httpClientUploadFile(url,files);
|
|
|
JSONObject resultJson = new JSONObject(result);
|
|
|
String fileUrls = (String) resultJson.get("urls");
|
|
|
article.setImages(fileUrls);
|
|
|
if(StringUtils.isBlank(article.getId())){
|
|
|
article.setId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
|
}
|