| | |
| | | import java.io.InputStream;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SwiperPictureMapper;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | |
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private AdActivityVersionControlService adActivityVersionControlService;
|
| | |
|
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Override
|
| | | public int insertSelective(SwiperPicture record) {
|
| | |
| | | return swiperPictureMapper.countQueryByBannerID(bannerId);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void saveObject(MultipartFile file, SwiperPicture record, String jumpType) throws SwiperPictureException, Exception{
|
| | | public void saveObject(MultipartFile file, SwiperPicture record, String jumpType)
|
| | | throws SwiperPictureException, Exception {
|
| | |
|
| | | if (record == null) {
|
| | | throw new SwiperPictureException(1, "参数不能为空");
|
| | |
| | | if (remark != null && (remark.trim().length() == 0 || remark.equalsIgnoreCase("null"))) {
|
| | | record.setRemark(null);
|
| | | }
|
| | | |
| | |
|
| | | String picture = null;
|
| | | if (file != null) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 上传图片
|
| | | * |
| | | * @param file
|
| | | * @return
|
| | | * @throws Exception
|
| | |
| | | return fileLink;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 删除图片-不更新数据库
|
| | | * |
| | | * @param record
|
| | | * @throws Exception
|
| | | */
|
| | |
| | | return swiperPictureMapper.queryByListBannerID(list);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<SwiperPicture> getOrderByBannerID(Long bannerId, Integer type, Integer order) {
|
| | | return swiperPictureMapper.getOrderByBannerID(bannerId, type, order);
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 专题版本过滤
|
| | | * |
| | | * @param list
|
| | | * @param platform
|
| | | * @param versionCode
|
| | | */
|
| | | private void filterSwipePicture(List<SwiperPicture> list, String platform, int versionCode) {
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
|
| | | if (app == null) {
|
| | | list.clear();
|
| | | return;
|
| | | }
|
| | | List<Long> versionIdList = new ArrayList<>();
|
| | | versionIdList.add(app.getId());
|
| | | List<Long> sourceIdList = new ArrayList<>();
|
| | | for (SwiperPicture picture : list) {
|
| | | sourceIdList.add(picture.getId());
|
| | | }
|
| | |
|
| | | Set<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
|
| | | AdActivityType.banner, versionIdList);
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (!sourceIds.contains(list.get(i).getId())) {
|
| | | list.remove(i--);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerCardAndVersion-'+#card+'-'+#platform+'-'+#version")
|
| | | @Override
|
| | | public List<SwiperPicture> getByBannerCardAndVersion(String card, String platform, int version) {
|
| | | List<SwiperPicture> list = swiperPictureMapper.getByBannerCard(card);
|
| | | filterSwipePicture(list, platform, version);
|
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerId-'+#bannerId")
|
| | |
| | | return swiperPictureMapper.getByBannerId(bannerId);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerId-'+#bannerId+'-'+#platform+'-'+#version")
|
| | | @Override
|
| | | public List<SwiperPicture> getByBannerId(Long bannerId, String platform, int version)
|
| | | throws SwiperPictureException {
|
| | | List<SwiperPicture> pictureList = swiperPictureMapper.getByBannerId(bannerId);
|
| | | filterSwipePicture(pictureList, platform, version);
|
| | | return pictureList;
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void setVersions(Long id, List<Long> versions) throws SwiperPictureException {
|
| | | SwiperPicture swiperPicture = selectByPrimaryKey(id);
|
| | | if (swiperPicture == null) {
|
| | | throw new SwiperPictureException(1, "Banner不存在");
|
| | | }
|
| | |
|
| | | Set<Long> oldSet = new HashSet<>();
|
| | |
|
| | | List<AdActivityVersionControl> versionList = adActivityVersionControlService
|
| | | .listByTypeAndSourceId(AdActivityType.banner, swiperPicture.getId());
|
| | | if (versionList != null) {
|
| | | for (AdActivityVersionControl control : versionList)
|
| | | oldSet.add(control.getVersion().getId());
|
| | | }
|
| | |
|
| | | Set<Long> newSet = new HashSet<>();
|
| | |
|
| | | for (Long version : versions) {
|
| | | newSet.add(version);
|
| | | }
|
| | |
|
| | | Set<Long> delSet = new HashSet<>();
|
| | | delSet.addAll(oldSet);
|
| | | delSet.removeAll(newSet);
|
| | | for (Long versionId : delSet) {
|
| | | // 根据
|
| | | adActivityVersionControlService.deleteBySourceAndVersion(id, AdActivityType.banner, versionId);
|
| | | }
|
| | |
|
| | | Set<Long> addSet = new HashSet<>();
|
| | | addSet.addAll(newSet);
|
| | | addSet.removeAll(oldSet);
|
| | |
|
| | | // 添加映射
|
| | | for (Long versionId : addSet) {
|
| | | AdActivityVersionControl control = new AdActivityVersionControl();
|
| | | control.setCreateTime(new Date());
|
| | | control.setSourceId(swiperPicture.getId());
|
| | | control.setType(AdActivityType.banner);
|
| | | control.setVersion(new AppVersionInfo(versionId));
|
| | | try {
|
| | | adActivityVersionControlService.addVersionControl(control);
|
| | | } catch (Exception e) {
|
| | | throw new SwiperPictureException(2, e.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|