通用API处理,代码demo
1.使用Lombok中的处理日志
2.使用swagger处理接口文档
3.使用注解进行参数校验
@Slf4j
@RestController
@Api(value = "DemoController", tags = "示例接口")
@RequestMapping("/v1/demoController")
public class DemoController {
/**
* 删除
*/
@ApiOperation(value = "删除")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public Result deleteOffLineCustomer(@ApiParam(value = "数据id", required = true) @RequestParam @NotNull(message =
"数据id不能为空") String id) {
try {
// yewu
} catch (Exception e) {
}
}
/**
* 新增名称
*/
@ApiOperation(value = "新增名称")
@RequestMapping(value = "/adddto", method = RequestMethod.POST)
public Result adddto(@RequestBody @Validated({AgeVerify.class, NameVerify.class})
DemoDto demoDto) {
log.error("入参:{}", demoDto);
try {
// 业务
} catch (Exception e) {
log.error("xxxx异常:{}", e.getMessage());
return Result.error();
}
}
}
- 点赞
- 收藏
- 关注作者
评论(0)