Class design (execute different methods according to different types)

problem description

there are two types of users in a system, platform and enterprise (which may be increased later). No matter what type of users, the operations involved are additions, deletions, queries and changes, but different types of users may have different operation logic (mainly because the data used is different). At present, we want to use two categories to cover this part. For example, both platforms and enterprises have a common class A, which is done by adding, deleting, querying and changing. Then the class of the platform is a subclass of class A, and in the platform, it is not the addition, deletion, query and change of the platform, but the addition, deletion, query and change of the platform, that is, the name of the method has to be distinguished. The corporate approach is similar. The other is a super administrator, which requires the operation of the platform and the enterprise.

the environmental background of the problems and what methods you have tried

CRUD {
+ insert
+ update
+ delete
+ select
}

AccessCRUD extends CRUD {
+ beforeInsert
+ prepareInsert
+ postInsert
+ AfterInsert
...
}

OrganizeCRUD extends AccessCRUD {
+ platformBeforeInsert
+ platformPrepareInsert
+ platformPostInsert
+ platformAfterInsert
+ enterpriseBeforeInsert
+ enterprisePrepareInsert
+ enterprisePostInsert
+ enterpriseAfterInsert
}

what result do you expect? What is the error message actually seen?

there are too many methods in OrganizeCURD this way. It is expected that PlatformCRUD, EnterpriseCRUD, and then OrganizeCRUD inherits PlatformCRUD and EnterpriseCRUD to have methods to manipulate PlatformCRUD and EnterpriseCRUD. In addition, CRUD methods hope to be invisible in PlatformCRUD, EnterpriseCRUD and OrganizeCRUD

Jul.22,2021

complex logic should be disassembled.
yours are best written separately according to different roles. After that, it is easy to change and debug.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4d86e-43bf8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4d86e-43bf8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?