From 0cbdd620aac13ac8b06599294183cf1246626f0e Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 16 十二月 2019 16:05:32 +0800 Subject: [PATCH] 专题版本控制 --- fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java | 75 ++++++++++++++++++++++++++----------- 1 files changed, 52 insertions(+), 23 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java index 5a7ce9c..6d7151c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java @@ -19,7 +19,10 @@ import com.yeshi.fanli.dao.mybatis.homemodule.SpecialMapper; import com.yeshi.fanli.dto.common.CommonContentTypeEnum; +import com.yeshi.fanli.entity.AppVersionInfo; import com.yeshi.fanli.entity.accept.AcceptData; +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.common.JumpDetailV2; import com.yeshi.fanli.exception.homemodule.HomeNavbarException; @@ -27,6 +30,7 @@ import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; import com.yeshi.fanli.service.inter.config.AppVersionService; import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService; import com.yeshi.fanli.service.inter.homemodule.SpecialCardService; import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService; import com.yeshi.fanli.service.inter.homemodule.SpecialService; @@ -56,6 +60,9 @@ @Resource private AppVersionService appVersionService; + + @Resource + private AdActivityVersionControlService adActivityVersionControlService; @Override public Special selectByPrimaryKey(Long id) { @@ -87,7 +94,7 @@ } else if (!StringUtil.isJson(params)) { throw new SpecialException(1, "璺宠浆鍙傛暟闈濲SON鏍煎紡"); } - + String startTime_str = record.getStartTime_str(); if (record.isTimeTask() && (startTime_str == null || startTime_str.length() == 0)) { throw new SpecialException(1, "鎺у埗鏃堕棿涓嶈兘涓虹┖"); @@ -99,7 +106,7 @@ record.setJumpDetail(listByType.get(0)); } } - + // 鏃堕棿杞崲 conversionTime(record); @@ -210,18 +217,19 @@ /** * web娈垫椂闂磋浆鎹� + * * @param record */ public void conversionTime(Special record) throws SpecialException, Exception { // 鏄惁鏃堕棿鎺у埗 - if(!record.isTimeTask()) { + if (!record.isTimeTask()) { record.setStartTime(null); record.setEndTime(null); } else { String startTime_str = record.getStartTime_str(); String endTime_str = record.getEndTime_str(); - - if ((startTime_str == null|| startTime_str.trim().length() == 0) + + if ((startTime_str == null || startTime_str.trim().length() == 0) && (endTime_str == null || endTime_str.trim().length() == 0)) { throw new HomeNavbarException(1, "璇疯緭鍏ユ帶鍒舵椂闂�"); } else { @@ -230,7 +238,7 @@ startTime_str = startTime_str.replaceAll("T", " "); record.setStartTime(format.parse(startTime_str)); } - + if (endTime_str != null && endTime_str.trim().length() > 0) { endTime_str = endTime_str.replaceAll("T", " "); record.setEndTime(format.parse(endTime_str)); @@ -238,7 +246,7 @@ } } } - + /** * 涓婁紶鍥剧墖 * @@ -371,32 +379,31 @@ // 璺宠浆閾炬帴 for (Special special : list) { - + Date startTime = special.getStartTime(); Date endTime = special.getEndTime(); - + if (startTime == null && endTime == null) { special.setTimeTask(false); special.setStartTime_str(""); special.setEndTime_str(""); } else { special.setTimeTask(true); - + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); if (startTime == null) { special.setStartTime_str(""); } else { special.setStartTime_str(sdf.format(startTime)); } - + if (endTime == null) { special.setEndTime_str(""); } else { special.setEndTime_str(sdf.format(endTime)); } } - - + String params = special.getParams(); if (StringUtil.isNullOrEmpty(params)) { special.setParams(""); @@ -461,7 +468,7 @@ int platformCode = Constant.getPlatformCode(acceptData.getPlatform()); int version = Integer.parseInt(acceptData.getVersion()); - + List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex, platformCode, version); if (listArc == null) { listArc = new ArrayList<Special>(); @@ -570,26 +577,24 @@ public List<Special> listByPlaceKey(String placeKey, Integer platform, Integer versionCode) { return specialMapper.listByPlaceKey(placeKey, null, platform, versionCode); } - - + @Override - public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, Integer versionCode) { + public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, + Integer versionCode) { return specialMapper.listByPlaceKeyList(start, count, list, null, platform, versionCode); } - - + @Override public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode) { return specialMapper.countByPlaceKeyList(list, null, platform, versionCode); } - - + @Override @Cacheable(value = "specialCache", key = "'listByPlaceKeyHasLabel'+#start+'-'+#platform+'-'+#versionCode+'-'+#list") - public List<Special> listByPlaceKeyHasLabel(long start, int count, List<String> list, Integer platform, Integer versionCode) { + public List<Special> listByPlaceKeyHasLabel(long start, int count, List<String> list, Integer platform, + Integer versionCode) { return specialMapper.listByPlaceKeyHasLabel(start, count, list, null, platform, versionCode); } - /** * 澶勭悊 鏁版嵁 @@ -608,4 +613,28 @@ } } } + + @Transactional(rollbackFor = Exception.class) + @Override + public void setVersions(Long specialId, List<Long> versions) throws Exception { + Special special = selectByPrimaryKey(specialId); + if (special == null) { + throw new Exception("涓撻涓嶅瓨鍦�"); + } + List<AdActivityVersionControl> versionList = adActivityVersionControlService + .listByTypeAndSourceId(AdActivityType.special, special.getId()); + if (versionList != null) { + for (AdActivityVersionControl control : versionList) + adActivityVersionControlService.deleteByPrimaryKey(control.getId()); + } + // 娣诲姞鏄犲皠 + for (Long versionId : versions) { + AdActivityVersionControl control = new AdActivityVersionControl(); + control.setCreateTime(new Date()); + control.setSourceId(special.getId()); + control.setType(AdActivityType.special); + control.setVersion(new AppVersionInfo(versionId)); + adActivityVersionControlService.addVersionControl(control); + } + } } -- Gitblit v1.8.0