Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
35ff3125
Commit
35ff3125
authored
Apr 19, 2019
by
qiankunpingtai
Browse files
异常封装之机构信息后台修改
parent
642f36e8
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
35ff3125
...
...
@@ -18,17 +18,17 @@ public class ExceptionConstants {
**/
public
static
final
int
SERVICE_SUCCESS_CODE
=
200
;
public
static
final
String
SERVICE_SUCCESS_MSG
=
"操作成功"
;
/**
* 数据查询异常
*/
public
static
final
int
DATA_READ_FAIL_CODE
=
300
;
public
static
final
String
DATA_READ_FAIL_MSG
=
"数据查询异常"
;
/**
* 数据写入异常
*/
public
static
final
int
DATA_WRITE_FAIL_CODE
=
30
0
;
public
static
final
int
DATA_WRITE_FAIL_CODE
=
30
1
;
public
static
final
String
DATA_WRITE_FAIL_MSG
=
"数据写入异常"
;
/**
* 数据查询异常
*/
public
static
final
int
DATA_READ_FAIL_CODE
=
301
;
public
static
final
String
DATA_READ_FAIL_MSG
=
"数据查询异常"
;
/**
* 系统运行时未知错误
**/
...
...
src/main/java/com/jsh/erp/service/organization/OrganizationComponent.java
View file @
35ff3125
...
...
@@ -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
;
}
}
src/main/java/com/jsh/erp/service/organization/OrganizationService.java
View file @
35ff3125
...
...
@@ -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
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment