/*
  * (non-Javadoc)
  *
  * @see
  * com.legendshop.business.service.BrandService#save(com.legendshop.model
  * .entity.Brand)
  */
 @Override
 public Long save(Brand brand) {
   if (!AppUtils.isBlank(brand.getBrandId())) {
     update(brand);
     return brand.getBrandId();
   }
   return (Long) brandDao.save(brand);
 }
  @Override
  public List<Item> getUsableBrand(Long nsortId, String userName) {
    List<Item> list = new ArrayList<Item>();
    try {
      list = brandDao.getUsableBrand(nsortId, userName);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return list;
  }
 /*
  * (non-Javadoc)
  *
  * @see com.legendshop.business.service.BrandService#delete(java.lang.Long)
  */
 @Override
 @CacheEvict(value = "Brand", key = "#id")
 public void delete(Long id) {
   brandDao.exeByHQL("delete from NsortBrand where id.brandId = ?", id);
   brandDao.deleteBrandById(id);
 }
 /*
  * (non-Javadoc)
  *
  * @see com.legendshop.business.service.BrandService#load(java.lang.Long)
  */
 @Override
 public Brand getBrand(Long id) {
   return brandDao.get(Brand.class, id);
 }
 /*
  * (non-Javadoc)
  *
  * @see com.legendshop.business.service.BrandService#list(java.lang.String)
  */
 @Override
 public List<Brand> getBrand(String userName) {
   return brandDao.findByHQL("from Brand where userName = ?", new Object[] {userName});
 }
 @Override
 public boolean hasChildProduct(String userName, Long brandId) {
   return brandDao.hasChildProduct(userName, brandId);
 }
 @Override
 public List<Brand> loadBrandByName(Long subNsortId, String shopName, String brandName) {
   return brandDao.loadBrandByName(subNsortId, shopName, brandName);
 }
 @Override
 public List<Item> getUsedBrand(Long nsortId, String userName) {
   return brandDao.getUsedBrand(nsortId, userName);
 }
 @Override
 public String saveBrandItem(String idJson, String nameJson, Long nsortId, String userName) {
   List<String> idList = JSONUtil.getArray(idJson, String.class);
   return brandDao.saveBrandItem(idList, nsortId, userName);
 }
 @Override
 public List<Item> getUsableBrandByName(Long nsortId, String userName, String brandName) {
   return brandDao.getUsableBrandByName(nsortId, userName, brandName);
 }
  @Override
  public String saveBrandItem(List<String> idList, Long nsortId, String userName) {

    return brandDao.saveBrandItem(idList, nsortId, userName);
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * com.legendshop.business.service.BrandService#getDataByCriteriaQuery(com
  * .legendshop.core.dao.support.CriteriaQuery)
  */
 @Override
 public PageSupport getDataByCriteriaQuery(CriteriaQuery cq) {
   return brandDao.find(cq);
 }
 @Override
 public List<Brand> loadBrandBySubSortId(Long subNsortId, String userName) {
   return brandDao.loadBrandBySubSortId(subNsortId, userName);
 }
 @Override
 public List<KeyValueEntity> loadBrandEntityBySubSortId(Long subNsortId, String userName) {
   return convertToEntity(brandDao.loadBrandBySubSortId(subNsortId, userName));
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * com.legendshop.business.service.BrandService#update(com.legendshop.model
  * .entity.Brand)
  */
 @Override
 @CacheEvict(value = "Brand", key = "#brand.brandId")
 public void update(Brand brand) {
   brandDao.updateBrand(brand);
 }