There is a batch of products, all of which contain a config field. Now there are products with different IDs in a list, and the required config field needs to be taken out according to certain weight rules:
For example, the id is 1, The weight of 3 is higher than 2 and 4, and the weight of id 2 and 4 is higher than 5 and 7
So how can we design the code other than simply using if-else to operate? So that it is easier to maintain
switch? It’s better to encapsulate it into a function
if else is also ok, it’s not complicated