Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
e0293f14
Commit
e0293f14
authored
Sep 17, 2020
by
董建华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加异常
parent
e1b02636
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
3 deletions
+46
-3
ExceptionHandlingController.java
...antgroup/xyqb/controller/ExceptionHandlingController.java
+6
-0
AppletException.java
...in/java/cn/quantgroup/xyqb/exception/AppletException.java
+25
-0
JsonResult.java
src/main/java/cn/quantgroup/xyqb/model/JsonResult.java
+7
-0
AppletServiceImpl.java
...b/service/middleoffice/applet/impl/AppletServiceImpl.java
+8
-3
No files found.
src/main/java/cn/quantgroup/xyqb/controller/ExceptionHandlingController.java
View file @
e0293f14
...
...
@@ -158,6 +158,12 @@ public class ExceptionHandlingController implements IBaseController {
public
JsonResult
handleDataException
(
DataException
e
)
{
return
JsonResult
.
buildErrorStateResult
(
e
.
getMessage
(),
null
);
}
@ExceptionHandler
({
AppletException
.
class
})
@ResponseBody
@ResponseStatus
(
HttpStatus
.
OK
)
public
JsonResult
handleAppletException
(
AppletException
e
)
{
return
JsonResult
.
buildErrorResultWhithCode
(
e
.
getMessage
(),
e
.
getCode
());
}
@ExceptionHandler
(
BadSqlGrammarException
.
class
)
@ResponseBody
...
...
src/main/java/cn/quantgroup/xyqb/exception/AppletException.java
0 → 100644
View file @
e0293f14
package
cn
.
quantgroup
.
xyqb
.
exception
;
/**
* @author :dongjianhua
* @date :Created in 2020/9/17 14:43
* @description:小程序异常
* @modified By:
* @version: 1.0
*/
public
class
AppletException
extends
RuntimeException
{
private
String
code
;
public
AppletException
(
String
message
)
{
super
(
message
);
}
public
AppletException
(
String
message
,
String
code
)
{
super
(
message
);
this
.
code
=
code
;
}
public
String
getCode
()
{
return
code
;
}
}
src/main/java/cn/quantgroup/xyqb/model/JsonResult.java
View file @
e0293f14
...
...
@@ -102,6 +102,13 @@ public class JsonResult<T> implements Serializable {
public
static
<
T
>
JsonResult
<
T
>
buildFatalErrorStateResult
(
String
msg
,
T
data
,
Long
businessCode
)
{
return
new
JsonResult
(
msg
,
ERROR_STATE_CODE
,
data
,
businessCode
);
}
public
static
<
T
>
JsonResult
<
T
>
buildErrorResultWhithCode
(
String
msg
,
String
businessCode
)
{
JsonResult
jsonResult
=
new
JsonResult
();
jsonResult
.
setBusinessCode
(
businessCode
);
jsonResult
.
setCode
(
String
.
format
(
Constants
.
ZERO_FILL_TEMPLATE
,
SUCCESS_CODE
));
jsonResult
.
setMsg
(
msg
);
return
jsonResult
;
}
/**
* 判断当前JsonResult是否是成功
...
...
src/main/java/cn/quantgroup/xyqb/service/middleoffice/applet/impl/AppletServiceImpl.java
View file @
e0293f14
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.middleoffice.login.LoginVo;
import
cn.quantgroup.xyqb.entity.middleoffice.AppletParamEntry
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.WechatUserInfo
;
import
cn.quantgroup.xyqb.exception.AppletException
;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.repository.IWeChatUserRepository
;
import
cn.quantgroup.xyqb.service.middleoffice.applet.IAppletService
;
...
...
@@ -84,14 +85,18 @@ public class AppletServiceImpl implements IAppletService {
WechatUserInfo
wechatUserInfo
=
iWeChatUserRepository
.
findByOpenIdAndAppName
(
openId
,
appName
);
if
(
null
==
wechatUserInfo
)
{
log
.
error
(
"未找到此用户,appName:{} ,openId:{}"
,
appName
,
openId
);
throw
new
DataException
(
"未找到此用户
"
);
throw
new
AppletException
(
"未找到此用户"
,
"0401
"
);
}
if
(
null
==
wechatUserInfo
.
getUserId
())
{
log
.
error
(
"用户未绑定到xyqb,appName:{} ,openId:{}"
,
appName
,
openId
);
throw
new
DataException
(
"未找到此用户绑定信息
"
);
throw
new
AppletException
(
"未找到此用户绑定信息"
,
"0401
"
);
}
User
user
=
userService
.
findById
(
wechatUserInfo
.
getUserId
());
User
user
=
userService
.
findById
(
wechatUserInfo
.
getUserId
());
if
(
null
==
user
)
{
log
.
error
(
"未找到此用户,appName:{} ,openId:{}"
,
appName
,
openId
);
throw
new
AppletException
(
"未找到此用户"
,
"0401"
);
}
LoginVo
loginVo
=
loginModule
.
loginByUserId
(
user
.
getRegisteredFrom
(),
utmSource
==
null
?
""
:
utmSource
,
user
.
getId
());
...
...
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