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

!50 异常封装

Merge pull request !50 from 乾坤平台/master
parents 7ce3af46 8a831229
...@@ -47,105 +47,236 @@ public class SupplierService { ...@@ -47,105 +47,236 @@ public class SupplierService {
@Resource @Resource
private DepotHeadMapperEx depotHeadMapperEx; private DepotHeadMapperEx depotHeadMapperEx;
public Supplier getSupplier(long id) { public Supplier getSupplier(long id)throws Exception {
return supplierMapper.selectByPrimaryKey(id); Supplier result=null;
try{
result=supplierMapper.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<Supplier> getSupplier() { public List<Supplier> getSupplier()throws Exception {
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return supplierMapper.selectByExample(example); List<Supplier> list=null;
try{
list=supplierMapper.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<Supplier> select(String supplier, String type, String phonenum, String telephone, String description, int offset, int rows) { public List<Supplier> select(String supplier, String type, String phonenum,
return supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows); String telephone, String description, int offset, int rows) throws Exception{
List<Supplier> list=null;
try{
list=supplierMapperEx.selectByConditionSupplier(supplier, type, phonenum, telephone, description, 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 countSupplier(String supplier, String type, String phonenum, String telephone, String description) { public Long countSupplier(String supplier, String type, String phonenum, String telephone, String description) throws Exception{
return supplierMapperEx.countsBySupplier(supplier, type, phonenum, telephone, description); Long result=null;
try{
result=supplierMapperEx.countsBySupplier(supplier, type, phonenum, telephone, description);
}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 insertSupplier(String beanJson, HttpServletRequest request) { public int insertSupplier(String beanJson, HttpServletRequest request)throws Exception {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
return supplierMapper.insertSelective(supplier); int result=0;
try{
result=supplierMapper.insertSelective(supplier);
}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 updateSupplier(String beanJson, Long id) { public int updateSupplier(String beanJson, Long id)throws Exception {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
supplier.setId(id); supplier.setId(id);
return supplierMapper.updateByPrimaryKeySelective(supplier); int result=0;
try{
result=supplierMapper.updateByPrimaryKeySelective(supplier);
}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 deleteSupplier(Long id) { public int deleteSupplier(Long id)throws Exception {
int result=0;
try{
result=supplierMapper.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 supplierMapper.deleteByPrimaryKey(id); return supplierMapper.deleteByPrimaryKey(id);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplier(String ids) { public int batchDeleteSupplier(String ids) throws Exception{
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return supplierMapper.deleteByExample(example); int result=0;
try{
result=supplierMapper.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 {
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Supplier> list = supplierMapper.selectByExample(example); List<Supplier> list=null;
return list.size(); try{
list= supplierMapper.selectByExample(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 list==null?0:list.size();
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAdvanceIn(Long supplierId, BigDecimal advanceIn){ public int updateAdvanceIn(Long supplierId, BigDecimal advanceIn)throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplierId).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplierId).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId); Supplier supplier=null;
if(supplier!=null){ try{
supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值 supplier = supplierMapper.selectByPrimaryKey(supplierId);
return supplierMapper.updateByPrimaryKeySelective(supplier); }catch(Exception e){
}else{ logger.error("异常码[{}],异常提示[{}],异常[{}]",
return 0; ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
} }
int result=0;
try{
if(supplier!=null){
supplier.setAdvancein(supplier.getAdvancein().add(advanceIn)); //增加预收款的金额,可能增加的是负值
result=supplierMapper.updateByPrimaryKeySelective(supplier);
}
}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<Supplier> findBySelectCus() { public List<Supplier> findBySelectCus()throws Exception {
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc"); example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example); List<Supplier> list=null;
try{
list = supplierMapper.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<Supplier> findBySelectSup() { public List<Supplier> findBySelectSup()throws Exception {
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true) example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc"); example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example); List<Supplier> list=null;
try{
list = supplierMapper.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<Supplier> findBySelectRetail() { public List<Supplier> findBySelectRetail()throws Exception {
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true) example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc"); example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example); List<Supplier> list=null;
try{
list = supplierMapper.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<Supplier> findById(Long supplierId) { public List<Supplier> findById(Long supplierId)throws Exception {
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andIdEqualTo(supplierId) example.createCriteria().andIdEqualTo(supplierId)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc"); example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example); List<Supplier> list=null;
try{
list = supplierMapper.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 batchSetEnable(Boolean enabled, String supplierIDs) { public int batchSetEnable(Boolean enabled, String supplierIDs)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplierIDs).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(supplierIDs).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
...@@ -154,20 +285,47 @@ public class SupplierService { ...@@ -154,20 +285,47 @@ public class SupplierService {
supplier.setEnabled(enabled); supplier.setEnabled(enabled);
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andIdIn(ids); example.createCriteria().andIdIn(ids);
return supplierMapper.updateByExampleSelective(supplier, example); int result=0;
try{
result = supplierMapper.updateByExampleSelective(supplier, 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<Supplier> findUserCustomer(){ public List<Supplier> findUserCustomer()throws Exception{
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
example.createCriteria().andTypeEqualTo("客户") example.createCriteria().andTypeEqualTo("客户")
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id desc"); example.setOrderByClause("id desc");
List<Supplier> list = supplierMapper.selectByExample(example); List<Supplier> list=null;
try{
list = supplierMapper.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; return list;
} }
public List<Supplier> findByAll(String supplier, String type, String phonenum, String telephone, String description) { public List<Supplier> findByAll(String supplier, String type, String phonenum,
return supplierMapperEx.findByAll(supplier, type, phonenum, telephone, description); String telephone, String description) throws Exception{
List<Supplier> list=null;
try{
list = supplierMapperEx.findByAll(supplier, type, phonenum, telephone, description);
}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 BaseResponseInfo importExcel(List<Supplier> mList) throws Exception { public BaseResponseInfo importExcel(List<Supplier> mList) throws Exception {
...@@ -183,6 +341,8 @@ public class SupplierService { ...@@ -183,6 +341,8 @@ public class SupplierService {
info.code = 200; info.code = 200;
data.put("message", "成功"); data.put("message", "成功");
} catch (Exception e) { } catch (Exception e) {
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
e.printStackTrace(); e.printStackTrace();
info.code = 500; info.code = 500;
data.put("message", e.getMessage()); data.put("message", e.getMessage());
...@@ -191,13 +351,22 @@ public class SupplierService { ...@@ -191,13 +351,22 @@ public class SupplierService {
return info; return info;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplierByIds(String ids) { public int batchDeleteSupplierByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SUPPLIER,
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 supplierMapperEx.batchDeleteSupplierByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result = supplierMapperEx.batchDeleteSupplierByIds(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;
} }
/** /**
* create by: qiankunpingtai * create by: qiankunpingtai
...@@ -224,7 +393,15 @@ public class SupplierService { ...@@ -224,7 +393,15 @@ public class SupplierService {
/** /**
* 校验财务主表 jsh_accounthead * 校验财务主表 jsh_accounthead
* */ * */
List<AccountHead> accountHeadList=accountHeadMapperEx.getAccountHeadListByOrganIds(idArray); List<AccountHead> accountHeadList=null;
try{
accountHeadList = accountHeadMapperEx.getAccountHeadListByOrganIds(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(accountHeadList!=null&&accountHeadList.size()>0){ if(accountHeadList!=null&&accountHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,OrganIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,OrganIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
...@@ -234,7 +411,15 @@ public class SupplierService { ...@@ -234,7 +411,15 @@ public class SupplierService {
/** /**
* 校验单据主表 jsh_depothead * 校验单据主表 jsh_depothead
* */ * */
List<DepotHead> depotHeadList=depotHeadMapperEx.getDepotHeadListByOrganIds(idArray); List<DepotHead> depotHeadList=null;
try{
depotHeadList = depotHeadMapperEx.getDepotHeadListByOrganIds(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(depotHeadList!=null&&depotHeadList.size()>0){ if(depotHeadList!=null&&depotHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,OrganIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,OrganIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
......
...@@ -21,16 +21,16 @@ public class SystemConfigComponent implements ICommonQuery { ...@@ -21,16 +21,16 @@ public class SystemConfigComponent implements ICommonQuery {
private SystemConfigService systemConfigService; private SystemConfigService systemConfigService;
@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 getSystemConfigList(map); return getSystemConfigList(map);
} }
private List<?> getSystemConfigList(Map<String, String> map) { private List<?> getSystemConfigList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String companyName = StringUtil.getInfo(search, "companyName"); String companyName = StringUtil.getInfo(search, "companyName");
String order = QueryUtils.order(map); String order = QueryUtils.order(map);
...@@ -38,34 +38,34 @@ public class SystemConfigComponent implements ICommonQuery { ...@@ -38,34 +38,34 @@ public class SystemConfigComponent 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 companyName = StringUtil.getInfo(search, "companyName"); String companyName = StringUtil.getInfo(search, "companyName");
return systemConfigService.countSystemConfig(companyName); return systemConfigService.countSystemConfig(companyName);
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return systemConfigService.insertSystemConfig(beanJson, request); return systemConfigService.insertSystemConfig(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return systemConfigService.updateSystemConfig(beanJson, id); return systemConfigService.updateSystemConfig(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return systemConfigService.deleteSystemConfig(id); return systemConfigService.deleteSystemConfig(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return systemConfigService.batchDeleteSystemConfig(ids); return systemConfigService.batchDeleteSystemConfig(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return systemConfigService.checkIsNameExist(id, name); return systemConfigService.checkIsNameExist(id, name);
} }
......
...@@ -2,11 +2,14 @@ package com.jsh.erp.service.systemConfig; ...@@ -2,11 +2,14 @@ package com.jsh.erp.service.systemConfig;
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.Supplier;
import com.jsh.erp.datasource.entities.SystemConfig; import com.jsh.erp.datasource.entities.SystemConfig;
import com.jsh.erp.datasource.entities.SystemConfigExample; import com.jsh.erp.datasource.entities.SystemConfigExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.SystemConfigMapper; import com.jsh.erp.datasource.mappers.SystemConfigMapper;
import com.jsh.erp.datasource.mappers.SystemConfigMapperEx; 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.log.LogService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
...@@ -36,63 +39,152 @@ public class SystemConfigService { ...@@ -36,63 +39,152 @@ public class SystemConfigService {
@Resource @Resource
private LogService logService; private LogService logService;
public SystemConfig getSystemConfig(long id) { public SystemConfig getSystemConfig(long id)throws Exception {
return systemConfigMapper.selectByPrimaryKey(id); 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<SystemConfig> getSystemConfig() { public List<SystemConfig> getSystemConfig()throws Exception {
SystemConfigExample example = new SystemConfigExample(); SystemConfigExample example = new SystemConfigExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return systemConfigMapper.selectByExample(example); List<SystemConfig> 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<SystemConfig> select(String companyName, int offset, int rows) { public List<SystemConfig> select(String companyName, int offset, int rows)throws Exception {
return systemConfigMapperEx.selectByConditionSystemConfig(companyName, offset, rows); List<SystemConfig> 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) { public Long countSystemConfig(String companyName)throws Exception {
return systemConfigMapperEx.countsBySystemConfig(companyName); 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) @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); 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) @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 systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
systemConfig.setId(id); 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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSystemConfig(Long id) { public int deleteSystemConfig(Long id)throws Exception {
return systemConfigMapper.deleteByPrimaryKey(id); 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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSystemConfig(String ids) { public int batchDeleteSystemConfig(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
SystemConfigExample example = new SystemConfigExample(); SystemConfigExample example = new SystemConfigExample();
example.createCriteria().andIdIn(idList); 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(); SystemConfigExample example = new SystemConfigExample();
example.createCriteria().andIdNotEqualTo(id).andCompanyNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andCompanyNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<SystemConfig> list = systemConfigMapper.selectByExample(example); List<SystemConfig> list =null;
return list.size(); 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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSystemConfigByIds(String ids) { public int batchDeleteSystemConfigByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SYSTEM_CONFIG, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_SYSTEM_CONFIG,
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 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;
} }
} }
...@@ -20,16 +20,16 @@ public class UnitComponent implements ICommonQuery { ...@@ -20,16 +20,16 @@ public class UnitComponent implements ICommonQuery {
private UnitService unitService; private UnitService unitService;
@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 getUnitList(map); return getUnitList(map);
} }
private List<?> getUnitList(Map<String, String> map) { private List<?> getUnitList(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);
...@@ -37,34 +37,34 @@ public class UnitComponent implements ICommonQuery { ...@@ -37,34 +37,34 @@ public class UnitComponent 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 unitService.countUnit(name); return unitService.countUnit(name);
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return unitService.insertUnit(beanJson, request); return unitService.insertUnit(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return unitService.updateUnit(beanJson, id); return unitService.updateUnit(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return unitService.deleteUnit(id); return unitService.deleteUnit(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return unitService.batchDeleteUnit(ids); return unitService.batchDeleteUnit(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return unitService.checkIsNameExist(id, name); return unitService.checkIsNameExist(id, name);
} }
......
...@@ -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.Material; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.entities.Unit;
import com.jsh.erp.datasource.entities.UnitExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.MaterialMapperEx; import com.jsh.erp.datasource.mappers.MaterialMapperEx;
import com.jsh.erp.datasource.mappers.UnitMapper; import com.jsh.erp.datasource.mappers.UnitMapper;
import com.jsh.erp.datasource.mappers.UnitMapperEx; import com.jsh.erp.datasource.mappers.UnitMapperEx;
...@@ -43,64 +40,153 @@ public class UnitService { ...@@ -43,64 +40,153 @@ public class UnitService {
@Resource @Resource
private MaterialMapperEx materialMapperEx; private MaterialMapperEx materialMapperEx;
public Unit getUnit(long id) { public Unit getUnit(long id)throws Exception {
return unitMapper.selectByPrimaryKey(id); Unit result=null;
try{
result=unitMapper.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<Unit> getUnit() { public List<Unit> getUnit()throws Exception {
UnitExample example = new UnitExample(); UnitExample example = new UnitExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return unitMapper.selectByExample(example); List<Unit> list=null;
try{
list=unitMapper.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<Unit> select(String name, int offset, int rows) { public List<Unit> select(String name, int offset, int rows)throws Exception {
return unitMapperEx.selectByConditionUnit(name, offset, rows); List<Unit> list=null;
try{
list=unitMapperEx.selectByConditionUnit(name, 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 countUnit(String name) { public Long countUnit(String name)throws Exception {
return unitMapperEx.countsByUnit(name); Long result=null;
try{
result=unitMapperEx.countsByUnit(name);
}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 insertUnit(String beanJson, HttpServletRequest request) { public int insertUnit(String beanJson, HttpServletRequest request)throws Exception {
Unit unit = JSONObject.parseObject(beanJson, Unit.class); Unit unit = JSONObject.parseObject(beanJson, Unit.class);
return unitMapper.insertSelective(unit); int result=0;
try{
result=unitMapper.insertSelective(unit);
}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 updateUnit(String beanJson, Long id) { public int updateUnit(String beanJson, Long id)throws Exception {
Unit unit = JSONObject.parseObject(beanJson, Unit.class); Unit unit = JSONObject.parseObject(beanJson, Unit.class);
unit.setId(id); unit.setId(id);
return unitMapper.updateByPrimaryKeySelective(unit); int result=0;
try{
result=unitMapper.updateByPrimaryKeySelective(unit);
}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 deleteUnit(Long id) { public int deleteUnit(Long id)throws Exception {
return unitMapper.deleteByPrimaryKey(id); int result=0;
try{
result=unitMapper.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 batchDeleteUnit(String ids) { public int batchDeleteUnit(String ids) throws Exception{
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
UnitExample example = new UnitExample(); UnitExample example = new UnitExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return unitMapper.deleteByExample(example); int result=0;
try{
result=unitMapper.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 {
UnitExample example = new UnitExample(); UnitExample example = new UnitExample();
example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Unit> list = unitMapper.selectByExample(example); List<Unit> list=null;
return list.size(); try{
list=unitMapper.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) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUnitByIds(String ids) { public int batchDeleteUnitByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_UNIT, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_UNIT,
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 unitMapperEx.batchDeleteUnitByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result=unitMapperEx.batchDeleteUnitByIds(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;
} }
/** /**
...@@ -127,7 +213,15 @@ public class UnitService { ...@@ -127,7 +213,15 @@ public class UnitService {
/** /**
* 校验产品表 jsh_material * 校验产品表 jsh_material
* */ * */
List<Material> materialList=materialMapperEx.getMaterialListByUnitIds(idArray); List<Material> materialList=null;
try{
materialList=materialMapperEx.getMaterialListByUnitIds(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(materialList!=null&&materialList.size()>0){ if(materialList!=null&&materialList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,UnitIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,UnitIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
......
...@@ -18,16 +18,16 @@ public class UserComponent implements ICommonQuery { ...@@ -18,16 +18,16 @@ public class UserComponent implements ICommonQuery {
private UserService userService; private UserService userService;
@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 userName = StringUtil.getInfo(search, "userName"); String userName = StringUtil.getInfo(search, "userName");
String loginName = StringUtil.getInfo(search, "loginName"); String loginName = StringUtil.getInfo(search, "loginName");
...@@ -37,7 +37,7 @@ public class UserComponent implements ICommonQuery { ...@@ -37,7 +37,7 @@ public class UserComponent 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 userName = StringUtil.getInfo(search, "userName"); String userName = StringUtil.getInfo(search, "userName");
String loginName = StringUtil.getInfo(search, "loginName"); String loginName = StringUtil.getInfo(search, "loginName");
...@@ -45,27 +45,27 @@ public class UserComponent implements ICommonQuery { ...@@ -45,27 +45,27 @@ public class UserComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return userService.insertUser(beanJson, request); return userService.insertUser(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return userService.updateUser(beanJson, id); return userService.updateUser(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return userService.deleteUser(id); return userService.deleteUser(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return userService.batchDeleteUser(ids); return userService.batchDeleteUser(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return userService.checkIsNameExist(id, name); return userService.checkIsNameExist(id, name);
} }
......
...@@ -11,16 +11,17 @@ import com.jsh.erp.datasource.entities.UserEx; ...@@ -11,16 +11,17 @@ import com.jsh.erp.datasource.entities.UserEx;
import com.jsh.erp.datasource.entities.UserExample; import com.jsh.erp.datasource.entities.UserExample;
import com.jsh.erp.datasource.mappers.UserMapper; import com.jsh.erp.datasource.mappers.UserMapper;
import com.jsh.erp.datasource.mappers.UserMapperEx; import com.jsh.erp.datasource.mappers.UserMapperEx;
import com.jsh.erp.datasource.vo.TreeNode;
import com.jsh.erp.datasource.vo.TreeNodeEx; import com.jsh.erp.datasource.vo.TreeNodeEx;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService; import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.service.userBusiness.UserBusinessService; import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.ExceptionCodeConstants;
import com.jsh.erp.utils.JshException;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
...@@ -28,9 +29,11 @@ import org.springframework.web.context.request.ServletRequestAttributes; ...@@ -28,9 +29,11 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.net.URLEncoder;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service @Service
public class UserService { public class UserService {
...@@ -51,21 +54,57 @@ public class UserService { ...@@ -51,21 +54,57 @@ public class UserService {
private UserBusinessService userBusinessService; private UserBusinessService userBusinessService;
public User getUser(long id) { public User getUser(long id)throws Exception {
return userMapper.selectByPrimaryKey(id); User result=null;
try{
result=userMapper.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<User> getUser() { public List<User> getUser()throws Exception {
UserExample example = new UserExample(); UserExample example = new UserExample();
return userMapper.selectByExample(example); List<User> list=null;
try{
list=userMapper.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<User> select(String userName, String loginName, int offset, int rows) { public List<User> select(String userName, String loginName, int offset, int rows)throws Exception {
return userMapperEx.selectByConditionUser(userName, loginName, offset, rows); List<User> list=null;
try{
list=userMapperEx.selectByConditionUser(userName, loginName, 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 countUser(String userName, String loginName) { public Long countUser(String userName, String loginName)throws Exception {
return userMapperEx.countsByUser(userName, loginName); Long result=null;
try{
result=userMapperEx.countsByUser(userName, loginName);
}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: cjl * create by: cjl
...@@ -77,7 +116,7 @@ public class UserService { ...@@ -77,7 +116,7 @@ public class UserService {
* @return int * @return int
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUser(String beanJson, HttpServletRequest request) { public int insertUser(String beanJson, HttpServletRequest request)throws Exception {
User user = JSONObject.parseObject(beanJson, User.class); User user = JSONObject.parseObject(beanJson, User.class);
String password = "123456"; String password = "123456";
//因密码用MD5加密,需要对密码进行转化 //因密码用MD5加密,需要对密码进行转化
...@@ -88,7 +127,16 @@ public class UserService { ...@@ -88,7 +127,16 @@ public class UserService {
e.printStackTrace(); e.printStackTrace();
logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage()); logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage());
} }
return userMapper.insertSelective(user); int result=0;
try{
result=userMapper.insertSelective(user);
}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;
} }
/** /**
* create by: cjl * create by: cjl
...@@ -100,10 +148,19 @@ public class UserService { ...@@ -100,10 +148,19 @@ public class UserService {
* @return int * @return int
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUser(String beanJson, Long id) { public int updateUser(String beanJson, Long id) throws Exception{
User user = JSONObject.parseObject(beanJson, User.class); User user = JSONObject.parseObject(beanJson, User.class);
user.setId(id); user.setId(id);
return userMapper.updateByPrimaryKeySelective(user); int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}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;
} }
/** /**
* create by: cjl * create by: cjl
...@@ -114,11 +171,20 @@ public class UserService { ...@@ -114,11 +171,20 @@ public class UserService {
* @return int * @return int
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserByObj(User user) { public int updateUserByObj(User user) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getId()).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getId()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
return userMapper.updateByPrimaryKeySelective(user); int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}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;
} }
/** /**
* create by: cjl * create by: cjl
...@@ -130,27 +196,54 @@ public class UserService { ...@@ -130,27 +196,54 @@ public class UserService {
* @return int * @return int
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int resetPwd(String md5Pwd, Long id) { public int resetPwd(String md5Pwd, Long id) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User user = new User(); User user = new User();
user.setId(id); user.setId(id);
user.setPassword(md5Pwd); user.setPassword(md5Pwd);
return userMapper.updateByPrimaryKeySelective(user); int result=0;
try{
result=userMapper.updateByPrimaryKeySelective(user);
}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 deleteUser(Long id) { public int deleteUser(Long id)throws Exception {
return userMapper.deleteByPrimaryKey(id); int result=0;
try{
result= userMapper.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 batchDeleteUser(String ids) { public int batchDeleteUser(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
UserExample example = new UserExample(); UserExample example = new UserExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return userMapper.deleteByExample(example); int result=0;
try{
result= userMapper.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 validateUser(String username, String password) throws JshException { public int validateUser(String username, String password) throws JshException {
...@@ -162,6 +255,8 @@ public class UserService { ...@@ -162,6 +255,8 @@ public class UserService {
example.createCriteria().andLoginameEqualTo(username); example.createCriteria().andLoginameEqualTo(username);
list = userMapper.selectByExample(example); list = userMapper.selectByExample(example);
} catch (Exception e) { } catch (Exception e) {
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e); logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
} }
...@@ -188,22 +283,41 @@ public class UserService { ...@@ -188,22 +283,41 @@ public class UserService {
} }
} }
public User getUserByUserName(String username) { public User getUserByUserName(String username)throws Exception {
UserExample example = new UserExample(); UserExample example = new UserExample();
example.createCriteria().andLoginameEqualTo(username); example.createCriteria().andLoginameEqualTo(username);
List<User> list = userMapper.selectByExample(example); List<User> list=null;
User user = list.get(0); try{
list= userMapper.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);
}
User user =null;
if(list!=null&&list.size()>0){
user = list.get(0);
}
return user; return user;
} }
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
UserExample example = new UserExample(); UserExample example = new UserExample();
List <Byte> userStatus=new ArrayList<Byte>(); List <Byte> userStatus=new ArrayList<Byte>();
userStatus.add(BusinessConstants.USER_STATUS_DELETE); userStatus.add(BusinessConstants.USER_STATUS_DELETE);
userStatus.add(BusinessConstants.USER_STATUS_BANNED); userStatus.add(BusinessConstants.USER_STATUS_BANNED);
example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name).andStatusNotIn(userStatus); example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name).andStatusNotIn(userStatus);
List<User> list = userMapper.selectByExample(example); List<User> list=null;
return list.size(); try{
list= userMapper.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();
} }
/** /**
* create by: cjl * create by: cjl
...@@ -213,13 +327,22 @@ public class UserService { ...@@ -213,13 +327,22 @@ public class UserService {
* @Param: * @Param:
* @return com.jsh.erp.datasource.entities.User * @return com.jsh.erp.datasource.entities.User
*/ */
public User getCurrentUser(){ public User getCurrentUser()throws Exception{
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
return (User)request.getSession().getAttribute("user"); return (User)request.getSession().getAttribute("user");
} }
public List<UserEx> getUserList(Map<String, Object> parameterMap) throws Exception{ public List<UserEx> getUserList(Map<String, Object> parameterMap) throws Exception{
return userMapperEx.getUserList(parameterMap); List<UserEx> list=null;
try{
list= userMapperEx.getUserList(parameterMap);
}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 void addUserAndOrgUserRel(UserEx ue) throws Exception{ public void addUserAndOrgUserRel(UserEx ue) throws Exception{
...@@ -277,8 +400,16 @@ public class UserService { ...@@ -277,8 +400,16 @@ public class UserService {
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER); ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
} }
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL); ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
int i=userMapperEx.addUser(ue); int result=0;
if(i>0){ try{
result= userMapperEx.addUser(ue);
}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);
}
if(result>0){
return ue; return ue;
} }
return null; return null;
...@@ -303,7 +434,15 @@ public class UserService { ...@@ -303,7 +434,15 @@ public class UserService {
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER); ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
} }
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL); ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
int i = userMapperEx.addUser(ue); int result=0;
try{
result= userMapperEx.addUser(ue);
}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);
}
//更新租户id //更新租户id
User user = new User(); User user = new User();
user.setId(ue.getId()); user.setId(ue.getId());
...@@ -317,7 +456,7 @@ public class UserService { ...@@ -317,7 +456,7 @@ public class UserService {
ubArr.add(manageRoleId); ubArr.add(manageRoleId);
ubObj.put("value", ubArr.toString()); ubObj.put("value", ubArr.toString());
userBusinessService.insertUserBusiness(ubObj.toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); userBusinessService.insertUserBusiness(ubObj.toString(), ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
if (i > 0) { if (result > 0) {
return ue; return ue;
} }
return null; return null;
...@@ -328,7 +467,14 @@ public class UserService { ...@@ -328,7 +467,14 @@ public class UserService {
public void updateUserTenant(User user) throws Exception{ public void updateUserTenant(User user) throws Exception{
UserExample example = new UserExample(); UserExample example = new UserExample();
example.createCriteria().andIdEqualTo(user.getId()); example.createCriteria().andIdEqualTo(user.getId());
userMapper.updateByPrimaryKeySelective(user); try{
userMapper.updateByPrimaryKeySelective(user);
}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);
}
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
...@@ -380,9 +526,17 @@ public class UserService { ...@@ -380,9 +526,17 @@ public class UserService {
} }
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx updateUser(UserEx ue){ public UserEx updateUser(UserEx ue)throws Exception{
int i=userMapperEx.updateUser(ue); int result =0;
if(i>0){ try{
result=userMapperEx.updateUser(ue);
}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);
}
if(result>0){
return ue; return ue;
} }
return null; return null;
...@@ -395,7 +549,7 @@ public class UserService { ...@@ -395,7 +549,7 @@ public class UserService {
* @Param: userEx * @Param: userEx
* @return void * @return void
*/ */
public void checkUserNameAndLoginName(UserEx userEx){ public void checkUserNameAndLoginName(UserEx userEx)throws Exception{
List<User> list=null; List<User> list=null;
if(userEx==null){ if(userEx==null){
return; return;
...@@ -454,26 +608,52 @@ public class UserService { ...@@ -454,26 +608,52 @@ public class UserService {
/** /**
* 通过用户名获取用户列表 * 通过用户名获取用户列表
* */ * */
public List<User> getUserListByUserName(String userName){ public List<User> getUserListByUserName(String userName)throws Exception{
return userMapperEx.getUserListByUserNameOrLoginName(userName,null); List<User> list =null;
try{
list=userMapperEx.getUserListByUserNameOrLoginName(userName,null);
}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<User> getUserListByloginName(String loginName){ public List<User> getUserListByloginName(String loginName){
return userMapperEx.getUserListByUserNameOrLoginName(null,loginName); List<User> list =null;
try{
list=userMapperEx.getUserListByUserNameOrLoginName(null,loginName);
}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 void batDeleteUser(String ids) { public void batDeleteUser(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
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());
String idsArray[]=ids.split(","); String idsArray[]=ids.split(",");
int i= userMapperEx.batDeleteOrUpdateUser(idsArray,BusinessConstants.USER_STATUS_DELETE); int result =0;
if(i<1){ try{
result=userMapperEx.batDeleteOrUpdateUser(idsArray,BusinessConstants.USER_STATUS_DELETE);
}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);
}
if(result<1){
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]", logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
ExceptionConstants.USER_DELETE_FAILED_CODE,ExceptionConstants.USER_DELETE_FAILED_MSG,ids); ExceptionConstants.USER_DELETE_FAILED_CODE,ExceptionConstants.USER_DELETE_FAILED_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.USER_DELETE_FAILED_CODE, throw new BusinessRunTimeException(ExceptionConstants.USER_DELETE_FAILED_CODE,
...@@ -481,7 +661,16 @@ public class UserService { ...@@ -481,7 +661,16 @@ public class UserService {
} }
} }
public List<TreeNodeEx> getOrganizationUserTree() { public List<TreeNodeEx> getOrganizationUserTree()throws Exception {
return userMapperEx.getNodeTree(); List<TreeNodeEx> list =null;
try{
list=userMapperEx.getNodeTree();
}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;
} }
} }
...@@ -22,46 +22,46 @@ public class UserBusinessComponent implements ICommonQuery { ...@@ -22,46 +22,46 @@ public class UserBusinessComponent implements ICommonQuery {
private UserBusinessService userBusinessService; private UserBusinessService userBusinessService;
@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 getUserBusinessList(map); return getUserBusinessList(map);
} }
private List<?> getUserBusinessList(Map<String, String> map) { private List<?> getUserBusinessList(Map<String, String> map)throws Exception {
return null; return null;
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
return BusinessConstants.DEFAULT_LIST_NULL_NUMBER; return BusinessConstants.DEFAULT_LIST_NULL_NUMBER;
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception {
return userBusinessService.insertUserBusiness(beanJson, request); return userBusinessService.insertUserBusiness(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return userBusinessService.updateUserBusiness(beanJson, id); return userBusinessService.updateUserBusiness(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return userBusinessService.deleteUserBusiness(id); return userBusinessService.deleteUserBusiness(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return userBusinessService.batchDeleteUserBusiness(ids); return userBusinessService.batchDeleteUserBusiness(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return userBusinessService.checkIsNameExist(id, name); return userBusinessService.checkIsNameExist(id, name);
} }
......
...@@ -2,16 +2,14 @@ package com.jsh.erp.service.userBusiness; ...@@ -2,16 +2,14 @@ package com.jsh.erp.service.userBusiness;
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.datasource.entities.App; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Functions; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.datasource.entities.UserBusinessExample;
import com.jsh.erp.datasource.mappers.UserBusinessMapper; import com.jsh.erp.datasource.mappers.UserBusinessMapper;
import com.jsh.erp.datasource.mappers.UserBusinessMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.CommonQueryManager; import com.jsh.erp.service.CommonQueryManager;
import com.jsh.erp.service.app.AppService; import com.jsh.erp.service.app.AppService;
import com.jsh.erp.service.functions.FunctionsService; import com.jsh.erp.service.functions.FunctionsService;
import com.jsh.erp.datasource.mappers.UserBusinessMapperEx;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
...@@ -25,11 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; ...@@ -25,11 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.*;
import java.util.HashSet;
import java.util.Date;
import java.util.List;
import java.util.Set;
@Service @Service
public class UserBusinessService { public class UserBusinessService {
...@@ -53,77 +47,145 @@ public class UserBusinessService { ...@@ -53,77 +47,145 @@ public class UserBusinessService {
@Resource @Resource
private CommonQueryManager configResourceManager; private CommonQueryManager configResourceManager;
public UserBusiness getUserBusiness(long id) { public UserBusiness getUserBusiness(long id)throws Exception {
return userBusinessMapper.selectByPrimaryKey(id); UserBusiness result=null;
try{
result=userBusinessMapper.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<UserBusiness> getUserBusiness() { public List<UserBusiness> getUserBusiness()throws Exception {
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return userBusinessMapper.selectByExample(example); List<UserBusiness> list=null;
try{
list=userBusinessMapper.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 insertUserBusiness(String beanJson, HttpServletRequest request) { public int insertUserBusiness(String beanJson, HttpServletRequest request) throws Exception {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
int inserts = userBusinessMapper.insertSelective(userBusiness); int result=0;
try{
result=userBusinessMapper.insertSelective(userBusiness);
}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);
}
// 更新应用权限 // 更新应用权限
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && inserts > 0) { if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) {
inserts = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue()); result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
} }
return inserts; return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @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 userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
userBusiness.setId(id); userBusiness.setId(id);
int updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness); int result=0;
try{
result=userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
}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);
}
// 更新应用权限 // 更新应用权限
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && updates > 0) { if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) {
updates = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue()); result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
} }
return updates; return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUserBusiness(Long id) { public int deleteUserBusiness(Long id)throws Exception {
return userBusinessMapper.deleteByPrimaryKey(id); int result=0;
try{
result=userBusinessMapper.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 batchDeleteUserBusiness(String ids) { public int batchDeleteUserBusiness(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return userBusinessMapper.deleteByExample(example); int result=0;
try{
result=userBusinessMapper.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 {
return 1; return 1;
} }
public List<UserBusiness> getBasicData(String keyId, String type){ public List<UserBusiness> getBasicData(String keyId, String type)throws Exception{
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type) example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<UserBusiness> list = userBusinessMapper.selectByExample(example); List<UserBusiness> list=null;
try{
list= userBusinessMapper.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; return list;
} }
public Long checkIsValueExist(String type, String keyId) { public Long checkIsValueExist(String type, String keyId)throws Exception {
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId) example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<UserBusiness> list = userBusinessMapper.selectByExample(example); List<UserBusiness> list=null;
try{
list= userBusinessMapper.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);
}
Long id = null; Long id = null;
if(list.size() > 0) { if(list!=null&&list.size() > 0) {
id = list.get(0).getId(); id = list.get(0).getId();
} }
return id; return id;
} }
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) { public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue)throws Exception {
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
String newVaule = "%" + UBValue + "%"; String newVaule = "%" + UBValue + "%";
if(TypeVale !=null && KeyIdValue !=null) { if(TypeVale !=null && KeyIdValue !=null) {
...@@ -133,8 +195,16 @@ public class UserBusinessService { ...@@ -133,8 +195,16 @@ public class UserBusinessService {
example.createCriteria().andValueLike(newVaule) example.createCriteria().andValueLike(newVaule)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} }
List<UserBusiness> list = userBusinessMapper.selectByExample(example); List<UserBusiness> list=null;
if(list.size() > 0) { try{
list= userBusinessMapper.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);
}
if(list!=null&&list.size() > 0) {
return true; return true;
} else { } else {
return false; return false;
...@@ -142,7 +212,7 @@ public class UserBusinessService { ...@@ -142,7 +212,7 @@ public class UserBusinessService {
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateBtnStr(Long userBusinessId, String btnStr) { public int updateBtnStr(Long userBusinessId, String btnStr) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER_BUSINESS, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER_BUSINESS,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(userBusinessId).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(userBusinessId).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
...@@ -150,34 +220,68 @@ public class UserBusinessService { ...@@ -150,34 +220,68 @@ public class UserBusinessService {
userBusiness.setBtnstr(btnStr); userBusiness.setBtnstr(btnStr);
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andIdEqualTo(userBusinessId); example.createCriteria().andIdEqualTo(userBusinessId);
return userBusinessMapper.updateByExampleSelective(userBusiness, example); int result=0;
try{
result= userBusinessMapper.updateByExampleSelective(userBusiness, 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<UserBusiness> findRoleByUserId(String userId){ public List<UserBusiness> findRoleByUserId(String userId)throws Exception{
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andKeyidEqualTo(userId).andTypeEqualTo("UserRole") example.createCriteria().andKeyidEqualTo(userId).andTypeEqualTo("UserRole")
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<UserBusiness> list = userBusinessMapper.selectByExample(example); List<UserBusiness> list=null;
try{
list= userBusinessMapper.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; return list;
} }
public List<UserBusiness> findAppByRoles(String roles){ public List<UserBusiness> findAppByRoles(String roles)throws Exception{
List<String> rolesList = StringUtil.strToStringList(roles); List<String> rolesList = StringUtil.strToStringList(roles);
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
example.createCriteria().andKeyidIn(rolesList).andTypeEqualTo("RoleAPP") example.createCriteria().andKeyidIn(rolesList).andTypeEqualTo("RoleAPP")
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<UserBusiness> list = userBusinessMapper.selectByExample(example); List<UserBusiness> list=null;
try{
list= userBusinessMapper.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; return list;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUserBusinessByIds(String ids) { public int batchDeleteUserBusinessByIds(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER_BUSINESS, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER_BUSINESS,
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 userBusinessMapperEx.batchDeleteUserBusinessByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result= userBusinessMapperEx.batchDeleteUserBusinessByIds(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;
} }
/** /**
...@@ -187,49 +291,46 @@ public class UserBusinessService { ...@@ -187,49 +291,46 @@ public class UserBusinessService {
* @param functionIds * @param functionIds
* @return * @return
*/ */
public int insertOrUpdateAppValue(String type, String keyId, String functionIds) { public int insertOrUpdateAppValue(String type, String keyId, String functionIds) throws Exception{
int result=0;
int updates = 0;
functionIds = functionIds.replaceAll("\\]\\[", ","). functionIds = functionIds.replaceAll("\\]\\[", ",").
replaceAll("\\[","").replaceAll("\\]",""); replaceAll("\\[","").replaceAll("\\]","");
List<Functions> functionsList = functionsService.findByIds(functionIds); List<Functions> functionsList = functionsService.findByIds(functionIds);
if (!CollectionUtils.isEmpty(functionsList)) { if (!CollectionUtils.isEmpty(functionsList)) {
Set<String> appNumbers = new HashSet<>(); Set<String> appNumbers = new HashSet<>();
String appNumber; String appNumber;
for (Functions functions : functionsList) { for (Functions functions : functionsList) {
appNumber = functions.getNumber().substring(0, 2); appNumber = functions.getNumber().substring(0, 2);
appNumbers.add(appNumber); appNumbers.add(appNumber);
} }
List<String> appNumberList = new ArrayList<>(appNumbers); List<String> appNumberList = new ArrayList<>(appNumbers);
List<App> appList = appService.findAppByNumber(appNumberList); List<App> appList = appService.findAppByNumber(appNumberList);
StringBuilder appIdSb = new StringBuilder(); StringBuilder appIdSb = new StringBuilder();
if (!CollectionUtils.isEmpty(appList)) { if (!CollectionUtils.isEmpty(appList)) {
for (App app : appList) { for (App app : appList) {
appIdSb.append("[" + app.getId() + "]"); appIdSb.append("[" + app.getId() + "]");
} }
List<UserBusiness> userBusinessList = getBasicData(keyId, type); List<UserBusiness> userBusinessList = getBasicData(keyId, type);
if(userBusinessList.size() > 0) { try{
UserBusiness userBusiness = userBusinessList.get(0); if(userBusinessList.size() > 0) {
userBusiness.setValue(appIdSb.toString()); UserBusiness userBusiness = userBusinessList.get(0);
updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness); userBusiness.setValue(appIdSb.toString());
} else { result = userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
UserBusiness userBusiness = new UserBusiness(); } else {
userBusiness.setType(type); UserBusiness userBusiness = new UserBusiness();
userBusiness.setKeyid(keyId); userBusiness.setType(type);
userBusiness.setValue(appIdSb.toString()); userBusiness.setKeyid(keyId);
updates = userBusinessMapper.insertSelective(userBusiness); userBusiness.setValue(appIdSb.toString());
result = userBusinessMapper.insertSelective(userBusiness);
}
}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 updates; return result;
} }
} }
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