use of com.bc.pmpheep.back.vo.CmsAdvertisementOrImageVO in project pmph by BCSquad.
the class MigrationPlus method initCmsAdvertisementData.
// 初始化广告数据
@SuppressWarnings("unchecked")
public void initCmsAdvertisementData() {
// 初始化的数据
String dataJson = "[" + "{adname:'首页轮播', type:1,autoPlay:true, animationInterval:3000, image:[{image:'/img/banner4.png'},{image:'/img/banner3.png'},{image:'/img/banner2.png'}]} ," + "{adname:'首页中部1', type:0,autoPlay:false,animationInterval:0, image:[{image:'/upload/site/2670f031-35da-4dd6-b079-8f295c51a339.png'}]} ," + "{adname:'首页中部2', type:0,autoPlay:false,animationInterval:0, image:[{image:'/upload/site/af598f9e-ae9e-48a0-a3e4-17acc363051a.png'}]} ," + "{adname:'首页中部3', type:0,autoPlay:false,animationInterval:0, image:[{image:'/upload/site/a4160c1e-8beb-4530-9f2b-df022a6f751d.png'}]} ," + "{adname:'首页中部4', type:0,autoPlay:false,animationInterval:0, image:[{image:'/upload/site/a69b782d-f1ad-42e6-a91a-08432963b54a.png'}]} ," + "{adname:'信息快报和遴选公告列表', type:0,autoPlay:false,animationInterval:0, image:[{image:'/img/caode.png'}]} ," + "{adname:'首页原重点推荐1', type:0,autoPlay:false,animationInterval:0, image:[{image:'/upload/site/a2067cf8-d076-4ba5-90b8-f63dd4d3a172.png'}]} ," + "{adname:'首页原重点推荐2', type:0,autoPlay:false,animationInterval:0, image:[{image:'/upload/site/aafeba35-79e8-49f6-931c-45678ef58d86.png'}]} ," + "{adname:'读书首页轮播 ', type:1,autoPlay:true ,animationInterval:3000,image:[{image:'/img/bannerd.png'},{image:'/img/banner2d.png'}]} " + "]";
Gson gson = new Gson();
List<CmsAdvertisementOrImageVO> lst = gson.fromJson(dataJson, new TypeToken<ArrayList<CmsAdvertisementOrImageVO>>() {
}.getType());
for (CmsAdvertisementOrImageVO cmsAdvertisementAndImages : lst) {
CmsAdvertisement cmsAdvertisement = new CmsAdvertisement();
// 广告名称
cmsAdvertisement.setAdname(cmsAdvertisementAndImages.getAdname());
// 是否自动播放
cmsAdvertisement.setAutoPlay(cmsAdvertisementAndImages.getAutoPlay());
// 循环间隔时间
cmsAdvertisement.setAnimationInterval(cmsAdvertisementAndImages.getAnimationInterval());
// 类型 0 普通 1 轮播 2两张
cmsAdvertisement.setType(cmsAdvertisementAndImages.getType());
// 保存广告
cmsAdvertisementDao.addCmsAdvertisement(cmsAdvertisement);
List<CmsAdvertisementImage> images = (List<CmsAdvertisementImage>) (cmsAdvertisementAndImages.getImage());
for (CmsAdvertisementImage image : images) {
String filePath = image.getImage();
image.setAdvertId(cmsAdvertisement.getId());
image.setImage("----");
// 保存图片文件
cmsAdvertisementImageDao.addCmsAdvertisementImage(image);
String mongoId = null;
try {
// 保存图片至mongo
mongoId = fileService.migrateFile(filePath, FileType.CMS_ADVERTISEMENT, image.getId());
} catch (Exception ex) {
logger.warn("文件上传失败 :{}", ex.getMessage());
// 文件保存失败删除这条记录
cmsAdvertisementImageDao.deleteCmsAdvertisementByImages(image.getId());
continue;
}
image.setImage(mongoId);
// 修改图片文件地址
cmsAdvertisementImageDao.updateCmsAdvertisementImage(image);
}
}
}
use of com.bc.pmpheep.back.vo.CmsAdvertisementOrImageVO in project pmph by BCSquad.
the class CmsAdvertisementServiceImpl method getAdvertisementList.
@Override
public List<CmsAdvertisementOrImageVO> getAdvertisementList(String sessionId) throws CheckedServiceException {
// 获取当前登陆用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser) || ObjectUtil.isNull(pmphUser.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
List<CmsAdvertisementOrImageVO> cmsAdvertisementOrImageVOs = cmsAdvertisementDao.getAdvertisementList();
if (pmphUser.getIsAdmin()) {
for (CmsAdvertisementOrImageVO cmsAdvertisementOrImageVO : cmsAdvertisementOrImageVOs) {
cmsAdvertisementOrImageVO.setIsPlay(true);
}
}
return cmsAdvertisementOrImageVOs;
}
Aggregations