forked from vector4wang/spring-boot-quick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebController.java
More file actions
51 lines (41 loc) · 1.33 KB
/
WebController.java
File metadata and controls
51 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package spark.controller;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import spark.service.WordCountService;
import spark.util.BaseResp;
import spark.util.ResultStatus;
import javax.annotation.Resource;
import java.io.FileNotFoundException;
import java.util.Map;
/**
* Created with IDEA
* User: vector
* Data: 2017/4/13
* Time: 18:02
* Description:
*/
@RestController
@RequestMapping("/spark")
public class WebController {
private Logger logger = Logger.getLogger(WebController.class);
@Resource
private WordCountService wordCountService;
@RequestMapping("/wordCount")
@ResponseBody
public BaseResp<Map<String, Integer>> wordCount(){
logger.info("start submit spark tast...");
Map<String, Integer> counts = null;
try {
counts = wordCountService.run();
} catch (FileNotFoundException e) {
return new BaseResp<>(ResultStatus.error_record_not_found);
}
return new BaseResp<Map<String, Integer>>(ResultStatus.SUCCESS,counts);
}
@RequestMapping("/hello")
public BaseResp<String> pring(){
return new BaseResp<String>(ResultStatus.SUCCESS,"hihi");
}
}