Commit 42835c94 authored by 乾坤平台's avatar 乾坤平台 Committed by 季圣华
Browse files

!50 异常封装

Merge pull request !50 from 乾坤平台/master
parents 7ce3af46 8a831229
...@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.AccountItem; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.entities.InOutItem;
import com.jsh.erp.datasource.entities.InOutItemExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.AccountItemMapperEx; import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
import com.jsh.erp.datasource.mappers.InOutItemMapper; import com.jsh.erp.datasource.mappers.InOutItemMapper;
import com.jsh.erp.datasource.mappers.InOutItemMapperEx; import com.jsh.erp.datasource.mappers.InOutItemMapperEx;
...@@ -43,58 +40,139 @@ public class InOutItemService { ...@@ -43,58 +40,139 @@ public class InOutItemService {
@Resource @Resource
private AccountItemMapperEx accountItemMapperEx; private AccountItemMapperEx accountItemMapperEx;
public InOutItem getInOutItem(long id) { public InOutItem getInOutItem(long id)throws Exception {
return inOutItemMapper.selectByPrimaryKey(id); InOutItem result=null;
try{
result=inOutItemMapper.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<InOutItem> getInOutItem() { public List<InOutItem> getInOutItem()throws Exception {
InOutItemExample example = new InOutItemExample(); InOutItemExample example = new InOutItemExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return inOutItemMapper.selectByExample(example); List<InOutItem> list=null;
try{
list=inOutItemMapper.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<InOutItem> select(String name, String type, String remark, int offset, int rows) { public List<InOutItem> select(String name, String type, String remark, int offset, int rows)throws Exception {
return inOutItemMapperEx.selectByConditionInOutItem(name, type, remark, offset, rows); List<InOutItem> list=null;
try{
list=inOutItemMapperEx.selectByConditionInOutItem(name, type, remark, 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 countInOutItem(String name, String type, String remark) { public Long countInOutItem(String name, String type, String remark)throws Exception {
return inOutItemMapperEx.countsByInOutItem(name, type, remark); Long result=null;
try{
result=inOutItemMapperEx.countsByInOutItem(name, type, remark);
}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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertInOutItem(String beanJson, HttpServletRequest request) { public int insertInOutItem(String beanJson, HttpServletRequest request)throws Exception {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
return inOutItemMapper.insertSelective(depot); int result=0;
try{
result=inOutItemMapper.insertSelective(depot);
}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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateInOutItem(String beanJson, Long id) { public int updateInOutItem(String beanJson, Long id)throws Exception {
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class); InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
depot.setId(id); depot.setId(id);
return inOutItemMapper.updateByPrimaryKeySelective(depot); int result=0;
try{
result=inOutItemMapper.updateByPrimaryKeySelective(depot);
}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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteInOutItem(Long id) { public int deleteInOutItem(Long id)throws Exception {
return inOutItemMapper.deleteByPrimaryKey(id); int result=0;
try{
result=inOutItemMapper.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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItem(String ids) { public int batchDeleteInOutItem(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
InOutItemExample example = new InOutItemExample(); InOutItemExample example = new InOutItemExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return inOutItemMapper.deleteByExample(example); int result=0;
try{
result=inOutItemMapper.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 {
InOutItemExample example = new InOutItemExample(); InOutItemExample example = new InOutItemExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<InOutItem> list = inOutItemMapper.selectByExample(example); List<InOutItem> list = null;
return list.size(); try{
list=inOutItemMapper.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();
} }
public List<InOutItem> findBySelect(String type) { public List<InOutItem> findBySelect(String type)throws Exception {
InOutItemExample example = new InOutItemExample(); InOutItemExample example = new InOutItemExample();
if (type.equals("in")) { if (type.equals("in")) {
example.createCriteria().andTypeEqualTo("收入").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andTypeEqualTo("收入").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
...@@ -102,16 +180,34 @@ public class InOutItemService { ...@@ -102,16 +180,34 @@ public class InOutItemService {
example.createCriteria().andTypeEqualTo("支出").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andTypeEqualTo("支出").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} }
example.setOrderByClause("id desc"); example.setOrderByClause("id desc");
return inOutItemMapper.selectByExample(example); List<InOutItem> list = null;
try{
list=inOutItemMapper.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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItemByIds(String ids) { public int batchDeleteInOutItemByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_IN_OUT_ITEM, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_IN_OUT_ITEM,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
return inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result = 0;
try{
result=inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}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;
} }
/** /**
* create by: qiankunpingtai * create by: qiankunpingtai
...@@ -137,7 +233,15 @@ public class InOutItemService { ...@@ -137,7 +233,15 @@ public class InOutItemService {
/** /**
* 校验财务子表 jsh_accountitem * 校验财务子表 jsh_accountitem
* */ * */
List<AccountItem> accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray); List<AccountItem> accountItemList=null;
try{
accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray);
}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);
}
if(accountItemList!=null&&accountItemList.size()>0){ if(accountItemList!=null&&accountItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,InOutItemIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,InOutItemIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
......
...@@ -19,16 +19,16 @@ public class LogComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class LogComponent implements ICommonQuery {
private LogService logService; private LogService logService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getUserList(map); return getUserList(map);
} }
private List<?> getUserList(Map<String, String> map) { private List<?> getUserList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String operation = StringUtil.getInfo(search, "operation"); String operation = StringUtil.getInfo(search, "operation");
Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID")); Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID"));
...@@ -43,7 +43,7 @@ public class LogComponent implements ICommonQuery { ...@@ -43,7 +43,7 @@ public class LogComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String operation = StringUtil.getInfo(search, "operation"); String operation = StringUtil.getInfo(search, "operation");
Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID")); Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID"));
...@@ -56,27 +56,27 @@ public class LogComponent implements ICommonQuery { ...@@ -56,27 +56,27 @@ public class LogComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return logService.insertLog(beanJson, request); return logService.insertLog(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return logService.updateLog(beanJson, id); return logService.updateLog(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return logService.deleteLog(id); return logService.deleteLog(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return logService.batchDeleteLog(ids); return logService.batchDeleteLog(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return 0; return 0;
} }
......
...@@ -2,16 +2,15 @@ package com.jsh.erp.service.log; ...@@ -2,16 +2,15 @@ package com.jsh.erp.service.log;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Log; import com.jsh.erp.datasource.entities.Log;
import com.jsh.erp.datasource.entities.LogExample; import com.jsh.erp.datasource.entities.LogExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.LogMapper; import com.jsh.erp.datasource.mappers.LogMapper;
import com.jsh.erp.datasource.mappers.LogMapperEx; import com.jsh.erp.datasource.mappers.LogMapperEx;
import com.jsh.erp.datasource.vo.LogVo4List; import com.jsh.erp.datasource.vo.LogVo4List;
import com.jsh.erp.utils.ExceptionCodeConstants; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.utils.JshException;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -19,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -19,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.security.NoSuchAlgorithmException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -34,50 +32,122 @@ public class LogService { ...@@ -34,50 +32,122 @@ public class LogService {
@Resource @Resource
private LogMapperEx logMapperEx; private LogMapperEx logMapperEx;
public Log getLog(long id) { public Log getLog(long id)throws Exception {
return logMapper.selectByPrimaryKey(id); Log result=null;
try{
result=logMapper.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<Log> getLog() { public List<Log> getLog()throws Exception {
LogExample example = new LogExample(); LogExample example = new LogExample();
return logMapper.selectByExample(example); List<Log> list=null;
try{
list=logMapper.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<LogVo4List> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime, public List<LogVo4List> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
String contentdetails, int offset, int rows) { String contentdetails, int offset, int rows)throws Exception {
return logMapperEx.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime, List<LogVo4List> list=null;
contentdetails, offset, rows); try{
list=logMapperEx.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime,
contentdetails, 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 countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime, public Long countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
String contentdetails) { String contentdetails)throws Exception {
return logMapperEx.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails); Long result=null;
try{
result=logMapperEx.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
}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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertLog(String beanJson, HttpServletRequest request) { public int insertLog(String beanJson, HttpServletRequest request) throws Exception{
Log log = JSONObject.parseObject(beanJson, Log.class); Log log = JSONObject.parseObject(beanJson, Log.class);
return logMapper.insertSelective(log); int result=0;
try{
result=logMapper.insertSelective(log);
}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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateLog(String beanJson, Long id) { public int updateLog(String beanJson, Long id)throws Exception {
Log log = JSONObject.parseObject(beanJson, Log.class); Log log = JSONObject.parseObject(beanJson, Log.class);
log.setId(id); log.setId(id);
return logMapper.updateByPrimaryKeySelective(log); int result=0;
try{
result=logMapper.updateByPrimaryKeySelective(log);
}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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteLog(Long id) { public int deleteLog(Long id)throws Exception {
return logMapper.deleteByPrimaryKey(id); int result=0;
try{
result=logMapper.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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteLog(String ids) { public int batchDeleteLog(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
LogExample example = new LogExample(); LogExample example = new LogExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return logMapper.deleteByExample(example); int result=0;
try{
result=logMapper.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;
} }
/** /**
...@@ -85,7 +155,7 @@ public class LogService { ...@@ -85,7 +155,7 @@ public class LogService {
* @param request * @param request
* @return * @return
*/ */
public Long getUserId(HttpServletRequest request) { public Long getUserId(HttpServletRequest request) throws Exception{
Object userInfo = request.getSession().getAttribute("user"); Object userInfo = request.getSession().getAttribute("user");
if(userInfo!=null) { if(userInfo!=null) {
User user = (User) userInfo; User user = (User) userInfo;
...@@ -95,7 +165,7 @@ public class LogService { ...@@ -95,7 +165,7 @@ public class LogService {
} }
} }
public String getModule(String apiName){ public String getModule(String apiName)throws Exception{
String moduleName = null; String moduleName = null;
switch (apiName) { switch (apiName) {
case BusinessConstants.LOG_INTERFACE_NAME_USER: case BusinessConstants.LOG_INTERFACE_NAME_USER:
...@@ -144,7 +214,7 @@ public class LogService { ...@@ -144,7 +214,7 @@ public class LogService {
return moduleName; return moduleName;
} }
public void insertLog(String apiName, String type, HttpServletRequest request){ public void insertLog(String apiName, String type, HttpServletRequest request)throws Exception{
Log log = new Log(); Log log = new Log();
log.setUserid(getUserId(request)); log.setUserid(getUserId(request));
log.setOperation(getModule(apiName)); log.setOperation(getModule(apiName));
...@@ -154,7 +224,15 @@ public class LogService { ...@@ -154,7 +224,15 @@ public class LogService {
log.setStatus(status); log.setStatus(status);
log.setContentdetails(type + getModule(apiName)); log.setContentdetails(type + getModule(apiName));
log.setRemark(type + getModule(apiName)); log.setRemark(type + getModule(apiName));
logMapper.insertSelective(log); try{
logMapper.insertSelective(log);
}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);
}
} }
} }
...@@ -21,16 +21,16 @@ public class MaterialComponent implements ICommonQuery { ...@@ -21,16 +21,16 @@ public class MaterialComponent implements ICommonQuery {
private MaterialService materialService; private MaterialService materialService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getMaterialList(map); return getMaterialList(map);
} }
private List<?> getMaterialList(Map<String, String> map) { private List<?> getMaterialList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String model = StringUtil.getInfo(search, "model"); String model = StringUtil.getInfo(search, "model");
...@@ -42,7 +42,7 @@ public class MaterialComponent implements ICommonQuery { ...@@ -42,7 +42,7 @@ public class MaterialComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String model = StringUtil.getInfo(search, "model"); String model = StringUtil.getInfo(search, "model");
...@@ -53,27 +53,27 @@ public class MaterialComponent implements ICommonQuery { ...@@ -53,27 +53,27 @@ public class MaterialComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return materialService.insertMaterial(beanJson, request); return materialService.insertMaterial(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return materialService.updateMaterial(beanJson, id); return materialService.updateMaterial(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return materialService.deleteMaterial(id); return materialService.deleteMaterial(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return materialService.batchDeleteMaterial(ids); return materialService.batchDeleteMaterial(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return materialService.checkIsNameExist(id, name); return materialService.checkIsNameExist(id, name);
} }
......
...@@ -21,16 +21,16 @@ public class MaterialCategoryComponent implements ICommonQuery { ...@@ -21,16 +21,16 @@ public class MaterialCategoryComponent implements ICommonQuery {
private MaterialCategoryService materialCategoryService; private MaterialCategoryService materialCategoryService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getMaterialCategoryList(map); return getMaterialCategoryList(map);
} }
private List<?> getMaterialCategoryList(Map<String, String> map) { private List<?> getMaterialCategoryList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId")); Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId"));
...@@ -39,7 +39,7 @@ public class MaterialCategoryComponent implements ICommonQuery { ...@@ -39,7 +39,7 @@ public class MaterialCategoryComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId")); Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId"));
...@@ -47,27 +47,27 @@ public class MaterialCategoryComponent implements ICommonQuery { ...@@ -47,27 +47,27 @@ public class MaterialCategoryComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return materialCategoryService.insertMaterialCategory(beanJson, request); return materialCategoryService.insertMaterialCategory(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return materialCategoryService.updateMaterialCategory(beanJson, id); return materialCategoryService.updateMaterialCategory(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return materialCategoryService.deleteMaterialCategory(id); return materialCategoryService.deleteMaterialCategory(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return materialCategoryService.batchDeleteMaterialCategory(ids); return materialCategoryService.batchDeleteMaterialCategory(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return materialCategoryService.checkIsNameExist(id, name); return materialCategoryService.checkIsNameExist(id, name);
} }
......
...@@ -19,16 +19,16 @@ public class MaterialPropertyComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class MaterialPropertyComponent implements ICommonQuery {
private MaterialPropertyService materialPropertyService; private MaterialPropertyService materialPropertyService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getMaterialPropertyList(map); return getMaterialPropertyList(map);
} }
private List<?> getMaterialPropertyList(Map<String, String> map) { private List<?> getMaterialPropertyList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String order = QueryUtils.order(map); String order = QueryUtils.order(map);
...@@ -36,34 +36,34 @@ public class MaterialPropertyComponent implements ICommonQuery { ...@@ -36,34 +36,34 @@ public class MaterialPropertyComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
return materialPropertyService.countMaterialProperty(name); return materialPropertyService.countMaterialProperty(name);
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return materialPropertyService.insertMaterialProperty(beanJson, request); return materialPropertyService.insertMaterialProperty(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return materialPropertyService.updateMaterialProperty(beanJson, id); return materialPropertyService.updateMaterialProperty(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return materialPropertyService.deleteMaterialProperty(id); return materialPropertyService.deleteMaterialProperty(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return materialPropertyService.batchDeleteMaterialProperty(ids); return materialPropertyService.batchDeleteMaterialProperty(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return materialPropertyService.checkIsNameExist(id, name); return materialPropertyService.checkIsNameExist(id, name);
} }
......
...@@ -22,44 +22,44 @@ public class OrgaUserRelComponent implements ICommonQuery { ...@@ -22,44 +22,44 @@ public class OrgaUserRelComponent implements ICommonQuery {
@Resource @Resource
private OrgaUserRelService orgaUserRelService; private OrgaUserRelService orgaUserRelService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> parameterMap) { public List<?> select(Map<String, String> parameterMap)throws Exception {
return getOrgaUserRelList(parameterMap); return getOrgaUserRelList(parameterMap);
} }
private List<?> getOrgaUserRelList(Map<String, String> map) { private List<?> getOrgaUserRelList(Map<String, String> map)throws Exception {
return null; return null;
} }
@Override @Override
public Long counts(Map<String, String> parameterMap) { public Long counts(Map<String, String> parameterMap)throws Exception {
return null; return null;
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return orgaUserRelService.insertOrgaUserRel(beanJson,request); return orgaUserRelService.insertOrgaUserRel(beanJson,request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return orgaUserRelService.updateOrgaUserRel(beanJson,id); return orgaUserRelService.updateOrgaUserRel(beanJson,id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return orgaUserRelService.deleteOrgaUserRel(id); return orgaUserRelService.deleteOrgaUserRel(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return orgaUserRelService.batchDeleteOrgaUserRel(ids); return orgaUserRelService.batchDeleteOrgaUserRel(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return 0; return 0;
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment