package com.yc.sdk.shopping.service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
import org.springframework.context.annotation.Scope;
|
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.stereotype.Service;
|
|
import com.yc.action.grid.GridUtils;
|
import com.yc.sdk.shopping.entity.BannerEntity;
|
import com.yc.service.BaseService;
|
|
@Service("BannerImpl")
|
@Scope("prototype")
|
public class BannerImpl extends BaseService implements BannerIfc {
|
|
@Override
|
public List<BannerEntity> getBanners(String shopCcCode,String authorizationAppid) {
|
String sql = " set nocount on ; \n"
|
+ " declare @ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(shopCcCode)+" ,@AuthorizationAppid varchar(50) = "+GridUtils.prossSqlParm(authorizationAppid)+" \n"
|
+ " select a.BannerId,a.Title,a.Link,a.Image,a.ImageUrl,a.PathCode,b.PathUrl, \n"
|
+ " case when exists(select 1 from t720123 y where a.pathcode = y.pathcode and y.AuthorizationAppid = @AuthorizationAppid) then 1 else 0 end as isTabBarButton , \n"
|
+ " a.CoverImg,a.CoverImgUrl,a.isVideoFile \n"
|
+ " from t710306 a left join t730117 b on a.PathCode = b.PathCode \n "
|
+ " where ISNULL(a.Status,0) = 1 \n "
|
+ " and (isnull(@ShopCcCode,'') = '' or a.ShopCcCode = @ShopCcCode ) \n"
|
+ " order by a.SortOrder asc,a.BannerId asc ;" ;
|
|
List<Map<String,Object>> list = null ;
|
try {
|
list = this.jdbcTemplate.queryForList(sql) ;
|
List<BannerEntity> bannerList = new ArrayList<BannerEntity>() ;
|
for (int i = 0 ; list != null && i < list.size();i++) {
|
Map<String,Object> map = list.get(i) ;
|
BannerEntity banner = new BannerEntity();
|
banner.setBannerId(map.get("BannerId") == null ? null: (Integer)map.get("BannerId"));
|
banner.setTitle(map.get("Title") == null ? "": (String)map.get("Title"));
|
banner.setLink(map.get("Link") == null ? "": (String)map.get("Link"));
|
banner.setImage(map.get("Image") == null ? "": (String)map.get("Image"));
|
banner.setImageUrl(map.get("ImageUrl") == null ? "": (String)map.get("ImageUrl"));
|
banner.setPathCode(map.get("PathCode") == null ? "": (String)map.get("PathCode"));
|
banner.setPathUrl(map.get("PathUrl") == null ? "": (String)map.get("PathUrl"));
|
banner.setTabBarButton(map.get("isTabBarButton")!=null&&map.get("isTabBarButton").equals(1)?true:false);
|
banner.setCoverImg(map.get("CoverImg") == null ? "": (String)map.get("CoverImg"));
|
banner.setCoverImgUrl(map.get("CoverImgUrl") == null ? "": (String)map.get("CoverImgUrl"));
|
banner.setVideoFile(map.get("isVideoFile")!=null&&map.get("isVideoFile").equals(1)?true:false);
|
bannerList.add(banner);
|
}
|
return bannerList;
|
}catch(DataAccessException e ) {
|
if (e instanceof EmptyResultDataAccessException){
|
return null ;
|
}else {
|
e.printStackTrace();
|
throw e;
|
}
|
}catch(Exception e){
|
e.printStackTrace();
|
throw e;
|
}
|
}
|
|
}
|