Subversion Repositories SmartDukaan

Rev

Rev 35726 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35726 Rev 35857
Line 103... Line 103...
103
    private OfferService offerService;
103
    private OfferService offerService;
104
    @Autowired
104
    @Autowired
105
    private CacheManager oneDayCacheManager;
105
    private CacheManager oneDayCacheManager;
106
 
106
 
107
    @Autowired
107
    @Autowired
-
 
108
    private CacheManager redisCacheManager;
-
 
109
 
-
 
110
    @Autowired
-
 
111
    private CacheManager redisShortCacheManager;
-
 
112
 
-
 
113
    @Autowired
108
    BrandsService brandsService;
114
    BrandsService brandsService;
109
 
115
 
110
    @Autowired
116
    @Autowired
111
    private CatalogRepository catalogRepository;
117
    private CatalogRepository catalogRepository;
112
 
118
 
Line 179... Line 185...
179
            offer.setActive(active);
185
            offer.setActive(active);
180
            yearMonthsToEvict.add(YearMonth.from(offer.getStartDate()));
186
            yearMonthsToEvict.add(YearMonth.from(offer.getStartDate()));
181
        }
187
        }
182
        //Evict caches
188
        //Evict caches
183
        for (YearMonth ymToEvict : yearMonthsToEvict) {
189
        for (YearMonth ymToEvict : yearMonthsToEvict) {
184
            oneDayCacheManager.getCache("catalog.published_yearmonth").evict(ymToEvict);
190
            redisCacheManager.getCache("catalog.published_yearmonth").evict(ymToEvict);
185
            oneDayCacheManager.getCache("allOffers").evict(ymToEvict);
191
            oneDayCacheManager.getCache("allOffers").evict(ymToEvict);
186
        }
192
        }
-
 
193
        redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
187
        if (active) {
194
        if (active) {
188
            for (Offer offer : offers) {
195
            for (Offer offer : offers) {
189
                this.sendNotification(offer);
196
                this.sendNotification(offer);
190
            }
197
            }
191
        }
198
        }
Line 193... Line 200...
193
 
200
 
194
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
201
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
195
        return "response";
202
        return "response";
196
    }
203
    }
197
 
204
 
-
 
205
    @RequestMapping(value = "/offers/publishAll", method = RequestMethod.POST)
-
 
206
    public ResponseEntity<?> publishAllUnpublished(@RequestParam YearMonth yearMonth)
-
 
207
            throws ProfitMandiBusinessException, Exception {
-
 
208
        List<Offer> published = offerService.publishAllUnpublished(yearMonth);
-
 
209
        if (!published.isEmpty()) {
-
 
210
            redisCacheManager.getCache("catalog.published_yearmonth").evict(yearMonth);
-
 
211
            oneDayCacheManager.getCache("allOffers").evict(yearMonth);
-
 
212
            redisShortCacheManager.getCache("publishedOffersWithAchievement").clear();
-
 
213
            for (Offer offer : published) {
-
 
214
                this.sendNotification(offer);
-
 
215
            }
-
 
216
        }
-
 
217
        return responseSender.ok(published.size() + " offers published");
-
 
218
    }
-
 
219
 
-
 
220
    @RequestMapping(value = "/offer/delete/{offerId}", method = RequestMethod.DELETE)
-
 
221
    public ResponseEntity<?> deleteOffer(@PathVariable int offerId) throws ProfitMandiBusinessException {
-
 
222
        offerService.deleteOffer(offerId);
-
 
223
        return responseSender.ok(true);
-
 
224
    }
-
 
225
 
198
    @RequestMapping(value = "/offer/testimage/{offerId}", method = RequestMethod.GET)
226
    @RequestMapping(value = "/offer/testimage/{offerId}", method = RequestMethod.GET)
199
    public String testOffer(HttpServletRequest request, @PathVariable int offerId, Model model,
227
    public String testOffer(HttpServletRequest request, @PathVariable int offerId, Model model,
200
                            @RequestParam(defaultValue = "true") boolean active) throws ProfitMandiBusinessException, Exception {
228
                            @RequestParam(defaultValue = "true") boolean active) throws ProfitMandiBusinessException, Exception {
201
        Offer offer = offerRepository.selectById(offerId);
229
        Offer offer = offerRepository.selectById(offerId);
202
        // model.addAttribute("response1", mvcResponseSender.createResponseString(true));
230
        // model.addAttribute("response1", mvcResponseSender.createResponseString(true));