Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
extend
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
park
extend
Commits
bf880f12
Commit
bf880f12
authored
Jun 24, 2020
by
lixian7
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
业务异常编码调整
parent
ebf155a6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
36 deletions
+87
-36
api/src/main/java/com/hikcreate/edl/pub/web/mobile/api/controller/BindInfoControlller.java
+5
-4
api/src/main/java/com/hikcreate/edl/pub/web/mobile/api/exception/GlobalExceptionHandler.java
+5
-5
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/impl/BindServiceImpl.java
+3
-2
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ParkServiceCode.java
+31
-0
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/Result.java
+3
-2
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ResultCode.java
+37
-21
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ResultGenerator.java
+3
-2
No files found.
api/src/main/java/com/hikcreate/edl/pub/web/mobile/api/controller/BindInfoControlller.java
View file @
bf880f12
package
com
.
hikcreate
.
edl
.
pub
.
web
.
mobile
.
api
.
controller
;
import
com.hikcreate.common.orika.DefaultConverter
;
import
com.hikcreate.common.sdk.response.statuscode.StatusCode
;
import
com.hikcreate.edl.common.distributed.lock.exception.DistributedLockException
;
import
com.hikcreate.edl.pub.web.mobile.domain.IBindService
;
import
com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result
;
...
...
@@ -60,10 +61,10 @@ public class BindInfoControlller extends BaseController {
response
=
service
.
bind
(
bindInfo
);
}
catch
(
DistributedLockException
e
)
{
log
.
error
(
"分布式锁超时"
);
return
ResultGenerator
.
fail
(
Result
Code
.
REPEAT_SUBMIT
);
return
ResultGenerator
.
fail
(
Status
Code
.
REPEAT_SUBMIT
);
}
catch
(
Exception
e
)
{
log
.
error
(
"系统异常:{}"
,
e
);
return
ResultGenerator
.
fail
(
Result
Code
.
SYSTEM_ERROR
);
return
ResultGenerator
.
fail
(
Status
Code
.
SYSTEM_ERROR
);
}
return
response
;
}
...
...
@@ -84,10 +85,10 @@ public class BindInfoControlller extends BaseController {
try
{
result
=
service
.
unbindInfo
(
req
);
}
catch
(
DistributedLockException
e
)
{
return
ResultGenerator
.
fail
(
Result
Code
.
REPEAT_SUBMIT
);
return
ResultGenerator
.
fail
(
Status
Code
.
REPEAT_SUBMIT
);
}
catch
(
Exception
e
)
{
log
.
error
(
"系统异常:{}"
,
e
);
return
ResultGenerator
.
fail
(
Result
Code
.
SYSTEM_ERROR
);
return
ResultGenerator
.
fail
(
Status
Code
.
SYSTEM_ERROR
);
}
return
result
;
}
...
...
api/src/main/java/com/hikcreate/edl/pub/web/mobile/api/exception/GlobalExceptionHandler.java
View file @
bf880f12
...
...
@@ -36,7 +36,7 @@ public class GlobalExceptionHandler {
@ResponseStatus
(
HttpStatus
.
OK
)
public
Result
handleServletRequestBindingException
(
ServletRequestBindingException
e
)
{
log
.
error
(
"param bind failure"
,
e
);
return
ResultGenerator
.
fail
(
Result
Code
.
PARAM_ERROR
);
return
ResultGenerator
.
fail
(
Status
Code
.
PARAM_ERROR
);
}
/**
...
...
@@ -59,7 +59,7 @@ public class GlobalExceptionHandler {
message
=
fieldError
.
getDefaultMessage
();
}
}
return
ResultGenerator
.
fail
(
Result
Code
.
PARAM_ERROR
.
getCode
(),
message
);
return
ResultGenerator
.
fail
(
Status
Code
.
PARAM_ERROR
.
getCode
(),
message
);
}
/**
...
...
@@ -76,16 +76,16 @@ public class GlobalExceptionHandler {
public
Result
handleValidationException
(
ConstraintViolationException
e
)
{
for
(
ConstraintViolation
<?>
s
:
e
.
getConstraintViolations
())
{
log
.
error
(
"Request parameter is invalid {}"
,
s
.
getMessage
());
return
ResultGenerator
.
fail
(
Result
Code
.
PARAM_ERROR
);
return
ResultGenerator
.
fail
(
Status
Code
.
PARAM_ERROR
);
}
return
ResultGenerator
.
fail
(
Result
Code
.
PARAM_ERROR
);
return
ResultGenerator
.
fail
(
Status
Code
.
PARAM_ERROR
);
}
@ExceptionHandler
(
value
=
RetryableException
.
class
)
@ResponseBody
public
Result
retryableExceptionHandler
(
HttpServletRequest
req
,
RetryableException
e
)
throws
Exception
{
log
.
error
(
" connect timed out"
,
e
);
return
ResultGenerator
.
fail
(
Result
Code
.
SYSTEM_ERROR
.
getCode
(),
"服务请求超时或不可用"
);
return
ResultGenerator
.
fail
(
Status
Code
.
SYSTEM_ERROR
.
getCode
(),
"服务请求超时或不可用"
);
}
/**
...
...
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/impl/BindServiceImpl.java
View file @
bf880f12
...
...
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.hikcreate.common.sdk.response.statuscode.StatusCode
;
import
com.hikcreate.edl.common.distributed.lock.annotation.DistributedLock
;
import
com.hikcreate.edl.pub.web.mobile.domain.IBindService
;
import
com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result
;
...
...
@@ -128,7 +129,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
if
(
phones
!=
null
&&
!
phones
.
isEmpty
())
{
boolean
phoneExist
=
phones
.
get
(
0
).
getUserId
().
equals
(
info
.
getUserId
());
if
(!
phoneExist
)
{
return
ResultGenerator
.
fail
(
Result
Code
.
DATA_ERROR
.
getCode
(),
"当前手机号已被其他客户绑定"
);
return
ResultGenerator
.
fail
(
Status
Code
.
DATA_ERROR
.
getCode
(),
"当前手机号已被其他客户绑定"
);
}
}
...
...
@@ -329,7 +330,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
ParkVerifyInfo
verify
=
verifyInfo
.
checkValidity
(
query
.
getPhone
(),
query
.
getUserId
(),
DateUtil
.
offsetDay
(
DateTime
.
now
(),
-
1
));
if
(
verify
==
null
)
{
return
ResultGenerator
.
fail
(
Result
Code
.
PERMISSION_DENIED
);
return
ResultGenerator
.
fail
(
Status
Code
.
PERMISSION_DENIED
);
}
/**
...
...
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ParkServiceCode.java
0 → 100644
View file @
bf880f12
package
com
.
hikcreate
.
edl
.
pub
.
web
.
mobile
.
infra
.
core
.
Result
;
import
com.hikcreate.common.sdk.response.statuscode.ServiceCode
;
/**
* @Description
* @Author lixian
* @Date 2020/6/24 14:15
**/
public
enum
ParkServiceCode
implements
ServiceCode
{
PARK_OPEN
(
2L
,
"停车对外服务"
)
;
private
long
code
;
private
String
name
;
private
ParkServiceCode
(
long
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
@Override
public
long
getCode
()
{
return
code
;
}
@Override
public
String
getName
()
{
return
name
;
}
}
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/Result.java
View file @
bf880f12
...
...
@@ -2,6 +2,7 @@ package com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import
com.hikcreate.common.sdk.exception.BusinessException
;
import
com.hikcreate.common.sdk.response.apiparam.Response
;
import
com.hikcreate.common.sdk.response.statuscode.StatusCode
;
import
lombok.Data
;
/**
...
...
@@ -23,12 +24,12 @@ public class Result<T> {
/**
* 状态码
*/
private
long
code
=
Result
Code
.
SUCCESS
.
getCode
();
private
long
code
=
Status
Code
.
SUCCESS
.
getCode
();
/**
* 描述
*/
private
String
msg
=
Result
Code
.
SUCCESS
.
getMsg
();
private
String
msg
=
Status
Code
.
SUCCESS
.
getMsg
();
/**
* 挂载数据
...
...
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ResultCode.java
View file @
bf880f12
package
com
.
hikcreate
.
edl
.
pub
.
web
.
mobile
.
infra
.
core
.
Result
;
import
com.hikcreate.common.sdk.response.statuscode.IStatusCode
;
import
com.hikcreate.common.sdk.response.statuscode.ProductCode
;
import
com.hikcreate.common.sdk.response.statuscode.StatusCodeHelper
;
import
com.hikcreate.edl.common.sdk.enums.EdlServiceCode
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
...
...
@@ -8,34 +12,46 @@ import lombok.Getter;
* @time:2020/6/24 10:28
**/
@AllArgsConstructor
@Getter
public
enum
ResultCode
{
public
enum
ResultCode
implements
IStatusCode
{
SUCCESS
(
1000
,
"操作成功"
),
/*
SUCCESS(1000, "操作成功"),
SYSTEM_ERROR(1001, "系统未知错误"),
PERMISSION_DENIED(1002, "没有权限"),
DATA_ERROR(1003, "数据错误"),
REPEAT_SUBMIT(1004, "重复提交"),
PARAM_ERROR(1005, "参数错误"),
BUSINESS_ERROR
(
1006
,
"业务错误"
),
BIND_NUM_ERROR
(
1501
,
"同一客户绑定认证不超过3辆"
),
UNBIND_TOTAL_ERROR
(
1502
,
"30天内解绑次数超过10次,不能再次绑定认证"
),
USERID_PHONE_ERROR
(
1503
,
"客户ID与手机号不一致"
),
CAR_MESSAGE_UNKNOWN
(
1504
,
"车辆信息不存在"
),
CAR_PHONE_UNMATCHED
(
1505
,
"手机号与车辆备案手机号不一致"
),
CAR_HAVE_BIND
(
1506
,
"车辆已被绑定"
),
BIND_INFO_UNKNOWN
(
1507
,
"绑定认证不存在"
),
DRIVING_LICENSE_UNKNOWN
(
1508
,
"车主驾照信息不存在"
);
/**
* 状态码
*/
private
long
code
;
/**
* 描述信息
*/
BUSINESS_ERROR(1006, "业务错误"),*/
BIND_NUM_ERROR
(
2
,
"同一客户绑定认证不超过3辆"
),
UNBIND_TOTAL_ERROR
(
3
,
"30天内解绑次数超过10次,不能再次绑定认证"
),
USERID_PHONE_ERROR
(
4
,
"客户ID与手机号不一致"
),
CAR_MESSAGE_UNKNOWN
(
5
,
"车辆信息不存在"
),
CAR_PHONE_UNMATCHED
(
6
,
"手机号与车辆备案手机号不一致"
),
CAR_HAVE_BIND
(
7
,
"车辆已被绑定"
),
BIND_INFO_UNKNOWN
(
8
,
"绑定认证不存在"
),
DRIVING_LICENSE_UNKNOWN
(
9
,
"车主驾照信息不存在"
);
private
int
customCode
;
private
String
msg
;
private
StatusCodeHelper
statusCodeHelper
=
new
StatusCodeHelper
(
ProductCode
.
PARKING
,
ParkServiceCode
.
PARK_OPEN
);
ResultCode
(
int
customCode
,
String
msg
)
{
this
.
customCode
=
customCode
;
this
.
msg
=
msg
;
}
@Override
public
long
getCode
()
{
return
statusCodeHelper
.
getCode
(
this
.
customCode
);
}
@Override
public
String
getMsg
()
{
return
this
.
msg
;
}
public
static
void
main
(
String
[]
args
)
{
for
(
ResultCode
code
:
ResultCode
.
values
()){
System
.
out
.
println
(
code
.
getMsg
()+
"----"
+
code
.
getCode
());
}
}
}
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ResultGenerator.java
View file @
bf880f12
package
com
.
hikcreate
.
edl
.
pub
.
web
.
mobile
.
infra
.
core
.
Result
;
import
com.hikcreate.common.sdk.response.statuscode.IStatusCode
;
import
com.hikcreate.common.sdk.response.statuscode.StatusCode
;
/**
...
...
@@ -33,12 +34,12 @@ public class ResultGenerator {
public
static
<
T
>
Result
<
T
>
fail
(
String
msg
)
{
Result
<
T
>
result
=
new
Result
<>();
result
.
setSuccess
(
false
);
result
.
setCode
(
Result
Code
.
BUSINESS_ERROR
.
getCode
());
result
.
setCode
(
Status
Code
.
BUSINESS_ERROR
.
getCode
());
result
.
setMsg
(
msg
);
return
result
;
}
public
static
<
T
>
Result
<
T
>
fail
(
Result
Code
statusCode
)
{
public
static
<
T
>
Result
<
T
>
fail
(
IStatus
Code
statusCode
)
{
Result
<
T
>
result
=
new
Result
<>();
result
.
setSuccess
(
false
);
result
.
setCode
(
statusCode
.
getCode
());
...
...
Write
Preview
Markdown
is supported
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