SampleController.java
1.48 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
package com.bsth.controller.forecast;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bsth.common.ResponseCode;
import com.bsth.controller.BaseController;
import com.bsth.controller.forecast.dto.CreateSampleParam;
import com.bsth.entity.forecast.Sample;
import com.bsth.service.forecast.SampleService;
@RestController
@RequestMapping("sample")
public class SampleController extends BaseController<Sample, Long>{
@Autowired
SampleService sampleService;
Logger loger = LoggerFactory.getLogger(this.getClass());
@RequestMapping("/create/gps")
public Map<String, Object> createDataByGps(@RequestParam String data){
Map<String, Object> rs = new HashMap<>();
try {
data = URLDecoder.decode(data, "utf-8");
CreateSampleParam param = JSONObject.toJavaObject(JSON.parseObject(data), CreateSampleParam.class);
rs = sampleService.createDataByGps(param);
} catch (UnsupportedEncodingException e) {
loger.info("", e);
rs.put("status", ResponseCode.ERROR);
}
return rs;
}
}