Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit d474006c
由
LN
编写于
2021-08-03 13:53:45 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
BadRequestException修改:增加国际化
1 个父辈
7cda0b7a
隐藏空白字符变更
内嵌
并排
正在显示
24 个修改的文件
包含
178 行增加
和
96 行删除
src/main/java/com/neotel/smfcore/common/exception/BadRequestException.java
src/main/java/com/neotel/smfcore/common/exception/handler/GlobalExceptionHandler.java
src/main/java/com/neotel/smfcore/common/utils/FileUtil.java
src/main/java/com/neotel/smfcore/core/barcode/rest/BarcodeController.java
src/main/java/com/neotel/smfcore/core/barcode/rest/ComponentController.java
src/main/java/com/neotel/smfcore/core/barcode/service/manager/impl/BarcodeManagerImpl.java
src/main/java/com/neotel/smfcore/core/barcode/service/manager/impl/ComponentManagerImpl.java
src/main/java/com/neotel/smfcore/core/language/config/LocaleConfig.java
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
src/main/java/com/neotel/smfcore/core/order/rest/OrderController.java
src/main/java/com/neotel/smfcore/core/storage/rest/StorageController.java
src/main/java/com/neotel/smfcore/core/storage/rest/StoragePosController.java
src/main/java/com/neotel/smfcore/core/storage/rest/dto/CheckOutDto.java
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
src/main/java/com/neotel/smfcore/security/rest/GroupController.java
src/main/java/com/neotel/smfcore/security/rest/MenuController.java
src/main/java/com/neotel/smfcore/security/rest/RoleController.java
src/main/java/com/neotel/smfcore/security/rest/UserController.java
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
src/main/java/com/neotel/smfcore/security/service/manager/impl/GroupManagerImpl.java
src/main/java/com/neotel/smfcore/security/service/manager/impl/MenuManagerImpl.java
src/main/java/com/neotel/smfcore/security/service/manager/impl/RoleManagerImpl.java
src/main/java/com/neotel/smfcore/security/service/manager/impl/UserManagerImpl.java
src/main/java/com/neotel/smfcore/common/exception/BadRequestException.java
查看文件 @
d474006
...
@@ -30,8 +30,27 @@ public class BadRequestException extends RuntimeException{
...
@@ -30,8 +30,27 @@ public class BadRequestException extends RuntimeException{
private
Integer
status
=
BAD_REQUEST
.
value
();
private
Integer
status
=
BAD_REQUEST
.
value
();
public
BadRequestException
(
String
msg
){
private
String
msgKey
=
""
;
super
(
msg
);
private
String
[]
msgParam
;
private
String
defaultMsg
=
""
;
// public BadRequestException( String defMsg){
// super(defMsg);
// this.msgKey=defMsg;
// this.msgParam=null;
// this.defaultMsg=defMsg;
// }
public
BadRequestException
(
String
msgKey
,
String
defMsg
){
super
(
defMsg
);
this
.
msgKey
=
msgKey
;
this
.
msgParam
=
null
;
this
.
defaultMsg
=
defMsg
;
}
public
BadRequestException
(
String
msgKey
,
String
defMsg
,
String
[]
msgParam
){
super
(
defMsg
);
this
.
msgKey
=
msgKey
;
this
.
msgParam
=
msgParam
;
this
.
defaultMsg
=
defMsg
;
}
}
public
BadRequestException
(
HttpStatus
status
,
String
msg
){
public
BadRequestException
(
HttpStatus
status
,
String
msg
){
...
...
src/main/java/com/neotel/smfcore/common/exception/handler/GlobalExceptionHandler.java
查看文件 @
d474006
...
@@ -5,8 +5,10 @@ import com.neotel.smfcore.common.exception.EntityExistException;
...
@@ -5,8 +5,10 @@ import com.neotel.smfcore.common.exception.EntityExistException;
import
com.neotel.smfcore.common.exception.EntityNotFoundException
;
import
com.neotel.smfcore.common.exception.EntityNotFoundException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.ThrowableUtil
;
import
com.neotel.smfcore.common.utils.ThrowableUtil
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.BadCredentialsException
;
...
@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
...
@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import
org.springframework.web.context.support.HttpRequestHandlerServlet
;
import
org.springframework.web.context.support.HttpRequestHandlerServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Locale
;
import
java.util.Objects
;
import
java.util.Objects
;
import
static
org
.
springframework
.
http
.
HttpStatus
.
BAD_REQUEST
;
import
static
org
.
springframework
.
http
.
HttpStatus
.
BAD_REQUEST
;
...
@@ -24,6 +27,8 @@ import static org.springframework.http.HttpStatus.NOT_FOUND;
...
@@ -24,6 +27,8 @@ import static org.springframework.http.HttpStatus.NOT_FOUND;
@Slf4j
@Slf4j
@RestControllerAdvice
@RestControllerAdvice
public
class
GlobalExceptionHandler
{
public
class
GlobalExceptionHandler
{
@Autowired
private
MessageUtils
messageUtils
;
/**
/**
* 处理所有不可知的异常
* 处理所有不可知的异常
*/
*/
...
@@ -53,7 +58,8 @@ public class GlobalExceptionHandler {
...
@@ -53,7 +58,8 @@ public class GlobalExceptionHandler {
String
language
=
servlet
.
getLocale
().
getLanguage
();
String
language
=
servlet
.
getLocale
().
getLanguage
();
// 打印堆栈信息
// 打印堆栈信息
log
.
error
(
ThrowableUtil
.
getStackTrace
(
e
));
log
.
error
(
ThrowableUtil
.
getStackTrace
(
e
));
return
buildResponseEntity
(
ApiError
.
error
(
e
.
getStatus
(),
e
.
getMessage
()+
servlet
.
toString
()));
String
targetMsg
=
messageUtils
.
getText
(
e
.
getMsgKey
(),
e
.
getMsgParam
(),
new
Locale
(
language
)
,
e
.
getDefaultMsg
());
return
buildResponseEntity
(
ApiError
.
error
(
e
.
getStatus
(),
targetMsg
));
}
}
/**
/**
...
...
src/main/java/com/neotel/smfcore/common/utils/FileUtil.java
查看文件 @
d474006
...
@@ -20,6 +20,7 @@ import cn.hutool.core.util.IdUtil;
...
@@ -20,6 +20,7 @@ import cn.hutool.core.util.IdUtil;
import
cn.hutool.poi.excel.BigExcelWriter
;
import
cn.hutool.poi.excel.BigExcelWriter
;
import
cn.hutool.poi.excel.ExcelUtil
;
import
cn.hutool.poi.excel.ExcelUtil
;
import
com.neotel.smfcore.common.exception.BadRequestException
;
import
com.neotel.smfcore.common.exception.BadRequestException
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
org.apache.poi.util.IOUtils
;
import
org.apache.poi.util.IOUtils
;
import
org.apache.poi.xssf.streaming.SXSSFSheet
;
import
org.apache.poi.xssf.streaming.SXSSFSheet
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -254,7 +255,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
...
@@ -254,7 +255,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
// 1M
// 1M
int
len
=
1024
*
1024
;
int
len
=
1024
*
1024
;
if
(
size
>
(
maxSize
*
len
))
{
if
(
size
>
(
maxSize
*
len
))
{
throw
new
BadRequestException
(
"文件超出规定大小"
);
throw
new
BadRequestException
(
"
smfcode.fileToLong"
,
"
文件超出规定大小"
);
}
}
}
}
...
...
src/main/java/com/neotel/smfcore/core/barcode/rest/BarcodeController.java
查看文件 @
d474006
...
@@ -89,7 +89,7 @@ public class BarcodeController {
...
@@ -89,7 +89,7 @@ public class BarcodeController {
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
BarcodeDto
resources
)
{
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
BarcodeDto
resources
)
{
Barcode
barcode
=
barcodeMapper
.
toEntity
(
resources
);
Barcode
barcode
=
barcodeMapper
.
toEntity
(
resources
);
if
(
barcode
.
getId
()
==
null
)
{
if
(
barcode
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"
修改条码:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
barcodeManager
.
saveBarcode
(
barcode
);
barcodeManager
.
saveBarcode
(
barcode
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
...
@@ -102,7 +102,7 @@ public class BarcodeController {
...
@@ -102,7 +102,7 @@ public class BarcodeController {
List
<
Barcode
>
barcodes
=
new
ArrayList
<
Barcode
>();
List
<
Barcode
>
barcodes
=
new
ArrayList
<
Barcode
>();
for
(
String
id
:
ids
)
{
for
(
String
id
:
ids
)
{
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
new
BadRequestException
(
"
删除条码:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
}
}
barcodeManager
.
deleteBarcodes
(
ids
);
barcodeManager
.
deleteBarcodes
(
ids
);
...
@@ -123,13 +123,13 @@ public class BarcodeController {
...
@@ -123,13 +123,13 @@ public class BarcodeController {
@PreAuthorize
(
"@el.check('barcode:setting')"
)
@PreAuthorize
(
"@el.check('barcode:setting')"
)
public
ResponseEntity
<
Object
>
updateSetting
(
@Validated
@RequestBody
BarcodeSettingDto
settingDto
)
{
public
ResponseEntity
<
Object
>
updateSetting
(
@Validated
@RequestBody
BarcodeSettingDto
settingDto
)
{
if
(
settingDto
.
getCodeRuleList
().
isEmpty
()){
if
(
settingDto
.
getCodeRuleList
().
isEmpty
()){
throw
new
BadRequestException
(
"
条码规则不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"codeRuleList"
}
);
}
}
if
(
settingDto
.
getPageHeight
()==
null
){
if
(
settingDto
.
getPageHeight
()==
null
){
throw
new
BadRequestException
(
"
纸张高度不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"pageHeight"
}
);
}
}
if
(
settingDto
.
getPageWidth
()==
null
){
if
(
settingDto
.
getPageWidth
()==
null
){
throw
new
BadRequestException
(
"
纸张宽度不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"pageWidth"
}
);
}
}
Settings
settings
=
dataCache
.
getSettings
();
Settings
settings
=
dataCache
.
getSettings
();
settings
.
setCodeRuleList
(
settingDto
.
getCodeRuleList
());
settings
.
setCodeRuleList
(
settingDto
.
getCodeRuleList
());
...
@@ -146,7 +146,7 @@ public class BarcodeController {
...
@@ -146,7 +146,7 @@ public class BarcodeController {
String
image
=
"csv"
;
String
image
=
"csv"
;
String
fileType
=
FileUtil
.
getExtensionName
(
uploadFile
.
getOriginalFilename
());
String
fileType
=
FileUtil
.
getExtensionName
(
uploadFile
.
getOriginalFilename
());
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
)){
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
)){
throw
new
BadRequestException
(
"
文件格式错误!, 仅支持 "
+
image
+
" 格式"
);
throw
new
BadRequestException
(
"
smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
image
}
);
}
}
File
folder
=
new
File
(
properties
.
getPath
(),
"pos"
);
File
folder
=
new
File
(
properties
.
getPath
(),
"pos"
);
File
file
=
FileUtil
.
upload
(
uploadFile
,
folder
.
getAbsolutePath
());
File
file
=
FileUtil
.
upload
(
uploadFile
,
folder
.
getAbsolutePath
());
...
...
src/main/java/com/neotel/smfcore/core/barcode/rest/ComponentController.java
查看文件 @
d474006
...
@@ -70,7 +70,7 @@ public class ComponentController {
...
@@ -70,7 +70,7 @@ public class ComponentController {
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
ComponentDto
resources
)
{
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
ComponentDto
resources
)
{
Component
component
=
componentMapper
.
toEntity
(
resources
);
Component
component
=
componentMapper
.
toEntity
(
resources
);
if
(
component
.
getId
()
==
null
)
{
if
(
component
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"
修改条码:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
componentManager
.
saveComponent
(
component
);
componentManager
.
saveComponent
(
component
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
...
@@ -83,7 +83,7 @@ public class ComponentController {
...
@@ -83,7 +83,7 @@ public class ComponentController {
List
<
Component
>
Components
=
new
ArrayList
<
Component
>();
List
<
Component
>
Components
=
new
ArrayList
<
Component
>();
for
(
String
id
:
ids
)
{
for
(
String
id
:
ids
)
{
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
new
BadRequestException
(
"
删除元器件:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
}
}
componentManager
.
deleteComponents
(
ids
);
componentManager
.
deleteComponents
(
ids
);
...
...
src/main/java/com/neotel/smfcore/core/barcode/service/manager/impl/BarcodeManagerImpl.java
查看文件 @
d474006
...
@@ -109,7 +109,7 @@ public class BarcodeManagerImpl implements IBarcodeManager {
...
@@ -109,7 +109,7 @@ public class BarcodeManagerImpl implements IBarcodeManager {
//readID不能重复
//readID不能重复
Barcode
data
=
barcodeDao
.
findOne
(
query
);
Barcode
data
=
barcodeDao
.
findOne
(
query
);
if
(
data
!=
null
){
if
(
data
!=
null
){
throw
new
BadRequestException
(
"条码["
+
resources
.
getBarcode
()+
"]已存在"
);
throw
new
BadRequestException
(
"
smfcode.codeExist"
,
"
条码["
+
resources
.
getBarcode
()+
"]已存在"
);
}
}
if
(
resources
.
getProvider
()==
null
){
if
(
resources
.
getProvider
()==
null
){
...
@@ -177,22 +177,26 @@ public class BarcodeManagerImpl implements IBarcodeManager {
...
@@ -177,22 +177,26 @@ public class BarcodeManagerImpl implements IBarcodeManager {
protected
void
validateSave
(
Barcode
barcode
)
throws
BadRequestException
{
protected
void
validateSave
(
Barcode
barcode
)
throws
BadRequestException
{
if
(
barcode
.
getBarcode
()==
null
)
{
if
(
barcode
.
getBarcode
()==
null
)
{
throw
new
ValidateException
(
"barcode.error.empty"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"barcode"
}
);
// throw new ValidateException("barcode.error.empty");
}
}
if
(
barcode
.
getPartNumber
()==
null
)
{
if
(
barcode
.
getPartNumber
()==
null
)
{
throw
new
BadRequestException
(
"["
+
barcode
.
getBarcode
()+
"]barcode.error.partNumber.empty"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"partNumber"
}
);
// throw new BadRequestException("["+barcode.getBarcode()+"]barcode.error.partNumber.empty");
}
}
if
(
barcode
.
getBatch
()
==
null
)
{
if
(
barcode
.
getBatch
()
==
null
)
{
throw
new
BadRequestException
(
"批次不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"batch"
}
);
// throw new BadRequestException("批次不能为空");
}
}
if
(
barcode
.
getAmount
()
<
0
)
{
if
(
barcode
.
getAmount
()
<
0
)
{
throw
new
BadRequestException
(
"["
+
barcode
.
getBarcode
()+
"]barcode.error.amount.negative"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"batch"
}
);
// throw new BadRequestException("["+barcode.getBarcode()+"]barcode.error.amount.negative" );
}
}
if
(!
validateUnique
(
barcode
))
{
if
(!
validateUnique
(
barcode
))
{
throw
new
BadRequestException
(
"["
+
barcode
.
getBarcode
()+
"]barcode.error.unique"
);
//
throw new BadRequestException("["+barcode.getBarcode()+"]barcode.error.unique" );
}
}
if
(!
validateComponent
(
barcode
))
{
if
(!
validateComponent
(
barcode
))
{
throw
new
BadRequestException
(
"["
+
barcode
.
getBarcode
()+
"]barcode.error.component.notExist"
);
//
throw new BadRequestException("["+barcode.getBarcode()+"]barcode.error.component.notExist" );
}
}
}
}
protected
boolean
validateUnique
(
Barcode
barcode
)
{
protected
boolean
validateUnique
(
Barcode
barcode
)
{
...
...
src/main/java/com/neotel/smfcore/core/barcode/service/manager/impl/ComponentManagerImpl.java
查看文件 @
d474006
...
@@ -124,7 +124,8 @@ public class ComponentManagerImpl implements IComponentManager {
...
@@ -124,7 +124,8 @@ public class ComponentManagerImpl implements IComponentManager {
public
Component
saveComponent
(
Component
resources
)
{
public
Component
saveComponent
(
Component
resources
)
{
if
(
resources
.
getPartNumber
()==
null
){
if
(
resources
.
getPartNumber
()==
null
){
throw
new
BadRequestException
(
"料号不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"partNumber"
}
);
// throw new BadRequestException("料号不能为空");
}
}
if
(
resources
.
getProvider
()==
null
){
if
(
resources
.
getProvider
()==
null
){
resources
.
setProvider
(
""
);
resources
.
setProvider
(
""
);
...
@@ -150,7 +151,8 @@ public class ComponentManagerImpl implements IComponentManager {
...
@@ -150,7 +151,8 @@ public class ComponentManagerImpl implements IComponentManager {
}
}
Component
com
=
componentDao
.
findOne
(
new
Query
(
c
));
Component
com
=
componentDao
.
findOne
(
new
Query
(
c
));
if
(
com
!=
null
)
{
if
(
com
!=
null
)
{
throw
new
BadRequestException
(
"料号["
+
resources
.
getPartNumber
()+
"]已存在"
);
throw
new
BadRequestException
(
"smfcode.valueAlreadyExist"
,
"{0}[{1}]已存在"
,
new
String
[]{
"partNumber"
,
resources
.
getPartNumber
()});
// throw new BadRequestException("料号["+resources.getPartNumber()+"]已存在");
}
}
resources
=
componentDao
.
save
(
resources
);
resources
=
componentDao
.
save
(
resources
);
...
...
src/main/java/com/neotel/smfcore/core/language/config/LocaleConfig.java
查看文件 @
d474006
...
@@ -20,7 +20,7 @@ public class LocaleConfig {
...
@@ -20,7 +20,7 @@ public class LocaleConfig {
/**
/**
* 默认解析器 其中locale表示默认语言
* 默认解析器 其中locale表示默认语言
*/
*/
@Bean
//
@Bean
public
LocaleResolver
localeResolver
()
{
public
LocaleResolver
localeResolver
()
{
SessionLocaleResolver
localeResolver
=
new
SessionLocaleResolver
();
SessionLocaleResolver
localeResolver
=
new
SessionLocaleResolver
();
localeResolver
.
setDefaultLocale
(
Locale
.
CHINESE
);
localeResolver
.
setDefaultLocale
(
Locale
.
CHINESE
);
...
...
src/main/java/com/neotel/smfcore/core/language/util/MessageUtils.java
查看文件 @
d474006
...
@@ -4,6 +4,7 @@ import org.springframework.context.MessageSource;
...
@@ -4,6 +4,7 @@ import org.springframework.context.MessageSource;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.text.MessageFormat
;
import
java.util.Locale
;
import
java.util.Locale
;
/**
/**
...
@@ -25,10 +26,12 @@ public class MessageUtils {
...
@@ -25,10 +26,12 @@ public class MessageUtils {
public
String
getText
(
String
msgKey
,
String
[]
params
,
Locale
locale
,
String
defaultMsg
)
{
public
String
getText
(
String
msgKey
,
String
[]
params
,
Locale
locale
,
String
defaultMsg
)
{
try
{
try
{
if
(
params
!=
null
)
{
if
(
params
==
null
)
{
return
messageSource
.
getMessage
(
msgKey
,
params
,
locale
);
return
defaultMsg
;
// return messageSource.getMessage(msgKey, params, locale);
}
else
{
}
else
{
return
messageSource
.
getMessage
(
msgKey
,
new
String
[]{},
locale
);
return
MessageFormat
.
format
(
defaultMsg
,
params
);
// return messageSource.getMessage(msgKey, new String[]{}, locale);
}
}
}
catch
(
Exception
ex
){
}
catch
(
Exception
ex
){
if
(
defaultMsg
!=
null
){
if
(
defaultMsg
!=
null
){
...
...
src/main/java/com/neotel/smfcore/core/order/rest/OrderController.java
查看文件 @
d474006
...
@@ -99,14 +99,15 @@ public class OrderController {
...
@@ -99,14 +99,15 @@ public class OrderController {
String
image
=
"csv"
;
String
image
=
"csv"
;
String
fileType
=
FileUtil
.
getExtensionName
(
orderFile
.
getOriginalFilename
());
String
fileType
=
FileUtil
.
getExtensionName
(
orderFile
.
getOriginalFilename
());
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
))
{
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
))
{
throw
new
BadRequestException
(
"
文件格式错误!, 仅支持 "
+
image
+
" 格式"
);
throw
new
BadRequestException
(
"
smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
image
}
);
}
}
File
folder
=
new
File
(
properties
.
getPath
(),
"pos"
);
File
folder
=
new
File
(
properties
.
getPath
(),
"pos"
);
File
localFile
=
FileUtil
.
upload
(
orderFile
,
folder
.
getAbsolutePath
());
File
localFile
=
FileUtil
.
upload
(
orderFile
,
folder
.
getAbsolutePath
());
List
<
LiteOrderItem
>
liteOrderItems
=
handleOrderCsv
(
localFile
.
getAbsolutePath
());
List
<
LiteOrderItem
>
liteOrderItems
=
handleOrderCsv
(
localFile
.
getAbsolutePath
());
if
(
liteOrderItems
==
null
||
liteOrderItems
.
size
()
<=
0
)
{
if
(
liteOrderItems
==
null
||
liteOrderItems
.
size
()
<=
0
)
{
throw
new
BadRequestException
(
"文件解析失败"
);
throw
new
BadRequestException
(
"smfcode.fileError"
,
"文件解析失败"
);
}
}
LiteOrder
liteOrder
=
new
LiteOrder
(
localFile
.
getName
(),
liteOrderItems
);
LiteOrder
liteOrder
=
new
LiteOrder
(
localFile
.
getName
(),
liteOrderItems
);
...
@@ -120,7 +121,9 @@ public class OrderController {
...
@@ -120,7 +121,9 @@ public class OrderController {
// TaskService.liteOrderMap.put(liteOrder.getOrderNo(), liteOrder);
// TaskService.liteOrderMap.put(liteOrder.getOrderNo(), liteOrder);
}
else
{
}
else
{
log
.
info
(
"数据库中已存在工单号为["
+
liteOrder
.
getOrderNo
()
+
"],忽略文件:"
+
localFile
.
getAbsolutePath
());
log
.
info
(
"数据库中已存在工单号为["
+
liteOrder
.
getOrderNo
()
+
"],忽略文件:"
+
localFile
.
getAbsolutePath
());
throw
new
BadRequestException
(
"工单号["
+
liteOrder
.
getOrderNo
()
+
"]已存在"
);
throw
new
BadRequestException
(
"smfcode.valueAlreadyExist"
,
"{0}[{1}]已存在"
,
new
String
[]{
"orderNo"
,
liteOrder
.
getOrderNo
()});
// throw new BadRequestException("工单号[" + liteOrder.getOrderNo() + "]已存在");
}
}
return
ResultBean
.
newOkResult
(
"工单上传成功"
);
return
ResultBean
.
newOkResult
(
"工单上传成功"
);
...
@@ -132,11 +135,12 @@ public class OrderController {
...
@@ -132,11 +135,12 @@ public class OrderController {
public
ResultBean
delete
(
@RequestBody
Map
<
String
,
String
>
mapValues
)
{
public
ResultBean
delete
(
@RequestBody
Map
<
String
,
String
>
mapValues
)
{
String
orderNo
=
mapValues
.
get
(
"orderNo"
);
String
orderNo
=
mapValues
.
get
(
"orderNo"
);
if
(
orderNo
==
null
)
{
if
(
orderNo
==
null
)
{
throw
new
BadRequestException
(
"工单号不能为空"
);
// throw new BadRequestException("工单号不能为空");
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"orderNo"
}
);
}
}
LiteOrder
liteOrder
=
liteOrderManager
.
findByOrderNo
(
orderNo
);
LiteOrder
liteOrder
=
liteOrderManager
.
findByOrderNo
(
orderNo
);
if
(
liteOrder
==
null
)
{
if
(
liteOrder
==
null
)
{
throw
new
BadRequestException
(
"
未找到工单:"
+
orderNo
);
throw
new
BadRequestException
(
"
smfcode.valueNotFind"
,
"未找到{0}[{1}]"
,
new
String
[]{
"orderNo"
,
orderNo
}
);
}
}
// ResultBean resultBean = liteOrderCache.checkOutOrder(liteOrder);
// ResultBean resultBean = liteOrderCache.checkOutOrder(liteOrder);
String
result
=
liteOrderCache
.
checkOutLiteOrder
(
orderNo
,
false
);
String
result
=
liteOrderCache
.
checkOutLiteOrder
(
orderNo
,
false
);
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/StorageController.java
查看文件 @
d474006
...
@@ -101,7 +101,7 @@ public class StorageController {
...
@@ -101,7 +101,7 @@ public class StorageController {
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
StorageDto
resources
)
{
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
StorageDto
resources
)
{
Storage
Storage
=
storageMapper
.
toEntity
(
resources
);
Storage
Storage
=
storageMapper
.
toEntity
(
resources
);
if
(
Storage
.
getId
()
==
null
)
{
if
(
Storage
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"
修改条码:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
saveStorage
(
Storage
);
saveStorage
(
Storage
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
...
@@ -116,7 +116,7 @@ public class StorageController {
...
@@ -116,7 +116,7 @@ public class StorageController {
for
(
String
id
:
ids
)
{
for
(
String
id
:
ids
)
{
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
new
BadRequestException
(
"
删除料仓:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
}
}
deleteStorages
(
ids
);
deleteStorages
(
ids
);
...
@@ -138,7 +138,8 @@ public class StorageController {
...
@@ -138,7 +138,8 @@ public class StorageController {
if
(
pos
.
getBarcode
()
==
null
||
pos
.
getBarcode
().
equals
(
""
))
{
if
(
pos
.
getBarcode
()
==
null
||
pos
.
getBarcode
().
equals
(
""
))
{
}
else
{
}
else
{
throw
new
BadRequestException
(
"料仓["
+
storage
.
getName
()
+
"]的库位["
+
pos
.
getPosName
()
+
"]有料["
+
pos
.
getBarcode
()
+
"],删除失败"
);
throw
new
BadRequestException
(
"smfcode.posIsused"
,
"料仓[{0}]的库位[{1}}]有料[{2}],删除失败"
,
new
String
[]{
storage
.
getName
()
,
pos
.
getPosName
(),
pos
.
getBarcode
().
getBarcode
()});
// throw new BadRequestException("料仓[" + storage.getName() + "]的库位[" + pos.getPosName() + "]有料[" + pos.getBarcode() + "],删除失败");
}
}
}
}
}
}
...
@@ -152,13 +153,17 @@ public class StorageController {
...
@@ -152,13 +153,17 @@ public class StorageController {
}
}
private
Storage
saveStorage
(
Storage
storage
)
{
private
Storage
saveStorage
(
Storage
storage
)
{
if
(
storage
.
getName
()==
null
){
if
(
storage
.
getName
()==
null
){
throw
new
BadRequestException
(
"料仓名称不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"name"
}
);
// throw new BadRequestException("料仓名称不能为空");
}
if
(
storage
.
getCid
()==
null
){
}
if
(
storage
.
getCid
()==
null
){
throw
new
BadRequestException
(
"料仓编号不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"cid"
}
);
// throw new BadRequestException("料仓编号不能为空");
}
if
(
storage
.
getType
()==
null
){
}
if
(
storage
.
getType
()==
null
){
throw
new
BadRequestException
(
"料仓类型不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"type"
}
);
// throw new BadRequestException("料仓类型不能为空");
}
if
(
storage
.
getCompatibleType
()==
null
){
}
if
(
storage
.
getCompatibleType
()==
null
){
throw
new
BadRequestException
(
"料仓兼容性不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"compatibleType"
}
);
// throw new BadRequestException("料仓兼容性不能为空");
}
}
boolean
isNew
=(
storage
.
getId
()==
null
);
boolean
isNew
=(
storage
.
getId
()==
null
);
...
@@ -169,10 +174,12 @@ public class StorageController {
...
@@ -169,10 +174,12 @@ public class StorageController {
if
(
isNew
||
(!
storage
.
getId
().
equals
(
s
.
getId
())))
{
if
(
isNew
||
(!
storage
.
getId
().
equals
(
s
.
getId
())))
{
if
(
s
.
getCid
().
equals
(
storage
.
getCid
())){
if
(
s
.
getCid
().
equals
(
storage
.
getCid
())){
throw
new
BadRequestException
(
"料仓cid["
+
storage
.
getCid
()+
"]已存在"
);
throw
new
BadRequestException
(
"smfcode.valueAlreadyExist"
,
"{0}[{1}]已存在"
,
new
String
[]{
"cid"
,
storage
.
getCid
()});
// throw new BadRequestException("料仓cid["+storage.getCid()+"]已存在");
}
}
else
if
(
s
.
getName
().
equals
(
storage
.
getName
())){
else
if
(
s
.
getName
().
equals
(
storage
.
getName
())){
throw
new
BadRequestException
(
"料仓名称["
+
storage
.
getCid
()+
"]已存在"
);
throw
new
BadRequestException
(
"smfcode.valueAlreadyExist"
,
"{0}[{1}]已存在"
,
new
String
[]{
"name"
,
storage
.
getName
()});
// throw new BadRequestException("料仓名称["+storage.getCid()+"]已存在");
}
}
}
}
}
}
...
@@ -197,7 +204,7 @@ public class StorageController {
...
@@ -197,7 +204,7 @@ public class StorageController {
String
image
=
"csv"
;
String
image
=
"csv"
;
String
fileType
=
FileUtil
.
getExtensionName
(
uploadFile
.
getOriginalFilename
());
String
fileType
=
FileUtil
.
getExtensionName
(
uploadFile
.
getOriginalFilename
());
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
)){
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
)){
throw
new
BadRequestException
(
"
文件格式错误!, 仅支持 "
+
image
+
" 格式"
);
throw
new
BadRequestException
(
"
smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
image
}
);
}
}
File
folder
=
new
File
(
properties
.
getPath
(),
"pos"
);
File
folder
=
new
File
(
properties
.
getPath
(),
"pos"
);
File
file
=
FileUtil
.
upload
(
uploadFile
,
folder
.
getAbsolutePath
());
File
file
=
FileUtil
.
upload
(
uploadFile
,
folder
.
getAbsolutePath
());
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/StoragePosController.java
查看文件 @
d474006
...
@@ -78,7 +78,8 @@ public class StoragePosController {
...
@@ -78,7 +78,8 @@ public class StoragePosController {
log
.
info
(
"开始清理料仓["
+
cid
+
"] 所有位置"
);
log
.
info
(
"开始清理料仓["
+
cid
+
"] 所有位置"
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
==
null
){
if
(
storage
==
null
){
throw
new
BadRequestException
(
"未找到料仓:"
+
cid
);
throw
new
BadRequestException
(
"smfcode.valueNotFind"
,
"未找到{0}[{1}]"
,
new
String
[]{
"cid"
,
cid
});
// throw new BadRequestException("未找到料仓:"+cid);
}
}
storagePosManager
.
removePosByStorageId
(
storage
.
getId
());
storagePosManager
.
removePosByStorageId
(
storage
.
getId
());
log
.
info
(
"清理料仓["
+
cid
+
"] 所有位置完成"
);
log
.
info
(
"清理料仓["
+
cid
+
"] 所有位置完成"
);
...
@@ -98,11 +99,12 @@ public class StoragePosController {
...
@@ -98,11 +99,12 @@ public class StoragePosController {
@PreAuthorize
(
"@el.check('storage:edit')"
)
@PreAuthorize
(
"@el.check('storage:edit')"
)
public
ResponseEntity
<
Object
>
enabledPos
(
@RequestBody
StoragePosEnabledDto
enabledDto
)
{
public
ResponseEntity
<
Object
>
enabledPos
(
@RequestBody
StoragePosEnabledDto
enabledDto
)
{
if
(
enabledDto
.
getId
()==
null
){
if
(
enabledDto
.
getId
()==
null
){
throw
new
BadRequestException
(
"
库位ID为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
StoragePos
pos
=
storagePosDao
.
findOneById
(
enabledDto
.
getId
());
StoragePos
pos
=
storagePosDao
.
findOneById
(
enabledDto
.
getId
());
if
(
pos
==
null
){
if
(
pos
==
null
){
throw
new
BadRequestException
(
"未找到库位 "
);
throw
new
BadRequestException
(
"smfcode.valueNotFind"
,
"未找到{0}[{1}]"
,
new
String
[]{
"PosId"
,
enabledDto
.
getId
()});
// throw new BadRequestException("未找到库位 ");
}
}
pos
.
setEnabled
(
enabledDto
.
isEnabled
());
pos
.
setEnabled
(
enabledDto
.
isEnabled
());
storagePosDao
.
save
(
pos
);
storagePosDao
.
save
(
pos
);
...
@@ -117,14 +119,15 @@ public class StoragePosController {
...
@@ -117,14 +119,15 @@ public class StoragePosController {
@PreAuthorize
(
"@el.check('storage:edit')"
)
@PreAuthorize
(
"@el.check('storage:edit')"
)
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
StoragePosSaveDto
saveDto
)
{
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
StoragePosSaveDto
saveDto
)
{
if
(
saveDto
.
getId
()==
null
){
if
(
saveDto
.
getId
()==
null
){
throw
new
BadRequestException
(
"
库位ID为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
if
(
saveDto
.
getPosName
()==
null
){
if
(
saveDto
.
getPosName
()==
null
){
throw
new
BadRequestException
(
"
库位ID为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
StoragePos
pos
=
storagePosDao
.
findOneById
(
saveDto
.
getId
());
StoragePos
pos
=
storagePosDao
.
findOneById
(
saveDto
.
getId
());
if
(
pos
==
null
){
if
(
pos
==
null
){
throw
new
BadRequestException
(
"未找到库位 "
);
throw
new
BadRequestException
(
"smfcode.valueNotFind"
,
"未找到{0}[{1}]"
,
new
String
[]{
"PosId"
,
saveDto
.
getId
()});
// throw new BadRequestException("未找到库位 ");
}
}
pos
.
setPosName
(
saveDto
.
getPosName
());
pos
.
setPosName
(
saveDto
.
getPosName
());
pos
.
setPriority
(
saveDto
.
getPriority
());
pos
.
setPriority
(
saveDto
.
getPriority
());
...
@@ -150,7 +153,7 @@ public class StoragePosController {
...
@@ -150,7 +153,7 @@ public class StoragePosController {
for
(
String
id
:
ids
)
{
for
(
String
id
:
ids
)
{
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
new
BadRequestException
(
"
删除库位:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
}
}
storagePosManager
.
deletePoss
(
ids
);
storagePosManager
.
deletePoss
(
ids
);
...
@@ -201,26 +204,34 @@ public class StoragePosController {
...
@@ -201,26 +204,34 @@ public class StoragePosController {
@PutMapping
(
"/checkout"
)
@PutMapping
(
"/checkout"
)
public
ResponseEntity
<
Object
>
checkout
(
@Validated
@RequestBody
CheckOutDto
checkOutDto
)
{
public
ResponseEntity
<
Object
>
checkout
(
@Validated
@RequestBody
CheckOutDto
checkOutDto
)
{
if
(
checkOutDto
.
getPids
()
==
null
)
{
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
if
(
checkOutDto
.
getSingleOut
()==
null
){
checkOutDto
.
setSingleOut
(
true
+
""
);
}
String
isSingleOutStr
=
checkOutDto
.
getSingleOut
();
String
isSingleOutStr
=
checkOutDto
.
getSingleOut
();
boolean
isSingleOut
=
Boolean
.
valueOf
(
isSingleOutStr
);
boolean
isSingleOut
=
Boolean
.
valueOf
(
isSingleOutStr
);
String
pids
=
checkOutDto
.
getPids
();
// String pids = checkOutDto.getPids();
for
(
String
pid
:
pids
.
split
(
";"
))
{
for
(
String
pid
:
checkOutDto
.
getPids
())
{
StoragePos
pos
=
storagePosManager
.
get
(
pid
);
StoragePos
pos
=
storagePosManager
.
get
(
pid
);
if
(
pos
==
null
)
{
if
(
pos
==
null
)
{
throw
new
BadRequestException
(
"位置["
+
pid
+
"]不存在"
);
throw
new
BadRequestException
(
"smfcode.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"pid"
,
pid
});
// throw new BadRequestException("位置[" + pid + "]不存在");
}
}
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
Storage
storage
=
dataCache
.
getStorageById
(
pos
.
getStorageId
());
if
(
storage
==
null
)
{
if
(
storage
==
null
)
{
throw
new
BadRequestException
(
"料仓["
+
pos
.
getStorageId
()
+
"]不存在"
);
throw
new
BadRequestException
(
"smfcode.valueNotExist"
,
"{0}[{1}]不存在"
,
new
String
[]{
"storageId"
,
pos
.
getStorageId
()});
// throw new BadRequestException("料仓[" + pos.getStorageId() + "]不存在");
}
}
log
.
info
(
"出库料仓【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
log
.
info
(
"出库料仓【"
+
storage
.
getName
()
+
"_"
+
storage
.
getCid
()
+
"】位置仓位【"
+
pos
.
getPosName
()
+
"】"
);
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
isSingleOut
);
String
outResult
=
taskService
.
checkout
(
storage
,
pos
,
isSingleOut
);
if
(!
Strings
.
isNullOrEmpty
(
outResult
))
{
if
(!
Strings
.
isNullOrEmpty
(
outResult
))
{
throw
new
BadRequestException
(
outResult
);
throw
new
BadRequestException
(
"smfcode.error"
,
outResult
);
}
}
}
}
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
}
}
}
}
src/main/java/com/neotel/smfcore/core/storage/rest/dto/CheckOutDto.java
查看文件 @
d474006
...
@@ -5,8 +5,8 @@ import lombok.Data;
...
@@ -5,8 +5,8 @@ import lombok.Data;
@Data
@Data
public
class
CheckOutDto
{
public
class
CheckOutDto
{
@ApiModelProperty
(
"库位
号,多个用;分隔
"
)
@ApiModelProperty
(
"库位
ID号
"
)
private
String
pids
;
private
String
[]
pids
;
@ApiModelProperty
(
"是否是单盘出库"
)
@ApiModelProperty
(
"是否是单盘出库"
)
private
String
singleOut
;
private
String
singleOut
;
}
}
src/main/java/com/neotel/smfcore/core/storage/service/manager/impl/StoragePosManagerImpl.java
查看文件 @
d474006
...
@@ -266,7 +266,8 @@ public class StoragePosManagerImpl implements IStoragePosManager {
...
@@ -266,7 +266,8 @@ public class StoragePosManagerImpl implements IStoragePosManager {
if
(
pos
.
getBarcode
()==
null
||
pos
.
getBarcode
().
equals
(
""
))
{
if
(
pos
.
getBarcode
()==
null
||
pos
.
getBarcode
().
equals
(
""
))
{
}
else
{
}
else
{
throw
new
BadRequestException
(
"库位["
+
pos
.
getPosName
()
+
"]中有料["
+
pos
.
getBarcode
()
+
"],不能删除"
);
throw
new
BadRequestException
(
"smfcode.thePosIsused"
,
" 库位[{0}]有料[{1}],不能删除"
,
new
String
[]{
pos
.
getPosName
(),
pos
.
getBarcode
().
getBarcode
()});
// throw new BadRequestException("库位[" + pos.getPosName() + "]中有料[" + pos.getBarcode() + "],不能删除");
}
}
delPosName
+=
"["
+
pos
.
getId
()+
"_"
+
pos
.
getPosName
()+
"]"
;
delPosName
+=
"["
+
pos
.
getId
()+
"_"
+
pos
.
getPosName
()+
"]"
;
}
}
...
...
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
查看文件 @
d474006
...
@@ -48,16 +48,21 @@ public class SettingsController {
...
@@ -48,16 +48,21 @@ public class SettingsController {
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
SettingsDto
settingsDto
)
{
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
SettingsDto
settingsDto
)
{
if
(
settingsDto
.
getMaxHumidity
()<=
settingsDto
.
getMinHumidity
()){
if
(
settingsDto
.
getMaxHumidity
()<=
settingsDto
.
getMinHumidity
()){
throw
new
BadRequestException
(
"温度范围数据错误"
);
throw
new
BadRequestException
(
"smfcode.humidityValueError"
,
"温度范围数据错误"
);
// throw new BadRequestException("温度范围数据错误");
}
}
if
(
settingsDto
.
getMaxHumidityShow
()<=
settingsDto
.
getMinHumidityShow
()){
if
(
settingsDto
.
getMaxHumidityShow
()<=
settingsDto
.
getMinHumidityShow
()){
throw
new
BadRequestException
(
"温度显示范围数据错误"
);
throw
new
BadRequestException
(
"smfcode.humidityShowValueError"
,
"温度显示范围数据错误"
);
// throw new BadRequestException("温度显示范围数据错误");
}
}
if
(
settingsDto
.
getMaxTemperature
()<=
settingsDto
.
getMinTemperature
()){
if
(
settingsDto
.
getMaxTemperature
()<=
settingsDto
.
getMinTemperature
()){
throw
new
BadRequestException
(
"湿度范围数据错误"
);
throw
new
BadRequestException
(
"smfcode.temperatureValueError"
,
"湿度范围数据错误"
);
// throw new BadRequestException("湿度范围数据错误");
}
}
if
(
settingsDto
.
getMaxTemperatureShow
()<=
settingsDto
.
getMinTemperatureShow
()){
if
(
settingsDto
.
getMaxTemperatureShow
()<=
settingsDto
.
getMinTemperatureShow
()){
throw
new
BadRequestException
(
"湿度显示范围数据错误"
);
throw
new
BadRequestException
(
"smfcode.temperatureShowValueError"
,
"湿度显示范围数据错误"
);
// throw new BadRequestException("湿度显示范围数据错误");
}
}
if
(
settingsDto
.
getInNotifyApi
()==
null
){
if
(
settingsDto
.
getInNotifyApi
()==
null
){
...
...
src/main/java/com/neotel/smfcore/security/rest/GroupController.java
查看文件 @
d474006
...
@@ -96,7 +96,7 @@ public class GroupController {
...
@@ -96,7 +96,7 @@ public class GroupController {
public
ResponseEntity
<
Object
>
update
(
@RequestBody
GroupDto
groupDto
)
{
public
ResponseEntity
<
Object
>
update
(
@RequestBody
GroupDto
groupDto
)
{
Group
resources
=
groupMapper
.
toEntity
(
groupDto
);
Group
resources
=
groupMapper
.
toEntity
(
groupDto
);
if
(
resources
.
getId
()
==
null
)
{
if
(
resources
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"
新增分组: 组ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
groupManager
.
saveGroup
(
resources
);
groupManager
.
saveGroup
(
resources
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
...
@@ -109,20 +109,21 @@ public class GroupController {
...
@@ -109,20 +109,21 @@ public class GroupController {
Set
<
Group
>
menuSet
=
new
HashSet
<>();
Set
<
Group
>
menuSet
=
new
HashSet
<>();
for
(
String
id
:
ids
)
{
for
(
String
id
:
ids
)
{
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
new
BadRequestException
(
"
删除: 组ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
Group
group
=
groupManager
.
get
(
id
);
Group
group
=
groupManager
.
get
(
id
);
//查找组下是否有设备
//查找组下是否有设备
Query
query
=
new
Query
(
Criteria
.
where
(
"groupId"
).
is
(
id
));
Query
query
=
new
Query
(
Criteria
.
where
(
"groupId"
).
is
(
id
));
List
<
Storage
>
storages
=
storageManager
.
findByQuery
(
query
);
List
<
Storage
>
storages
=
storageManager
.
findByQuery
(
query
);
if
(
storages
!=
null
&&
storages
.
size
()
>=
1
)
{
if
(
storages
!=
null
&&
storages
.
size
()
>=
1
)
{
throw
new
BadRequestException
(
"
删除失败,组["
+
group
.
getGroupName
()
+
"]已和设备关联"
);
throw
new
BadRequestException
(
"
smfcode.groupWithStorage"
,
"组[{0}]已和设备关联"
,
new
String
[]{
group
.
getGroupName
()}
);
}
}
Query
userQuery
=
new
Query
(
Criteria
.
where
(
"groups"
).
all
(
id
));
Query
userQuery
=
new
Query
(
Criteria
.
where
(
"groups"
).
all
(
id
));
List
<
User
>
users
=
userManager
.
findByQuery
(
userQuery
);
List
<
User
>
users
=
userManager
.
findByQuery
(
userQuery
);
if
(
users
!=
null
&&
users
.
size
()
>=
1
)
{
if
(
users
!=
null
&&
users
.
size
()
>=
1
)
{
throw
new
BadRequestException
(
"删除失败,组["
+
group
.
getGroupName
()
+
"]已和用户关联"
);
throw
new
BadRequestException
(
"smfcode.groupWithUser"
,
"组[{0}]已和用户关联"
,
new
String
[]{
group
.
getGroupName
()});
// throw new BadRequestException("删除失败,组[" + group.getGroupName() + "]已和用户关联");
}
}
groupManager
.
delete
(
group
);
groupManager
.
delete
(
group
);
}
}
...
...
src/main/java/com/neotel/smfcore/security/rest/MenuController.java
查看文件 @
d474006
...
@@ -156,7 +156,7 @@ public class MenuController {
...
@@ -156,7 +156,7 @@ public class MenuController {
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
MenuDto
menuDto
)
{
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
MenuDto
menuDto
)
{
Menu
resources
=
menuMapper
.
toEntity
(
menuDto
);
Menu
resources
=
menuMapper
.
toEntity
(
menuDto
);
if
(
resources
.
getId
()
==
null
)
{
if
(
resources
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"
修改菜单 :ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
menuManager
.
saveMenu
(
resources
);
menuManager
.
saveMenu
(
resources
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
...
@@ -168,7 +168,7 @@ public class MenuController {
...
@@ -168,7 +168,7 @@ public class MenuController {
@PreAuthorize
(
"@el.check('menu:del')"
)
@PreAuthorize
(
"@el.check('menu:del')"
)
public
ResponseEntity
<
Object
>
delete
(
@RequestBody
Set
<
String
>
ids
)
{
public
ResponseEntity
<
Object
>
delete
(
@RequestBody
Set
<
String
>
ids
)
{
if
(!
SecurityUtils
.
getCurrentUsername
().
equals
(
Constants
.
SUPER_USERNAME
)){
if
(!
SecurityUtils
.
getCurrentUsername
().
equals
(
Constants
.
SUPER_USERNAME
)){
throw
new
BadRequestException
(
"没有删除菜单的权限"
);
throw
new
BadRequestException
(
"
smfcode.noAccessUpdate"
,
"
没有删除菜单的权限"
);
}
}
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
for
(
String
id
:
ids
)
{
for
(
String
id
:
ids
)
{
...
...
src/main/java/com/neotel/smfcore/security/rest/RoleController.java
查看文件 @
d474006
...
@@ -104,7 +104,7 @@ public class RoleController {
...
@@ -104,7 +104,7 @@ public class RoleController {
Role
resources
=
roleMapper
.
toEntity
(
roleDto
);
Role
resources
=
roleMapper
.
toEntity
(
roleDto
);
if
(
resources
.
getId
()
==
null
)
{
if
(
resources
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"
修改角色:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
roleManager
.
saveRole
(
resources
);
roleManager
.
saveRole
(
resources
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
...
@@ -116,7 +116,7 @@ public class RoleController {
...
@@ -116,7 +116,7 @@ public class RoleController {
public
ResponseEntity
<
Object
>
updateMenu
(
@RequestBody
RoleDto
roleDto
)
{
public
ResponseEntity
<
Object
>
updateMenu
(
@RequestBody
RoleDto
roleDto
)
{
Role
resources
=
roleMapper
.
toEntity
(
roleDto
);
Role
resources
=
roleMapper
.
toEntity
(
roleDto
);
if
(
resources
.
getId
()
==
null
)
{
if
(
resources
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"
修改角色菜单:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
Role
role
=
roleManager
.
get
(
resources
.
getId
());
Role
role
=
roleManager
.
get
(
resources
.
getId
());
roleManager
.
updateMenu
(
resources
);
roleManager
.
updateMenu
(
resources
);
...
@@ -131,13 +131,13 @@ public class RoleController {
...
@@ -131,13 +131,13 @@ public class RoleController {
List
<
Role
>
roles
=
new
ArrayList
<
Role
>();
List
<
Role
>
roles
=
new
ArrayList
<
Role
>();
for
(
String
id
:
ids
)
{
for
(
String
id
:
ids
)
{
if
(
id
==
null
)
{
if
(
id
==
null
)
{
throw
new
BadRequestException
(
"
删除角色:ID不能为空"
);
throw
new
BadRequestException
(
"
smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
}
}
Role
role
=
roleManager
.
get
(
id
);
Role
role
=
roleManager
.
get
(
id
);
// 验证是否被用户关联
// 验证是否被用户关联
List
<
User
>
users
=
userManager
.
findByRoleId
(
role
.
getId
());
List
<
User
>
users
=
userManager
.
findByRoleId
(
role
.
getId
());
if
(
users
!=
null
&&
users
.
size
()
>
0
)
{
if
(
users
!=
null
&&
users
.
size
()
>
0
)
{
throw
new
BadRequestException
(
"
删除失败:角色["
+
role
.
getName
()
+
"]有["
+
users
.
size
()
+
"]个用户关联改角色"
);
throw
new
BadRequestException
(
"
smfcode.roleCannotDel"
,
"角色[{0}]有[{1}]个用户关联改角色,不能删除"
,
new
String
[]{
role
.
getName
(),
users
.
size
()+
""
}
);
}
}
roles
.
add
(
role
);
roles
.
add
(
role
);
}
}
...
...
src/main/java/com/neotel/smfcore/security/rest/UserController.java
查看文件 @
d474006
...
@@ -105,13 +105,16 @@ public class UserController {
...
@@ -105,13 +105,16 @@ public class UserController {
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
UserDto
userDto
)
{
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
UserDto
userDto
)
{
User
resources
=
userMapper
.
toEntity
(
userDto
);
User
resources
=
userMapper
.
toEntity
(
userDto
);
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"新增用户:ID已存在"
);
throw
new
BadRequestException
(
"smfcode.valueAlreadyExist"
,
"{0}[{1}]已存在"
,
new
String
[]{
"ID"
,
resources
.
getId
()});
// throw new BadRequestException("新增用户:ID已存在");
}
}
if
(
resources
.
getUsername
()==
null
){
if
(
resources
.
getUsername
()==
null
){
throw
new
BadRequestException
(
"新增用户:用户名不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"username"
}
);
// throw new BadRequestException("新增用户:用户名不能为空");
}
}
if
(
resources
.
getRoleId
()==
null
){
if
(
resources
.
getRoleId
()==
null
){
throw
new
BadRequestException
(
"新增用户:角色ID不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"roleId"
}
);
// throw new BadRequestException("新增用户:角色ID不能为空");
}
}
if
(
resources
.
getEnabled
()==
null
){
if
(
resources
.
getEnabled
()==
null
){
resources
.
setEnabled
(
false
);
resources
.
setEnabled
(
false
);
...
@@ -137,17 +140,21 @@ public class UserController {
...
@@ -137,17 +140,21 @@ public class UserController {
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
UserDto
userDto
)
{
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
UserDto
userDto
)
{
User
resources
=
userMapper
.
toEntity
(
userDto
);
User
resources
=
userMapper
.
toEntity
(
userDto
);
if
(
resources
.
getId
()
==
null
)
{
if
(
resources
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"修改用户:ID不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
// throw new BadRequestException("修改用户:ID不能为空");
}
}
if
(
resources
.
getUsername
()==
null
){
if
(
resources
.
getUsername
()==
null
){
throw
new
BadRequestException
(
"修改用户:用户名不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"username"
}
);
// throw new BadRequestException("修改用户:用户名不能为空");
}
}
if
(
resources
.
getRoleId
()==
null
){
if
(
resources
.
getRoleId
()==
null
){
throw
new
BadRequestException
(
"修改用户:角色ID不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"roleId"
}
);
// throw new BadRequestException("修改用户:角色ID不能为空");
}
}
if
(
resources
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
))
{
if
(
resources
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
))
{
if
(!
resources
.
getId
().
equals
(
SecurityUtils
.
getCurrentUserId
()))
{
if
(!
resources
.
getId
().
equals
(
SecurityUtils
.
getCurrentUserId
()))
{
throw
new
BadRequestException
(
"无权限修改此用户信息"
);
throw
new
BadRequestException
(
"smfcode.hasNoAccess"
,
"无权限修改此用户信息"
);
// throw new BadRequestException("无权限修改此用户信息");
}
}
}
}
userManager
.
update
(
resources
);
userManager
.
update
(
resources
);
...
@@ -161,7 +168,8 @@ public class UserController {
...
@@ -161,7 +168,8 @@ public class UserController {
public
ResponseEntity
<
Object
>
center
(
@Validated
@RequestBody
UserDto
userDto
)
{
public
ResponseEntity
<
Object
>
center
(
@Validated
@RequestBody
UserDto
userDto
)
{
User
resources
=
userMapper
.
toEntity
(
userDto
);
User
resources
=
userMapper
.
toEntity
(
userDto
);
if
(!
resources
.
getId
().
equals
(
SecurityUtils
.
getCurrentUserId
()))
{
if
(!
resources
.
getId
().
equals
(
SecurityUtils
.
getCurrentUserId
()))
{
throw
new
BadRequestException
(
"不能修改他人资料"
);
throw
new
BadRequestException
(
"smfcode.hasNoAccess"
,
"无权限修改此用户信息"
);
// throw new BadRequestException("不能修改他人资料");
}
}
userManager
.
updateCenter
(
resources
);
userManager
.
updateCenter
(
resources
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>(
HttpStatus
.
NO_CONTENT
);
...
@@ -176,13 +184,14 @@ public class UserController {
...
@@ -176,13 +184,14 @@ public class UserController {
//不能删除自己
//不能删除自己
String
currId
=
SecurityUtils
.
getCurrentUserId
();
String
currId
=
SecurityUtils
.
getCurrentUserId
();
if
(
currId
==
id
)
{
if
(
currId
==
id
)
{
throw
new
BadRequestException
(
"删除用户:不能删除自己"
);
throw
new
BadRequestException
(
"
smfcode.canotDelSelf"
,
"
删除用户:不能删除自己"
);
}
}
User
user
=
userManager
.
get
(
id
);
User
user
=
userManager
.
get
(
id
);
//admin的用户不让删除
//admin的用户不让删除
if
(
user
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
))
{
if
(
user
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
))
{
throw
new
BadRequestException
(
"删除用户:此用户不能删除"
);
throw
new
BadRequestException
(
"smfcode.canotDelUser"
,
"删除用户:此用户不能删除"
);
// throw new BadRequestException("删除用户:此用户不能删除");
}
}
}
}
userManager
.
deleteUsers
(
ids
);
userManager
.
deleteUsers
(
ids
);
...
@@ -195,10 +204,10 @@ public class UserController {
...
@@ -195,10 +204,10 @@ public class UserController {
User
user
=
userManager
.
get
(
SecurityUtils
.
getCurrentUserId
());
User
user
=
userManager
.
get
(
SecurityUtils
.
getCurrentUserId
());
if
(!
passwordEncoder
.
matches
(
passVo
.
getOldPass
(),
user
.
getPassword
()))
{
if
(!
passwordEncoder
.
matches
(
passVo
.
getOldPass
(),
user
.
getPassword
()))
{
throw
new
BadRequestException
(
"修改失败,旧密码错误"
);
throw
new
BadRequestException
(
"
smfcode.oldPwdError"
,
"
修改失败,旧密码错误"
);
}
}
if
(
passwordEncoder
.
matches
(
passVo
.
getNewPass
(),
user
.
getPassword
()))
{
if
(
passwordEncoder
.
matches
(
passVo
.
getNewPass
(),
user
.
getPassword
()))
{
throw
new
BadRequestException
(
"新密码不能与旧密码相同"
);
throw
new
BadRequestException
(
"
smfcode.newPwdError"
,
"
新密码不能与旧密码相同"
);
}
}
userManager
.
updatePass
(
user
.
getUsername
(),
passwordEncoder
.
encode
(
passVo
.
getNewPass
()));
userManager
.
updatePass
(
user
.
getUsername
(),
passwordEncoder
.
encode
(
passVo
.
getNewPass
()));
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
HttpStatus
.
OK
);
...
@@ -212,7 +221,7 @@ public class UserController {
...
@@ -212,7 +221,7 @@ public class UserController {
String
password
=
RsaUtils
.
decryptByPrivateKey
(
RsaProperties
.
privateKey
,
user
.
getPassword
());
String
password
=
RsaUtils
.
decryptByPrivateKey
(
RsaProperties
.
privateKey
,
user
.
getPassword
());
User
myUser
=
userManager
.
findByUserName
(
SecurityUtils
.
getCurrentUsername
());
User
myUser
=
userManager
.
findByUserName
(
SecurityUtils
.
getCurrentUsername
());
if
(!
passwordEncoder
.
matches
(
password
,
myUser
.
getPassword
()))
{
if
(!
passwordEncoder
.
matches
(
password
,
myUser
.
getPassword
()))
{
throw
new
BadRequestException
(
"修改邮箱失败,密码错误"
);
throw
new
BadRequestException
(
"
smfcode.pwdError"
,
"
修改邮箱失败,密码错误"
);
}
}
// verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + user.getEmail(), code);
// verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + user.getEmail(), code);
userManager
.
updateEmail
(
myUser
.
getUsername
(),
myUser
.
getEmail
());
userManager
.
updateEmail
(
myUser
.
getUsername
(),
myUser
.
getEmail
());
...
@@ -224,7 +233,8 @@ public class UserController {
...
@@ -224,7 +233,8 @@ public class UserController {
public
ResponseEntity
<
Object
>
updateGroup
(
@RequestBody
UserDto
userDto
)
{
public
ResponseEntity
<
Object
>
updateGroup
(
@RequestBody
UserDto
userDto
)
{
User
resources
=
userMapper
.
toEntity
(
userDto
);
User
resources
=
userMapper
.
toEntity
(
userDto
);
if
(
resources
.
getId
()
==
null
)
{
if
(
resources
.
getId
()
==
null
)
{
throw
new
BadRequestException
(
"修改用户组:ID不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
// throw new BadRequestException("修改用户组:ID不能为空");
}
}
User
user
=
userManager
.
get
(
resources
.
getId
());
User
user
=
userManager
.
get
(
resources
.
getId
());
userManager
.
updateGroups
(
resources
);
userManager
.
updateGroups
(
resources
);
...
@@ -237,7 +247,7 @@ public class UserController {
...
@@ -237,7 +247,7 @@ public class UserController {
String
image
=
"csv"
;
String
image
=
"csv"
;
String
fileType
=
FileUtil
.
getExtensionName
(
uploadFile
.
getOriginalFilename
());
String
fileType
=
FileUtil
.
getExtensionName
(
uploadFile
.
getOriginalFilename
());
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
)){
if
(
fileType
!=
null
&&
!
image
.
contains
(
fileType
)){
throw
new
BadRequestException
(
"
文件格式错误!, 仅支持 "
+
image
+
" 格式"
);
throw
new
BadRequestException
(
"
smfcode.feleFormatError"
,
"文件格式错误!, 仅支持{0}格式"
,
new
String
[]{
image
}
);
}
}
File
folder
=
new
File
(
properties
.
getPath
(),
"user"
);
File
folder
=
new
File
(
properties
.
getPath
(),
"user"
);
File
file
=
FileUtil
.
upload
(
uploadFile
,
folder
.
getAbsolutePath
());
File
file
=
FileUtil
.
upload
(
uploadFile
,
folder
.
getAbsolutePath
());
...
...
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
查看文件 @
d474006
...
@@ -82,10 +82,10 @@ public class UserDetailsServiceImpl implements UserDetailsService {
...
@@ -82,10 +82,10 @@ public class UserDetailsServiceImpl implements UserDetailsService {
throw
new
UsernameNotFoundException
(
""
);
throw
new
UsernameNotFoundException
(
""
);
}
else
{
}
else
{
if
(
user
.
getEnabled
()==
null
){
if
(
user
.
getEnabled
()==
null
){
throw
new
BadRequestException
(
"账号未激活"
);
throw
new
BadRequestException
(
"
smfcode.notActivated"
,
"
账号未激活"
);
}
}
if
(!
user
.
getEnabled
())
{
if
(!
user
.
getEnabled
())
{
throw
new
BadRequestException
(
"
账号未激活!
"
);
throw
new
BadRequestException
(
"
smfcode.notActivated"
,
"账号未激活
"
);
}
}
if
(
user
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
)){
if
(
user
.
getUsername
().
equals
(
Constants
.
SUPER_USERNAME
)){
...
@@ -93,7 +93,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
...
@@ -93,7 +93,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
//判断激活码是否正确
//判断激活码是否正确
String
code
=
Md5Utls
.
getMd5
(
user
.
getId
(),
user
.
getCreateDate
());
String
code
=
Md5Utls
.
getMd5
(
user
.
getId
(),
user
.
getCreateDate
());
if
(!
code
.
equals
(
user
.
getCheckCode
()))
{
if
(!
code
.
equals
(
user
.
getCheckCode
()))
{
throw
new
BadRequestException
(
"
账号未激活!
"
);
throw
new
BadRequestException
(
"
smfcode.notActivated"
,
"账号未激活
"
);
}
}
}
}
List
<
Long
>
dataScopes
=
new
ArrayList
<>();
List
<
Long
>
dataScopes
=
new
ArrayList
<>();
...
...
src/main/java/com/neotel/smfcore/security/service/manager/impl/GroupManagerImpl.java
查看文件 @
d474006
...
@@ -43,7 +43,8 @@ public class GroupManagerImpl implements IGroupManager {
...
@@ -43,7 +43,8 @@ public class GroupManagerImpl implements IGroupManager {
logName
=
"修改分组:"
;
logName
=
"修改分组:"
;
}
}
if
(
resources
.
getGroupName
()
==
null
)
{
if
(
resources
.
getGroupName
()
==
null
)
{
throw
new
BadRequestException
(
logName
+
"组名称不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"groupName"
}
);
// throw new BadRequestException(logName+"组名称不能为空");
}
}
Query
que
=
new
Query
(
c
);
Query
que
=
new
Query
(
c
);
List
<
Group
>
groups
=
findByQuery
(
que
);
List
<
Group
>
groups
=
findByQuery
(
que
);
...
...
src/main/java/com/neotel/smfcore/security/service/manager/impl/MenuManagerImpl.java
查看文件 @
d474006
...
@@ -229,10 +229,12 @@ public class MenuManagerImpl implements IMenuManager {
...
@@ -229,10 +229,12 @@ public class MenuManagerImpl implements IMenuManager {
if
(
menu
.
getType
()==
null
){
if
(
menu
.
getType
()==
null
){
throw
new
BadRequestException
(
"菜单类型不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"Type"
}
);
// throw new BadRequestException("菜单类型不能为空");
}
}
if
(
menu
.
getTitle
()==
null
){
if
(
menu
.
getTitle
()==
null
){
throw
new
BadRequestException
(
"菜单标题不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"Title"
}
);
// throw new BadRequestException( "菜单标题不能为空");
}
}
if
(
menu
.
getChildren
()==
null
){
if
(
menu
.
getChildren
()==
null
){
menu
.
setChildren
(
new
ArrayList
<
Menu
>());
menu
.
setChildren
(
new
ArrayList
<
Menu
>());
...
@@ -265,7 +267,8 @@ public class MenuManagerImpl implements IMenuManager {
...
@@ -265,7 +267,8 @@ public class MenuManagerImpl implements IMenuManager {
//菜单path不能重复
//菜单path不能重复
Menu
pathMenu
=
menuDao
.
findOne
(
quer
);
Menu
pathMenu
=
menuDao
.
findOne
(
quer
);
if
(
pathMenu
!=
null
){
if
(
pathMenu
!=
null
){
throw
new
BadRequestException
(
"路径["
+
pathMenu
+
"]已存在"
);
throw
new
BadRequestException
(
"smfcode.valueAlreadyExist"
,
"{0}[{1}]已存在"
,
new
String
[]{
"path"
,
pathMenu
.
getPath
()});
// throw new BadRequestException("路径["+pathMenu+"]已存在");
}
}
return
menuDao
.
save
(
menu
);
return
menuDao
.
save
(
menu
);
...
...
src/main/java/com/neotel/smfcore/security/service/manager/impl/RoleManagerImpl.java
查看文件 @
d474006
...
@@ -81,7 +81,8 @@ public class RoleManagerImpl implements IRoleManager {
...
@@ -81,7 +81,8 @@ public class RoleManagerImpl implements IRoleManager {
@Override
@Override
public
Role
saveRole
(
Role
role
)
throws
ValidateException
{
public
Role
saveRole
(
Role
role
)
throws
ValidateException
{
if
(
role
.
getName
()==
null
){
if
(
role
.
getName
()==
null
){
throw
new
BadRequestException
(
"角色名称不能为空"
);
throw
new
BadRequestException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"name"
}
);
// throw new BadRequestException("角色名称不能为空");
}
}
if
(
role
.
getMenus
()
==
null
)
{
if
(
role
.
getMenus
()
==
null
)
{
role
.
setMenus
(
new
HashSet
<
String
>());
role
.
setMenus
(
new
HashSet
<
String
>());
...
@@ -109,11 +110,13 @@ public class RoleManagerImpl implements IRoleManager {
...
@@ -109,11 +110,13 @@ public class RoleManagerImpl implements IRoleManager {
Role
role
=
this
.
get
(
resources
.
getId
());
Role
role
=
this
.
get
(
resources
.
getId
());
if
(
role
==
null
){
if
(
role
==
null
){
throw
new
BadRequestException
(
"请要修改的选择角色"
);
throw
new
BadRequestException
(
"smfcode.notSelRole"
,
"请要修改的选择角色"
);
// throw new BadRequestException("请要修改的选择角色");
}
}
if
(
role
.
getName
().
equals
(
"admin"
)){
if
(
role
.
getName
().
equals
(
"admin"
)){
if
(!
SecurityUtils
.
getCurrentUsername
().
equals
(
Constants
.
SUPER_USERNAME
)){
if
(!
SecurityUtils
.
getCurrentUsername
().
equals
(
Constants
.
SUPER_USERNAME
)){
throw
new
BadRequestException
(
"只有超级管理员才能修改此角色的菜单"
);
throw
new
BadRequestException
(
"smfcode.noaccess"
,
"无权限修改此角色的菜单"
);
// throw new BadRequestException("只有超级管理员才能修改此角色的菜单");
}
}
}
}
role
.
setMenus
(
resources
.
getMenus
());
role
.
setMenus
(
resources
.
getMenus
());
...
...
src/main/java/com/neotel/smfcore/security/service/manager/impl/UserManagerImpl.java
查看文件 @
d474006
...
@@ -202,7 +202,8 @@ public class UserManagerImpl implements IUserManager {
...
@@ -202,7 +202,8 @@ public class UserManagerImpl implements IUserManager {
public
String
GetUserCheckCode
(
User
user
){
public
String
GetUserCheckCode
(
User
user
){
if
(
user
.
getId
()==
null
||
user
.
getCreateDate
()==
null
){
if
(
user
.
getId
()==
null
||
user
.
getCreateDate
()==
null
){
throw
new
BadRequestException
(
"用户信息不完整"
);
throw
new
BadRequestException
(
"smfcode.userInfoError"
,
"用户信息不完整"
);
// throw new BadRequestException("用户信息不完整");
}
}
return
""
;
return
""
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论