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
10fa40f5
Commit
10fa40f5
authored
Apr 16, 2019
by
qiankunpingtai
Browse files
异常封装之账户信息后台修改
parent
f0dfd906
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
10fa40f5
...
...
@@ -18,6 +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_WRITE_FAIL_CODE
=
300
;
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/controller/AccountController.java
View file @
10fa40f5
package
com.jsh.erp.controller
;
import
com.alibaba.druid.util.StringUtils
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
...
...
@@ -41,7 +40,7 @@ public class AccountController {
* @return
*/
@GetMapping
(
value
=
"/findBySelect"
)
public
String
findBySelect
(
HttpServletRequest
request
)
{
public
String
findBySelect
(
HttpServletRequest
request
)
throws
Exception
{
String
res
=
null
;
try
{
List
<
Account
>
dataList
=
accountService
.
findBySelect
();
...
...
@@ -70,7 +69,7 @@ public class AccountController {
* @return
*/
@GetMapping
(
value
=
"/getAccount"
)
public
BaseResponseInfo
getAccount
(
HttpServletRequest
request
)
{
public
BaseResponseInfo
getAccount
(
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
try
{
...
...
@@ -100,7 +99,7 @@ public class AccountController {
@RequestParam
(
"pageSize"
)
Integer
pageSize
,
@RequestParam
(
"accountId"
)
Long
accountId
,
@RequestParam
(
"initialAmount"
)
BigDecimal
initialAmount
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
try
{
...
...
@@ -133,7 +132,7 @@ public class AccountController {
@PostMapping
(
value
=
"/updateAmountIsDefault"
)
public
String
updateAmountIsDefault
(
@RequestParam
(
"isDefault"
)
Boolean
isDefault
,
@RequestParam
(
"accountId"
)
Long
accountId
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
res
=
accountService
.
updateAmountIsDefault
(
isDefault
,
accountId
);
if
(
res
>
0
)
{
...
...
src/main/java/com/jsh/erp/controller/ResourceController.java
View file @
10fa40f5
...
...
@@ -4,13 +4,16 @@ import com.alibaba.fastjson.JSONObject;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.service.CommonQueryManager
;
import
com.jsh.erp.utils.*
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
jsh
.
erp
.
utils
.
ResponseJsonUtil
.
returnJson
;
...
...
@@ -25,7 +28,7 @@ public class ResourceController {
private
CommonQueryManager
configResourceManager
;
@GetMapping
(
value
=
"/test/heart"
)
public
JSONObject
exitHeart
(
HttpServletRequest
request
)
{
public
JSONObject
exitHeart
(
HttpServletRequest
request
)
throws
Exception
{
return
JsonUtils
.
ok
();
}
...
...
@@ -34,7 +37,7 @@ public class ResourceController {
@RequestParam
(
value
=
Constants
.
PAGE_SIZE
,
required
=
false
)
Integer
pageSize
,
@RequestParam
(
value
=
Constants
.
CURRENT_PAGE
,
required
=
false
)
Integer
currentPage
,
@RequestParam
(
value
=
Constants
.
SEARCH
,
required
=
false
)
String
search
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
String
>
parameterMap
=
ParamUtils
.
requestToMap
(
request
);
parameterMap
.
put
(
Constants
.
SEARCH
,
search
);
PageQueryInfo
queryInfo
=
new
PageQueryInfo
();
...
...
@@ -60,7 +63,7 @@ public class ResourceController {
@PostMapping
(
value
=
"/{apiName}/add"
,
produces
=
{
"application/javascript"
,
"application/json"
})
public
String
addResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
@RequestParam
(
"info"
)
String
beanJson
,
HttpServletRequest
request
)
{
@RequestParam
(
"info"
)
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
insert
=
configResourceManager
.
insert
(
apiName
,
beanJson
,
request
);
if
(
insert
>
0
)
{
...
...
@@ -73,7 +76,7 @@ public class ResourceController {
@PostMapping
(
value
=
"/{apiName}/update"
,
produces
=
{
"application/javascript"
,
"application/json"
})
public
String
updateResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
@RequestParam
(
"info"
)
String
beanJson
,
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
{
@RequestParam
(
"id"
)
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
update
=
configResourceManager
.
update
(
apiName
,
beanJson
,
id
,
request
);
if
(
update
>
0
)
{
...
...
@@ -85,7 +88,7 @@ public class ResourceController {
@PostMapping
(
value
=
"/{apiName}/{id}/delete"
,
produces
=
{
"application/javascript"
,
"application/json"
})
public
String
deleteResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
@PathVariable
Long
id
,
HttpServletRequest
request
)
{
@PathVariable
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
delete
=
configResourceManager
.
delete
(
apiName
,
id
,
request
);
if
(
delete
>
0
)
{
...
...
@@ -97,7 +100,7 @@ public class ResourceController {
@PostMapping
(
value
=
"/{apiName}/batchDelete"
,
produces
=
{
"application/javascript"
,
"application/json"
})
public
String
batchDeleteResource
(
@PathVariable
(
"apiName"
)
String
apiName
,
@RequestParam
(
"ids"
)
String
ids
,
HttpServletRequest
request
)
{
@RequestParam
(
"ids"
)
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
delete
=
configResourceManager
.
batchDelete
(
apiName
,
ids
,
request
);
if
(
delete
>
0
)
{
...
...
@@ -110,7 +113,7 @@ public class ResourceController {
@GetMapping
(
value
=
"/{apiName}/checkIsNameExist"
)
public
String
checkIsNameExist
(
@PathVariable
(
"apiName"
)
String
apiName
,
@RequestParam
Long
id
,
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
objectMap
=
new
HashMap
<
String
,
Object
>();
int
exist
=
configResourceManager
.
checkIsNameExist
(
apiName
,
id
,
name
);
if
(
exist
>
0
)
{
...
...
src/main/java/com/jsh/erp/service/CommonQueryManager.java
View file @
10fa40f5
package
com.jsh.erp.service
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.Log
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.mappers.LogMapper
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.springframework.stereotype.Service
;
...
...
@@ -12,12 +9,9 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
static
com
.
jsh
.
erp
.
utils
.
Tools
.
getLocalIp
;
/**
* @author jishenghua 752718920 2018-10-7 15:25:58
*/
...
...
@@ -36,7 +30,7 @@ public class CommonQueryManager {
* @param apiName 接口名称
* @param id ID
*/
public
Object
selectOne
(
String
apiName
,
String
id
)
{
public
Object
selectOne
(
String
apiName
,
String
id
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
)
&&
StringUtil
.
isNotEmpty
(
id
))
{
return
container
.
getCommonQuery
(
apiName
).
selectOne
(
id
);
}
...
...
@@ -49,7 +43,7 @@ public class CommonQueryManager {
* @param parameterMap
* @return
*/
public
List
<?>
select
(
String
apiName
,
Map
<
String
,
String
>
parameterMap
)
{
public
List
<?>
select
(
String
apiName
,
Map
<
String
,
String
>
parameterMap
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
select
(
parameterMap
);
}
...
...
@@ -62,7 +56,7 @@ public class CommonQueryManager {
* @param parameterMap
* @return
*/
public
Long
counts
(
String
apiName
,
Map
<
String
,
String
>
parameterMap
)
{
public
Long
counts
(
String
apiName
,
Map
<
String
,
String
>
parameterMap
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
counts
(
parameterMap
);
}
...
...
@@ -76,7 +70,7 @@ public class CommonQueryManager {
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insert
(
String
apiName
,
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insert
(
String
apiName
,
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
logService
.
insertLog
(
apiName
,
BusinessConstants
.
LOG_OPERATION_TYPE_ADD
,
request
);
return
container
.
getCommonQuery
(
apiName
).
insert
(
beanJson
,
request
);
...
...
@@ -92,7 +86,7 @@ public class CommonQueryManager {
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
update
(
String
apiName
,
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
{
public
int
update
(
String
apiName
,
String
beanJson
,
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
logService
.
insertLog
(
apiName
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_EDIT
).
append
(
id
).
toString
(),
request
);
...
...
@@ -108,7 +102,7 @@ public class CommonQueryManager {
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
delete
(
String
apiName
,
Long
id
,
HttpServletRequest
request
)
{
public
int
delete
(
String
apiName
,
Long
id
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
logService
.
insertLog
(
apiName
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_DELETE
).
append
(
id
).
toString
(),
request
);
...
...
@@ -124,7 +118,7 @@ public class CommonQueryManager {
* @return
*/
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDelete
(
String
apiName
,
String
ids
,
HttpServletRequest
request
)
{
public
int
batchDelete
(
String
apiName
,
String
ids
,
HttpServletRequest
request
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
logService
.
insertLog
(
apiName
,
"批量删除,id集:"
+
ids
,
request
);
return
container
.
getCommonQuery
(
apiName
).
batchDelete
(
ids
);
...
...
@@ -139,7 +133,7 @@ public class CommonQueryManager {
* @param name
* @return
*/
public
int
checkIsNameExist
(
String
apiName
,
Long
id
,
String
name
)
{
public
int
checkIsNameExist
(
String
apiName
,
Long
id
,
String
name
)
throws
Exception
{
if
(
StringUtil
.
isNotEmpty
(
apiName
))
{
return
container
.
getCommonQuery
(
apiName
).
checkIsNameExist
(
id
,
name
);
}
...
...
src/main/java/com/jsh/erp/service/ICommonQuery.java
View file @
10fa40f5
...
...
@@ -18,7 +18,7 @@ public interface ICommonQuery {
* @param condition 资源id
* @return 资源
*/
Object
selectOne
(
String
condition
);
Object
selectOne
(
String
condition
)
throws
Exception
;
/**
* 自定义查询
...
...
@@ -26,7 +26,7 @@ public interface ICommonQuery {
* @param parameterMap 查询参数
* @return 查询结果
*/
List
<?>
select
(
Map
<
String
,
String
>
parameterMap
);
List
<?>
select
(
Map
<
String
,
String
>
parameterMap
)
throws
Exception
;
/**
* 查询数量
...
...
@@ -34,7 +34,7 @@ public interface ICommonQuery {
* @param parameterMap 查询参数
* @return 查询结果
*/
Long
counts
(
Map
<
String
,
String
>
parameterMap
);
Long
counts
(
Map
<
String
,
String
>
parameterMap
)
throws
Exception
;
/**
* 新增数据
...
...
@@ -42,7 +42,7 @@ public interface ICommonQuery {
* @param beanJson
* @return
*/
int
insert
(
String
beanJson
,
HttpServletRequest
request
);
int
insert
(
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
;
/**
* 更新数据
...
...
@@ -50,7 +50,7 @@ public interface ICommonQuery {
* @param beanJson
* @return
*/
int
update
(
String
beanJson
,
Long
id
);
int
update
(
String
beanJson
,
Long
id
)
throws
Exception
;
/**
* 删除数据
...
...
@@ -58,7 +58,7 @@ public interface ICommonQuery {
* @param id
* @return
*/
int
delete
(
Long
id
);
int
delete
(
Long
id
)
throws
Exception
;
/**
* 批量删除数据
...
...
@@ -66,7 +66,7 @@ public interface ICommonQuery {
* @param ids
* @return
*/
int
batchDelete
(
String
ids
);
int
batchDelete
(
String
ids
)
throws
Exception
;
/**
* 查询名称是否存在
...
...
@@ -74,5 +74,5 @@ public interface ICommonQuery {
* @param id
* @return
*/
int
checkIsNameExist
(
Long
id
,
String
name
);
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/com/jsh/erp/service/account/AccountComponent.java
View file @
10fa40f5
package
com.jsh.erp.service.account
;
import
com.jsh.erp.service.ICommonQuery
;
import
com.jsh.erp.service.depot.DepotResource
;
import
com.jsh.erp.service.depot.DepotService
;
import
com.jsh.erp.utils.Constants
;
import
com.jsh.erp.utils.QueryUtils
;
import
com.jsh.erp.utils.StringUtil
;
...
...
@@ -26,11 +24,11 @@ public class AccountComponent implements ICommonQuery {
}
@Override
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
{
public
List
<?>
select
(
Map
<
String
,
String
>
map
)
throws
Exception
{
return
getAccountList
(
map
);
}
private
List
<?>
getAccountList
(
Map
<
String
,
String
>
map
)
{
private
List
<?>
getAccountList
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
serialNo
=
StringUtil
.
getInfo
(
search
,
"serialNo"
);
...
...
@@ -40,7 +38,7 @@ public class AccountComponent implements ICommonQuery {
}
@Override
public
Long
counts
(
Map
<
String
,
String
>
map
)
{
public
Long
counts
(
Map
<
String
,
String
>
map
)
throws
Exception
{
String
search
=
map
.
get
(
Constants
.
SEARCH
);
String
name
=
StringUtil
.
getInfo
(
search
,
"name"
);
String
serialNo
=
StringUtil
.
getInfo
(
search
,
"serialNo"
);
...
...
@@ -49,27 +47,27 @@ public class AccountComponent implements ICommonQuery {
}
@Override
public
int
insert
(
String
beanJson
,
HttpServletRequest
request
)
{
public
int
insert
(
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
return
accountService
.
insertAccount
(
beanJson
,
request
);
}
@Override
public
int
update
(
String
beanJson
,
Long
id
)
{
public
int
update
(
String
beanJson
,
Long
id
)
throws
Exception
{
return
accountService
.
updateAccount
(
beanJson
,
id
);
}
@Override
public
int
delete
(
Long
id
)
{
public
int
delete
(
Long
id
)
throws
Exception
{
return
accountService
.
deleteAccount
(
id
);
}
@Override
public
int
batchDelete
(
String
ids
)
{
public
int
batchDelete
(
String
ids
)
throws
Exception
{
return
accountService
.
batchDeleteAccount
(
ids
);
}
@Override
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
public
int
checkIsNameExist
(
Long
id
,
String
name
)
throws
Exception
{
return
accountService
.
checkIsNameExist
(
id
,
name
);
}
...
...
src/main/java/com/jsh/erp/service/account/AccountService.java
View file @
10fa40f5
This diff is collapsed.
Click to expand it.
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