I am working in a jsp project an got stuck in a big problem.
My project consist of accounts table for super admin, reseller, admin and users for executives and manager mapped in the account
Permission
Super admin can see or add details of reseller, admin, executives and manager, and edit its own account
Reseller can see or add details of admin,executives and manager ,and edit its own account but unable to create reseller
Admin can see or add details of executives and manager ,and can see or edit its own account but unable to create admin
Executives can see only his details and edit it
So the highest priority is for super admin account which have access of everyone,then comes reseller account which have access to the admin account and lower account that he created,then admin account can access manager and executives users ,then manager user can access executives and then executive can see only his information
I have accounts and users table,Accounts can be super admin, reseller, and admin they all have an account_id and users are manager and executives which has a user_id
My problem is that how to do that ,how to map these id because reseller have account_id and can add account id ( admin) so to fetch details of reseller i have to also fetch details of lower admin account
In the same way for every type of account or user which login i have to apply a different sql query For ex if i have an extra table of call-details which have details on which user(user_id) receive call and which account(account_id) the user is mapped so i have to apply different sql query for different accounts and users login
like for super-admin select * from call-details
for reseller select * from call-details
of reseller and call-details of account associated with it
for admin select * from call-details
where call receive on that account.
and so on and i have more table and more pages then it is very difficult to apply this approach.
Is there any approach by which i can solve this problem with a less difficult way. I tried my best to explain my problem please ask again if you have any doubts understanding my problem.
Any help would be appreciated.