Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit a1e3cfe3
由
zshaohui
编写于
2024-03-19 13:55:55 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.增加用户激活信息
2.登录验证语言展示错误处理
1 个父辈
9bbcc26b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
35 行增加
和
15 行删除
src/main/java/com/neotel/smfcore/common/exception/handler/GlobalExceptionHandler.java
src/main/java/com/neotel/smfcore/core/storage/rest/dto/StorageSearchDto.java
src/main/java/com/neotel/smfcore/core/storage/service/po/Storage.java
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
src/main/java/com/neotel/smfcore/common/exception/handler/GlobalExceptionHandler.java
查看文件 @
a1e3cfe
...
...
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.InternalAuthenticationServiceException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
...
...
@@ -90,6 +91,15 @@ public class GlobalExceptionHandler {
return
buildResponseEntity
(
ApiError
.
error
(
e
.
getStatus
(),
targetMsg
));
}
@ExceptionHandler
(
value
=
InternalAuthenticationServiceException
.
class
)
public
ResponseEntity
<
ApiError
>
internalAuthenticationServiceException
(
HttpServletRequest
servlet
,
ValidateException
e
){
// String language= servlet.getLocale().getLanguage();
// 打印堆栈信息
//log.error(ThrowableUtil.getStackTrace(e));
String
targetMsg
=
messageUtils
.
getText
(
e
.
getMsgKey
(),
e
.
getMsgParam
(),
servlet
.
getLocale
()
,
e
.
getDefaultMsg
());
return
buildResponseEntity
(
ApiError
.
error
(
e
.
getStatus
(),
targetMsg
));
}
/**
* 处理所有接口数据验证异常
*/
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/dto/StorageSearchDto.java
查看文件 @
a1e3cfe
...
...
@@ -19,6 +19,9 @@ public class StorageSearchDto implements Serializable {
@ApiModelProperty
(
"分组ID"
)
private
String
groupId
=
""
;
@ApiModelProperty
(
"分组名称"
)
private
String
groupName
=
""
;
@ApiModelProperty
(
"料仓类型"
)
private
String
type
=
""
;
}
src/main/java/com/neotel/smfcore/core/storage/service/po/Storage.java
查看文件 @
a1e3cfe
...
...
@@ -66,6 +66,11 @@ public class Storage extends BasePo implements Serializable {
private
String
groupId
=
""
;
/**
* 分组名称
*/
private
String
groupName
=
""
;
/**
* 当前绑定的入库单名称
*/
private
String
inListName
=
""
;
...
...
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
查看文件 @
a1e3cfe
...
...
@@ -17,6 +17,8 @@ package com.neotel.smfcore.security.service;
import
com.neotel.smfcore.common.exception.EntityNotFoundException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.Md5Utls
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.api.SmfApi
;
import
com.neotel.smfcore.security.rest.bean.dto.JwtUserDto
;
...
...
@@ -57,21 +59,21 @@ public class UserDetailsServiceImpl implements UserDetailsService {
if
(
user
==
null
)
{
throw
new
ValidateException
(
"smfcore.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"username"
,
username
});
}
else
{
//
if(user.getEnabled()==null){
//
throw new ValidateException("smfcore.notActivated","账号未激活");
//
}
//
if (!user.getEnabled()) {
//
throw new ValidateException("smfcore.notActivated","账号未激活");
//
}
//
if(user.getUsername().equals(Constants.SUPER_USERNAME)){
//
//
}else {
//
//判断激活码是否正确
//
String code = Md5Utls.getMd5(user.getId(), user.getCreateDate());
//
if (!code.equals(user.getCheckCode())) {
//
throw new ValidateException("smfcore.notActivated","账号未激活");
//
}
//
}
if
(
user
.
getEnabled
()==
null
){
throw
new
ValidateException
(
"smfcore.notActivated"
,
"账号未激活"
);
}
if
(!
user
.
getEnabled
())
{
throw
new
ValidateException
(
"smfcore.notActivated"
,
"账号未激活"
);
}
if
(
user
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
)){
}
else
{
//判断激活码是否正确
String
code
=
Md5Utls
.
getMd5
(
user
.
getId
(),
user
.
getCreateDate
());
if
(!
code
.
equals
(
user
.
getCheckCode
()))
{
throw
new
ValidateException
(
"smfcore.notActivated"
,
"账号未激活"
);
}
}
List
<
Long
>
dataScopes
=
new
ArrayList
<>();
jwtUserDto
=
new
JwtUserDto
(
user
,
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论