| Line 34... |
Line 34... |
| 34 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
34 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 35 |
import org.apache.logging.log4j.LogManager;
|
35 |
import org.apache.logging.log4j.LogManager;
|
| 36 |
import org.apache.logging.log4j.Logger;
|
36 |
import org.apache.logging.log4j.Logger;
|
| 37 |
import org.apache.velocity.app.VelocityEngine;
|
37 |
import org.apache.velocity.app.VelocityEngine;
|
| 38 |
import org.springframework.beans.factory.annotation.Autowired;
|
38 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
39 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 39 |
import org.springframework.cache.CacheManager;
|
40 |
import org.springframework.cache.CacheManager;
|
| 40 |
import org.springframework.core.io.InputStreamResource;
|
41 |
import org.springframework.core.io.InputStreamResource;
|
| 41 |
import org.springframework.http.HttpHeaders;
|
42 |
import org.springframework.http.HttpHeaders;
|
| 42 |
import org.springframework.http.HttpStatus;
|
43 |
import org.springframework.http.HttpStatus;
|
| 43 |
import org.springframework.http.ResponseEntity;
|
44 |
import org.springframework.http.ResponseEntity;
|
| Line 255... |
Line 256... |
| 255 |
|| createOfferRequest.getPartnerCriteria().getRegionIds().size() > 0) {
|
256 |
|| createOfferRequest.getPartnerCriteria().getRegionIds().size() > 0) {
|
| 256 |
List<Integer> fofoIds = offersMap.entrySet().stream().filter(x -> x.getValue().contains(offer))
|
257 |
List<Integer> fofoIds = offersMap.entrySet().stream().filter(x -> x.getValue().contains(offer))
|
| 257 |
.map(x -> x.getKey()).collect(Collectors.toList());
|
258 |
.map(x -> x.getKey()).collect(Collectors.toList());
|
| 258 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
259 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
| 259 |
sendNotificationModel.setUserIds(userIds);
|
260 |
sendNotificationModel.setUserIds(userIds);
|
| 260 |
/*
|
- |
|
| 261 |
* if(createOfferRequest.getPartnerCriteria().getRegionIds().size() > 0) {
|
- |
|
| 262 |
* List<Integer> regionIds =
|
- |
|
| 263 |
* createOfferRequest.getPartnerCriteria().getRegionIds(); }
|
- |
|
| 264 |
*/
|
- |
|
| 265 |
notificationService.sendNotification(sendNotificationModel);
|
261 |
notificationService.sendNotification(sendNotificationModel);
|
| 266 |
} else {
|
262 |
} else {
|
| 267 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
263 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
| 268 |
}
|
264 |
}
|
| 269 |
|
265 |
|
| Line 342... |
Line 338... |
| 342 |
ImageIO.write(img, "png", os);
|
338 |
ImageIO.write(img, "png", os);
|
| 343 |
return new ByteArrayInputStream(os.toByteArray());
|
339 |
return new ByteArrayInputStream(os.toByteArray());
|
| 344 |
}
|
340 |
}
|
| 345 |
|
341 |
|
| 346 |
@Autowired
|
342 |
@Autowired
|
| 347 |
VelocityEngine velocityEngine;
|
343 |
private VelocityEngine velocityEngine;
|
| - |
|
344 |
|
| - |
|
345 |
|
| - |
|
346 |
@Autowired
|
| - |
|
347 |
@Qualifier("velocityAttributesMap")
|
| - |
|
348 |
private Map<String, Object> velocityAttributesMap;
|
| 348 |
|
349 |
|
| 349 |
private String getContentFromTemplate(String template, Map<String, Object> model) {
|
350 |
private String getContentFromTemplate(String template, Map<String, Object> model) {
|
| 350 |
StringBuffer content = new StringBuffer();
|
351 |
StringBuffer content = new StringBuffer();
|
| 351 |
try {
|
352 |
try {
|
| - |
|
353 |
((HashMap<String, Object>) (velocityAttributesMap.entrySet().stream().findAny().get()).getValue()).entrySet().stream().forEach(x -> {
|
| - |
|
354 |
model.put(x.getKey(), x.getValue());
|
| - |
|
355 |
});
|
| 352 |
content.append(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, template, model));
|
356 |
content.append(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, template, model));
|
| 353 |
} catch (Exception e) {
|
357 |
} catch (Exception e) {
|
| 354 |
e.printStackTrace();
|
358 |
e.printStackTrace();
|
| 355 |
}
|
359 |
}
|
| 356 |
return content.toString();
|
360 |
return content.toString();
|