Common

Hope brings several extensions to the framework layer:

ModuleNote
it-commonIncludes: Common utility classes (Utils), common protocol definitions
it-common-apiInvolves common API classes, auxiliary class definitions
it-common-mockRuntime mock context definitions
it-common-springSpring extensions, detailed reference in the Spring series below
it-common-spring-commonCommon Spring extensions
it-common-spring-apiSpring API definition extensions
it-common-spring-cacheSpring cache extensions
it-common-spring-coreSpring core extensions
it-common-spring-dataSpring data extensions
it-common-spring-mockSpring mock extensions

it-common

Package NameNoteScope
asyncContains two common Executor Global helper classesOptional
contractContract testing protocol definitionsMock usage
enumerationConstant definition protocolRequired
metaFramework meta information definitions, required by the framework (not needed at runtime)Framework
persistenceFramework ORM definition information, required by the framework (not needed at runtime)Framework
runtimeRuntime context, exposed as actuator information, handled by the frameworkFramework
scriptEmbedded scripts needed for IDEA extensions, not needed at runtimeFramework
serviceAPI service information annotations, runtime informationFramework
  1. Most are objects that the framework relies on at runtime and are generally not referenced in your business logic code;
  2. enumeration is a fixed pattern for constants defined within the framework that need to be exposed externally, defined using proto will automatically conform to this standard;

it-common-api

Includes common data types and helper classes for API runtime definitions;

Class NameNote
PageRequestPagination query parameter object
PageablePaginated dataset
ResultStandard API return result
ResultBuilderResult Builder

Pagination

Refer to Spring:

  1. Spring Data PageRequest
  2. Spring Data Pageable

Pagination Request - PageRequest

NameNote
pageZero-based page index (0..N)
sizeSize of the page to be returned
offSetInfinite scroll load; this is the last offset if any key is specific
sortSorting criteria in the format: property,(asc or desc). Default sort order is ascending. Multiple sort criteria are supported.

Paginated Dataset - Pageable

NameNote
pageIndexCurrent page number
pageSizeNumber of objects on this page
totalPageTotal count
totalPageTotal number of pages
dataList of objects

Response Body

Return Object - Result

NameNote
codeReturn code, non-zero indicates failure, zero indicates success
messageReturn prompt message
payloadInformation carrier (generic type object T)
errorsList of errors Error

Error

Hope general error definitions:

NameNoteExample
codeError code100002401
titleError titleUSER_NAME_EMPTY
descriptionError descriptionuser name should not be empty
description2Error description 2用户名不可以为空
pathField pathuser.name
fieldField namename
rejectedValueRejected value (original value)jake
constraintConstraintNOT_NULL
tipsTips价格必须是正数如:1000.12
phasePhaseCONTROLLER
severitySeverityERROR
domainDomainaccount
propertiesExtended fields (Map)-
httpStatusHTTP statusBAD_REQUEST

Phase

NameNoteExample
CONTROLLERControllerForm layer
SERVICEServiceService layer
DOMAINDomainDomain layer

Severity

NameNoteExample
LOWLowLow, no impact
WARNWarnWarning, business error can be retried
ERRORErrorError, business cannot proceed
FATALFatalDisaster, data corruption

HttpStatus

Includes standard HTTP status codes, not enumerated one by one, such as BAD_REQUEST(400), FORBIDDEN(403);

it-common-mock

Mock allows testing interface data formats without writing a single line of code; there is a separate introduction and explanation for mocking;

To be done 🏗️