| Line 31... |
Line 31... |
| 31 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
31 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 32 |
import org.apache.commons.io.FileUtils;
|
32 |
import org.apache.commons.io.FileUtils;
|
| 33 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
33 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 34 |
import org.apache.logging.log4j.LogManager;
|
34 |
import org.apache.logging.log4j.LogManager;
|
| 35 |
import org.apache.logging.log4j.Logger;
|
35 |
import org.apache.logging.log4j.Logger;
|
| - |
|
36 |
import com.google.gson.Gson;
|
| - |
|
37 |
import com.spice.profitmandi.service.offers.PartnerCriteria;
|
| 36 |
import org.springframework.beans.factory.annotation.Autowired;
|
38 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
39 |
import org.springframework.cache.interceptor.SimpleKey;
|
| 37 |
import org.springframework.beans.factory.annotation.Value;
|
40 |
import org.springframework.beans.factory.annotation.Value;
|
| 38 |
import org.springframework.cache.CacheManager;
|
41 |
import org.springframework.cache.CacheManager;
|
| 39 |
import org.springframework.core.io.InputStreamResource;
|
42 |
import org.springframework.core.io.InputStreamResource;
|
| 40 |
import org.springframework.http.HttpHeaders;
|
43 |
import org.springframework.http.HttpHeaders;
|
| 41 |
import org.springframework.http.HttpStatus;
|
44 |
import org.springframework.http.HttpStatus;
|
| Line 107... |
Line 110... |
| 107 |
|
110 |
|
| 108 |
@Autowired
|
111 |
@Autowired
|
| 109 |
private CacheManager redisShortCacheManager;
|
112 |
private CacheManager redisShortCacheManager;
|
| 110 |
|
113 |
|
| 111 |
@Autowired
|
114 |
@Autowired
|
| - |
|
115 |
private CacheManager thirtyMinsTimeOutCacheManager;
|
| - |
|
116 |
|
| - |
|
117 |
@Autowired
|
| 112 |
BrandsService brandsService;
|
118 |
BrandsService brandsService;
|
| 113 |
|
119 |
|
| 114 |
@Autowired
|
120 |
@Autowired
|
| 115 |
private CatalogRepository catalogRepository;
|
121 |
private CatalogRepository catalogRepository;
|
| 116 |
|
122 |
|
| Line 647... |
Line 653... |
| 647 |
message = "Partner(s) removed from Offer #" + offerId + ". New Offer #" + newOfferId + " created (Unpublished).";
|
653 |
message = "Partner(s) removed from Offer #" + offerId + ". New Offer #" + newOfferId + " created (Unpublished).";
|
| 648 |
} else {
|
654 |
} else {
|
| 649 |
message = "Partner(s) removed from Offer #" + offerId + ".";
|
655 |
message = "Partner(s) removed from Offer #" + offerId + ".";
|
| 650 |
}
|
656 |
}
|
| 651 |
|
657 |
|
| - |
|
658 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
| - |
|
659 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
| - |
|
660 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| - |
|
661 |
// Evict partnerOffers cache for removed partners + admin view
|
| - |
|
662 |
for (Integer fofoId : fofoIds) {
|
| - |
|
663 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
| - |
|
664 |
}
|
| - |
|
665 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(0, offerId));
|
| - |
|
666 |
|
| 652 |
Map<String, Object> response = new HashMap<>();
|
667 |
Map<String, Object> response = new HashMap<>();
|
| 653 |
response.put("message", message);
|
668 |
response.put("message", message);
|
| 654 |
response.put("newOfferId", newOfferId);
|
669 |
response.put("newOfferId", newOfferId);
|
| 655 |
response.put("yearMonth", ym.toString());
|
670 |
response.put("yearMonth", ym.toString());
|
| 656 |
return responseSender.ok(response);
|
671 |
return responseSender.ok(response);
|
| Line 665... |
Line 680... |
| 665 |
}
|
680 |
}
|
| 666 |
offerService.addPartnersToOffer(offerId, fofoIds);
|
681 |
offerService.addPartnersToOffer(offerId, fofoIds);
|
| 667 |
|
682 |
|
| 668 |
Offer offer = offerRepository.selectById(offerId);
|
683 |
Offer offer = offerRepository.selectById(offerId);
|
| 669 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
684 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
| - |
|
685 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
| - |
|
686 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
| - |
|
687 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| - |
|
688 |
// Evict partnerOffers cache for added partners + admin view
|
| - |
|
689 |
for (Integer fofoId : fofoIds) {
|
| - |
|
690 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
| - |
|
691 |
}
|
| - |
|
692 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(0, offerId));
|
| 670 |
|
693 |
|
| 671 |
Map<String, Object> response = new HashMap<>();
|
694 |
Map<String, Object> response = new HashMap<>();
|
| 672 |
response.put("message", "Partner(s) added to Offer #" + offerId + ".");
|
695 |
response.put("message", "Partner(s) added to Offer #" + offerId + ".");
|
| 673 |
response.put("yearMonth", ym.toString());
|
696 |
response.put("yearMonth", ym.toString());
|
| 674 |
return responseSender.ok(response);
|
697 |
return responseSender.ok(response);
|
| Line 686... |
Line 709... |
| 686 |
Offer offer = offerRepository.selectById(offerId);
|
709 |
Offer offer = offerRepository.selectById(offerId);
|
| 687 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
710 |
YearMonth ym = YearMonth.from(offer.getStartDate());
|
| 688 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
711 |
oneDayCacheManager.getCache("allOffers").evict(ym);
|
| 689 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
712 |
redisCacheManager.getCache("catalog.published_yearmonth").evict(ym);
|
| 690 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
713 |
redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
|
| - |
|
714 |
// Evict partnerOffers cache for all partners of this offer + admin view
|
| - |
|
715 |
PartnerCriteria partnerCriteria = new Gson().fromJson(offer.getPartnerCriteria(), PartnerCriteria.class);
|
| - |
|
716 |
if (partnerCriteria != null && partnerCriteria.getFofoIds() != null) {
|
| - |
|
717 |
for (Integer fofoId : partnerCriteria.getFofoIds()) {
|
| - |
|
718 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(fofoId, offerId));
|
| - |
|
719 |
}
|
| - |
|
720 |
}
|
| - |
|
721 |
thirtyMinsTimeOutCacheManager.getCache("partnerOffers").evict(new SimpleKey(0, offerId));
|
| 691 |
|
722 |
|
| 692 |
return responseSender.ok("Targets updated for Offer #" + offerId);
|
723 |
return responseSender.ok("Targets updated for Offer #" + offerId);
|
| 693 |
}
|
724 |
}
|
| 694 |
|
725 |
|
| 695 |
}
|
726 |
}
|
| 696 |
|
727 |
|