VehicleMappingController.java
1.85 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
package com.bsth.controller;
import com.bsth.common.ResponseCode;
import com.bsth.entity.VehicleMapping;
import com.bsth.service.VehicleMappingService;
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.Map;
@RestController
@RequestMapping("vehicle-mapping")
public class VehicleMappingController {
private final static Logger log = LoggerFactory.getLogger(VehicleMappingController.class);
@Autowired
private VehicleMappingService vehicleMappingService;
@RequestMapping(method = RequestMethod.POST)
public Map<String, Object> save(VehicleMapping vehicleMapping) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("status", ResponseCode.ERROR);
try {
vehicleMappingService.save(vehicleMapping);
result.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
log.error("", e);
result.put("msg", e.getMessage());
}
return result;
}
@RequestMapping(value = "/all", method = RequestMethod.GET)
public Map<String, Object> findByParams(@RequestParam Map<String, Object> params) {
Map<String, Object> result = new HashMap<>();
result.put("status", ResponseCode.ERROR);
try {
result.put("data", vehicleMappingService.findByParams(params));
result.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
log.error("", e);
result.put("msg", e.getMessage());
}
return result;
}
}