| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package com.uas.eis.controller;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.uas.eis.service.UserService;
- import com.uas.eis.utils.HttpUtil;
- import com.uas.eis.utils.HttpUtil.Response;
- @RestController
- public class HelloWorldController {
- @Autowired
- private UserService userService;
-
- @RequestMapping(value = "/hello", produces = "application/json;charset=utf-8")
- public String hello(){
- return "Hello,World!";
- }
-
- @RequestMapping("/getUser")
- public Map<String, Object> getUser(String username){
- return userService.getUser(username);
- }
-
- /**
- * 首次登陆请求token
- */
- @RequestMapping("/login")
- public String login(String username, String password){
- return "<pre style=\"width:50%;font-family: mic;white-space: pre-wrap;word-wrap: break-word;\">"+userService.login(username, password)+"</pre>";
- }
-
- /**
- * token 测试
- */
- @RequestMapping(value = "/test", produces = "application/json;charset=utf-8")
- public String test(String username){
- return "中文";
- }
-
- /**
- * http请求测试
- * @return
- */
- @RequestMapping(value = "/baidu", produces = "text/html;charset=utf-8")
- public String testHttpRequest() {
- try {
- return HttpUtil.sendGetRequest("https://www.baidu.com/", null).getResponseText();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- }
|