From ae416e8fece1dc3909718ef13c8d4de854fcc9a8 Mon Sep 17 00:00:00 2001 From: qiankunpingtai Date: Wed, 17 Apr 2019 10:09:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=B0=81=E8=A3=85=E4=B9=8B?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=BF=A1=E6=81=AF=E5=90=8E=E5=8F=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jsh/erp/controller/AppController.java | 8 +- .../com/jsh/erp/service/app/AppComponent.java | 18 +- .../com/jsh/erp/service/app/AppService.java | 182 +++++++++++++++--- .../userBusiness/UserBusinessComponent.java | 4 +- .../userBusiness/UserBusinessService.java | 6 +- 5 files changed, 171 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/jsh/erp/controller/AppController.java b/src/main/java/com/jsh/erp/controller/AppController.java index 88d9dc1d..37601862 100644 --- a/src/main/java/com/jsh/erp/controller/AppController.java +++ b/src/main/java/com/jsh/erp/controller/AppController.java @@ -48,7 +48,7 @@ public class AppController { * @return */ @GetMapping(value = "/findAppByUserId") - public JSONObject findAppByUserId(@RequestParam("userId") String userId, HttpServletRequest request) { + public JSONObject findAppByUserId(@RequestParam("userId") String userId, HttpServletRequest request)throws Exception { List roleList = userBusinessService.findRoleByUserId(userId); String roles = null; if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){ @@ -109,7 +109,7 @@ public class AppController { } @GetMapping(value = "/findDesk") - public JSONObject findDesk(HttpServletRequest request) { + public JSONObject findDesk(HttpServletRequest request)throws Exception { JSONObject obj = new JSONObject(); List dockList = appService.findDock(); JSONArray dockArray = new JSONArray(); @@ -160,7 +160,7 @@ public class AppController { */ @PostMapping(value = "/findRoleAPP") public JSONArray findRoleAPP(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { JSONArray arr = new JSONArray(); try { List dataListApp = appService.findRoleAPP(); @@ -229,7 +229,7 @@ public class AppController { */ @PostMapping(value = "/uploadImg") public BaseResponseInfo uploadImg(MultipartFile fileInfo, @RequestParam("fileInfoName") String fileName, - HttpServletRequest request) { + HttpServletRequest request)throws Exception { BaseResponseInfo res = new BaseResponseInfo(); try { if (fileInfo != null) { diff --git a/src/main/java/com/jsh/erp/service/app/AppComponent.java b/src/main/java/com/jsh/erp/service/app/AppComponent.java index d7d5f7f6..a5759efd 100644 --- a/src/main/java/com/jsh/erp/service/app/AppComponent.java +++ b/src/main/java/com/jsh/erp/service/app/AppComponent.java @@ -19,16 +19,16 @@ public class AppComponent implements ICommonQuery { private AppService appService; @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 getAppList(map); } - private List getAppList(Map map) { + private List getAppList(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -37,7 +37,7 @@ public class AppComponent implements ICommonQuery { } @Override - public Long counts(Map map) { + public Long counts(Map map)throws Exception { String search = map.get(Constants.SEARCH); String name = StringUtil.getInfo(search, "name"); String type = StringUtil.getInfo(search, "type"); @@ -45,27 +45,27 @@ public class AppComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request)throws Exception { return appService.insertApp(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return appService.updateApp(beanJson, id); } @Override - public int delete(Long id) { + public int delete(Long id)throws Exception { return appService.deleteApp(id); } @Override - public int batchDelete(String ids) { + public int batchDelete(String ids)throws Exception { return appService.batchDeleteApp(ids); } @Override - public int checkIsNameExist(Long id, String name) { + public int checkIsNameExist(Long id, String name)throws Exception { return 0; } diff --git a/src/main/java/com/jsh/erp/service/app/AppService.java b/src/main/java/com/jsh/erp/service/app/AppService.java index 150091a1..907d5c5c 100644 --- a/src/main/java/com/jsh/erp/service/app/AppService.java +++ b/src/main/java/com/jsh/erp/service/app/AppService.java @@ -2,12 +2,14 @@ package com.jsh.erp.service.app; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.App; import com.jsh.erp.datasource.entities.AppExample; import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.UserBusiness; import com.jsh.erp.datasource.mappers.AppMapper; import com.jsh.erp.datasource.mappers.AppMapperEx; +import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.userBusiness.UserBusinessService; @@ -40,11 +42,19 @@ public class AppService { @Resource private UserBusinessService userBusinessService; - public List findDock(){ + public List findDock()throws Exception{ AppExample example = new AppExample(); example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.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; } /** @@ -55,86 +65,191 @@ public class AppService { * @Param: null * @return */ - public List findDesk(){ + public List findDesk()throws Exception{ AppExample example = new AppExample(); example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.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 App getApp(long id) { - return appMapper.selectByPrimaryKey(id); + public App getApp(long id)throws Exception { + App result=null; + try{ + result=appMapper.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 getApp() { + public List getApp()throws Exception { AppExample example = new AppExample(); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); - return appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.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 name, String type, int offset, int rows) { - return appMapperEx.selectByConditionApp(name, type, offset, rows); + public List select(String name, String type, int offset, int rows)throws Exception { + List list=null; + try{ + list=appMapperEx.selectByConditionApp(name, type, 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 countApp(String name, String type) { - return appMapperEx.countsByApp(name, type); + public Long countApp(String name, String type)throws Exception { + Long result=null; + try{ + result=appMapperEx.countsByApp(name, type); + }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 insertApp(String beanJson, HttpServletRequest request) { + public int insertApp(String beanJson, HttpServletRequest request)throws Exception { App app = JSONObject.parseObject(beanJson, App.class); - return appMapper.insertSelective(app); + int result=0; + try{ + result=appMapper.insertSelective(app); + }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 updateApp(String beanJson, Long id) { + public int updateApp(String beanJson, Long id) throws Exception{ App app = JSONObject.parseObject(beanJson, App.class); app.setId(id); - return appMapper.updateByPrimaryKeySelective(app); + int result=0; + try{ + result=appMapper.updateByPrimaryKeySelective(app); + }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 deleteApp(Long id) { - return appMapper.deleteByPrimaryKey(id); + public int deleteApp(Long id)throws Exception { + int result=0; + try{ + result=appMapper.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 batchDeleteApp(String ids) { + public int batchDeleteApp(String ids)throws Exception { List idList = StringUtil.strToLongList(ids); AppExample example = new AppExample(); example.createCriteria().andIdIn(idList); - return appMapper.deleteByExample(example); + int result=0; + try{ + result=appMapper.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 List findRoleAPP(){ + public List findRoleAPP()throws Exception{ AppExample example = new AppExample(); example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.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 findAppInIds(String ids, String type){ + public List findAppInIds(String ids, String type)throws Exception{ List idList = StringUtil.strToLongList(ids); AppExample example = new AppExample(); example.createCriteria().andZlEqualTo(type).andEnabledEqualTo(true).andIdIn(idList) .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.setOrderByClause("Sort"); - List list = appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.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; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int batchDeleteAppByIds(String ids) { + public int batchDeleteAppByIds(String ids) throws Exception{ logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_APP, new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); - return appMapperEx.batchDeleteAppByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + int result=0; + try{ + result=appMapperEx.batchDeleteAppByIds(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; } - public List findAppByUserId(String userId) { + public List findAppByUserId(String userId)throws Exception { List roleList = userBusinessService.findRoleByUserId(userId); String roles = null; if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){ @@ -162,10 +277,19 @@ public class AppService { * @param numberList * @return */ - public List findAppByNumber(List numberList) { + public List findAppByNumber(List numberList) throws Exception{ AppExample example = new AppExample(); example.createCriteria().andEnabledEqualTo(true).andNumberIn(numberList); - return appMapper.selectByExample(example); + List list=null; + try{ + list=appMapper.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; } } diff --git a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java index 26d962a7..dabdd340 100644 --- a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java +++ b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessComponent.java @@ -41,12 +41,12 @@ public class UserBusinessComponent implements ICommonQuery { } @Override - public int insert(String beanJson, HttpServletRequest request) { + public int insert(String beanJson, HttpServletRequest request) throws Exception { return userBusinessService.insertUserBusiness(beanJson, request); } @Override - public int update(String beanJson, Long id) { + public int update(String beanJson, Long id)throws Exception { return userBusinessService.updateUserBusiness(beanJson, id); } diff --git a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java index 9c07a555..4ff8f204 100644 --- a/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java +++ b/src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java @@ -64,7 +64,7 @@ public class UserBusinessService { } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int insertUserBusiness(String beanJson, HttpServletRequest request) { + public int insertUserBusiness(String beanJson, HttpServletRequest request) throws Exception { UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); int inserts = userBusinessMapper.insertSelective(userBusiness); // 更新应用权限 @@ -75,7 +75,7 @@ public class UserBusinessService { } @Transactional(value = "transactionManager", rollbackFor = Exception.class) - public int updateUserBusiness(String beanJson, Long id) { + public int updateUserBusiness(String beanJson, Long id) throws Exception { UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); userBusiness.setId(id); int updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness); @@ -187,7 +187,7 @@ public class UserBusinessService { * @param functionIds * @return */ - public int insertOrUpdateAppValue(String type, String keyId, String functionIds) { + public int insertOrUpdateAppValue(String type, String keyId, String functionIds) throws Exception{ int updates = 0;