GeoPremiseController.java
1.32 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
package com.bsth.controller;
import com.bsth.common.ResponseCode;
import com.bsth.entity.GeoPremise;
import com.bsth.service.GeoPremiseService;
import com.bsth.util.GeoConverter;
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.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* @author Hill
*/
@RestController
@RequestMapping("/api/geopremise")
public class GeoPremiseController extends BaseController<GeoPremise, Integer> {
@Autowired
private GeoPremiseService geoPremiseService;
@Override
@RequestMapping(method = RequestMethod.POST)
public Map<String, Object> save(GeoPremise geoPremise) {
Map<String, Object> result = new HashMap<>();
try {
String coords = geoPremise.getCoords();
geoPremise.setCoordsWgs(GeoConverter.polygonBd2wgs(String.format("POLYGON((%s))", coords)).toString().replace("POLYGON((", "").replace("))", ""));
result.putAll(geoPremiseService.save(geoPremise));
result.put("status", ResponseCode.SUCCESS);
} catch (Exception e) {
result.put("status", ResponseCode.ERROR);
}
return result;
}
}