Return to the directory

  • Lesson 5: Use SmartList and BaseEntity
    • SmartList
    • Understand the BaseEntity
      • Basic implementation of serialization
      • Utility class methods

Lesson 5: Use SmartList and BaseEntity

SmartList

SmartList is an enhanced wrapper of JDK List in the DAAS framework, which facilitates data processing during service processing. All batch query interfaces in daAS return SmartList<T> by default.

The code for SmartList is located at:

Xxx_core_src /< project package path, for example, com/demo/bank>/ smartList.java

In general, just use it as a normal list.

In cases where paging is required, the following interfaces are used

int page = rList.getCurrentPageNumber();
int pageSize = rList.getRowsPerPage();
int totalCount = rList.getTotalCount();
Copy the code

There is also a shortcut to get the ids of all the members of the list:

String[] ids = rList.idArray();
Copy the code

And a list to map method:

Map<String, ChangeRequest> objMap = rList.mapWithId();
Copy the code

Understand the BaseEntity

Dass generates entity classes for each model defined in XML.

All of these entity classes inherit from BaseEntity.

BaseEntity is an enhancement of Java Object to ensure that all entity classes in daAS-generated applications are characteristically consistent.

The code for BaseEntity is located in:

Xxx_core_src /< project package path, for example, com/demo/bank>/ baseentity.java

Basic implementation of serialization

BaseEntity provides the base implementation of serialization for all entity classes.

The entity class XXX will have a corresponding serialization class xxxSerializer.java.

Daas uses com.fasterxml.jackson for serialization. Need to use the entity class

public List<KeyValuePair> keyValuePairOf()
protected void appendKeyValuePair(List<KeyValuePair> list, String key, Object value)
Copy the code

Utility class methods

MaskChinaMobileNumber (String chinaMobileNumber) public String getInternalType() // Returns the short class name public Object propertyOf(String propertyName) public void setPropertyOf(String propertyName, Object value) public void incVersion () / / version used for optimistic locking public int nextVersion () / / the following two used to add | get temporary additional data to the public in the entity < T > void addItemToValueMap(String key, T item) public Object valueByKey(String Key) public BaseEntity copyTo(BaseEntity Dest)Copy the code

For more details, you can view its source code (yes, you have all the source code).