Commit dfe90516 authored by 赵然's avatar 赵然

zr

parent ced8db91
/**
* Copyright (C), 2015-2018
* FileName: HbaseService
* Author: qianwenjun
* Date: 2018/8/27 18:20
* Description:
*/
package main.com.atguigu.springmvc.common;
import io.restassured.response.Response;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* 〈〉
*
* @author qianwenjun
* @create 2018/8/27
* @since 1.0.0
*/
@Service
public class HbaseService {
private static String activtyHost = "http://activity.m.duibatest.com.cn";
public static Response getHBASEKey(String key,String reverse) {
String url = activtyHost + "/aaw/hb/get";
Map<String,Object> parm = new HashMap<>();
parm.put("key",key);
if(reverse.equals("")||reverse.equals(null)||reverse.isEmpty()){
parm.put("reverse","false");
}else {
parm.put("reverse", reverse);
}
Response response = given().params(parm).get(url);
return response;
}
public static Response reset(String key,String lvalue,String reverse) {
String url = activtyHost + "/aaw/hb/reset/lvalue";
Map<String,Object> parm = new HashMap<>();
parm.put("key",key);
parm.put("lvalue", lvalue);
if(reverse.equals("")||reverse.equals(null)||reverse.isEmpty()){
parm.put("reverse","false");
}else {
parm.put("reverse", reverse);
}
Response response = given().params(parm).get(url);
return response;
}
}
\ No newline at end of file
package main.com.atguigu.springmvc.handlers;
import io.restassured.response.Response;
import main.com.atguigu.springmvc.common.HbaseService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@Controller
public class HbaseModule {
/**
* 功能:Hbase查改操作
* @return
*/
@RequestMapping(value = "/doHbase", method= RequestMethod.POST)
@ResponseBody
public Map urlLink(HttpServletRequest request) throws Exception {
String select = request.getParameter("select");
String reverse = request.getParameter("reverse");
if(reverse.equals(null) || reverse.equals("") || reverse.isEmpty()){
reverse = "false";
}
String key = request.getParameter("key");
String value = request.getParameter("value");
System.out.println("select为:"+select);
System.out.println("reverse为:"+reverse);
System.out.println("key为:"+key);
System.out.println("value为:"+value);
Map<String, String> map = new HashMap<>();
if(select.equals("search")){
Response response = HbaseService.getHBASEKey(key,reverse);
map.put("message", response.asString());
}
if(select.equals("reset")){
Response response = HbaseService.reset(key,value,reverse);
map.put("message", response.asString());
}
return map;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment