From 5b67c4312e676419323d6a24fa0ce54315054429 Mon Sep 17 00:00:00 2001 From: landong2015 Date: Thu, 12 May 2016 14:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E5=B9=BB?= =?UTF-8?q?=E7=81=AF=E7=89=87=E5=92=8C=E8=82=B2=E5=84=BF=E8=AF=BE=E5=A0=82?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lymsh/yimiao/main/data/util/ArticleUtil.java | 46 ++++++++++++++++++++++ .../web/controller/v1/ArticleController.java | 35 ++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 mainData/src/main/java/com/lymsh/yimiao/main/data/util/ArticleUtil.java create mode 100644 webApi/src/main/java/com/lyms/yimiao/web/controller/v1/ArticleController.java diff --git a/mainData/src/main/java/com/lymsh/yimiao/main/data/util/ArticleUtil.java b/mainData/src/main/java/com/lymsh/yimiao/main/data/util/ArticleUtil.java new file mode 100644 index 0000000..6224dfc --- /dev/null +++ b/mainData/src/main/java/com/lymsh/yimiao/main/data/util/ArticleUtil.java @@ -0,0 +1,46 @@ +package com.lymsh.yimiao.main.data.util; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.GetMethod; + +/** + * Created by Administrator on 2016/5/12 0012. + */ +public class ArticleUtil { + + public static String getArticlesImages() { + HttpClient client = new HttpClient(); + GetMethod get = new MessageUtil.UTF8GetMethod("http://ams.api.stage.healthbaby.com.cn/v1/imageArticles.action"); + try { + client.executeMethod(get); + String result = new String(get.getResponseBodyAsString()); + int statusCode = get.getStatusCode(); + if (statusCode==200){ + return result; + } + get.releaseConnection(); + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + + public static String getCategoryArticle(){ + HttpClient client = new HttpClient(); + GetMethod get = new MessageUtil.UTF8GetMethod("http://ams.api.stage.healthbaby.com.cn/v1/yiMiaoArticles.action"); + try { + client.executeMethod(get); + String result = new String(get.getResponseBodyAsString()); + int statusCode = get.getStatusCode(); + if (statusCode==200){ + return result; + } + get.releaseConnection(); + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + + +} diff --git a/webApi/src/main/java/com/lyms/yimiao/web/controller/v1/ArticleController.java b/webApi/src/main/java/com/lyms/yimiao/web/controller/v1/ArticleController.java new file mode 100644 index 0000000..6207c16 --- /dev/null +++ b/webApi/src/main/java/com/lyms/yimiao/web/controller/v1/ArticleController.java @@ -0,0 +1,35 @@ +package com.lyms.yimiao.web.controller.v1; + +import com.lymsh.mommybaby.basecommon.base.BaseController; +import com.lymsh.mommybaby.basecommon.base.TokenRequired; +import com.lymsh.mommybaby.basecommon.util.JsonUtil; +import com.lymsh.yimiao.main.data.util.ArticleUtil; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import javax.servlet.http.HttpServletResponse; + +/** + * Created by Administrator on 2016/5/12 0012. + */ + +@Controller +@RequestMapping("/v1") +public class ArticleController extends BaseController{ + + //幻灯片 + @RequestMapping(value = "/image/slide", method = RequestMethod.GET) + @TokenRequired + public void getSlide(HttpServletResponse response){ + writeJson(response, JsonUtil.obj2JsonString(ArticleUtil.getArticlesImages())); + } + + //获取育儿课堂 + @RequestMapping(value = "/category/article", method = RequestMethod.GET) + @TokenRequired + public void getColumn(HttpServletResponse response){ + writeJson(response, JsonUtil.obj2JsonString(ArticleUtil.getCategoryArticle())); + } + +} -- 1.8.3.1