From 51a4ff5d777028d52a19c314a99f796334cb7b51 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 23 十一月 2019 18:30:01 +0800 Subject: [PATCH] 配置文件修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java | 152 +++++++++++++++++++++++++++++++++----------------- 1 files changed, 101 insertions(+), 51 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java index 8a15324..66b56ac 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/FloatADServiceImpl.java @@ -8,16 +8,17 @@ import java.util.UUID; import javax.annotation.Resource; -import javax.transaction.Transactional; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import org.yeshi.utils.tencentcloud.COSManager; import com.yeshi.fanli.dao.mybatis.homemodule.FloatADMapper; import com.yeshi.fanli.entity.bus.homemodule.FloatAD; +import com.yeshi.fanli.entity.bus.homemodule.FloatAD.FloatADTypeEnum; import com.yeshi.fanli.entity.common.JumpDetailV2; -import com.yeshi.fanli.exception.FloatADException; +import com.yeshi.fanli.exception.homemodule.FloatADException; import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; import com.yeshi.fanli.service.inter.homemodule.FloatADService; import com.yeshi.fanli.util.StringUtil; @@ -46,10 +47,16 @@ } String params = record.getParams(); - if ((params != null && params.trim().length() == 0) || "null".equalsIgnoreCase(params) ) { + if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params) ) { record.setParams(null); + } else if (!StringUtil.isJson(params)) { + throw new FloatADException(1, "璺宠浆鍙傛暟闈濲SON鏍煎紡"); } + FloatADTypeEnum typeEnum = record.getTypeEnum(); + if (typeEnum == null) + throw new FloatADException(1, "绫诲瀷涓嶈兘涓虹┖"); + if (!StringUtil.isNullOrEmpty(jumpType)) { List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType); if (listByType !=null && listByType.size() > 0) { @@ -58,33 +65,46 @@ } try { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date startTime = record.getStartTime(); - if (startTime != null) { - record.setStartTime(format.parse(format.format(startTime))); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + + String startTime_str = record.getStartTime_str(); + if (startTime_str != null && startTime_str.trim().length() > 0) { + startTime_str = startTime_str.replaceAll("T", " "); + record.setStartTime(format.parse(startTime_str)); } - Date endTime = record.getEndTime(); - if (endTime != null) { - record.setEndTime(format.parse(format.format(endTime))); + String endTime_str = record.getEndTime_str(); + if (endTime_str != null && endTime_str.trim().length() > 0) { + endTime_str = endTime_str.replaceAll("T", " "); + record.setEndTime(format.parse(endTime_str)); } } catch (ParseException e) { e.printStackTrace(); } + // 鍥剧墖涓婁紶 String picture = null; if (file != null) { picture = uploadPicture(file); } + // 閫傜敤绫诲瀷 锛� 0閫氱敤 1鏂颁汉 + Integer type = record.getType(); + if (type == null) { + record.setType(0); + } + Long id = record.getId(); if (id == null) { - int maxOrder = floatADMapper.countByPosition(position); + int maxOrder = floatADMapper.getMaxOrderByPosition(position); record.setPicture(picture); - record.setState(0); + Integer state = record.getState(); + if (state == null) { + record.setState(0); + } + record.setOrder(maxOrder + 1); - record.setJumpNeedLogin(false); record.setCreateTime(new Date()); record.setUpdateTime(new Date()); floatADMapper.insert(record); @@ -96,9 +116,10 @@ } if (picture != null && picture.trim().length() > 0) { + // 鍒犻櫎鑰佸浘 + removePicture(resultObj.getPicture()); + // 瀛樺偍鏂板浘 record.setPicture(picture); - // 鍒犻櫎宸插瓨鍦ㄥ浘鐗� - removePicture(resultObj); } else { record.setPicture(resultObj.getPicture()); } @@ -110,6 +131,38 @@ } } + + /** + * 涓婁紶鍥剧墖 + * @param file + * @return + * @throws Exception + */ + public String uploadPicture(MultipartFile file) throws Exception { + + // 鏂囦欢瑙f瀽 + InputStream inputStream = file.getInputStream(); + String contentType = file.getContentType(); + String type = contentType.substring(contentType.indexOf("/") + 1); + + // 鏂囦欢璺緞 + String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type; + // 鎵ц涓婁紶 + String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); + + return fileLink; + } + + /** + * 鍒犻櫎鍥剧墖-涓嶆洿鏂版暟鎹簱 + * @param record + * @throws Exception + */ + public void removePicture(String picture) throws Exception { + if (picture != null && picture.trim().length() > 0) { + COSManager.getInstance().deleteFile(picture); + } + } @Override @Transactional @@ -155,45 +208,12 @@ // 鍒犻櫎宸插瓨鍦ㄥ浘鐗� for (FloatAD floatAD: listSwiper) { - removePicture(floatAD); + removePicture(floatAD.getPicture()); } return floatADMapper.deleteByPrimaryKeyList(list); } - - /** - * 涓婁紶鍥剧墖 - * @param file - * @return - * @throws Exception - */ - public String uploadPicture(MultipartFile file) throws Exception { - - // 鏂囦欢瑙f瀽 - InputStream inputStream = file.getInputStream(); - String contentType = file.getContentType(); - String type = contentType.substring(contentType.indexOf("/") + 1); - - // 鏂囦欢璺緞 - String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type; - // 鎵ц涓婁紶 - String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); - - return fileLink; - } - - /** - * 鍒犻櫎鍥剧墖-涓嶆洿鏂版暟鎹簱 - * @param record - * @throws Exception - */ - public void removePicture(FloatAD record) throws Exception { - String picture = record.getPicture(); - if (picture != null && picture.trim().length() > 0) { - COSManager.getInstance().deleteFile(picture); - } - } @Override @@ -205,6 +225,26 @@ } for (FloatAD floatAD : listQuery) { + + FloatADTypeEnum typeEnum = floatAD.getTypeEnum(); + if (typeEnum != null) { + floatAD.setTypeName(typeEnum.getDesc()); + } + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); + Date startTime = floatAD.getStartTime(); + if (startTime == null) { + floatAD.setStartTime_str(""); + } else { + floatAD.setStartTime_str(sdf.format(startTime)); + } + + Date endTime = floatAD.getEndTime(); + if (endTime == null) { + floatAD.setEndTime_str(""); + } else { + floatAD.setEndTime_str(sdf.format(endTime)); + } String params = floatAD.getParams(); if (params == null) { @@ -234,8 +274,8 @@ } @Override - public FloatAD getEffectiveFloatAD(String position) { - FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position); + public FloatAD getEffectiveFloatAD(String position, Integer type) { + FloatAD floatAD = floatADMapper.getEffectiveFloatAD(position, type); if (floatAD != null) { JumpDetailV2 jumpDetail = floatAD.getJumpDetail(); @@ -253,5 +293,15 @@ return floatAD; } + + @Override + public List<FloatAD> getValidCommonByPosition(String position) { + return floatADMapper.getValidFloatAD(position, 1); + } + + @Override + public List<FloatAD> getValidByPosition(String position) { + return floatADMapper.getValidFloatAD(position, null); + } } -- Gitblit v1.8.0