i want according role value,get associated service,like
LogisticsUserEntity user = this.getLogisticsUserById(userId);
UserDealService userDealService = getUserDealService(user.getRole());
UserEntity userEntity = userDealService.getUserEntity(user);
LogisticsUserDao and TruckOwnerDao all implements UserDealService interface, if role is 4,driverDao return,if is 5 ,truckOwnerDao return,but i have use
@Autowired
private DriverDao driverDao;
@Autowired
private TruckOwnerDao truckOwnerDao;
i don't want use a map,like put(4,driverDao );because if i want to add other dao,i have to modify the code,it violate the open-closed. so how can i solve the extend problem? thanks all your help and suggestion in advance.
Aucun commentaire:
Enregistrer un commentaire