how to implement retrieval of DB records by two params?

hey guys. i want to ask you for advice. so im coding an api which takes two params (season of the year, distance of the hike) and returns a list of items that i should put in my backpack. in DB i have one table Items with three columns id, name, season, distance. but i was wondering how to incorporate these two criterias in my code. like how to approach it? i have this service now:
@Service
public class ItemService {
private ItemRepository itemRepository;
public ItemService(ItemRepository itemRepository) {
this.itemRepository = itemRepository;
}
public String getItemsBySeason(String season) {
//call repo, etc
return "Get items";
}
}
@Service
public class ItemService {
private ItemRepository itemRepository;
public ItemService(ItemRepository itemRepository) {
this.itemRepository = itemRepository;
}
public String getItemsBySeason(String season) {
//call repo, etc
return "Get items";
}
}
and idk how to add get by distance functionality. i dont want to have two separate methods (one for retrieving items by season, and one for filtering those records by distance). I can have just one method (obviously). but idk if having public List<Item> getItemsBySeasonAndDistance(String season, double distance) method makes sense. what do u guys think? thanks
3 Replies
JavaBot
JavaBot11mo ago
This post has been reserved for your question.
Hey @bambyzas! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Kyo-chan
Kyo-chan11mo ago
..... Obviously it makes sense, since this is the sort of stuff the api users may want to query
JavaBot
JavaBot11mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server