I carried out the remaining tasks from last week’s internship this week by putting the entity into practice. The ability to create and update commands was something I had finished. Thus, I still need to create the functionality to obtain entity by id query, get list query, and delete the entity command. Therefore, before querying the entity list and entity information by id, I started implementing the removing entity feature. When I implemented the feature of querying the entity list, I realized that I needed to add two more functions to the repository part. The first function is to get the entity list with page number and page size. Meanwhile, the second function is to get the number of entities from the query.
Based on the search result, the handler portion of this feature will return the dto with the entity list, page size, page number, and number of entities. Mr. Peter informed me that there will only be one response to the get entity list query—an HTTP status code of 200 OK—after I had completed developing the entity entity. The response of HTTP status code 204 No Content will not be returned since it is a search function. So, I quickly fixed the problem and continue to implement another new entity.
A few fundamental CRUD operations, including the create, update, and delete entity commands as well as the get entity list and get item entity by id query, will be included in this object.
When testing the API for this entity, I need to include the table and data from another entity, which are entity and store, in order to make the test work. The test won’t function if I don’t include the entity and store entities because the entity table is related to entity A table and the entity A table is linked to the entity B table. Mr. Peter has advised that I include a check to ensure that there are no duplicate of complex ids after I have completed creating this entity. In order to solve this puzzle, he also advised me to use complex keys.
Since the price is required for the frontend to generate the post page, I have also included the selling price to the item API. Last but not least, Mr. Peter has requested that I include sorting to each table list. This is a result of the data’s constant inconsistency with the ids order. Consequently, I have updated each table list in the repository section with a “ORDER BY id” statement. The table will be listed in ascending order of id when the get list API is invoked.
