use of net.osmand.server.api.repo.DeviceSubscriptionsRepository.SupporterDeviceSubscription in project OsmAnd-tools by osmandapp.
the class AdminController method searchSubscription.
@PostMapping(path = { "/search-subscription" })
public String searchSubscription(Model model, @RequestParam(required = true) String orderId, final RedirectAttributes redirectAttrs) throws JsonProcessingException {
SupporterDeviceSubscription deviceSub = new SupporterDeviceSubscription();
deviceSub.sku = "not found";
deviceSub.orderId = "none";
deviceSub.valid = false;
if (emailSender.isEmail(orderId)) {
PremiumUser pu = usersRepository.findByEmail(orderId);
if (pu != null) {
deviceSub.sku = orderId + " (pro email)";
List<SupporterDeviceSubscription> ls = subscriptionsRepository.findByOrderId(pu.orderid);
if (ls != null && ls.size() > 0) {
deviceSub = ls.get(0);
}
if (deviceSub != null) {
UserFilesResults ufs = userDataController.generateFiles(pu.id, null, null, true, false);
ufs.allFiles.clear();
ufs.uniqueFiles.clear();
deviceSub.payload = gson.toJson(ufs);
}
}
} else {
List<SupporterDeviceSubscription> ls = subscriptionsRepository.findByOrderId(orderId);
if (ls != null && ls.size() > 0) {
deviceSub = ls.get(0);
}
}
redirectAttrs.addFlashAttribute("subscriptions", Collections.singleton(deviceSub));
return "redirect:info#audience";
}
Aggregations