public class G extends SuperService implements IG{
//private static String goodsUrl = "http://baidu.com";
Logger log = LoggerFactory.getLogger(G.class);
@Override
public JSONObject getAllG(G gInteger num,Integer page,HttpServletRequest req) {
URL connect;
StringBuffer data = new StringBuffer();
// JSONArray json = new JSONArray();
JSONObject node = new JSONObject();
JSONObject obj = null;
try {
// node.put("num", num);
// node.put("page", page);
// node.put("goodsid", g.getShopId());
// node.put("groupby_type", g.getGroup());
// node.put("goods_name", g.getStore());
String goodsid="";
String groupby_type="";
String goods_name="";
if(null != groupPurchase.getShopId()){
goodsid=g.getShopId();
}
if(null != g.getGroup()){
groupby_type=g.getGroup();
}
if(null != g.getStore()){
goods_name=g.getStore();
}
connect = new URL(goodsUrl+"?num="+num+"&page="+page+"&goodsId="+goodsid+"&group="+groupby_type+"&store="+goods_name);
HttpURLConnection connection = (HttpURLConnection)connect.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
OutputStreamWriter paramout = new OutputStreamWriter(
connection.getOutputStream(),"UTF-8");
paramout.write(node.toString());
paramout.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(
connection.getInputStream(), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
data.append(line);
}
paramout.close();
reader.close();
obj = new JSONObject(data.toString());
// json = JSONArray.fromObject(obj.getString("data"));
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
//private static String goodsUrl = "http://baidu.com";
Logger log = LoggerFactory.getLogger(G.class);
@Override
public JSONObject getAllG(G gInteger num,Integer page,HttpServletRequest req) {
URL connect;
StringBuffer data = new StringBuffer();
// JSONArray json = new JSONArray();
JSONObject node = new JSONObject();
JSONObject obj = null;
try {
// node.put("num", num);
// node.put("page", page);
// node.put("goodsid", g.getShopId());
// node.put("groupby_type", g.getGroup());
// node.put("goods_name", g.getStore());
String goodsid="";
String groupby_type="";
String goods_name="";
if(null != groupPurchase.getShopId()){
goodsid=g.getShopId();
}
if(null != g.getGroup()){
groupby_type=g.getGroup();
}
if(null != g.getStore()){
goods_name=g.getStore();
}
connect = new URL(goodsUrl+"?num="+num+"&page="+page+"&goodsId="+goodsid+"&group="+groupby_type+"&store="+goods_name);
HttpURLConnection connection = (HttpURLConnection)connect.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
OutputStreamWriter paramout = new OutputStreamWriter(
connection.getOutputStream(),"UTF-8");
paramout.write(node.toString());
paramout.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(
connection.getInputStream(), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
data.append(line);
}
paramout.close();
reader.close();
obj = new JSONObject(data.toString());
// json = JSONArray.fromObject(obj.getString("data"));
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}