Giter VIP home page Giter VIP logo

rest-spring-boot-starter's Introduction

rest-spring-boot-starter

统一业务异常处理,统一返回格式包装

依赖

<dependency>
    <groupId>tk.fishfish</groupId>
    <artifactId>rest-spring-boot-starter</artifactId>
    <version>1.1.0.RELEASE</version>
</dependency>

统一业务异常处理

@RestController
public class DemoController {

    @GetMapping("/list")
    public List<String> list() {
        throw new BizException(10001, "xxx错误");
    }

}

业务异常统一处理:

{
    "code": 10001,
    "msg": "xxx错误",
    "data": null
}

统一返回格式包装

@RestController
public class DemoController {

    @GetMapping("/list")
    public List<String> list() {
        return Arrays.asList("1", "2");
    }

}

默认(增加 @ApiResultIgnore 注解可忽略)对返回值进行统一包装,忽略org.springframework.http.ResponseEntity值类型。

{
    "code": 0,
    "msg": null,
    "data": [
        "1",
        "2"
    ]
}

1.1.0.RELEASE

  • 增加 @ApiResultIgnore 注解,显式声明不包装 API 返回结果

1.0.0.RELEASE

  • 统一业务异常处理
  • 统一 API 返回格式包装

rest-spring-boot-starter's People

Contributors

xuanbo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.