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())); + } + +}