Ejemplo n.º 1
0
 /** 随机得到一个广告 */
 @Override
 @Cacheable(value = "AdvertisementList")
 public List<Advertisement> getOneAdvertisement(String shopName, String type) {
   if (log.isDebugEnabled()) {
     log.debug("shopName = {},key = {}", shopName, type);
   }
   List<Advertisement> resunt = null;
   List<Advertisement> list =
       findByHQL(ConfigCode.getInstance().getCode("ad.getAdvertisementByType"), shopName, type);
   if (AppUtils.isNotBlank(list)) {
     resunt = new ArrayList<Advertisement>(1);
     resunt.add(list.get(CommonServiceUtil.random(list.size())));
   }
   return resunt;
 }
Ejemplo n.º 2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * com.legendshop.business.dao.impl.AdvertisementDao#checkMaxNum(java.lang
  * .String, java.lang.String)
  */
 @Override
 public boolean isMaxNum(String userName, String type) {
   boolean result = false;
   Long num =
       findUniqueBy(
           ConfigCode.getInstance().getCode("ad.getAdvertisementCount"),
           Long.class,
           userName,
           type);
   if (num != null) {
     result = num <= maxNumPerType;
   }
   if (log.isDebugEnabled()) {
     log.debug("userName = {},type = {},result = {}", new Object[] {userName, type, result});
   }
   return result;
 }
Ejemplo n.º 3
0
 /** 得到某个页面的广告 */
 @Override
 @Cacheable(value = "Advertisement", key = "#shopName + #page")
 public Map<String, List<Advertisement>> getAdvertisement(
     final String shopName, final String page) {
   log.debug("getAdvertisement shopName = {}, page = {}", shopName, page);
   Map<String, List<Advertisement>> advertisementMap =
       new LinkedHashMap<String, List<Advertisement>>();
   List<Advertisement> list =
       findByHQL(ConfigCode.getInstance().getCode("ad.getAdvertisement"), shopName, page + "%");
   for (Advertisement advertisement : list) {
     List<Advertisement> ads = advertisementMap.get(advertisement.getType());
     if (ads == null) {
       ads = new ArrayList<Advertisement>();
     }
     ads.add(advertisement);
     advertisementMap.put(advertisement.getType(), ads);
   }
   return advertisementMap;
 }