This is the 10th day of my participation in Gwen Challenge
preface
Welcome to our GitHub repository Star: github.com/bin39232820…
omg
Small six plans to open a series to share some of their usual development experience and discuss with you a best practice in our usual development process, is to sort out for your reference, and then learn together, progress together
What is populating a public property?
Is in our table design process, we must need the same field, then these fields, each time the new time, we have to set the default value, so we in the real project development said how to design? Take a look below
What are the common public fields?
- A primary key
- Creation time
- founder
- Modify the time
- The modifier
- Logical delete: 0 is deleted
I believe that the vast number of tables, these several fields will certainly have, of course, small 66 said is not absolute ha, to raise bar detour, ha ha!
So how will little Six six go to design the entity?
First we will have a BaseEntity to hold these common entities, as follows
And then, if I have a form and I have a signature form, because sixers are the ones who pay for this, then signing these is a common thing.
Heh heh, I this is the entity design, I believe that most of the partners should be designed in this way, the next is our common function abstraction
Common attribute abstraction
For example, when I add the signature table above, I need to fill in these public attributes, and then I need to configure the table, so this part of the function is actually the same, so how do we extract this part of the function? Here to see the small 66 side of the custom annotations
Define a custom annotation
DefaultParams
Define an annotation to make the cut point of the section
Facet implementation of custom annotations
DefaultParamsAspect
So let’s explain how to write this section right here!
- First get the current user ID for the operation
- The second step is to get the method’s input parameter
- The method of getting the getId of an entity by reflection
- Then determine whether the entity of the database is empty, if it is empty, it is new, otherwise it is updated
- These common parameters are populated by reflection
Specific use
Let’s take a look at our interface for saving signatures
All we need to do is add an @defaultParams annotation to our method to populate the public properties.
The end of the
This is the end of today’s sharing, just a small skill, the next few series will be used to share, the usual development of small skills. Thank you for your support, I am small 66, three days fishing, two days drying nets.
Daily for praise
Ok, everybody, that’s all for this article, you can see people here, they are real fans.
Creation is not easy, your support and recognition, is the biggest motivation for my creation, we will see in the next article
Wechat search “six pulse Excalibur program life” reply 888 I find a lot of information to you