Browse Source

固定的数据接口返回格式:返回信息、返回编码、返回异常。

huangbo 7 years ago
parent
commit
7ae2e05013

+ 10 - 7
ipu-rest-demo/src/main/java/com/ai/ipu/server/demo/control/data/DataController.java

@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
8 8
import org.springframework.web.bind.annotation.RequestParam;
9 9
import org.springframework.web.bind.annotation.ResponseBody;
10 10

11
import com.ai.ipu.basic.util.IpuBaseException;
11 12
import com.ailk.common.data.IData;
12 13
import com.ailk.common.data.impl.DataMap;
13 14

@ -29,6 +30,15 @@ public class DataController {
29 30
        return params;
30 31
    }
31 32
	
33
    @RequestMapping("/error")
34
    public void error() throws Exception {
35
        throw new Exception("使用默认异常抛出全局data异常");
36
    }
37
	
38
    @RequestMapping("/ipuerror")
39
    public void ipuerror() throws Exception {
40
        throw new IpuBaseException("使用IPU异常抛出全局data异常");
41
    }
32 42
	
33 43
	@ResponseBody
34 44
	@RequestMapping("/map")
@ -56,11 +66,4 @@ public class DataController {
56 66
		params.put("data", data);
57 67
        return params.toString();
58 68
    }
59
	
60
	@RequestMapping("/error")
61
    public void error() throws Exception {
62
		if(true){
63
			throw new Exception("抛出全局data异常");
64
		}
65
    }
66 69
}