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
10e392a0
Commit
10e392a0
authored
Aug 15, 2019
by
季圣华
Browse files
完善租户功能,默认开启
parent
630394c7
Changes
7
Hide whitespace changes
Inline
Side-by-side
erp_web/login.html
View file @
10e392a0
...
...
@@ -46,7 +46,6 @@
//进入页面聚焦在username输入框,方便 用户输入
$
(
"
#user_name
"
).
focus
();
browserFit
();
checkTenantStatus
();
});
//浏览器适配
...
...
@@ -57,32 +56,6 @@
$
(
"
#user_vcodepwd
"
).
empty
().
append
(
"
密 码:
"
);
}
//判断是否开启多租户
function
checkTenantStatus
(){
$
(
"
#btn_register
"
).
hide
();
$
.
ajax
({
type
:
"
get
"
,
url
:
"
/user/getTenantStatus
"
,
dataType
:
"
json
"
,
success
:
function
(
res
)
{
if
(
res
&&
res
.
code
===
200
)
{
if
(
res
.
data
)
{
if
(
res
.
data
.
status
==
"
open
"
)
{
$
(
"
#btn_register
"
).
show
();
}
else
if
(
res
.
data
.
status
==
"
close
"
)
{
$
(
"
#btn_register
"
).
hide
();
}
}
}
else
{
$
(
"
#btn_register
"
).
hide
();
}
},
error
:
function
()
{
$
(
"
#btn_register
"
).
hide
();
}
});
}
//初始化键盘enter事件
$
(
document
).
keydown
(
function
(
event
)
{
//兼容 IE和firefox 事件
...
...
src/main/java/com/jsh/erp/config/TenantConfig.java
View file @
10e392a0
...
...
@@ -48,8 +48,8 @@ public class TenantConfig {
@Override
public
boolean
doTableFilter
(
String
tableName
)
{
//获取开启状态
Object
mybatisPlusStatus
=
request
.
getSession
().
getAttribute
(
"
mybatisPlusStatus
"
);
if
(
mybatisPlusStatus
!=
null
&&
mybatisPlusStatus
.
toString
().
equals
(
"open"
)
)
{
Object
tenantId
=
request
.
getSession
().
getAttribute
(
"
tenantId
"
);
if
(
tenantId
!=
null
)
{
//从session中获取租户id
String
loginName
=
null
;
Object
userInfo
=
request
.
getSession
().
getAttribute
(
"user"
);
...
...
@@ -62,7 +62,7 @@ public class TenantConfig {
}
else
{
// 这里可以判断是否过滤表
if
(
"databasechangelog"
.
equals
(
tableName
)
||
"databasechangeloglock"
.
equals
(
tableName
)
||
"jsh_materialproperty"
.
equals
(
tableName
)
||
"tbl_sequence"
.
equals
(
tableName
)
||
"dual"
.
equals
(
tableName
)
||
"jsh_materialproperty"
.
equals
(
tableName
)
||
"tbl_sequence"
.
equals
(
tableName
)
||
"jsh_userbusiness"
.
equals
(
tableName
)
||
"jsh_app"
.
equals
(
tableName
)
||
"jsh_functions"
.
equals
(
tableName
)
||
"jsh_tenant"
.
equals
(
tableName
))
{
return
true
;
...
...
src/main/java/com/jsh/erp/controller/AppController.java
View file @
10e392a0
...
...
@@ -32,9 +32,6 @@ import java.util.Properties;
public
class
AppController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AppController
.
class
);
@Value
(
"${mybatis-plus.status}"
)
private
String
mybatisPlusStatus
;
@Resource
private
AppService
appService
;
...
...
@@ -175,23 +172,19 @@ public class AppController {
//根据条件从列表里面移除"系统管理"
List
<
App
>
dataList
=
new
ArrayList
<
App
>();
for
(
App
appOne
:
dataListApp
)
{
if
((
"open"
).
equals
(
mybatisPlusStatus
)){
//从session中获取租户id
String
loginName
=
null
;
Object
userInfo
=
request
.
getSession
().
getAttribute
(
"user"
);
if
(
userInfo
!=
null
)
{
User
user
=
(
User
)
userInfo
;
loginName
=
user
.
getLoginame
();
}
if
((
"admin"
).
equals
(
loginName
))
{
//从session中获取租户id
String
loginName
=
null
;
Object
userInfo
=
request
.
getSession
().
getAttribute
(
"user"
);
if
(
userInfo
!=
null
)
{
User
user
=
(
User
)
userInfo
;
loginName
=
user
.
getLoginame
();
}
if
((
"admin"
).
equals
(
loginName
))
{
dataList
.
add
(
appOne
);
}
else
{
if
(!(
"系统管理"
).
equals
(
appOne
.
getName
()))
{
dataList
.
add
(
appOne
);
}
else
{
if
(!(
"系统管理"
).
equals
(
appOne
.
getName
()))
{
dataList
.
add
(
appOne
);
}
}
}
else
{
dataList
.
add
(
appOne
);
}
}
...
...
src/main/java/com/jsh/erp/controller/DepotHeadController.java
View file @
10e392a0
...
...
@@ -39,9 +39,6 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
public
class
DepotHeadController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
DepotHeadController
.
class
);
@Value
(
"${mybatis-plus.status}"
)
private
String
mybatisPlusStatus
;
@Resource
private
DepotHeadService
depotHeadService
;
...
...
@@ -398,15 +395,11 @@ public class DepotHeadController {
@RequestParam
(
"deleted"
)
String
deleted
,
@RequestParam
(
"updated"
)
String
updated
,
HttpServletRequest
request
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
if
((
"open"
).
equals
(
mybatisPlusStatus
))
{
Long
billsNumLimit
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"billsNumLimit"
).
toString
());
Long
count
=
depotHeadService
.
countDepotHead
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
if
(
count
>=
billsNumLimit
)
{
throw
new
BusinessParamCheckingException
(
ExceptionConstants
.
DEPOT_HEAD_OVER_LIMIT_FAILED_CODE
,
ExceptionConstants
.
DEPOT_HEAD_OVER_LIMIT_FAILED_MSG
);
}
else
{
depotHeadService
.
addDepotHeadAndDetail
(
beanJson
,
inserted
,
deleted
,
updated
);
}
Long
billsNumLimit
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"billsNumLimit"
).
toString
());
Long
count
=
depotHeadService
.
countDepotHead
(
null
,
null
,
null
,
null
,
null
,
null
,
null
);
if
(
count
>=
billsNumLimit
)
{
throw
new
BusinessParamCheckingException
(
ExceptionConstants
.
DEPOT_HEAD_OVER_LIMIT_FAILED_CODE
,
ExceptionConstants
.
DEPOT_HEAD_OVER_LIMIT_FAILED_MSG
);
}
else
{
depotHeadService
.
addDepotHeadAndDetail
(
beanJson
,
inserted
,
deleted
,
updated
);
}
...
...
src/main/java/com/jsh/erp/controller/FunctionsController.java
View file @
10e392a0
...
...
@@ -29,9 +29,6 @@ import java.util.List;
public
class
FunctionsController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
FunctionsController
.
class
);
@Value
(
"${mybatis-plus.status}"
)
private
String
mybatisPlusStatus
;
@Resource
private
FunctionsService
functionsService
;
...
...
@@ -139,23 +136,19 @@ public class FunctionsController {
//根据条件从列表里面移除"系统管理"
List
<
Functions
>
dataList
=
new
ArrayList
<
Functions
>();
for
(
Functions
fun
:
dataListFun
)
{
if
((
"open"
).
equals
(
mybatisPlusStatus
)){
//从session中获取租户id
String
loginName
=
null
;
Object
userInfo
=
request
.
getSession
().
getAttribute
(
"user"
);
if
(
userInfo
!=
null
)
{
User
user
=
(
User
)
userInfo
;
loginName
=
user
.
getLoginame
();
}
if
((
"admin"
).
equals
(
loginName
))
{
//从session中获取租户id
String
loginName
=
null
;
Object
userInfo
=
request
.
getSession
().
getAttribute
(
"user"
);
if
(
userInfo
!=
null
)
{
User
user
=
(
User
)
userInfo
;
loginName
=
user
.
getLoginame
();
}
if
((
"admin"
).
equals
(
loginName
))
{
dataList
.
add
(
fun
);
}
else
{
if
(!(
"系统管理"
).
equals
(
fun
.
getName
()))
{
dataList
.
add
(
fun
);
}
else
{
if
(!(
"系统管理"
).
equals
(
fun
.
getName
()))
{
dataList
.
add
(
fun
);
}
}
}
else
{
dataList
.
add
(
fun
);
}
}
...
...
src/main/java/com/jsh/erp/controller/UserController.java
View file @
10e392a0
...
...
@@ -42,9 +42,6 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
public
class
UserController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
UserController
.
class
);
@Value
(
"${mybatis-plus.status}"
)
private
String
mybatisPlusStatus
;
@Value
(
"${manage.roleId}"
)
private
Integer
manageRoleId
;
...
...
@@ -110,22 +107,19 @@ public class UserController {
//验证通过 ,可以登录,放入session,记录登录日志
user
=
userService
.
getUserByUserName
(
username
);
request
.
getSession
().
setAttribute
(
"user"
,
user
);
if
((
"open"
).
equals
(
mybatisPlusStatus
))
{
if
(
user
.
getTenantId
()!=
null
)
{
Tenant
tenant
=
tenantService
.
getTenantByTenantId
(
user
.
getTenantId
());
if
(
tenant
!=
null
)
{
Long
tenantId
=
tenant
.
getTenantId
();
Integer
userNumLimit
=
tenant
.
getUserNumLimit
();
Integer
billsNumLimit
=
tenant
.
getBillsNumLimit
();
if
(
tenantId
!=
null
)
{
request
.
getSession
().
setAttribute
(
"tenantId"
,
tenantId
);
//租户tenantId
request
.
getSession
().
setAttribute
(
"userNumLimit"
,
userNumLimit
);
//用户限制数
request
.
getSession
().
setAttribute
(
"billsNumLimit"
,
billsNumLimit
);
//单据限制数
}
if
(
user
.
getTenantId
()!=
null
)
{
Tenant
tenant
=
tenantService
.
getTenantByTenantId
(
user
.
getTenantId
());
if
(
tenant
!=
null
)
{
Long
tenantId
=
tenant
.
getTenantId
();
Integer
userNumLimit
=
tenant
.
getUserNumLimit
();
Integer
billsNumLimit
=
tenant
.
getBillsNumLimit
();
if
(
tenantId
!=
null
)
{
request
.
getSession
().
setAttribute
(
"tenantId"
,
tenantId
);
//租户tenantId
request
.
getSession
().
setAttribute
(
"userNumLimit"
,
userNumLimit
);
//用户限制数
request
.
getSession
().
setAttribute
(
"billsNumLimit"
,
billsNumLimit
);
//单据限制数
}
}
}
request
.
getSession
().
setAttribute
(
"mybatisPlusStatus"
,
mybatisPlusStatus
);
//开启状态
logService
.
insertLog
(
BusinessConstants
.
LOG_INTERFACE_NAME_USER
,
new
StringBuffer
(
BusinessConstants
.
LOG_OPERATION_TYPE_LOGIN
).
append
(
user
.
getId
()).
toString
(),
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
());
...
...
@@ -182,12 +176,9 @@ public class UserController {
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
request
.
getSession
().
removeAttribute
(
"user"
);
request
.
getSession
().
removeAttribute
(
"mybatisPlusStatus"
);
if
((
"open"
).
equals
(
mybatisPlusStatus
))
{
request
.
getSession
().
removeAttribute
(
"tenantId"
);
request
.
getSession
().
removeAttribute
(
"userNumLimit"
);
request
.
getSession
().
removeAttribute
(
"billsNumLimit"
);
}
request
.
getSession
().
removeAttribute
(
"tenantId"
);
request
.
getSession
().
removeAttribute
(
"userNumLimit"
);
request
.
getSession
().
removeAttribute
(
"billsNumLimit"
);
response
.
sendRedirect
(
"/login.html"
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
@@ -323,16 +314,11 @@ public class UserController {
@ResponseBody
public
Object
addUser
(
@RequestParam
(
"info"
)
String
beanJson
,
HttpServletRequest
request
)
throws
Exception
{
JSONObject
result
=
ExceptionConstants
.
standardSuccess
();
if
((
"open"
).
equals
(
mybatisPlusStatus
))
{
Long
userNumLimit
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"userNumLimit"
).
toString
());
Long
count
=
userService
.
countUser
(
null
,
null
);
if
(
count
>=
userNumLimit
)
{
throw
new
BusinessParamCheckingException
(
ExceptionConstants
.
USER_OVER_LIMIT_FAILED_CODE
,
ExceptionConstants
.
USER_OVER_LIMIT_FAILED_MSG
);
}
else
{
UserEx
ue
=
JSON
.
parseObject
(
beanJson
,
UserEx
.
class
);
userService
.
addUserAndOrgUserRel
(
ue
);
}
Long
userNumLimit
=
Long
.
parseLong
(
request
.
getSession
().
getAttribute
(
"userNumLimit"
).
toString
());
Long
count
=
userService
.
countUser
(
null
,
null
);
if
(
count
>=
userNumLimit
)
{
throw
new
BusinessParamCheckingException
(
ExceptionConstants
.
USER_OVER_LIMIT_FAILED_CODE
,
ExceptionConstants
.
USER_OVER_LIMIT_FAILED_MSG
);
}
else
{
UserEx
ue
=
JSON
.
parseObject
(
beanJson
,
UserEx
.
class
);
userService
.
addUserAndOrgUserRel
(
ue
);
...
...
@@ -405,20 +391,4 @@ public class UserController {
}
return
arr
;
}
@GetMapping
(
"/getTenantStatus"
)
public
BaseResponseInfo
getTenantStatus
(
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
data
.
put
(
"status"
,
mybatisPlusStatus
);
res
.
code
=
200
;
res
.
data
=
data
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
res
.
code
=
500
;
res
.
data
=
"获取失败"
;
}
return
res
;
}
}
src/main/java/com/jsh/erp/filter/LogCostFilter.java
View file @
10e392a0
...
...
@@ -15,7 +15,7 @@ import java.util.regex.Pattern;
@WebFilter
(
filterName
=
"LogCostFilter"
,
urlPatterns
=
{
"/*"
},
initParams
=
{
@WebInitParam
(
name
=
"ignoredUrl"
,
value
=
".css#.js#.jpg#.png#.gif#.ico"
),
@WebInitParam
(
name
=
"filterPath"
,
value
=
"/user/login#/user/registerUser
#/user/getTenantStatus
"
)})
value
=
"/user/login#/user/registerUser"
)})
public
class
LogCostFilter
implements
Filter
{
private
static
final
String
FILTER_PATH
=
"filterPath"
;
...
...
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