From c338aa60df58bee9f4c25afedf94fe6930a119c1 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 29 七月 2020 19:01:56 +0800 Subject: [PATCH] SpringContext中的循环任务优化,添加业务监控 --- fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java | 58 +++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 41 insertions(+), 17 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java index df529b8..d32114c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java @@ -12,6 +12,7 @@ import javax.annotation.Resource; +import com.yeshi.fanli.entity.SystemEnum; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -21,14 +22,11 @@ import com.yeshi.fanli.entity.AppVersionInfo; import com.yeshi.fanli.entity.bus.help.HelpClass; import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl; -import com.yeshi.fanli.entity.bus.homemodule.FloatAD; -import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture; import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType; -import com.yeshi.fanli.exception.banner.SwiperPictureException; import com.yeshi.fanli.exception.config.HelpClassException; -import com.yeshi.fanli.exception.homemodule.FloatADException; import com.yeshi.fanli.service.inter.help.HelpClassService; import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService; +import com.yeshi.fanli.util.FilePathEnum; import com.yeshi.fanli.util.StringUtil; @Service @@ -82,7 +80,7 @@ InputStream inputStream = file.getInputStream(); String contentType = file.getContentType(); String type = contentType.substring(contentType.indexOf("/") + 1); - String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type; + String filePath =FilePathEnum.helpClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type; picture = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl(); } @@ -94,13 +92,14 @@ if (record.getId() == null) { int maxOrder = helpClassMapper.getMaxOrder(); record.setSort(maxOrder + 1); + record.setPicture(picture); record.setCreateTime(new Date()); helpClassMapper.insertSelective(record); } else { // 淇敼 HelpClass resultObj = helpClassMapper.selectByPrimaryKey(record.getId()); if (resultObj == null) - throw new FloatADException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); + throw new HelpClassException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); if (picture != null && picture.trim().length() > 0) { String pictureOld = resultObj.getPicture(); @@ -117,6 +116,31 @@ record.setCreateTime(resultObj.getCreateTime()); helpClassMapper.updateByPrimaryKey(record); } + } + + + @Override + public void switchState(Long id) throws HelpClassException { + if (id == null) { + throw new HelpClassException(1, "璇蜂紶閫掓纭弬鏁�"); + } + + HelpClass resultObj = helpClassMapper.selectByPrimaryKey(id); + if (resultObj == null) { + throw new HelpClassException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�"); + } + + Integer state = resultObj.getShowState(); + if (state == null || state == 0) { + state = 1; + } else { + state = 0; + } + + HelpClass updateObj = new HelpClass(); + updateObj.setId(id); + updateObj.setShowState(state); + helpClassMapper.updateByPrimaryKeySelective(updateObj); } @@ -151,7 +175,7 @@ @Override - public void updateSort(Integer moveType, Long id) throws HelpClassException { + public void updateSort(Integer moveType, Long id, SystemEnum system) throws HelpClassException { if (id == null || moveType == null) { throw new HelpClassException(1, "浼犻�掑弬鏁颁笉鑳戒负绌�"); @@ -162,7 +186,7 @@ throw new HelpClassException(1, "鏇存柊鏁版嵁宸蹭笉瀛樺湪"); } - HelpClass changeObjct = helpClassMapper.getChangeOrder(moveType, helpClass.getSort()); + HelpClass changeObjct = helpClassMapper.getChangeOrder(moveType, helpClass.getSort(),system); if (changeObjct == null) { throw new HelpClassException(1, "宸茬粡鏄渶杈圭紭浣嶇疆"); @@ -194,7 +218,7 @@ String contentType = file.getContentType(); String type = contentType.substring(contentType.indexOf("/") + 1); - String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type; + String filePath =FilePathEnum.helpClass.getPath()+ UUID.randomUUID().toString().replace("-", "") + "." + type; /* 淇敼鍥剧墖鏃讹紝鍏堝垹闄ゅ凡瀛樺湪鍥剧墖 */ String picture = helpClass.getPicture(); @@ -214,24 +238,24 @@ @Override - public List<HelpClass> query(int start, int count, String key, Integer state) + public List<HelpClass> query(int start, int count, String key, Integer state, SystemEnum system) throws HelpClassException { - return helpClassMapper.listQuery(start, count, key, state); + return helpClassMapper.listQuery(start, count, key, state,system); } @Override - public long countQuery(String key, Integer state) { - return helpClassMapper.countQuery(key, state); + public long countQuery(String key, Integer state, SystemEnum system) { + return helpClassMapper.countQuery(key, state,system); } @Override - public List<HelpClass> getClassByState(Integer state) throws HelpClassException { - return helpClassMapper.getClassByState(state); + public List<HelpClass> getClassByState(Integer state, SystemEnum system) throws HelpClassException { + return helpClassMapper.getClassByState(state,system); } @Override - public List<HelpClass> getProvidedClass() throws HelpClassException { - return helpClassMapper.getProvidedClass(); + public List<HelpClass> getProvidedClass(SystemEnum system) throws HelpClassException { + return helpClassMapper.getProvidedClass(system); } -- Gitblit v1.8.0