LineRegionController.java
1.89 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
52
53
54
55
56
57
58
59
60
61
62
63
package com.bsth.controller;
import com.bsth.common.ResponseCode;
import com.bsth.entity.LineRegion;
import com.bsth.entity.LsStationRoute;
import com.bsth.service.LineRegionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author Hill
*/
@RestController
@RequestMapping("/api/lineregion")
public class LineRegionController extends BaseController<LineRegion, Integer> {
private Logger log = LoggerFactory.getLogger(LineRegionController.class);
@Autowired
private LineRegionService lineRegionService;
@RequestMapping(path = "findStationRoutes")
public List<LsStationRoute> findStationRoutes(@RequestParam(defaultValue = "id") Integer regionId) {
return lineRegionService.findStationRoutes(regionId);
}
@RequestMapping(path = "add", method = RequestMethod.POST)
public Map<String, Object> add(LineRegion lineRegion) {
Map<String, Object> result = new HashMap<>();
try {
lineRegionService.add(lineRegion);
result.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
log.error("添加线路区间异常", e);
result.put("status", ResponseCode.ERROR);
}
return result;
}
@RequestMapping(path = "modify", method = RequestMethod.POST)
public Map<String, Object> modify(LineRegion lineRegion) {
Map<String, Object> result = new HashMap<>();
try {
lineRegionService.save(lineRegion);
result.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
log.error("变更线路区间异常", e);
result.put("status", ResponseCode.ERROR);
}
return result;
}
}