From b7694fa4d89ff0d685b4e31953f44d55fc9684ff Mon Sep 17 00:00:00 2001 From: qiankunpingtai Date: Fri, 19 Apr 2019 14:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=B0=81=E8=A3=85=E4=B9=8B?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../systemConfig/SystemConfigComponent.java | 18 +-- .../systemConfig/SystemConfigService.java | 132 +++++++++++++++--- 2 files changed, 121 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java index 65a6f771..427cd516 100644 --- a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java +++ b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigComponent.java @@ -21,16 +21,16 @@ public class SystemConfigComponent implements ICommonQuery { private SystemConfigService systemConfigService; @Override - public Object selectOne(String condition) { + public Object selectOne(String condition)throws Exception { return null; } @Override - public List select(Map map) { + public List select(Map map)throws Exception { return getSystemConfigList(map); } - private List getSystemConfigList(Map map) { + private List getSystemConfigList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String companyName = StringUtil.getInfo(search, "companyName"); String order = QueryUtils.order(map); @@ -38,34 +38,34 @@ public class SystemConfigComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String companyName = StringUtil.getInfo(search, "companyName"); return systemConfigService.countSystemConfig(companyName); } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return systemConfigService.insertSystemConfig(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return systemConfigService.updateSystemConfig(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return systemConfigService.deleteSystemConfig(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return systemConfigService.batchDeleteSystemConfig(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return systemConfigService.checkIsNameExist(id, name); } diff --git a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java index d4ce6b85..eb6befdc 100644 --- a/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java +++ b/src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java @@ -2,11 +2,14 @@ package com.jsh.erp.service.systemConfig; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; +import com.jsh.erp.datasource.entities.Supplier; import com.jsh.erp.datasource.entities.SystemConfig; import com.jsh.erp.datasource.entities.SystemConfigExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.SystemConfigMapper; import com.jsh.erp.datasource.mappers.SystemConfigMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.StringUtil; @@ -36,54 +39,134 @@ public class SystemConfigService { @Resource private LogService logService; - public SystemConfig getSystemConfig(long id) { - return systemConfigMapper.selectByPrimaryKey(id); + public SystemConfig getSystemConfig(long id)throws Exception { + SystemConfig result=null; + try{ + result=systemConfigMapper.selectByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } - public List getSystemConfig() { + public List getSystemConfig()throws Exception { SystemConfigExample example = new SystemConfigExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return systemConfigMapper.selectByExample(example); + List list=null; + try{ + list=systemConfigMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public List select(String companyName, int offset, int rows) { - return systemConfigMapperEx.selectByConditionSystemConfig(companyName, offset, rows); + public List select(String companyName, int offset, int rows)throws Exception { + List list=null; + try{ + list=systemConfigMapperEx.selectByConditionSystemConfig(companyName, offset, rows); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list; } - public Long countSystemConfig(String companyName) { - return systemConfigMapperEx.countsBySystemConfig(companyName); + public Long countSystemConfig(String companyName)throws Exception { + Long result=null; + try{ + result=systemConfigMapperEx.countsBySystemConfig(companyName); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertSystemConfig(String beanJson, HttpServletRequest request) { + public int insertSystemConfig(String beanJson, HttpServletRequest request) throws Exception{ SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class); - return systemConfigMapper.insertSelective(systemConfig); + int result=0; + try{ + result=systemConfigMapper.insertSelective(systemConfig); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateSystemConfig(String beanJson, Long id) { + public int updateSystemConfig(String beanJson, Long id) throws Exception{ SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class); systemConfig.setId(id); - return systemConfigMapper.updateByPrimaryKeySelective(systemConfig); + int result=0; + try{ + result=systemConfigMapper.updateByPrimaryKeySelective(systemConfig); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int deleteSystemConfig(Long id) { - return systemConfigMapper.deleteByPrimaryKey(id); + public int deleteSystemConfig(Long id)throws Exception { + int result=0; + try{ + result=systemConfigMapper.deleteByPrimaryKey(id); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteSystemConfig(String ids) { + public int batchDeleteSystemConfig(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); SystemConfigExample example = new SystemConfigExample(); example.createCriteria().andIdIn(idList); - return systemConfigMapper.deleteByExample(example); + int result=0; + try{ + result=systemConfigMapper.deleteByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name) throws Exception{ SystemConfigExample example = new SystemConfigExample(); example.createCriteria().andIdNotEqualTo(id).andCompanyNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - List list = systemConfigMapper.selectByExample(example); - return list.size(); + List list =null; + try{ + list=systemConfigMapper.selectByExample(example); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return list==null?0:list.size(); } @Transactional(value = "transactionManager", rollbackFor = Exception.class) @@ -93,6 +176,15 @@ public class SystemConfigService { ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE, + ExceptionConstants.DATA_WRITE_FAIL_MSG); + } + return result; } }