dimanche 11 juillet 2021

how to divide entities and share it in clean architecture

For my new project in flutter, I am trying to follow the Clean Architecture and diving each different feature in domain, data and presentation`.

Now, I have initiated with the Authentication feature where I have started creating the Entities however, I am pretty much confused and stuck on how to modularize the code based on the Clean Architecture practice.

For example,

The response of my login service is as follow,

  1. so do I need to create entities and models for all JSON nested objects like for response , data , user , accountData and permissions ?

    or is there any way to use IResponse to store common elements like status , message and data and then use only for relevant feature.

  2. Not sure whether it is allowed to share entities in between the features. Like user block below can be a feature in Authorization and Employee

{
  "status": "success",
  "message": "successfully login",
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NywiaXNMb2dnZWRJbiI6dHJ1ZSwidGVuYW50SWQiOjEyLCJpYXQiOjE2MjU5OTE5MTAsImV4cCI6MTYyNjA3ODMxMH0.I0z9OIDnQS-MI1ya6usqycoryZ1TBwj3K52BRfrpMuY",
    "user": {
      "user_id": 7,
      "email": "jd@gmail.com",
      "first_name": "John",
      "last_name": "Doe",
      "phone": "",
      "date_of_birth": "2015-08-06T00:00:00.000Z",
      
    },
    "accountData": {
      "name": "Amazon",
      "account_id": 1
    },
    "permissions": [
      "ViewAllEmployee",
      "AddNewEmployee"
    ]
  }
}

Aucun commentaire:

Enregistrer un commentaire