Skip to content

Unified Response Format, Exception Handle, Paging Model

Notifications You must be signed in to change notification settings

VilleBez/api-response

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Response

  • Response
  • Exception
  • Paging
    • CursorPagingModel 游標型分頁,搭配 CursorUtils 對游標加解密編碼
    • OffsetPagingModel 位移型分頁

Benefit

  • 統一API回傳樣式
  • 集中Exception Handle
  • 分離非商務邏輯之其他事務

Validate Exception

{"warning":{"code":"101","desc":"can not be null!!"}}

Validate Type Enum

  • PARAMETER("1") 參數檢查
  • LOGIC("2") 邏輯檢查

Validate Parameter Type Enum

  • REQUIRED("01") 必填
  • LENGTH("02") 長度
  • FORMAT("03") 格式
  • OTHER("99") 其他

Except Validate Exception

{"error":{"exception":"java.lang.ArrayIndexOutOfBoundsException","message":"1"}}

How to use

<bean id="exampleService" class="org.ApiResponseProxy">
	<constructor-arg ref="org.ExampleService" />
</bean>

Response format

{"response":Object}
{"error":{"exception":"java.lang.ArrayIndexOutOfBoundsException","message":"1"}}
{"warning":{"code":"101","desc":"can not be null!!"}}

About

Unified Response Format, Exception Handle, Paging Model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages