From 916f8851ccddff8ff764d950667b5fa86f77d7b2 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期五, 24 四月 2020 18:16:50 +0800 Subject: [PATCH] 后台状态切换 --- fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java | 89 ++++++++++++++++++++++++++------------------ 1 files changed, 52 insertions(+), 37 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 b9f55d3..8db309c 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 @@ -29,7 +29,6 @@ import com.yeshi.fanli.entity.common.JumpDetailV2; import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.exception.banner.SwiperPictureException; -import com.yeshi.fanli.exception.homemodule.HomeNavbarException; import com.yeshi.fanli.exception.homemodule.SpecialException; import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; import com.yeshi.fanli.service.inter.config.AppVersionService; @@ -102,11 +101,6 @@ record.setParams(params.trim()); } - String startTime_str = record.getStartTime_str(); - if (record.isTimeTask() && (startTime_str == null || startTime_str.length() == 0)) { - throw new SpecialException(1, "鎺у埗鏃堕棿涓嶈兘涓虹┖"); - } - if (!StringUtil.isNullOrEmpty(jumpType)) { List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType); if (listByType != null && listByType.size() > 0) { @@ -115,7 +109,7 @@ } // 鏃堕棿杞崲 - conversionTime(record); + handleTime(record); Long state = record.getState(); if (state == null) { @@ -227,30 +221,24 @@ * * @param record */ - public void conversionTime(Special record) throws SpecialException, Exception { - // 鏄惁鏃堕棿鎺у埗 - 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) - && (endTime_str == null || endTime_str.trim().length() == 0)) { - throw new HomeNavbarException(1, "璇疯緭鍏ユ帶鍒舵椂闂�"); - } else { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - if (startTime_str != null && startTime_str.trim().length() > 0) { - 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)); - } - } + private void handleTime(Special record) throws SpecialException, Exception { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + + String startTime_str = record.getStartTime_str(); + if (!StringUtil.isNullOrEmpty(startTime_str)) { + startTime_str = startTime_str.replaceAll("T", " "); + record.setStartTime(format.parse(startTime_str)); + } + + String endTime_str = record.getEndTime_str(); + if (!StringUtil.isNullOrEmpty(endTime_str)) { + endTime_str = endTime_str.replaceAll("T", " "); + record.setEndTime(format.parse(endTime_str)); + } + + if (record.getEndTime() != null && record.getStartTime() != null + && record.getStartTime().getTime() > record.getEndTime().getTime()) { + throw new SpecialException(1, "璧峰鏃堕棿涓嶈兘灏忎簬缁撴潫鏃堕棿"); } } @@ -395,17 +383,18 @@ // 璺宠浆閾炬帴 for (Special special : list) { - + if (special.getState() != null && special.getState().longValue() == 0) { + special.setState(1L); + } else { + special.setState(0L); + } + 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(""); @@ -564,7 +553,7 @@ } // 鏁版嵁澶勭悊 - handlelist(listArc); +// handlelist(listArc); arcMap.put("list", JsonUtil.getApiCommonGson().toJson(listArc)); // 棣栭〉-娲诲姩鍖哄煙锛堝コ鐜嬭妭锛� @@ -722,4 +711,30 @@ } } } + + @Override + public void switchState(Long id) throws SpecialException { + if (id == null) { + throw new SpecialException(1, "璇蜂紶閫掓纭弬鏁�"); + } + + Special resultObj = specialMapper.selectByPrimaryKey(id); + if (resultObj == null) { + throw new SpecialException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�"); + } + + Long state = resultObj.getState(); + if (state == null || state == 0) { + state = 1L; + } else { + state = 0L; + } + + Special updateObj = new Special(); + updateObj.setId(id); + updateObj.setState(state); + updateObj.setJumpLogin(resultObj.isJumpLogin()); + specialMapper.updateByPrimaryKeySelective(updateObj); + } + } -- Gitblit v1.8.0