packagecn.js.Controller;importcn.js.Exception.AppException;importcn.js.Exception.AppExceptionCodeMsg;importcn.js.Exception.Resp;importorg.springframework.web.bind.annotation.GetMapping;importorg.springframework.web.bind.annotation.RestController;importjava.util.Arrays;importjava.util.List;@RestControllerpublicclassDemoController{@GetMapping("demo")publicResp<String>demo1(String name){if("ok".equals(name)){returnResp.success("succ");}if("err".equals(name)){//抛业务相关的异常thrownewAppException(AppExceptionCodeMsg.USERNAME_NOT_EXISTS);}if("errcode".equals(name)){thrownewAppException(AppExceptionCodeMsg.INVALID_CODE);}if("0".equals(name)){int i=1/0;}//检查用户积分是否足够,如果不够,就抛出异常if("notenough".equals(name)){thrownewAppException(AppExceptionCodeMsg.USER_CREDIT_NOT_ENOUTH);}returnResp.success("default");}@GetMapping("list")publicResp<List>list(){List<String> list =Arrays.asList("zhangsan","lisi","wangwu");returnResp.success(list);}}