Package com.lgx8.gateway.service.impl

Source Code of com.lgx8.gateway.service.impl.GatewayService

package com.lgx8.gateway.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.lgx8.common.PageList;
import com.lgx8.common.dao.IIPObjectDao;
import com.lgx8.common.entities.IPObject;
import com.lgx8.common.entities.ProductImage;
import com.lgx8.gateway.dao.ICategoryDao;
import com.lgx8.gateway.dao.IGatewayCategoryDao;
import com.lgx8.gateway.dao.IGatewayCategoryDetailDao;
import com.lgx8.gateway.dao.IProductDao;
import com.lgx8.gateway.dao.IProductPropertyCategoryDao;
import com.lgx8.gateway.dao.IProductPropertyDao;
import com.lgx8.gateway.dao.ISinglePageDao;
import com.lgx8.gateway.entities.AreaCategory;
import com.lgx8.gateway.entities.Brand;
import com.lgx8.gateway.entities.Category;
import com.lgx8.gateway.entities.FareWay;
import com.lgx8.gateway.entities.GatewayCategory;
import com.lgx8.gateway.entities.GatewayCategoryDetail;
import com.lgx8.gateway.entities.Product;
import com.lgx8.gateway.entities.ProductProperty;
import com.lgx8.gateway.entities.ProductPropertyCategory;
import com.lgx8.gateway.entities.SinglePage;
import com.lgx8.gateway.entities.Supplier;
import com.lgx8.gateway.service.IGatewayService;
import com.lgx8.gateway.vo.ProductVO;
import com.lgx8.management.dao.IAdvertisementDao;
import com.lgx8.management.dao.IMerchantDao;
import com.lgx8.management.dao.INewsDao;
import com.lgx8.management.entities.Advertisement;
import com.lgx8.management.entities.Merchant;
import com.lgx8.management.entities.News;

/**
*
* @author lihui
*
*/
public class GatewayService implements IGatewayService {

  private static final AreaCategory detail = null;

  private ICategoryDao categoryDao;
 
  private IProductDao productDao;
 
  private IAdvertisementDao advertisementDao;
 
  private IProductPropertyCategoryDao productPropertyCategoryDao;
 
  private IProductPropertyDao productPropertyDao;
 
  private IGatewayCategoryDetailDao gatewayCategoryDetailDao;
 
  private IGatewayCategoryDao gatewayCategoryDao;
 
  private ISinglePageDao singlePageDao;
 
  private IMerchantDao merchantDao;
 
  private IIPObjectDao iPObjectDao;
 
  private INewsDao newsDao;

  public INewsDao getNewsDao() {
    return newsDao;
  }

  public void setNewsDao(INewsDao newsDao) {
    this.newsDao = newsDao;
  }

  public IIPObjectDao getiPObjectDao() {
    return iPObjectDao;
  }

  public void setiPObjectDao(IIPObjectDao iPObjectDao) {
    this.iPObjectDao = iPObjectDao;
  }

  public IMerchantDao getMerchantDao() {
    return merchantDao;
  }

  public void setMerchantDao(IMerchantDao merchantDao) {
    this.merchantDao = merchantDao;
  }

  public IGatewayCategoryDao getGatewayCategoryDao() {
    return gatewayCategoryDao;
  }

  public void setGatewayCategoryDao(IGatewayCategoryDao gatewayCategoryDao) {
    this.gatewayCategoryDao = gatewayCategoryDao;
  }

  public IGatewayCategoryDetailDao getGatewayCategoryDetailDao() {
    return gatewayCategoryDetailDao;
  }

  public void setGatewayCategoryDetailDao(
      IGatewayCategoryDetailDao gatewayCategoryDetailDao) {
    this.gatewayCategoryDetailDao = gatewayCategoryDetailDao;
  }

  public IProductPropertyCategoryDao getProductPropertyCategoryDao() {
    return productPropertyCategoryDao;
  }

  public void setProductPropertyCategoryDao(
      IProductPropertyCategoryDao productPropertyCategoryDao) {
    this.productPropertyCategoryDao = productPropertyCategoryDao;
  }

  public IProductPropertyDao getProductPropertyDao() {
    return productPropertyDao;
  }

  public void setProductPropertyDao(IProductPropertyDao productPropertyDao) {
    this.productPropertyDao = productPropertyDao;
  }

  public IAdvertisementDao getAdvertisementDao() {
    return advertisementDao;
  }

  public void setAdvertisementDao(IAdvertisementDao advertisementDao) {
    this.advertisementDao = advertisementDao;
  }

  public IProductDao getProductDao() {
    return productDao;
  }

  public void setProductDao(IProductDao productDao) {
    this.productDao = productDao;
  }

  public List<Category> findAllCategory() {
    return categoryDao.findAllCategory();
  }

  public ICategoryDao getCategoryDao() {
    return categoryDao;
  }

  public void setCategoryDao(ICategoryDao categoryDao) {
    this.categoryDao = categoryDao;
  }

  public void createAreaCategory(AreaCategory areaCategory) {
    categoryDao.createAreaCategory(areaCategory);
  }

  public void createCategory(Category category) {
    categoryDao.createCategory(category);
  }

  public List<AreaCategory> findAllAreaCategory() {
    return categoryDao.findAllAreaCategory();
  }

  public List<ProductVO> initGatewayInfo(Integer categoryId)
  {
    List<ProductVO> list = new ArrayList<ProductVO>();
   
    //获取模块分类信息
    List<GatewayCategoryDetail> details = this.categoryDao.findGatewayCategoryDetailByCategoryId(categoryId,null);
   
    for(GatewayCategoryDetail detail : details)
    {
      ProductVO vo = new ProductVO();
      vo.setEntityId(detail.getEntityId());
      vo.setImageurl(detail.getEntityUrl());
      vo.setType(detail.getType());
      vo.setName(detail.getEntityName());
      vo.setFlag(0);
      vo.setImageurl2(detail.getOtherUrl());
      if(detail.getType() == 0)
      {
        //商品
        Product product = detail.getEntityId()==null?null:this.productDao.getProductById(Long.parseLong(detail.getEntityId()));
       
        if(product != null)
        {
//          vo.setName(product.getName());
          vo.setDescription(product.getDescription());
          vo.setPrice(product.getPrice());
          vo.setUrl(product.getUrl());
          vo.setProductImage(product.getImage());
        }
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
       
      }else if(detail.getType() == 1)
      {
        //品牌
        Brand brand = detail.getEntityId() == null? null:this.productDao.getBrandById(Long.parseLong(detail.getEntityId()));
        if(brand != null)
        {
//          vo.setName(brand.getName());
          vo.setDescription(brand.getDescription());
          vo.setUrl(brand.getUrl());
        }
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }else if(detail.getType() == 2)
      {
        //广告
        Advertisement ad = detail.getEntityId() == null ? null: this.advertisementDao.findAdvertisementById(Integer.parseInt(detail.getEntityId()));
        if(ad != null)
        vo.setUrl(ad.getUrl());
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }else if(detail.getType() == 3)
      {
       
      }else if(detail.getType() == 4)
      {
       
      }else if(detail.getType() == 5)
      {
       
      }else if(detail.getType() == 6)
      {
        //商家
        Merchant mc =  detail.getEntityId() == null ? null : merchantDao.getMerchantById(Long.parseLong(detail.getEntityId()));
        if(mc != null)
        {
          vo.setUrl("merchant/"+mc.getID()+".html");
        }
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }else if(detail.getType() == 7)
      {
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }else if(detail.getType() == 8)
      {
        //商品类型
        vo.setUrl("");
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }
     
      if("null".equals(detail.getOtherUrl()) || "".equals(detail.getOtherUrl()) || detail.getOtherUrl() == null)
        vo.setImageurl2(vo.getImageurl());
       
      list.add(vo);
    }
   
    return list;
  }

  public GatewayCategory findGatewayCategoryById(Integer categoryId) {
    return this.gatewayCategoryDao.findGatewayCategoryById(categoryId);
  }

  public Category findCategory(long id) {
    return categoryDao.findCategory(id);
  }

  @Transactional
  public void createProductImage(ProductImage image) {
    productDao.createProductImage(image);
  }

  public List<ProductImage> findProductImageListOrderByTime(String desc) {
    return productDao.findProductImageListOrderByTime(desc);
  }

  @Transactional
  public ProductPropertyCategory createProductPropertyCategory(String name) {
    return this.productPropertyCategoryDao.createProductPropertyCategory(name);
  }

  @Transactional
  public ProductPropertyCategory updateProductPropertyCategory(
      ProductPropertyCategory category) {
    return this.productPropertyCategoryDao.updateProductPropertyCategory(category);
  }

  @Transactional
  public void deleteProductPropertyCategory(Long id) {
    this.productPropertyCategoryDao.deleteProductPropertyCategory(id);
  }

  @Transactional
  public void deleteProductPropertyCategorys(List<Long> ids) {
    this.productPropertyCategoryDao.deleteProductPropertyCategorys(ids);
  }

  public List<ProductPropertyCategory> findAllProductPropertyCategorys() {
    return this.productPropertyCategoryDao.findAllProductPropertyCategorys();
  }

  @Transactional
  public ProductPropertyCategory findProductPropertyCategoryById(Long id) {
    return this.productPropertyCategoryDao.findProductPropertyCategoryById(id);
  }

  @Transactional
  public ProductProperty createProductProperty(Long categoryId, String value) {
    return this.productPropertyDao.createProductProperty(categoryId, value);
  }

  @Transactional
  public ProductProperty updateProductProperty(ProductProperty property) {
    return this.productPropertyDao.updateProductProperty(property);
  }

  public ProductProperty findProductPropertyById(Long id) {
    return this.productPropertyDao.findProductPropertyById(id);
  }

  @Transactional
  public void deleteProductProperty(Long id) {
    this.productPropertyDao.deleteProductProperty(id);
  }

  @Transactional
  public void deleteProductPropertys(List<Long> ids) {
    this.productPropertyDao.deleteProductPropertys(ids);
  }

  public List<ProductProperty> findProductPropertyByCategoryId(Long categoryId) {
    return this.productPropertyDao.findProductPropertyByCategoryId(categoryId);
  }

  public ProductImage findProductImage(long id) {
    return productDao.findProductImage(id);
  }

  public AreaCategory findAreaCategory(long id) {
    return categoryDao.findAreaCategory(id);
  }

  @Transactional
  public void createProduct(Product product) {
    productDao.createProduct(product);
  }

  public List<Product> findAllProduct() {
    return productDao.findAllProduct();
  }

  public List<GatewayCategoryDetail> findGatewayCategoryDetailByCategoryId(
      Integer categoryId) {
    return this.gatewayCategoryDetailDao.findGatewayCategoryDetailByCategoryId(categoryId);
  }

  @Transactional
  public GatewayCategoryDetail saveGatewayCategoryDetail(
      GatewayCategory category, String entityId, String entityUrl,String entityName,
      String layerOrder, Integer type,String areaNode,String url,String otherUrl) {
    return this.gatewayCategoryDetailDao.saveGatewayCategoryDetail(category, entityId, entityUrl,entityName, layerOrder, type,areaNode,url,otherUrl);
  }

  @Transactional
  public GatewayCategoryDetail updateGatewayCategoryDetail(
      Integer categoryId, Integer id, String layerOrder) {
    return this.gatewayCategoryDetailDao.updateGatewayCategoryDetail(categoryId, id, layerOrder);
  }

  @Transactional
  public void updateGatewayCategoryDetails(Integer categoryId, String params) {
    this.gatewayCategoryDetailDao.updateGatewayCategoryDetails(categoryId, params);
  }

  @Transactional
  public void deleteGatewayCategoryDetail(Integer id) {
    this.gatewayCategoryDetailDao.deleteGatewayCategoryDetail(id);
  }

  public List<Advertisement> findAllAdvertisement() {
    return this.advertisementDao.findAllAdvertisement();
  }

  public Advertisement findAdvertisementById(Long id) {
    return advertisementDao.findAdvertisementById(id);
  }

  public Product findProductById(Long productId) {
    return productDao.getProductById(productId);
  }

  public Brand findBrandById(Long brandId) {
    return productDao.getBrandById(brandId);
  }

  public List<Product> findAllProductByAreaCategoryId(Long categoryId) {
    return this.productDao.findAllProductByAreaCategoryId(categoryId);
  }

  public List<Brand> findAllBrand() {
    return this.productDao.findAllBrand();
  }

  @Transactional
  public void createSinglePage(SinglePage singlePage) {
    singlePageDao.createSinglePage(singlePage);
  }

  public SinglePage findSinglePage(long id) {
    return singlePageDao.findSinglePage(id);
  }

  public ISinglePageDao getSinglePageDao() {
    return singlePageDao;
  }

  public void setSinglePageDao(ISinglePageDao singlePageDao) {
    this.singlePageDao = singlePageDao;
  }

  public PageList findProduct(long categoryid, String[] keys, int pageno,
      int pagesize,String orderStr) {
    return productDao.findProduct(categoryid, keys, pageno, pagesize, orderStr);
  }

  public PageList findProduct(String[] keys, int pageno, int pagesize,String orderStr) {
    return productDao.findProduct(keys, pageno, pagesize, orderStr);
  }

  public PageList findProduct(long areacategoryid, long categoryid, String[] keys, int pageno, int pagesize,String orderStr) {
    return productDao.findProduct(areacategoryid, categoryid, keys, pageno, pagesize, orderStr);
  }
 
  public PageList findProductAllCategory(long areacategoryid, String[] keys, int pageno, int pagesize,String orderStr) {
    return productDao.findProductAllCategory(areacategoryid, keys, pageno, pagesize, orderStr);
  }

  public List<Product> findLastWeekHotProduct(int size) {
    return productDao.findLastWeekHotProduct(size);
  }

  public List<Product> findProductByConditions(long areacategoryid,
      long categoryid, String[] keys, int pageno, int pagesize,
      String orderStr) {
    return this.productDao.findProductByConditions(areacategoryid, categoryid, keys, pageno, pagesize, orderStr);
  }

  public String getGatewayCategoryFullName(Integer id) {
    return this.gatewayCategoryDao.getGatewayCategoryFullName(id);
  }

  public PageList findProductByConditions(long areacategoryid,
      long categoryid, String bprice, String eprice, String areaNode,String page,String orderStr) {
    return productDao.findProductByConditions(areacategoryid, categoryid, bprice, eprice,areaNode,page,orderStr);
  }

  public PageList findProductByBrandConditions(long areacategoryid,
      long brandid, String bprice, String eprice, String areaNode,String page,String orderStr) {
    return productDao.findProductByBrandConditions(areacategoryid, brandid, bprice, eprice,areaNode,page,orderStr);
  }

  public List<Advertisement> findAllAdvertisement(String orgId) {
    return advertisementDao.findAllAdvertisement(orgId);
  }

  public void createSupplier(Supplier supplier) {
    productDao.createSupplier(supplier);
  }

  @Transactional
  public List<Supplier> findSupplier() {
    return productDao.findSupplier();
  }
 
  public Supplier findSupplier(long id) {
    return productDao.findSupplier(id);
  }

  @Transactional
  public void updateSupplier(Supplier supplier) {
    productDao.updateSupplier(supplier);
  }

  @Transactional
  public void createBrand(Brand brand) {
    productDao.createBrand(brand);
  }

  public List<Brand> findBrand() {
    return productDao.findAllBrand();
  }

  public Brand findBrandById(long id) {
    return productDao.findBrandById(id);
  }

  public List<Brand> findBrandBySupplier(long supplierid) {
    return productDao.findBrandBySupplier(supplierid);
  }

  @Transactional
  public void updateBrand(Brand brand) {
    productDao.updateBrand(brand);
  }

  public List<FareWay> findFare() {
    return productDao.findFare();
  }

  public List<ProductProperty> findProductPropertyByIds(String[] ids) {
    return productPropertyDao.findProductPropertyByIds(ids);
  }

  public IPObject findIPObjectByAreaName(String areaName) {
    return iPObjectDao.findIPObjectByAreaName(areaName);
  }

  public List<IPObject> findAllIPObject() {
    return iPObjectDao.findAllIPObject();
  }

  public PageList findProductByBrand(String[] keys, int pageno, int pagesize,
      String orderStr) {
    return productDao.findProductByBrand(keys, pageno, pagesize, orderStr);
  }

  public List<Product> findProductBySupplier(long supplierid, int onsal) {
    return productDao.findProductBySupplier(supplierid, onsal);
  }

  public PageList findProductByBrand(long brandid, int pageno, int pagesize,
      String orderStr) {
    return productDao.findProductByBrand(brandid, pageno, pagesize, orderStr);
  }

  @Transactional
  public void deleteSupplier(long supplierid) {
    productDao.deleteSupplier(supplierid);
  }

  public PageList findSupplierPage(int pageno, int pagesize) {
    return productDao.findSupplierPage(pageno, pagesize);
  }

  public PageList findBrandPage(int pageno, int pagesize) {
    return productDao.findBrandPage(pageno, pagesize);
  }
 
  public void deleteBrand(long brandid) {
    productDao.deleteBrand(brandid);
  }

  public PageList findProductPage(long areaCategoryId, long categoryId,
      String keytype, String[] keys, int pageno, int pagesize) {
    return productDao.findProductPage(areaCategoryId, categoryId, keytype, keys, pageno, pagesize);
  }

  @Transactional
  public void deleteProduct(long productid) {
    productDao.deleteProduct(productid);
  }

  @Transactional
  public void updateProduct(Product product) {
    productDao.updateProduct(product);
  }
 
  //根据供应商id,查找商品,按加入时间倒序
  public List<Product> findProductBySupplier(long supplierid,int onsal, int size) {
    return productDao.findProductBySupplier(supplierid, onsal, size);
  }

  public News findById(Integer id) {
    return this.newsDao.findById(id);
  }

  public List<News> findByType(Object type) {
    return this.newsDao.findByType(type);
  }

  public List<News> findByType2(Object type) {
    return this.newsDao.findByType2(type);
  }

  public PageList findSupplierPage(int pageno, int pagesize, String type,
      String[] keys) {
    return productDao.findSupplierPage(pageno, pagesize, type, keys);
  }

  public PageList findBrandPage(int pageno, int pagesize, String type,
      String[] keys) {
    return productDao.findBrandPage(pageno, pagesize, type, keys);
  }

  @Transactional
  public void deleteCategory(long id) {
    List<Category> categorys = findAllCategoryList(id);
    for(Category c:categorys) {
      productDao.deleteCategory(c.getId());
    }
  }
 
  /**
   * 根据id查找分类及子类
   * @param id
   * @return
   */
  public List<Category> findAllCategoryList(long id) {
    return categoryDao.findAllCategoryList(id);
  }

  public List<ProductVO> initGatewayInfo(Integer categoryId, String areaNode) {
   
    List<ProductVO> list = new ArrayList<ProductVO>();
   
    //获取模块分类信息
    List<GatewayCategoryDetail> details = this.categoryDao.findGatewayCategoryDetailByCategoryId(categoryId,areaNode);
   
    for(GatewayCategoryDetail detail : details)
    {
      ProductVO vo = new ProductVO();
      vo.setEntityId(detail.getEntityId());
      vo.setImageurl(detail.getEntityUrl());
      vo.setType(detail.getType());
      vo.setName(detail.getEntityName());
      vo.setFlag(0);
      vo.setImageurl2(detail.getOtherUrl());
      if(detail.getType() == 0)
      {
        //商品
        Product product = detail.getEntityId() == null? null:this.productDao.getProductById(Long.parseLong(detail.getEntityId()));
       
        if(product != null)
        {
//          vo.setName(product.getName());
          vo.setDescription(product.getDescription());
          vo.setPrice(product.getPrice());
          vo.setUrl(product.getUrl());
          vo.setProductImage(product.getImage());
        }
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
       
      }else if(detail.getType() == 1)
      {
        //品牌
        Brand brand = detail.getEntityId() == null? null:this.productDao.getBrandById(Long.parseLong(detail.getEntityId()));
        if(brand != null)
        {
//          vo.setName(brand.getName());
          vo.setDescription(brand.getDescription());
          vo.setUrl(brand.getUrl());
        }
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
       
      }else if(detail.getType() == 2)
      {
        //广告
        Advertisement ad = detail.getEntityId() == null? null:this.advertisementDao.findAdvertisementById(Integer.parseInt(detail.getEntityId()));
        if(ad != null)
        vo.setUrl(ad.getUrl());
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }else if(detail.getType() == 3)
      {
       
      }else if(detail.getType() == 4)
      {
       
      }else if(detail.getType() == 5)
      {
       
      }else if(detail.getType() == 6)
      {
        //商家
        Merchant mc = detail.getEntityId() == null? null:merchantDao.getMerchantById(Long.parseLong(detail.getEntityId()));
        if(mc != null)
        {
          vo.setUrl("");
        }
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }else if(detail.getType() == 7)
      {
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }else if(detail.getType() == 8)
      {
        //商品类型
        vo.setUrl("");
       
        if(!"".equals(detail.getUrl()) && !"null".equals(detail.getUrl()) && detail.getUrl() != null)
        {
          vo.setUrl(detail.getUrl());
          vo.setFlag(1);
        }
      }
     
      if("null".equals(detail.getOtherUrl()) || "".equals(detail.getOtherUrl()) || detail.getOtherUrl() == null)
        vo.setImageurl2(vo.getImageurl());
     
      list.add(vo);
    }
   
    return list;
  }

  public PageList findProductPageByCode(String code, int pagenum, int pagesize) {
    return productDao.findProductPageByCode(code,pagenum,pagesize);
  }

  public boolean checkSupplierNameExists(String name) {
    return productDao.checkSupplierNameExists(name);
  }

  public boolean chechBrandNameExsits(String name) {
    return productDao.chechBrandNameExsits(name);
  }

  public News findUpNewsByCurrId(String type, Integer id) {
    return this.newsDao.findUpNewsByCurrId(type, id);
  }

  public News findDownNewsByCurrId(String type, Integer id) {
    return this.newsDao.findDownNewsByCurrId(type, id);
  }

  public PageList findNewsByConditions(String type, String condition,
      int pageNum, int pageSize) {
    return newsDao.findNewsByConditions(type, condition, pageNum, pageSize);
  }

  public List<Product> yourLoveProducts() {
    return productDao.yourLoveProducts(4);
  }
}
TOP

Related Classes of com.lgx8.gateway.service.impl.GatewayService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.