异常封装之机构信息后台修改

This commit is contained in:
qiankunpingtai
2019-04-19 10:05:50 +08:00
parent 642f36e877
commit 35ff31251a
3 changed files with 122 additions and 30 deletions

View File

@@ -23,44 +23,44 @@ public class OrganizationComponent implements ICommonQuery {
@Resource
private OrganizationService organizationService;
@Override
public Object selectOne(String condition) {
public Object selectOne(String condition)throws Exception {
return null;
}
@Override
public List<?> select(Map<String, String> parameterMap) {
public List<?> select(Map<String, String> parameterMap)throws Exception {
return getOrganizationList(parameterMap);
}
private List<?> getOrganizationList(Map<String, String> map) {
private List<?> getOrganizationList(Map<String, String> map)throws Exception {
return null;
}
@Override
public Long counts(Map<String, String> parameterMap) {
public Long counts(Map<String, String> parameterMap)throws Exception {
return null;
}
@Override
public int insert(String beanJson, HttpServletRequest request) {
public int insert(String beanJson, HttpServletRequest request)throws Exception {
return organizationService.insertOrganization(beanJson,request);
}
@Override
public int update(String beanJson, Long id) {
public int update(String beanJson, Long id)throws Exception {
return organizationService.updateOrganization(beanJson,id);
}
@Override
public int delete(Long id) {
public int delete(Long id)throws Exception {
return organizationService.deleteOrganization(id);
}
@Override
public int batchDelete(String ids) {
public int batchDelete(String ids)throws Exception {
return organizationService.batchDeleteOrganization(ids);
}
@Override
public int checkIsNameExist(Long id, String name) {
public int checkIsNameExist(Long id, String name)throws Exception {
return 0;
}
}

View File

@@ -3,6 +3,7 @@ package com.jsh.erp.service.organization;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.MaterialProperty;
import com.jsh.erp.datasource.entities.Organization;
import com.jsh.erp.datasource.entities.OrganizationExample;
import com.jsh.erp.datasource.entities.User;
@@ -44,26 +45,62 @@ public class OrganizationService {
@Resource
private LogService logService;
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertOrganization(String beanJson, HttpServletRequest request) {
public int insertOrganization(String beanJson, HttpServletRequest request)throws Exception {
Organization organization = JSONObject.parseObject(beanJson, Organization.class);
return organizationMapper.insertSelective(organization);
int result=0;
try{
result=organizationMapper.insertSelective(organization);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateOrganization(String beanJson, Long id) {
public int updateOrganization(String beanJson, Long id)throws Exception {
Organization organization = JSONObject.parseObject(beanJson, Organization.class);
organization.setId(id);
return organizationMapper.updateByPrimaryKeySelective(organization);
int result=0;
try{
result=organizationMapper.updateByPrimaryKeySelective(organization);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteOrganization(Long id) {
return organizationMapper.deleteByPrimaryKey(id);
public int deleteOrganization(Long id)throws Exception {
int result=0;
try{
result=organizationMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteOrganization(String ids) {
public int batchDeleteOrganization(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
OrganizationExample example = new OrganizationExample();
example.createCriteria().andIdIn(idList);
return organizationMapper.deleteByExample(example);
int result=0;
try{
result=organizationMapper.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;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int addOrganization(Organization org) throws Exception{
@@ -92,7 +129,16 @@ public class OrganizationService {
if(StringUtil.isEmpty(org.getOrgParentNo())){
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO);
}
return organizationMapperEx.addOrganization(org);
int result=0;
try{
result=organizationMapperEx.addOrganization(org);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int editOrganization(Organization org)throws Exception {
@@ -116,23 +162,59 @@ public class OrganizationService {
if(StringUtil.isEmpty(org.getOrgParentNo())){
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_PARENT_NO);
}
return organizationMapperEx.editOrganization(org);
int result=0;
try{
result=organizationMapperEx.editOrganization(org);
}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<TreeNode> getOrganizationTree(Long id)throws Exception {
return organizationMapperEx.getNodeTree(id);
List<TreeNode> list=null;
try{
list=organizationMapperEx.getNodeTree(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 list;
}
public List<Organization> findById(Long id) throws Exception{
OrganizationExample example = new OrganizationExample();
example.createCriteria().andIdEqualTo(id);
return organizationMapper.selectByExample(example);
List<Organization> list=null;
try{
list=organizationMapper.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<Organization> findByOrgNo(String orgNo)throws Exception {
OrganizationExample example = new OrganizationExample();
example.createCriteria().andOrgNoEqualTo(orgNo).andOrgStcdNotEqualTo(BusinessConstants.ORGANIZATION_STCD_REMOVED);
return organizationMapper.selectByExample(example);
List<Organization> list=null;
try{
list=organizationMapper.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;
}
/**
* create by: cjl
@@ -177,6 +259,16 @@ public class OrganizationService {
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
return organizationMapperEx.batchDeleteOrganizationByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
int result=0;
try{
result=organizationMapperEx.batchDeleteOrganizationByIds(
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;
}
}