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
JeeSpringCloud
Commits
8b643e22
Commit
8b643e22
authored
Oct 12, 2018
by
HuangBingGui
Browse files
no commit message
parent
563ff060
Changes
385
Show whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 385+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/LogController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.entity.Log
;
import
com.jeespring.modules.sys.service.LogService
;
/**
* 日志Controller
* @author 黄炳桂 516821420@qq.com
* @version 2013-6-2
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/log"
)
public
class
LogController
extends
AbstractBaseController
{
@Autowired
private
LogService
logService
;
//RequiresPermissions("sys:log:list")
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
Log
log
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
Log
>
page
=
logService
.
findPage
(
new
Page
<
Log
>(
request
,
response
),
log
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/logList"
;
}
/**
* 批量删除
*/
//RequiresPermissions("sys:log:del")
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
logService
.
delete
(
logService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除日志成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/log/?repage"
;
}
/**
* 批量删除
*/
//RequiresPermissions("sys:log:del")
@RequestMapping
(
value
=
"empty"
)
public
String
empty
(
RedirectAttributes
redirectAttributes
)
{
logService
.
empty
();
addMessage
(
redirectAttributes
,
"清空日志成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/log/?repage"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/LoginController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.jeespring.modules.oa.entity.OaNotify
;
import
com.jeespring.modules.oa.service.OaNotifyService
;
import
com.jeespring.modules.sys.entity.Dict
;
import
com.jeespring.modules.sys.entity.SysConfig
;
import
com.jeespring.modules.sys.service.DictService
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
com.jeespring.modules.sys.service.SysUserOnlineService
;
import
org.apache.shiro.authz.UnauthorizedException
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.apache.shiro.web.util.SavedRequest
;
import
org.apache.shiro.web.util.WebUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.servlet.ValidateCodeServlet
;
import
com.jeespring.common.utils.CacheUtils
;
import
com.jeespring.common.utils.CookieUtils
;
import
com.jeespring.common.utils.IdGen
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.json.AjaxJson
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.security.shiro.session.SessionDAO
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.security.FormAuthenticationFilter
;
import
com.jeespring.modules.sys.security.SystemAuthorizingRealm.Principal
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
/**
* 登录Controller
* @author 黄炳桂 516821420@qq.com
* @version 2013-5-31
*/
@Controller
public
class
LoginController
extends
AbstractBaseController
{
@Autowired
private
SessionDAO
sessionDAO
;
@Autowired
private
OaNotifyService
oaNotifyService
;
@Autowired
private
SysConfigService
sysConfigService
;
@Autowired
private
DictService
dictService
;
/**
* 管理登录
* @throws IOException
*/
@RequestMapping
(
value
=
"${adminPath}/login"
,
method
=
RequestMethod
.
GET
)
public
String
login
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
throws
IOException
{
Principal
principal
=
UserUtils
.
getPrincipal
();
// 默认页签模式
String
tabmode
=
CookieUtils
.
getCookie
(
request
,
"tabmode"
);
if
(
tabmode
==
null
){
CookieUtils
.
setCookie
(
response
,
"tabmode"
,
"1"
);
}
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
"login, active session size: {}"
,
sessionDAO
.
getActiveSessions
(
false
).
size
());
}
// 如果已登录,再次访问主页,则退出原账号。
if
(
Global
.
TRUE
.
equals
(
Global
.
getConfig
(
"notAllowRefreshIndex"
))){
CookieUtils
.
setCookie
(
response
,
"LOGINED"
,
"false"
);
}
// 如果已经登录,则跳转到管理首页
if
(
principal
!=
null
&&
!
principal
.
isMobileLogin
()){
return
"redirect:"
+
adminPath
;
}
SavedRequest
savedRequest
=
WebUtils
.
getSavedRequest
(
request
);
//获取跳转到login之前的URL
// 如果是手机没有登录跳转到到login,则返回JSON字符串
if
(
savedRequest
!=
null
){
String
queryStr
=
savedRequest
.
getQueryString
();
if
(
queryStr
!=
null
&&(
queryStr
.
contains
(
"__ajax"
)
||
queryStr
.
contains
(
"mobileLogin"
))){
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"0"
);
j
.
setMsg
(
"没有登录!"
);
return
renderString
(
response
,
j
);
}
}
SysConfig
sysConfig
=
new
SysConfig
();
sysConfig
.
setType
(
"loginImgUrl"
);
List
<
SysConfig
>
loginImgUrlSysConfig
=
sysConfigService
.
findList
(
sysConfig
);
String
loginImgUrl
=
""
;
if
(
loginImgUrlSysConfig
.
size
()>
0
){
Random
rand
=
new
Random
();
loginImgUrl
=
loginImgUrlSysConfig
.
get
(
rand
.
nextInt
(
loginImgUrlSysConfig
.
size
())).
getPicture
();
}
SysConfig
validateCodeSysConfig
=
new
SysConfig
();
validateCodeSysConfig
.
setType
(
"validateCode"
);
validateCodeSysConfig
=
sysConfigService
.
findListFirstCache
(
validateCodeSysConfig
);
SysConfig
versionSysConfig
=
new
SysConfig
();
versionSysConfig
.
setType
(
"version"
);
versionSysConfig
=
sysConfigService
.
findListFirstCache
(
versionSysConfig
);
model
.
addAttribute
(
"loginImgUrl"
,
loginImgUrl
);
model
.
addAttribute
(
"systemMode"
,
sysConfigService
.
systemMode
());
model
.
addAttribute
(
"validateCode"
,
validateCodeSysConfig
.
getValue
());
model
.
addAttribute
(
"version"
,
versionSysConfig
.
getValue
());
//return "modules/sys/sysLogin";
return
"base/login"
;
}
@RequestMapping
(
value
=
"${adminPath}/register"
,
method
=
RequestMethod
.
GET
)
public
String
register
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
,
RedirectAttributes
redirectAttributes
)
throws
IOException
{
Principal
principal
=
UserUtils
.
getPrincipal
();
// 默认页签模式
String
tabmode
=
CookieUtils
.
getCookie
(
request
,
"tabmode"
);
if
(
tabmode
==
null
){
CookieUtils
.
setCookie
(
response
,
"tabmode"
,
"1"
);
}
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
"login, active session size: {}"
,
sessionDAO
.
getActiveSessions
(
false
).
size
());
}
// 如果已登录,再次访问主页,则退出原账号。
if
(
Global
.
TRUE
.
equals
(
Global
.
getConfig
(
"notAllowRefreshIndex"
))){
CookieUtils
.
setCookie
(
response
,
"LOGINED"
,
"false"
);
}
// 如果已经登录,则跳转到管理首页
if
(
principal
!=
null
&&
!
principal
.
isMobileLogin
()){
return
"redirect:"
+
adminPath
;
}
SavedRequest
savedRequest
=
WebUtils
.
getSavedRequest
(
request
);
//获取跳转到login之前的URL
// 如果是手机没有登录跳转到到login,则返回JSON字符串
if
(
savedRequest
!=
null
){
String
queryStr
=
savedRequest
.
getQueryString
();
if
(
queryStr
!=
null
&&(
queryStr
.
contains
(
"__ajax"
)
||
queryStr
.
contains
(
"mobileLogin"
))){
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"0"
);
j
.
setMsg
(
"没有登录!"
);
return
renderString
(
response
,
j
);
}
}
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/login"
;
}
//return "modules/sys/sysRegister";
return
"base/register"
;
}
/**
* 登录失败,真正登录的POST请求由Filter完成
*/
@RequestMapping
(
value
=
"${adminPath}/login"
,
method
=
RequestMethod
.
POST
)
public
String
loginFail
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Principal
principal
=
UserUtils
.
getPrincipal
();
// 如果已经登录,则跳转到管理首页
if
(
principal
!=
null
){
return
"redirect:"
+
adminPath
;
}
String
username
=
WebUtils
.
getCleanParam
(
request
,
FormAuthenticationFilter
.
DEFAULT_USERNAME_PARAM
);
boolean
rememberMe
=
WebUtils
.
isTrue
(
request
,
FormAuthenticationFilter
.
DEFAULT_REMEMBER_ME_PARAM
);
boolean
mobile
=
WebUtils
.
isTrue
(
request
,
FormAuthenticationFilter
.
DEFAULT_MOBILE_PARAM
);
String
exception
=
(
String
)
request
.
getAttribute
(
FormAuthenticationFilter
.
DEFAULT_ERROR_KEY_ATTRIBUTE_NAME
);
String
message
=
(
String
)
request
.
getAttribute
(
FormAuthenticationFilter
.
DEFAULT_MESSAGE_PARAM
);
if
(
StringUtils
.
isBlank
(
message
)
||
StringUtils
.
equals
(
message
,
"null"
)){
message
=
"用户或密码错误, 请重试."
;
}
model
.
addAttribute
(
FormAuthenticationFilter
.
DEFAULT_USERNAME_PARAM
,
username
);
model
.
addAttribute
(
FormAuthenticationFilter
.
DEFAULT_REMEMBER_ME_PARAM
,
rememberMe
);
model
.
addAttribute
(
FormAuthenticationFilter
.
DEFAULT_MOBILE_PARAM
,
mobile
);
model
.
addAttribute
(
FormAuthenticationFilter
.
DEFAULT_ERROR_KEY_ATTRIBUTE_NAME
,
exception
);
model
.
addAttribute
(
FormAuthenticationFilter
.
DEFAULT_MESSAGE_PARAM
,
message
);
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
"login fail, active session size: {}, message: {}, exception: {}"
,
sessionDAO
.
getActiveSessions
(
false
).
size
(),
message
,
exception
);
}
// 非授权异常,登录失败,验证码加1。
if
(!
UnauthorizedException
.
class
.
getName
().
equals
(
exception
)){
model
.
addAttribute
(
"isValidateCodeLogin"
,
isValidateCodeLogin
(
username
,
true
,
false
));
}
// 验证失败清空验证码
request
.
getSession
().
setAttribute
(
ValidateCodeServlet
.
VALIDATE_CODE
,
IdGen
.
uuid
());
model
.
addAttribute
(
"systemMode"
,
sysConfigService
.
systemMode
());
return
"base/login"
;
}
/**
* 管理登录
* @throws IOException
*/
@RequestMapping
(
value
=
"${adminPath}/logout"
,
method
=
RequestMethod
.
GET
)
public
String
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
throws
IOException
{
Principal
principal
=
UserUtils
.
getPrincipal
();
// 如果已经登录,则跳转到管理首页
if
(
principal
!=
null
){
UserUtils
.
getSubject
().
logout
();
}
// 如果是手机客户端退出跳转到login,则返回JSON字符串
String
ajax
=
request
.
getParameter
(
"__ajax"
);
if
(
ajax
!=
null
){
model
.
addAttribute
(
"success"
,
"1"
);
model
.
addAttribute
(
"msg"
,
"退出成功"
);
return
renderString
(
response
,
model
);
}
return
"redirect:"
+
adminPath
+
"/login"
;
}
/**
* 登录成功,进入管理首页
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"${adminPath}"
)
public
String
index
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
Principal
principal
=
UserUtils
.
getPrincipal
();
// 登录成功后,验证码计算器清零
isValidateCodeLogin
(
principal
.
getLoginName
(),
false
,
true
);
if
(
logger
.
isDebugEnabled
()){
logger
.
debug
(
"show index, active session size: {}"
,
sessionDAO
.
getActiveSessions
(
false
).
size
());
}
// 如果已登录,再次访问主页,则退出原账号。
if
(
Global
.
TRUE
.
equals
(
Global
.
getConfig
(
"notAllowRefreshIndex"
))){
String
logined
=
CookieUtils
.
getCookie
(
request
,
"LOGINED"
);
if
(
StringUtils
.
isBlank
(
logined
)
||
"false"
.
equals
(
logined
)){
CookieUtils
.
setCookie
(
response
,
"LOGINED"
,
"true"
);
}
else
if
(
StringUtils
.
equals
(
logined
,
"true"
)){
UserUtils
.
getSubject
().
logout
();
return
"redirect:"
+
adminPath
+
"/login"
;
}
}
SysConfig
sysConfig
=
new
SysConfig
();
sysConfig
.
setType
(
"IMEnable"
);
SysConfig
IMEnableSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
sysConfig
.
setType
(
"tabmode"
);
SysConfig
tabmodeSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
sysConfig
.
setType
(
"skinSetttings"
);
SysConfig
skinSetttingsSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
sysConfig
.
setType
(
"version"
);
SysConfig
versionSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
model
.
addAttribute
(
"IMEnable"
,
IMEnableSysConfig
.
getValue
());
model
.
addAttribute
(
"tabmode"
,
tabmodeSysConfig
.
getValue
());
model
.
addAttribute
(
"skinSetttings"
,
skinSetttingsSysConfig
.
getValue
());
model
.
addAttribute
(
"systemMode"
,
sysConfigService
.
systemMode
());
model
.
addAttribute
(
"version"
,
versionSysConfig
.
getValue
());
// 如果是手机登录,则返回JSON字符串
if
(
principal
.
isMobileLogin
()){
if
(
request
.
getParameter
(
"login"
)
!=
null
){
return
renderString
(
response
,
principal
);
}
if
(
request
.
getParameter
(
"index"
)
!=
null
){
return
"modules/sys/sysIndex"
;
}
return
"redirect:"
+
adminPath
+
"/login"
;
}
// // 登录成功后,获取上次登录的当前站点ID
// UserUtils.putCache("siteId", StringUtils.toLong(CookieUtils.getCookie(request, "siteId")));
// System.out.println("==========================a");
// try {
// byte[] bytes = com.jeespring.common.utils.FileUtils.readFileToByteArray(
// com.jeespring.common.utils.FileUtils.getFile("c:\\sxt.dmp"));
// UserUtils.getSession().setAttribute("kkk", bytes);
// UserUtils.getSession().setAttribute("kkk2", bytes);
// } catch (Exception e) {
// e.printStackTrace();
// }
//// for (int i=0; i<1000000; i++){
//// //UserUtils.getSession().setAttribute("a", "a");
//// request.getSession().setAttribute("aaa", "aa");
//// }
// System.out.println("==========================b");
//
//
//return "modules/sys/sysIndex";
return
"base/index"
;
}
/**
* 获取主题方案
*/
@RequestMapping
(
value
=
"/theme/{theme}"
)
public
String
getThemeInCookie
(
@PathVariable
String
theme
,
HttpServletRequest
request
,
HttpServletResponse
response
){
if
(
StringUtils
.
isNotBlank
(
theme
)){
CookieUtils
.
setCookie
(
response
,
"theme"
,
theme
);
}
else
{
theme
=
CookieUtils
.
getCookie
(
request
,
"theme"
);
}
return
"redirect:"
+
request
.
getParameter
(
"url"
);
}
/**
* 是否是验证码登录
* @param useruame 用户名
* @param isFail 计数加1
* @param clean 计数清零
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
static
boolean
isValidateCodeLogin
(
String
useruame
,
boolean
isFail
,
boolean
clean
){
Map
<
String
,
Integer
>
loginFailMap
=
(
Map
<
String
,
Integer
>)
CacheUtils
.
get
(
"loginFailMap"
);
if
(
loginFailMap
==
null
){
loginFailMap
=
Maps
.
newHashMap
();
CacheUtils
.
put
(
"loginFailMap"
,
loginFailMap
);
}
Integer
loginFailNum
=
loginFailMap
.
get
(
useruame
);
if
(
loginFailNum
==
null
){
loginFailNum
=
0
;
}
if
(
isFail
){
loginFailNum
++;
loginFailMap
.
put
(
useruame
,
loginFailNum
);
}
if
(
clean
){
loginFailMap
.
remove
(
useruame
);
}
return
loginFailNum
>=
3
;
}
/**
* 首页
* @throws IOException
*/
@RequestMapping
(
value
=
"${adminPath}/home"
)
public
String
home
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
,
RedirectAttributes
redirectAttributes
)
throws
IOException
{
SysConfig
sysConfig
=
new
SysConfig
();
//new一个新的xxx对象
sysConfig
.
setType
(
"homePageAboveInfomation"
);
//传值
List
<
SysConfig
>
indexSysConfig
=
sysConfigService
.
findList
(
sysConfig
);
//查询系统配置项
sysConfig
.
setType
(
"homePageTechnical"
);
//传值
SysConfig
homePageTechnicalSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
//查询系统配置项
sysConfig
.
setType
(
"homePageAuthorization"
);
//传值
SysConfig
homePageAuthorizationSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
//查询系统配置项
sysConfig
.
setType
(
"homePageContactInfo"
);
//传值
SysConfig
homePageContactInfoSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
//查询系统配置项
sysConfig
.
setType
(
"homePageInfomation"
);
//传值
SysConfig
homePageInfomationSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
//查询系统配置项
sysConfig
.
setType
(
"version"
);
//传值
SysConfig
versionSysConfig
=
sysConfigService
.
findListFirstCache
(
sysConfig
);
//查询系统配置项
model
.
addAttribute
(
"homePageTechnical"
,
homePageTechnicalSysConfig
.
getDescription
().
toString
());
model
.
addAttribute
(
"homePageAuthorization"
,
homePageAuthorizationSysConfig
.
getDescription
().
toString
());
model
.
addAttribute
(
"homePageContactInfo"
,
homePageContactInfoSysConfig
.
getDescription
().
toString
());
model
.
addAttribute
(
"homePageInfomation"
,
homePageInfomationSysConfig
.
getDescription
().
toString
());
model
.
addAttribute
(
"version"
,
versionSysConfig
.
getValue
());
if
(
indexSysConfig
.
size
()
==
0
)
{
indexSysConfig
.
add
(
new
SysConfig
());
}
OaNotify
oaNotify
=
new
OaNotify
();
Dict
dict
=
new
Dict
();
dict
.
setValue
(
"1"
);
//传一个数据值
//dict.setLabel("会议通知"); //传一个标签名
List
<
Dict
>
getDict
=
dictService
.
findList
(
dict
);
//按传的值查数据字典
if
(
getDict
!=
null
){
if
(
getDict
.
size
()
>
0
){
oaNotify
.
setType
(
getDict
.
get
(
0
).
getValue
());
}
}
Page
<
OaNotify
>
pageOaNotify
=
oaNotifyService
.
find
(
new
Page
<
OaNotify
>(
request
,
response
),
oaNotify
);
model
.
addAttribute
(
"pageOaNotify"
,
pageOaNotify
);
dict
=
new
Dict
();
oaNotify
=
new
OaNotify
();
dict
.
setValue
(
"4"
);
//dict.setLabel("升级日志");
List
<
Dict
>
getDictLog
=
dictService
.
findList
(
dict
);
if
(
getDictLog
!=
null
){
if
(
getDictLog
.
size
()
>
0
){
oaNotify
.
setType
(
getDictLog
.
get
(
0
).
getValue
());
}
}
Page
<
OaNotify
>
pageOaNotifyLog
=
oaNotifyService
.
find
(
new
Page
<
OaNotify
>(
request
,
response
),
oaNotify
);
model
.
addAttribute
(
"pageOaNotifyLog"
,
pageOaNotifyLog
);
dict
=
new
Dict
();
oaNotify
=
new
OaNotify
();
dict
.
setValue
(
"5"
);
//dict.setLabel("技术支持");
List
<
Dict
>
getDictTechnology
=
dictService
.
findList
(
dict
);
if
(
getDictTechnology
!=
null
){
if
(
getDictTechnology
.
size
()
>
0
){
oaNotify
.
setType
(
getDictTechnology
.
get
(
0
).
getValue
());
}
}
Page
<
OaNotify
>
pageOaNotifyTechnology
=
oaNotifyService
.
find
(
new
Page
<
OaNotify
>(
request
,
response
),
oaNotify
);
model
.
addAttribute
(
"pageOaNotifyTechnology"
,
pageOaNotifyTechnology
);
model
.
addAttribute
(
"indexSysConfig"
,
indexSysConfig
.
get
(
0
));
//return "modules/sys/sysHome";
return
"base/home"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/MenuController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.entity.Menu
;
import
com.jeespring.modules.sys.service.SystemService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 菜单Controller
* @author 黄炳桂 516821420@qq.com
* @version 2013-3-23
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/menu"
)
public
class
MenuController
extends
AbstractBaseController
{
@Autowired
private
SystemService
systemService
;
@Autowired
private
SysConfigService
sysConfigService
;
@ModelAttribute
(
"menu"
)
public
Menu
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
)){
return
systemService
.
getMenu
(
id
);
}
else
{
return
new
Menu
();
}
}
//RequiresPermissions("sys:menu:list")
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
Model
model
,
RedirectAttributes
redirectAttributes
)
{
List
<
Menu
>
list
=
Lists
.
newArrayList
();
List
<
Menu
>
sourcelist
=
systemService
.
findAllMenu
();
//if(sysConfigService.isDemoMode()){
// model.addAttribute("list", list);
// model.addAttribute("message", sysConfigService.isDemoModeDescription());
// return "modules/sys/menuList";
//}else{
Menu
.
sortList
(
list
,
sourcelist
,
Menu
.
getRootId
(),
true
);
//}
model
.
addAttribute
(
"list"
,
list
);
return
"modules/sys/menuList"
;
}
//RequiresPermissions(value={"sys:menu:view","sys:menu:add","sys:menu:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
Menu
menu
,
Model
model
)
{
if
(
menu
.
getParent
()==
null
||
menu
.
getParent
().
getId
()==
null
){
menu
.
setParent
(
new
Menu
(
Menu
.
getRootId
()));
}
menu
.
setParent
(
systemService
.
getMenu
(
menu
.
getParent
().
getId
()));
// 获取排序号,最末节点排序号+30
if
(
StringUtils
.
isBlank
(
menu
.
getId
())){
List
<
Menu
>
list
=
Lists
.
newArrayList
();
List
<
Menu
>
sourcelist
=
systemService
.
findAllMenu
();
Menu
.
sortList
(
list
,
sourcelist
,
menu
.
getParentId
(),
false
);
if
(
list
.
size
()
>
0
){
menu
.
setSort
(
list
.
get
(
list
.
size
()-
1
).
getSort
()
+
30
);
}
}
model
.
addAttribute
(
"menu"
,
menu
);
return
"modules/sys/menuForm"
;
}
//RequiresPermissions(value={"sys:menu:add","sys:menu:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
Menu
menu
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(!
UserUtils
.
getUser
().
isAdmin
()){
addMessage
(
redirectAttributes
,
"越权操作,只有超级管理员才能添加或修改数据!"
);
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
if
(!
beanValidator
(
model
,
menu
)){
return
form
(
menu
,
model
);
}
systemService
.
saveMenu
(
menu
);
addMessage
(
redirectAttributes
,
"保存菜单'"
+
menu
.
getName
()
+
"'成功"
);
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
//RequiresPermissions("sys:menu:del")
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
Menu
menu
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
// if (Menu.isRoot(id)){
// addMessage(redirectAttributes, "删除菜单失败, 不允许删除顶级菜单或编号为空");
// }else{
systemService
.
deleteMenu
(
menu
);
addMessage
(
redirectAttributes
,
"删除菜单成功"
);
// }
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
//RequiresPermissions("sys:menu:del")
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
// if (Menu.isRoot(id)){
// addMessage(redirectAttributes, "删除菜单失败, 不允许删除顶级菜单或编号为空");
// }else{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
Menu
menu
=
systemService
.
getMenu
(
id
);
if
(
menu
!=
null
){
systemService
.
deleteMenu
(
systemService
.
getMenu
(
id
));
}
}
addMessage
(
redirectAttributes
,
"删除菜单成功"
);
// }
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
//RequiresPermissions("user")
@RequestMapping
(
value
=
"tree"
)
public
String
tree
()
{
return
"modules/sys/menuTree"
;
}
//RequiresPermissions("user")
@RequestMapping
(
value
=
"treeselect"
)
public
String
treeselect
(
String
parentId
,
Model
model
)
{
model
.
addAttribute
(
"parentId"
,
parentId
);
return
"modules/sys/menuTreeselect"
;
}
/**
* 批量修改菜单排序
*/
//RequiresPermissions("sys:menu:updateSort")
@RequestMapping
(
value
=
"updateSort"
)
public
String
updateSort
(
String
[]
ids
,
Integer
[]
sorts
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
for
(
int
i
=
0
;
i
<
ids
.
length
;
i
++)
{
Menu
menu
=
new
Menu
(
ids
[
i
]);
menu
.
setSort
(
sorts
[
i
]);
systemService
.
updateMenuSort
(
menu
);
}
addMessage
(
redirectAttributes
,
"保存菜单排序成功!"
);
return
"redirect:"
+
adminPath
+
"/sys/menu/"
;
}
/**
* isShowHide是否显示隐藏菜单
* @param extId
* @param isShowHidden
* @param response
* @return
*/
//RequiresPermissions("user")
@ResponseBody
@RequestMapping
(
value
=
"treeData"
)
public
List
<
Map
<
String
,
Object
>>
treeData
(
@RequestParam
(
required
=
false
)
String
extId
,
@RequestParam
(
required
=
false
)
String
isShowHide
,
HttpServletResponse
response
)
{
List
<
Map
<
String
,
Object
>>
mapList
=
Lists
.
newArrayList
();
List
<
Menu
>
list
=
systemService
.
findAllMenu
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
Menu
e
=
list
.
get
(
i
);
if
(
StringUtils
.
isBlank
(
extId
)
||
(
extId
!=
null
&&
!
extId
.
equals
(
e
.
getId
())
&&
e
.
getParentIds
().
indexOf
(
","
+
extId
+
","
)==-
1
)){
if
(
isShowHide
!=
null
&&
isShowHide
.
equals
(
"0"
)
&&
e
.
getIsShow
().
equals
(
"0"
)){
continue
;
}
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"id"
,
e
.
getId
());
map
.
put
(
"pId"
,
e
.
getParentId
());
map
.
put
(
"name"
,
e
.
getName
());
mapList
.
add
(
map
);
}
}
return
mapList
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/OfficeController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.entity.Office
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.OfficeService
;
import
com.jeespring.modules.sys.utils.DictUtils
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 机构Controller
* @author 黄炳桂 516821420@qq.com
* @version 2013-5-15
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/office"
)
public
class
OfficeController
extends
AbstractBaseController
{
@Autowired
private
OfficeService
officeService
;
@Autowired
private
SysConfigService
sysConfigService
;
@ModelAttribute
(
"office"
)
public
Office
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
)){
return
officeService
.
get
(
id
);
}
else
{
return
new
Office
();
}
}
//RequiresPermissions("sys:office:index")
@RequestMapping
(
value
=
{
""
,
"index"
})
public
String
index
(
Office
office
,
Model
model
)
{
// model.addAttribute("list", officeService.findAll());
return
"modules/sys/officeIndex"
;
}
//RequiresPermissions("sys:office:index")
@RequestMapping
(
value
=
{
"list"
})
public
String
list
(
Office
office
,
Model
model
)
{
if
(
office
==
null
||
office
.
getParentIds
()
==
null
){
model
.
addAttribute
(
"list"
,
officeService
.
findList
(
false
));
}
else
{
model
.
addAttribute
(
"list"
,
officeService
.
findList
(
office
));
}
return
"modules/sys/officeList"
;
}
//RequiresPermissions(value={"sys:office:view","sys:office:add","sys:office:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
Office
office
,
Model
model
)
{
User
user
=
UserUtils
.
getUser
();
if
(
office
.
getParent
()==
null
||
office
.
getParent
().
getId
()==
null
){
office
.
setParent
(
user
.
getOffice
());
}
office
.
setParent
(
officeService
.
get
(
office
.
getParent
().
getId
()));
if
(
office
.
getArea
()==
null
){
office
.
setArea
(
user
.
getOffice
().
getArea
());
}
// 自动获取排序号
if
(
StringUtils
.
isBlank
(
office
.
getId
())&&
office
.
getParent
()!=
null
){
int
size
=
0
;
List
<
Office
>
list
=
officeService
.
findAll
();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
Office
e
=
list
.
get
(
i
);
if
(
e
.
getParent
()!=
null
&&
e
.
getParent
().
getId
()!=
null
&&
e
.
getParent
().
getId
().
equals
(
office
.
getParent
().
getId
())){
size
++;
}
}
office
.
setCode
(
office
.
getParent
().
getCode
()
+
StringUtils
.
leftPad
(
String
.
valueOf
(
size
>
0
?
size
+
1
:
1
),
3
,
"0"
));
}
model
.
addAttribute
(
"office"
,
office
);
return
"modules/sys/officeForm"
;
}
//RequiresPermissions(value={"sys:office:add","sys:office:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
Office
office
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/office/"
;
}
if
(!
beanValidator
(
model
,
office
)){
return
form
(
office
,
model
);
}
officeService
.
save
(
office
);
if
(
office
.
getChildDeptList
()!=
null
){
Office
childOffice
=
null
;
for
(
String
id
:
office
.
getChildDeptList
()){
childOffice
=
new
Office
();
childOffice
.
setName
(
DictUtils
.
getDictLabel
(
id
,
"sys_office_common"
,
"未知"
));
childOffice
.
setParent
(
office
);
childOffice
.
setArea
(
office
.
getArea
());
childOffice
.
setType
(
"2"
);
childOffice
.
setGrade
(
String
.
valueOf
(
Integer
.
valueOf
(
office
.
getGrade
())+
1
));
childOffice
.
setUseable
(
Global
.
YES
);
officeService
.
save
(
childOffice
);
}
}
addMessage
(
redirectAttributes
,
"保存机构'"
+
office
.
getName
()
+
"'成功"
);
String
id
=
"0"
.
equals
(
office
.
getParentId
())
?
""
:
office
.
getParentId
();
return
"redirect:"
+
adminPath
+
"/sys/office/list?id="
+
id
+
"&parentIds="
+
office
.
getParentIds
();
}
//RequiresPermissions("sys:office:del")
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
Office
office
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/office/list"
;
}
// if (Office.isRoot(id)){
// addMessage(redirectAttributes, "删除机构失败, 不允许删除顶级机构或编号空");
// }else{
officeService
.
delete
(
office
);
addMessage
(
redirectAttributes
,
"删除机构成功"
);
// }
return
"redirect:"
+
adminPath
+
"/sys/office/list?id="
+
office
.
getParentId
()+
"&parentIds="
+
office
.
getParentIds
();
}
/**
* 获取机构JSON数据。
* @param extId 排除的ID
* @param type 类型(1:公司;2:部门/小组/其它:3:用户)
* @param grade 显示级别
* @param response
* @return
*/
//RequiresPermissions("user")
@ResponseBody
@RequestMapping
(
value
=
"treeData"
)
public
List
<
Map
<
String
,
Object
>>
treeData
(
@RequestParam
(
required
=
false
)
String
extId
,
@RequestParam
(
required
=
false
)
String
type
,
@RequestParam
(
required
=
false
)
Long
grade
,
@RequestParam
(
required
=
false
)
Boolean
isAll
,
HttpServletResponse
response
)
{
List
<
Map
<
String
,
Object
>>
mapList
=
Lists
.
newArrayList
();
List
<
Office
>
list
=
officeService
.
findList
(
isAll
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
Office
e
=
list
.
get
(
i
);
if
((
StringUtils
.
isBlank
(
extId
)
||
(
extId
!=
null
&&
!
extId
.
equals
(
e
.
getId
())
&&
e
.
getParentIds
().
indexOf
(
","
+
extId
+
","
)==-
1
))
&&
(
type
==
null
||
(
type
!=
null
&&
(
type
.
equals
(
"1"
)
?
type
.
equals
(
e
.
getType
())
:
true
)))
&&
(
grade
==
null
||
(
grade
!=
null
&&
Integer
.
parseInt
(
e
.
getGrade
())
<=
grade
.
intValue
()))
&&
Global
.
YES
.
equals
(
e
.
getUseable
())){
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"id"
,
e
.
getId
());
map
.
put
(
"pId"
,
e
.
getParentId
());
map
.
put
(
"pIds"
,
e
.
getParentIds
());
map
.
put
(
"name"
,
e
.
getName
());
if
(
type
!=
null
&&
"3"
.
equals
(
type
)){
map
.
put
(
"isParent"
,
true
);
}
mapList
.
add
(
map
);
}
}
return
mapList
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/RegisterController.java
0 → 100644
View file @
8b643e22
package
com.jeespring.modules.sys.web
;
import
java.io.IOException
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.json.AjaxJson
;
import
com.jeespring.common.utils.FileUtils
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.dao.UserDao
;
import
com.jeespring.modules.sys.entity.Office
;
import
com.jeespring.modules.sys.entity.Role
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.OfficeService
;
import
com.jeespring.modules.sys.service.SystemService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 用户Controller
* @author 黄炳桂 516821420@qq.com
* @version 2013-8-29
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/register"
)
public
class
RegisterController
extends
AbstractBaseController
{
@Autowired
private
SystemService
systemService
;
@Autowired
private
OfficeService
officeService
;
@Autowired
private
UserDao
userDao
;
@ModelAttribute
public
User
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
)){
return
systemService
.
getUser
(
id
);
}
else
{
return
new
User
();
}
}
@RequestMapping
(
value
=
{
"index"
,
""
})
public
String
register
(
User
user
,
Model
model
)
{
//return "modules/sys/register";
//return "redirect:" + adminPath + "/login";
//return "redirect:" + adminPath + "/register";
model
.
addAttribute
(
"user"
,
user
);
return
"modules/sys/sysRegister"
;
}
@RequestMapping
(
value
=
"registerUser"
)
public
String
registerUser
(
HttpServletRequest
request
,
HttpServletResponse
response
,
boolean
mobileLogin
,
String
randomCode
,
String
roleName
,
User
user
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
//验证手机号是否已经注册
if
(
userDao
.
findUniqueByProperty
(
"mobile"
,
user
.
getMobile
())
!=
null
){
// 如果是手机登录,则返回JSON字符串
if
(
mobileLogin
){
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"1"
);
j
.
setMsg
(
"手机号已经被使用!"
);
return
renderString
(
response
,
j
.
getJsonStr
());
}
else
{
addMessage
(
redirectAttributes
,
"手机号已经被使用!"
);
model
.
addAttribute
(
"message"
,
"手机号已经被使用!"
);
return
register
(
user
,
model
);
}
}
//验证用户是否已经注册
if
(
userDao
.
findUniqueByProperty
(
"login_name"
,
user
.
getLoginName
())
!=
null
){
// 如果是手机登录,则返回JSON字符串
if
(
mobileLogin
){
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"2"
);
j
.
setMsg
(
"用户名已经被注册!"
);
return
renderString
(
response
,
j
.
getJsonStr
());
}
else
{
addMessage
(
redirectAttributes
,
"用户名已经被注册!"
);
model
.
addAttribute
(
"message"
,
"用户名已经被注册!"
);
return
register
(
user
,
model
);
}
}
//验证短信内容
/*if(!randomCode.equals(request.getSession().getServletContext().getAttribute(user.getMobile()))){
// 如果是手机登录,则返回JSON字符串
if (mobileLogin){
AjaxJson j = new AjaxJson();
j.setSuccess(false);
j.setErrorCode("3");
j.setMsg("手机验证码不正确!");
return renderString(response, j.getJsonStr());
}else{
addMessage(model, "手机验证码不正确!");
return register(user, model);
}
}*/
// 修正引用赋值问题,不知道为何,Company和Office引用的一个实例地址,修改了一个,另外一个跟着修改。
Role
role
=
systemService
.
getRoleByEnname
(
roleName
);
String
officeCode
=
"1000"
;
if
(
roleName
.
equals
(
"patient"
)){
officeCode
=
"1001"
;
}
Office
office
=
officeService
.
getByCode
(
officeCode
);
// 密码MD5加密
user
.
setPassword
(
SystemService
.
entryptPassword
(
user
.
getPassword
()));
if
(
systemService
.
getUserByLoginName
(
user
.
getLoginName
())
!=
null
){
addMessage
(
redirectAttributes
,
"注册用户'"
+
user
.
getLoginName
()
+
"'失败,用户名已存在"
);
model
.
addAttribute
(
"message"
,
"注册用户'"
+
user
.
getLoginName
()
+
"'失败,用户名已存在"
);
return
register
(
user
,
model
);
}
// 角色数据有效性验证,过滤不在授权内的角色
List
<
Role
>
roleList
=
Lists
.
newArrayList
();
roleList
.
add
(
role
);
user
.
setRoleList
(
roleList
);
//保存机构
user
.
setCompany
(
office
);
user
.
setOffice
(
office
);
//生成用户二维码,使用登录名
String
realPath
=
Global
.
getUserfilesBaseDir
()
+
Global
.
USERFILES_BASE_URL
+
user
.
getId
()
+
"/qrcode/"
;
FileUtils
.
createDirectory
(
realPath
);
String
name
=
user
.
getId
()+
".png"
;
//encoderImgId此处二维码的图片名
String
filePath
=
realPath
+
name
;
//存放路径
//TwoDimensionCode.encoderQRCode(user.getLoginName(), filePath, "png");//执行生成二维码
user
.
setQrCode
(
request
.
getContextPath
()+
Global
.
USERFILES_BASE_URL
+
user
.
getId
()
+
"/qrcode/"
+
name
);
// 保存用户信息
systemService
.
saveUser
(
user
);
// 清除当前用户缓存
if
(
user
.
getLoginName
().
equals
(
UserUtils
.
getUser
().
getLoginName
())){
UserUtils
.
clearCache
();
//UserUtils.getCacheMap().clear();
}
request
.
getSession
().
getServletContext
().
removeAttribute
(
user
.
getMobile
());
//清除验证码
// 如果是手机登录,则返回JSON字符串
if
(
mobileLogin
){
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
true
);
j
.
setMsg
(
"注册用户'"
+
user
.
getLoginName
()
+
"'成功"
);
return
renderString
(
response
,
j
);
}
addMessage
(
redirectAttributes
,
"注册用户'"
+
user
.
getLoginName
()
+
"'成功"
);
return
"redirect:"
+
adminPath
+
"/login"
;
}
/**
* 获取验证码
* @param request
* @param response
* @param mobile
* @param model
* @param redirectAttributes
* @return
*/
@RequestMapping
(
value
=
"getRegisterCode"
)
@ResponseBody
public
AjaxJson
getRegisterCode
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
mobile
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
AjaxJson
j
=
new
AjaxJson
();
//验证手机号是否已经注册
if
(
userDao
.
findUniqueByProperty
(
"mobile"
,
mobile
)
!=
null
){
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"1"
);
j
.
setMsg
(
"手机号已经被使用!"
);
return
j
;
}
String
randomCode
=
String
.
valueOf
((
int
)
(
Math
.
random
()
*
9000
+
1000
));
try
{
String
result
=
UserUtils
.
sendRandomCode
(
mobile
,
randomCode
,
mobile
,
randomCode
);
if
(!
result
.
equals
(
"100"
))
{
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"2"
);
j
.
setMsg
(
"短信发送失败,错误代码:"
+
result
+
",请联系管理员。"
);
}
else
{
j
.
setSuccess
(
true
);
j
.
setErrorCode
(
"-1"
);
j
.
setMsg
(
"短信发送成功!"
);
request
.
getSession
().
getServletContext
().
setAttribute
(
mobile
,
randomCode
);
}
}
catch
(
IOException
e
)
{
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"3"
);
j
.
setMsg
(
"因未知原因导致短信发送失败,请联系管理员。"
);
}
return
j
;
}
/**
* web端ajax验证手机验证码是否正确
*/
@ResponseBody
@RequestMapping
(
value
=
"validateMobileCode"
)
public
boolean
validateMobileCode
(
HttpServletRequest
request
,
String
mobile
,
String
randomCode
)
{
if
(
randomCode
.
equals
(
request
.
getSession
().
getServletContext
().
getAttribute
(
mobile
)))
{
return
true
;
}
else
{
return
false
;
}
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/RoleController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.Collections3
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.entity.Office
;
import
com.jeespring.modules.sys.entity.Role
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.OfficeService
;
import
com.jeespring.modules.sys.service.SystemService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 角色Controller
* @author 黄炳桂 516821420@qq.com
* @version 2013-12-05
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/role"
)
public
class
RoleController
extends
AbstractBaseController
{
@Autowired
private
SystemService
systemService
;
@Autowired
private
OfficeService
officeService
;
@Autowired
private
SysConfigService
sysConfigService
;
@ModelAttribute
(
"role"
)
public
Role
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
)){
return
systemService
.
getRole
(
id
);
}
else
{
return
new
Role
();
}
}
//RequiresPermissions("sys:role:list")
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
Role
role
,
Model
model
)
{
List
<
Role
>
list
=
systemService
.
findRole
(
role
);
model
.
addAttribute
(
"list"
,
list
);
return
"modules/sys/roleList"
;
}
//RequiresPermissions(value={"sys:role:view","sys:role:add","sys:role:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
Role
role
,
Model
model
)
{
if
(
role
.
getOffice
()==
null
){
role
.
setOffice
(
UserUtils
.
getUser
().
getOffice
());
}
model
.
addAttribute
(
"role"
,
role
);
model
.
addAttribute
(
"menuList"
,
systemService
.
findAllMenu
());
model
.
addAttribute
(
"officeList"
,
officeService
.
findAll
());
return
"modules/sys/roleForm"
;
}
//RequiresPermissions("sys:role:auth")
@RequestMapping
(
value
=
"auth"
)
public
String
auth
(
Role
role
,
Model
model
)
{
if
(
role
.
getOffice
()==
null
){
role
.
setOffice
(
UserUtils
.
getUser
().
getOffice
());
}
model
.
addAttribute
(
"role"
,
role
);
model
.
addAttribute
(
"menuList"
,
systemService
.
findAllMenu
());
model
.
addAttribute
(
"officeList"
,
officeService
.
findAll
());
return
"modules/sys/roleAuth"
;
}
//RequiresPermissions(value={"sys:role:assign","sys:role:auth","sys:role:add","sys:role:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
Role
role
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(!
UserUtils
.
getUser
().
isAdmin
()&&
role
.
getSysData
().
equals
(
Global
.
YES
)){
addMessage
(
redirectAttributes
,
"越权操作,只有超级管理员才能修改此数据!"
);
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
if
(!
beanValidator
(
model
,
role
)){
return
list
(
role
,
model
);
}
if
(!
"true"
.
equals
(
checkName
(
role
.
getOldName
(),
role
.
getName
()))){
addMessage
(
model
,
"保存角色'"
+
role
.
getName
()
+
"'失败, 角色名已存在"
);
return
list
(
role
,
model
);
}
if
(!
"true"
.
equals
(
checkEnname
(
role
.
getOldEnname
(),
role
.
getEnname
()))){
addMessage
(
model
,
"保存角色'"
+
role
.
getName
()
+
"'失败, 英文名已存在"
);
return
list
(
role
,
model
);
}
systemService
.
saveRole
(
role
);
addMessage
(
redirectAttributes
,
"保存角色'"
+
role
.
getName
()
+
"'成功"
);
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
//RequiresPermissions("sys:role:del")
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
Role
role
,
RedirectAttributes
redirectAttributes
)
{
if
(!
UserUtils
.
getUser
().
isAdmin
()
&&
role
.
getSysData
().
equals
(
Global
.
YES
)){
addMessage
(
redirectAttributes
,
"越权操作,只有超级管理员才能修改此数据!"
);
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
// if (Role.isAdmin(id)){
// addMessage(redirectAttributes, "删除角色失败, 不允许内置角色或编号空");
//// }else if (UserUtils.getUser().getRoleIdList().contains(id)){
//// addMessage(redirectAttributes, "删除角色失败, 不能删除当前用户所在角色");
// }else{
systemService
.
deleteRole
(
role
);
addMessage
(
redirectAttributes
,
"删除角色成功"
);
// }
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
/**
* 批量删除角色
*/
//RequiresPermissions("sys:role:del")
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
String
idArray
[]
=
ids
.
split
(
","
);
StringBuffer
msg
=
new
StringBuffer
();
for
(
String
id
:
idArray
){
Role
role
=
systemService
.
getRole
(
id
);
if
(!
UserUtils
.
getUser
().
isAdmin
()
&&
role
.
getSysData
().
equals
(
Global
.
YES
)){
msg
.
append
(
"越权操作,只有超级管理员才能修改["
+
role
.
getName
()+
"]数据!<br/>"
);
}
else
{
systemService
.
deleteRole
(
role
);
msg
.
append
(
"删除角色["
+
role
.
getName
()+
"]成功<br/>"
);
}
}
addMessage
(
redirectAttributes
,
msg
.
toString
());
return
"redirect:"
+
adminPath
+
"/sys/role/?repage"
;
}
/**
* 角色分配页面
* @param role
* @param model
* @return
*/
//RequiresPermissions("sys:role:assign")
@RequestMapping
(
value
=
"assign"
)
public
String
assign
(
Role
role
,
Model
model
)
{
List
<
User
>
userList
=
systemService
.
findUser
(
new
User
(
new
Role
(
role
.
getId
())));
model
.
addAttribute
(
"userList"
,
userList
);
return
"modules/sys/roleAssign"
;
}
/**
* 角色分配 -- 打开角色分配对话框
* @param role
* @param model
* @return
*/
//RequiresPermissions("sys:role:assign")
@RequestMapping
(
value
=
"usertorole"
)
public
String
selectUserToRole
(
Role
role
,
Model
model
)
{
List
<
User
>
userList
=
systemService
.
findUser
(
new
User
(
new
Role
(
role
.
getId
())));
model
.
addAttribute
(
"role"
,
role
);
model
.
addAttribute
(
"userList"
,
userList
);
model
.
addAttribute
(
"selectIds"
,
Collections3
.
extractToString
(
userList
,
"name"
,
","
));
model
.
addAttribute
(
"officeList"
,
officeService
.
findAll
());
return
"modules/sys/selectUserToRole"
;
}
/**
* 角色分配 -- 根据部门编号获取用户列表
* @param officeId
* @param response
* @return
*/
//RequiresPermissions("sys:role:assign")
@ResponseBody
@RequestMapping
(
value
=
"users"
)
public
List
<
Map
<
String
,
Object
>>
users
(
String
officeId
,
HttpServletResponse
response
)
{
List
<
Map
<
String
,
Object
>>
mapList
=
Lists
.
newArrayList
();
User
user
=
new
User
();
user
.
setOffice
(
new
Office
(
officeId
));
Page
<
User
>
page
=
systemService
.
findUser
(
new
Page
<
User
>(
1
,
-
1
),
user
);
for
(
User
e
:
page
.
getList
())
{
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"id"
,
e
.
getId
());
map
.
put
(
"pId"
,
0
);
map
.
put
(
"name"
,
e
.
getName
());
mapList
.
add
(
map
);
}
return
mapList
;
}
/**
* 角色分配 -- 从角色中移除用户
* @param userId
* @param roleId
* @param redirectAttributes
* @return
*/
//RequiresPermissions("sys:role:assign")
@RequestMapping
(
value
=
"outrole"
)
public
String
outrole
(
String
userId
,
String
roleId
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/role/assign?id="
+
roleId
;
}
Role
role
=
systemService
.
getRole
(
roleId
);
User
user
=
systemService
.
getUser
(
userId
);
if
(
UserUtils
.
getUser
().
getId
().
equals
(
userId
))
{
addMessage
(
redirectAttributes
,
"无法从角色【"
+
role
.
getName
()
+
"】中移除用户【"
+
user
.
getName
()
+
"】自己!"
);
}
else
{
if
(
user
.
getRoleList
().
size
()
<=
1
){
addMessage
(
redirectAttributes
,
"用户【"
+
user
.
getName
()
+
"】从角色【"
+
role
.
getName
()
+
"】中移除失败!这已经是该用户的唯一角色,不能移除。"
);
}
else
{
Boolean
flag
=
systemService
.
outUserInRole
(
role
,
user
);
if
(!
flag
)
{
addMessage
(
redirectAttributes
,
"用户【"
+
user
.
getName
()
+
"】从角色【"
+
role
.
getName
()
+
"】中移除失败!"
);
}
else
{
addMessage
(
redirectAttributes
,
"用户【"
+
user
.
getName
()
+
"】从角色【"
+
role
.
getName
()
+
"】中移除成功!"
);
}
}
}
return
"redirect:"
+
adminPath
+
"/sys/role/assign?id="
+
role
.
getId
();
}
/**
* 角色分配
* @param role
* @param idsArr
* @param redirectAttributes
* @return
*/
//RequiresPermissions("sys:role:assign")
@RequestMapping
(
value
=
"assignrole"
)
public
String
assignRole
(
Role
role
,
String
[]
idsArr
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/role/assign?id="
+
role
.
getId
();
}
StringBuilder
msg
=
new
StringBuilder
();
int
newNum
=
0
;
for
(
int
i
=
0
;
i
<
idsArr
.
length
;
i
++)
{
User
user
=
systemService
.
assignUserToRole
(
role
,
systemService
.
getUser
(
idsArr
[
i
]));
if
(
null
!=
user
)
{
msg
.
append
(
"<br/>新增用户【"
+
user
.
getName
()
+
"】到角色【"
+
role
.
getName
()
+
"】!"
);
newNum
++;
}
}
addMessage
(
redirectAttributes
,
"已成功分配 "
+
newNum
+
" 个用户"
+
msg
);
return
"redirect:"
+
adminPath
+
"/sys/role/assign?id="
+
role
.
getId
();
}
/**
* 验证角色名是否有效
* @param oldName
* @param name
* @return
*/
//RequiresPermissions("user")
@ResponseBody
@RequestMapping
(
value
=
"checkName"
)
public
String
checkName
(
String
oldName
,
String
name
)
{
if
(
name
!=
null
&&
name
.
equals
(
oldName
))
{
return
"true"
;
}
else
if
(
name
!=
null
&&
systemService
.
getRoleByName
(
name
)
==
null
)
{
return
"true"
;
}
return
"false"
;
}
/**
* 验证角色英文名是否有效
* @param oldName
* @param name
* @return
*/
//RequiresPermissions("user")
@ResponseBody
@RequestMapping
(
value
=
"checkEnname"
)
public
String
checkEnname
(
String
oldEnname
,
String
enname
)
{
if
(
enname
!=
null
&&
enname
.
equals
(
oldEnname
))
{
return
"true"
;
}
else
if
(
enname
!=
null
&&
systemService
.
getRoleByEnname
(
enname
)
==
null
)
{
return
"true"
;
}
return
"false"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/SysConfigController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.DateUtils
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.utils.excel.ExportExcel
;
import
com.jeespring.common.utils.excel.ImportExcel
;
import
com.jeespring.modules.sys.entity.SysConfig
;
import
com.jeespring.modules.sys.service.SysConfigService
;
/**
* 系统配置Controller
* @author 黄炳桂 516821420@qq.com
* @version 2017-11-17
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/sysConfig"
)
public
class
SysConfigController
extends
AbstractBaseController
{
@Autowired
private
SysConfigService
sysConfigService
;
@ModelAttribute
public
SysConfig
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
SysConfig
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
sysConfigService
.
get
(
id
);
}
if
(
entity
==
null
){
entity
=
new
SysConfig
();
}
return
entity
;
}
/**
* 系统配置列表页面
*/
//RequiresPermissions("sys:sysConfig:list")
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
SysConfig
sysConfig
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysConfig
>
page
=
sysConfigService
.
findPage
(
new
Page
<
SysConfig
>(
request
,
response
),
sysConfig
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/sysConfigList"
;
}
/**
* 系统配置列表页面
*/
//RequiresPermissions("sys:sysConfig:select")
@RequestMapping
(
value
=
{
"select"
})
public
String
select
(
SysConfig
sysConfig
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysConfig
>
page
=
sysConfigService
.
findPage
(
new
Page
<
SysConfig
>(
request
,
response
),
sysConfig
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/sysConfigSelect"
;
}
/**
* 查看,增加,编辑系统配置表单页面
*/
//RequiresPermissions(value={"sys:sysConfig:view","sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
SysConfig
sysConfig
,
Model
model
)
{
model
.
addAttribute
(
"sysConfig"
,
sysConfig
);
return
"modules/sys/sysConfigForm"
;
}
/**
* 保存系统配置
*/
//RequiresPermissions(value={"sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
SysConfig
sysConfig
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfig/?repage"
;
}
if
(!
beanValidator
(
model
,
sysConfig
)){
return
form
(
sysConfig
,
model
);
}
sysConfigService
.
save
(
sysConfig
);
addMessage
(
redirectAttributes
,
"保存系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
/**
* 删除系统配置
*/
//RequiresPermissions("sys:sysConfig:del")
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
SysConfig
sysConfig
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfig/?repage"
;
}
sysConfigService
.
delete
(
sysConfig
);
addMessage
(
redirectAttributes
,
"删除系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
/**
* 删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
//RequiresPermissions("sys:sysConfig:delByLogic")
@RequestMapping
(
value
=
"deleteByLogic"
)
public
String
deleteByLogic
(
SysConfig
sysConfig
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfig/?repage"
;
}
sysConfigService
.
deleteByLogic
(
sysConfig
);
addMessage
(
redirectAttributes
,
"逻辑删除系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
/**
* 批量删除系统配置
*/
//RequiresPermissions("sys:sysConfig:del")
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfig/?repage"
;
}
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
sysConfigService
.
delete
(
sysConfigService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
/**
* 批量删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
//RequiresPermissions("sys:sysConfig:delByLogic")
@RequestMapping
(
value
=
"deleteAllByLogic"
)
public
String
deleteAllByLogic
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfig/?repage"
;
}
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
sysConfigService
.
deleteByLogic
(
sysConfigService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
/**
* 导出excel文件
*/
//RequiresPermissions("sys:sysConfig:export")
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
SysConfig
sysConfig
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"系统配置"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
SysConfig
>
page
=
sysConfigService
.
findPage
(
new
Page
<
SysConfig
>(
request
,
response
,
-
1
),
sysConfig
);
new
ExportExcel
(
"系统配置"
,
SysConfig
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出系统配置记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
/**
* 导入Excel数据
*/
//RequiresPermissions("sys:sysConfig:import")
@RequestMapping
(
value
=
"import"
,
method
=
RequestMethod
.
POST
)
public
String
importFile
(
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
try
{
int
successNum
=
0
;
ImportExcel
ei
=
new
ImportExcel
(
file
,
1
,
0
);
List
<
SysConfig
>
list
=
ei
.
getDataList
(
SysConfig
.
class
);
for
(
SysConfig
sysConfig
:
list
){
sysConfigService
.
save
(
sysConfig
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条系统配置记录"
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入系统配置失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
/**
* 下载导入系统配置数据模板
*/
//RequiresPermissions("sys:sysConfig:import")
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"系统配置数据导入模板.xlsx"
;
List
<
SysConfig
>
list
=
Lists
.
newArrayList
();
new
ExportExcel
(
"系统配置数据"
,
SysConfig
.
class
,
1
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfig/?repage"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/SysConfigTreeController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.sys.entity.SysConfigTree
;
import
com.jeespring.modules.sys.service.SysConfigTreeService
;
/**
* 系统配置Controller
* @author JeeSpring
* @version 2018-08-22
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/sysConfigTree"
)
public
class
SysConfigTreeController
extends
AbstractBaseController
{
@Autowired
private
SysConfigService
sysConfigService
;
@Autowired
private
SysConfigTreeService
sysConfigTreeService
;
@ModelAttribute
public
SysConfigTree
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
SysConfigTree
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
sysConfigTreeService
.
get
(
id
);
}
if
(
entity
==
null
){
entity
=
new
SysConfigTree
();
}
return
entity
;
}
/**
* 系统配置列表页面
*/
//@RequiresPermissions("sys:sysConfig:list")
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
SysConfigTree
sysConfig
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
List
<
SysConfigTree
>
list
=
sysConfigTreeService
.
findList
(
sysConfig
);
for
(
SysConfigTree
item:
list
){
if
(
item
.
getDescription
()==
null
)
item
.
setDescription
(
""
);
if
(
item
.
getDescription
().
length
()>
20
)
item
.
setDescription
(
item
.
getDescription
().
substring
(
0
,
20
));
}
model
.
addAttribute
(
"list"
,
list
);
return
"modules/sys/sysConfigTreeList"
;
}
/**
* 查看,增加,编辑系统配置表单页面
*/
//@RequiresPermissions(value={"sys:sysConfig:view","sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
SysConfigTree
sysConfig
,
Model
model
)
{
if
(
sysConfig
.
getParent
()!=
null
&&
StringUtils
.
isNotBlank
(
sysConfig
.
getParent
().
getId
())){
sysConfig
.
setParent
(
sysConfigTreeService
.
get
(
sysConfig
.
getParent
().
getId
()));
// 获取排序号,最末节点排序号+30
if
(
StringUtils
.
isBlank
(
sysConfig
.
getId
())){
SysConfigTree
sysConfigChild
=
new
SysConfigTree
();
sysConfigChild
.
setParent
(
new
SysConfigTree
(
sysConfig
.
getParent
().
getId
()));
List
<
SysConfigTree
>
list
=
sysConfigTreeService
.
findList
(
sysConfig
);
if
(
list
.
size
()
>
0
){
sysConfig
.
setSort
(
list
.
get
(
list
.
size
()-
1
).
getSort
());
if
(
sysConfig
.
getSort
()
!=
null
){
sysConfig
.
setSort
(
sysConfig
.
getSort
()
+
30
);
}
}
}
}
if
(
sysConfig
.
getSort
()
==
null
){
sysConfig
.
setSort
(
30
);
}
model
.
addAttribute
(
"sysConfig"
,
sysConfig
);
return
"modules/sys/sysConfigTreeForm"
;
}
/**
* 保存系统配置
*/
//@RequiresPermissions(value={"sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
SysConfigTree
sysConfig
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfigTree/?repage"
;
}
if
(!
beanValidator
(
model
,
sysConfig
)){
return
form
(
sysConfig
,
model
);
}
sysConfigTreeService
.
save
(
sysConfig
);
addMessage
(
redirectAttributes
,
"保存系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfigTree/?repage"
;
}
/**
* 删除系统配置
*/
//@RequiresPermissions("sys:sysConfig:del")
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
SysConfigTree
sysConfig
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfigTree/?repage"
;
}
sysConfigTreeService
.
delete
(
sysConfig
);
addMessage
(
redirectAttributes
,
"删除系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysConfigTree/?repage"
;
}
//@RequiresPermissions("user")
@ResponseBody
@RequestMapping
(
value
=
"treeData"
)
public
List
<
Map
<
String
,
Object
>>
treeData
(
@RequestParam
(
required
=
false
)
String
extId
,
HttpServletResponse
response
)
{
List
<
Map
<
String
,
Object
>>
mapList
=
Lists
.
newArrayList
();
List
<
SysConfigTree
>
list
=
sysConfigTreeService
.
findList
(
new
SysConfigTree
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
SysConfigTree
e
=
list
.
get
(
i
);
if
(
StringUtils
.
isBlank
(
extId
)
||
(
extId
!=
null
&&
!
extId
.
equals
(
e
.
getId
())
&&
e
.
getParentIds
().
indexOf
(
","
+
extId
+
","
)==-
1
)){
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"id"
,
e
.
getId
());
map
.
put
(
"pId"
,
e
.
getParentId
());
map
.
put
(
"name"
,
e
.
getName
());
mapList
.
add
(
map
);
}
}
return
mapList
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/SysDictTreeController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.sys.entity.SysDictTree
;
import
com.jeespring.modules.sys.service.SysDictTreeService
;
/**
* 数据字典Controller
* @author JeeSpring
* @version 2018-08-22
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/sysDictTree"
)
public
class
SysDictTreeController
extends
AbstractBaseController
{
@Autowired
private
SysConfigService
sysConfigService
;
@Autowired
private
SysDictTreeService
sysDictTreeService
;
@ModelAttribute
public
SysDictTree
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
SysDictTree
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
sysDictTreeService
.
get
(
id
);
}
if
(
entity
==
null
){
entity
=
new
SysDictTree
();
}
return
entity
;
}
/**
* 数据字典列表页面
*/
//@RequiresPermissions("sys:sysDict:list")
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
SysDictTree
sysDict
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
List
<
SysDictTree
>
list
=
sysDictTreeService
.
findList
(
sysDict
);
model
.
addAttribute
(
"list"
,
list
);
return
"modules/sys/sysDictTreeList"
;
}
/**
* 查看,增加,编辑数据字典表单页面
*/
//@RequiresPermissions(value={"sys:sysDict:view","sys:sysDict:add","sys:sysDict:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
SysDictTree
sysDict
,
Model
model
)
{
if
(
sysDict
.
getParent
()!=
null
&&
StringUtils
.
isNotBlank
(
sysDict
.
getParent
().
getId
())){
sysDict
.
setParent
(
sysDictTreeService
.
get
(
sysDict
.
getParent
().
getId
()));
// 获取排序号,最末节点排序号+30
if
(
StringUtils
.
isBlank
(
sysDict
.
getId
())){
SysDictTree
sysDictChild
=
new
SysDictTree
();
sysDictChild
.
setParent
(
new
SysDictTree
(
sysDict
.
getParent
().
getId
()));
List
<
SysDictTree
>
list
=
sysDictTreeService
.
findList
(
sysDict
);
if
(
list
.
size
()
>
0
){
sysDict
.
setSort
(
list
.
get
(
list
.
size
()-
1
).
getSort
());
if
(
sysDict
.
getSort
()
!=
null
){
sysDict
.
setSort
(
sysDict
.
getSort
()
+
30
);
}
}
}
}
if
(
sysDict
.
getSort
()
==
null
){
sysDict
.
setSort
(
30
);
}
model
.
addAttribute
(
"sysDict"
,
sysDict
);
return
"modules/sys/sysDictTreeForm"
;
}
/**
* 保存数据字典
*/
//@RequiresPermissions(value={"sys:sysDict:add","sys:sysDict:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
SysDictTree
sysDict
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfigTree/?repage"
;
}
if
(!
beanValidator
(
model
,
sysDict
)){
return
form
(
sysDict
,
model
);
}
sysDictTreeService
.
save
(
sysDict
);
addMessage
(
redirectAttributes
,
"保存数据字典成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysDictTree/?repage"
;
}
/**
* 删除数据字典
*/
//@RequiresPermissions("sys:sysDict:del")
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
SysDictTree
sysDict
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysConfigTree/?repage"
;
}
sysDictTreeService
.
delete
(
sysDict
);
addMessage
(
redirectAttributes
,
"删除数据字典成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysDictTree/?repage"
;
}
//@RequiresPermissions("user")
@ResponseBody
@RequestMapping
(
value
=
"treeData"
)
public
List
<
Map
<
String
,
Object
>>
treeData
(
@RequestParam
(
required
=
false
)
String
extId
,
HttpServletResponse
response
)
{
List
<
Map
<
String
,
Object
>>
mapList
=
Lists
.
newArrayList
();
List
<
SysDictTree
>
list
=
sysDictTreeService
.
findList
(
new
SysDictTree
());
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
SysDictTree
e
=
list
.
get
(
i
);
if
(
StringUtils
.
isBlank
(
extId
)
||
(
extId
!=
null
&&
!
extId
.
equals
(
e
.
getId
())
&&
e
.
getParentIds
().
indexOf
(
","
+
extId
+
","
)==-
1
)){
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"id"
,
e
.
getId
());
map
.
put
(
"pId"
,
e
.
getParentId
());
map
.
put
(
"name"
,
e
.
getName
());
mapList
.
add
(
map
);
}
}
return
mapList
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/SysUserOnlineController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.DateUtils
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.utils.excel.ExportExcel
;
import
com.jeespring.common.utils.excel.ImportExcel
;
import
com.jeespring.modules.sys.entity.SysUserOnline
;
import
com.jeespring.modules.sys.service.SysUserOnlineService
;
/**
* 在线用户记录Controller
* @author JeeSpring
* @version 2018-08-16
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/sysUserOnline"
)
public
class
SysUserOnlineController
extends
AbstractBaseController
{
@Autowired
private
SysUserOnlineService
sysUserOnlineService
;
@ModelAttribute
public
SysUserOnline
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
SysUserOnline
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
sysUserOnlineService
.
getCache
(
id
);
//entity = sysUserOnlineService.get(id);
}
if
(
entity
==
null
){
entity
=
new
SysUserOnline
();
}
return
entity
;
}
/**
* 在线用户记录统计页面
*/
@RequiresPermissions
(
"sys:sysUserOnline:total"
)
@RequestMapping
(
value
=
{
"total"
})
public
String
totalView
(
SysUserOnline
sysUserOnline
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
total
(
sysUserOnline
,
request
,
response
,
model
);
return
"modules/sys/sysUserOnlineTotal"
;
}
private
void
total
(
SysUserOnline
sysUserOnline
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
if
(
StringUtils
.
isEmpty
(
sysUserOnline
.
getTotalType
())){
sysUserOnline
.
setTotalType
(
"%Y-%m-%d"
);
}
//X轴的数据
List
<
String
>
xAxisData
=
new
ArrayList
<
String
>();
//Y轴的数据
Map
<
String
,
List
<
Double
>>
yAxisData
=
new
HashMap
<
String
,
List
<
Double
>>();
List
<
Double
>
countList
=
new
ArrayList
<
Double
>();
List
<
Double
>
sumList
=
new
ArrayList
<
Double
>();
if
(
sysUserOnline
.
getOrderBy
()==
""
){
sysUserOnline
.
setOrderBy
(
"totalDate"
);
}
List
<
SysUserOnline
>
list
=
sysUserOnlineService
.
totalCache
(
sysUserOnline
);
//List<SysUserOnline> list = sysUserOnlineService.total(sysUserOnline);
model
.
addAttribute
(
"list"
,
list
);
for
(
SysUserOnline
sysUserOnlineItem:
list
){
//x轴数据
xAxisData
.
add
(
sysUserOnlineItem
.
getTotalDate
());
countList
.
add
(
Double
.
valueOf
(
sysUserOnlineItem
.
getTotalCount
()));
}
yAxisData
.
put
(
"数量"
,
countList
);
request
.
setAttribute
(
"xAxisData"
,
xAxisData
);
request
.
setAttribute
(
"yAxisData"
,
yAxisData
);
model
.
addAttribute
(
"sumTotalCount"
,
list
.
stream
().
mapToInt
(
SysUserOnline:
:
getTotalCount
).
sum
());
//饼图数据
Map
<
String
,
Object
>
orientData
=
new
HashMap
<
String
,
Object
>();
for
(
SysUserOnline
sysUserOnlineItem:
list
){
orientData
.
put
(
sysUserOnlineItem
.
getTotalDate
(),
sysUserOnlineItem
.
getTotalCount
());
}
model
.
addAttribute
(
"orientData"
,
orientData
);
}
@RequiresPermissions
(
"sys:sysUserOnline:total"
)
@RequestMapping
(
value
=
{
"totalMap"
})
public
String
totalMap
(
SysUserOnline
sysUserOnline
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
if
(
StringUtils
.
isEmpty
(
sysUserOnline
.
getTotalType
())){
sysUserOnline
.
setTotalType
(
"%Y-%m-%d"
);
}
List
<
SysUserOnline
>
list
=
sysUserOnlineService
.
totalCache
(
sysUserOnline
);
//List<SysUserOnline> list = sysUserOnlineService.total(sysUserOnline);
model
.
addAttribute
(
"sumTotalCount"
,
list
.
stream
().
mapToInt
(
SysUserOnline:
:
getTotalCount
).
sum
());
model
.
addAttribute
(
"list"
,
list
);
return
"modules/sys/sysUserOnlineTotalMap"
;
}
/**
* 在线用户记录列表页面
*/
@RequiresPermissions
(
"sys:sysUserOnline:list"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
SysUserOnline
sysUserOnline
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysUserOnline
>
page
=
sysUserOnlineService
.
findPageCache
(
new
Page
<
SysUserOnline
>(
request
,
response
),
sysUserOnline
);
//Page<SysUserOnline> page = sysUserOnlineService.findPage(new Page<SysUserOnline>(request, response), sysUserOnline);
model
.
addAttribute
(
"page"
,
page
);
sysUserOnline
.
setOrderBy
(
"totalDate"
);
total
(
sysUserOnline
,
request
,
response
,
model
);
return
"modules/sys/sysUserOnlineList"
;
}
/**
* 在线用户记录列表页面
*/
@RequiresPermissions
(
"sys:sysUserOnline:list"
)
@RequestMapping
(
value
=
{
"listVue"
})
public
String
listVue
(
SysUserOnline
sysUserOnline
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysUserOnline
>
page
=
sysUserOnlineService
.
findPageCache
(
new
Page
<
SysUserOnline
>(
request
,
response
),
sysUserOnline
);
//Page<SysUserOnline> page = sysUserOnlineService.findPage(new Page<SysUserOnline>(request, response), sysUserOnline);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/sysUserOnlineListVue"
;
}
/**
* 在线用户记录列表页面
*/
//RequiresPermissions("sys:sysUserOnline:select")
@RequestMapping
(
value
=
{
"select"
})
public
String
select
(
SysUserOnline
sysUserOnline
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysUserOnline
>
page
=
sysUserOnlineService
.
findPageCache
(
new
Page
<
SysUserOnline
>(
request
,
response
),
sysUserOnline
);
//Page<SysUserOnline> page = sysUserOnlineService.findPage(new Page<SysUserOnline>(request, response), sysUserOnline);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/sysUserOnlineSelect"
;
}
/**
* 查看,增加,编辑在线用户记录表单页面
*/
@RequiresPermissions
(
value
={
"sys:sysUserOnline:view"
,
"sys:sysUserOnline:add"
,
"sys:sysUserOnline:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
SysUserOnline
sysUserOnline
,
Model
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
model
.
addAttribute
(
"action"
,
request
.
getParameter
(
"action"
));
model
.
addAttribute
(
"sysUserOnline"
,
sysUserOnline
);
if
(
request
.
getParameter
(
"ViewFormType"
)!=
null
&&
request
.
getParameter
(
"ViewFormType"
).
equals
(
"FormTwo"
))
return
"modules/sys/sysUserOnlineFormTwo"
;
return
"modules/sys/sysUserOnlineForm"
;
}
/**
* 保存在线用户记录
*/
@RequiresPermissions
(
value
={
"sys:sysUserOnline:add"
,
"sys:sysUserOnline:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
SysUserOnline
sysUserOnline
,
Model
model
,
RedirectAttributes
redirectAttributes
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(!
beanValidator
(
model
,
sysUserOnline
)){
return
form
(
sysUserOnline
,
model
,
request
,
response
);
}
sysUserOnlineService
.
save
(
sysUserOnline
);
addMessage
(
redirectAttributes
,
"保存在线用户记录成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
/**
* 删除在线用户记录
*/
@RequiresPermissions
(
"sys:sysUserOnline:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
SysUserOnline
sysUserOnline
,
RedirectAttributes
redirectAttributes
)
{
sysUserOnlineService
.
delete
(
sysUserOnline
);
addMessage
(
redirectAttributes
,
"删除在线用户记录成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
/**
* 删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions
(
value
={
"sys:sysUserOnline:del"
,
"sys:sysUserOnline:delByLogic"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"deleteByLogic"
)
public
String
deleteByLogic
(
SysUserOnline
sysUserOnline
,
RedirectAttributes
redirectAttributes
)
{
sysUserOnlineService
.
deleteByLogic
(
sysUserOnline
);
addMessage
(
redirectAttributes
,
"逻辑删除在线用户记录成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
/**
* 批量删除在线用户记录
*/
@RequiresPermissions
(
"sys:sysUserOnline:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
sysUserOnlineService
.
delete
(
sysUserOnlineService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除在线用户记录成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
/**
* 批量删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions
(
value
={
"sys:sysUserOnline:del"
,
"sys:sysUserOnline:delByLogic"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"deleteAllByLogic"
)
public
String
deleteAllByLogic
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
sysUserOnlineService
.
deleteByLogic
(
sysUserOnlineService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除在线用户记录成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
/**
* 导出excel文件
*/
@RequiresPermissions
(
"sys:sysUserOnline:export"
)
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
SysUserOnline
sysUserOnline
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"在线用户记录"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
SysUserOnline
>
page
=
sysUserOnlineService
.
findPage
(
new
Page
<
SysUserOnline
>(
request
,
response
,
-
1
),
sysUserOnline
);
new
ExportExcel
(
"在线用户记录"
,
SysUserOnline
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出在线用户记录记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
/**
* 导入Excel数据
*/
@RequiresPermissions
(
"sys:sysUserOnline:import"
)
@RequestMapping
(
value
=
"import"
,
method
=
RequestMethod
.
POST
)
public
String
importFile
(
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
try
{
int
successNum
=
0
;
ImportExcel
ei
=
new
ImportExcel
(
file
,
1
,
0
);
List
<
SysUserOnline
>
list
=
ei
.
getDataList
(
SysUserOnline
.
class
);
for
(
SysUserOnline
sysUserOnline
:
list
){
sysUserOnlineService
.
save
(
sysUserOnline
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条在线用户记录记录"
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入在线用户记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
/**
* 下载导入在线用户记录数据模板
*/
@RequiresPermissions
(
"sys:sysUserOnline:import"
)
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"在线用户记录数据导入模板.xlsx"
;
List
<
SysUserOnline
>
list
=
Lists
.
newArrayList
();
new
ExportExcel
(
"在线用户记录数据"
,
SysUserOnline
.
class
,
1
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysUserOnline/?repage"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/SystemConfigController.java
0 → 100644
View file @
8b643e22
/**
* Copyright © 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.sys.web
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.json.AjaxJson
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.utils.DateUtils
;
import
com.jeespring.common.utils.MyBeanUtils
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.utils.excel.ExportExcel
;
import
com.jeespring.common.utils.excel.ImportExcel
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.entity.SystemConfig
;
import
com.jeespring.modules.sys.service.SystemConfigService
;
/**
* 系统配置Controller
* @author liugf
* @version 2016-02-07
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/systemConfig"
)
public
class
SystemConfigController
extends
AbstractBaseController
{
@Autowired
private
SystemConfigService
systemConfigService
;
@ModelAttribute
public
SystemConfig
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
SystemConfig
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
systemConfigService
.
get
(
id
);
}
if
(
entity
==
null
){
entity
=
new
SystemConfig
();
}
return
entity
;
}
/**
* 系统配置列表页面
*/
@RequiresPermissions
(
"sys:systemConfig:index"
)
@RequestMapping
(
value
=
{
"index"
,
""
})
public
String
index
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
SystemConfig
systemConfig
=
systemConfigService
.
get
(
"1"
);
model
.
addAttribute
(
"systemConfig"
,
systemConfig
);
return
"modules/sys/systemConfig"
;
}
/**
* 保存系统配置
*/
@ResponseBody
@RequestMapping
(
value
=
"save"
)
public
AjaxJson
save
(
SystemConfig
systemConfig
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
AjaxJson
j
=
new
AjaxJson
();
String
message
=
"保存系统配置成功"
;
SystemConfig
t
=
systemConfigService
.
get
(
"1"
);
try
{
systemConfig
.
setId
(
"1"
);
MyBeanUtils
.
copyBeanNotNull2Bean
(
systemConfig
,
t
);
systemConfigService
.
save
(
t
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
j
.
setSuccess
(
false
);
message
=
"保存系统配置失败"
;
}
j
.
setMsg
(
message
);
return
j
;
}
/**
* 删除系统配置
*/
@RequiresPermissions
(
"sys:systemConfig:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
SystemConfig
systemConfig
,
RedirectAttributes
redirectAttributes
)
{
systemConfigService
.
delete
(
systemConfig
);
addMessage
(
redirectAttributes
,
"删除系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/systemConfig/?repage"
;
}
/**
* 批量删除系统配置
*/
@RequiresPermissions
(
"sys:systemConfig:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
systemConfigService
.
delete
(
systemConfigService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除系统配置成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/systemConfig/?repage"
;
}
/**
* 导出excel文件
*/
@RequiresPermissions
(
"sys:systemConfig:export"
)
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
SystemConfig
systemConfig
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"系统配置"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
SystemConfig
>
page
=
systemConfigService
.
findPage
(
new
Page
<
SystemConfig
>(
request
,
response
,
-
1
),
systemConfig
);
new
ExportExcel
(
"系统配置"
,
SystemConfig
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出系统配置记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/systemConfig/?repage"
;
}
/**
* 导入Excel数据
*/
@RequiresPermissions
(
"sys:systemConfig:import"
)
@RequestMapping
(
value
=
"import"
,
method
=
RequestMethod
.
POST
)
public
String
importFile
(
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
try
{
int
successNum
=
0
;
ImportExcel
ei
=
new
ImportExcel
(
file
,
1
,
0
);
List
<
SystemConfig
>
list
=
ei
.
getDataList
(
SystemConfig
.
class
);
for
(
SystemConfig
systemConfig
:
list
){
systemConfigService
.
save
(
systemConfig
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条系统配置记录"
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入系统配置失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/systemConfig/?repage"
;
}
/**
* 下载导入系统配置数据模板
*/
@RequiresPermissions
(
"sys:systemConfig:import"
)
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"系统配置数据导入模板.xlsx"
;
List
<
SystemConfig
>
list
=
Lists
.
newArrayList
();
new
ExportExcel
(
"系统配置数据"
,
SystemConfig
.
class
,
1
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/systemConfig/?repage"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/TagController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.jeespring.common.web.AbstractBaseController
;
/**
* 标签Controller
* * * * @author 黄炳桂 516821420@qq.com
* @version 2013-3-23
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/tag"
)
public
class
TagController
extends
AbstractBaseController
{
/**
* 树结构选择标签(treeselect.tag)
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"treeselect"
)
public
String
treeselect
(
HttpServletRequest
request
,
Model
model
)
{
model
.
addAttribute
(
"url"
,
request
.
getParameter
(
"url"
));
// 树结构数据URL
model
.
addAttribute
(
"extId"
,
request
.
getParameter
(
"extId"
));
// 排除的编号ID
model
.
addAttribute
(
"checked"
,
request
.
getParameter
(
"checked"
));
// 是否可复选
model
.
addAttribute
(
"selectIds"
,
request
.
getParameter
(
"selectIds"
));
// 指定默认选中的ID
model
.
addAttribute
(
"isAll"
,
request
.
getParameter
(
"isAll"
));
// 是否读取全部数据,不进行权限过滤
model
.
addAttribute
(
"module"
,
request
.
getParameter
(
"module"
));
// 过滤栏目模型(仅针对CMS的Category树)
return
"modules/sys/tagTreeselect"
;
}
/**
* 图标选择标签(iconselect.tag)
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"iconselect"
)
public
String
iconselect
(
HttpServletRequest
request
,
Model
model
)
{
model
.
addAttribute
(
"value"
,
request
.
getParameter
(
"value"
));
return
"modules/sys/tagIconselect"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/web/UserController.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.web
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.ConstraintViolationException
;
import
com.jeespring.common.sms.SMSUtils
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.validator.BeanValidators
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.json.AjaxJson
;
import
com.jeespring.common.utils.DateUtils
;
import
com.jeespring.common.utils.FileUtils
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.utils.excel.ExportExcel
;
import
com.jeespring.common.utils.excel.ImportExcel
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.dao.UserDao
;
import
com.jeespring.modules.sys.entity.Office
;
import
com.jeespring.modules.sys.entity.Role
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.SystemService
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 用户Controller
* @author 黄炳桂 516821420@qq.com
* @version 2013-8-29
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/user"
)
public
class
UserController
extends
AbstractBaseController
{
@Autowired
private
SystemService
systemService
;
@Autowired
private
UserDao
userDao
;
@Autowired
private
SysConfigService
sysConfigService
;
@ModelAttribute
public
User
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
if
(
StringUtils
.
isNotBlank
(
id
)){
return
systemService
.
getUser
(
id
);
}
else
{
return
new
User
();
}
}
//RequiresPermissions("sys:user:index")
@RequestMapping
(
value
=
{
"index"
})
public
String
index
(
User
user
,
Model
model
)
{
return
"modules/sys/userIndex"
;
}
//RequiresPermissions("sys:user:index")
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
User
user
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
User
>
page
=
systemService
.
findUser
(
new
Page
<
User
>(
request
,
response
),
user
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/userList"
;
}
@RequestMapping
(
value
=
{
"listjson"
})
@ResponseBody
public
Page
<
User
>
listjson
(
User
user
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
User
>
page
=
systemService
.
findUser
(
new
Page
<
User
>(
request
,
response
),
user
);
return
page
;
}
@RequiresPermissions
(
value
={
"sys:user:view"
,
"sys:user:add"
,
"sys:user:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
User
user
,
Model
model
)
{
if
(
user
.
getCompany
()==
null
||
user
.
getCompany
().
getId
()==
null
){
user
.
setCompany
(
UserUtils
.
getUser
().
getCompany
());
}
if
(
user
.
getOffice
()==
null
||
user
.
getOffice
().
getId
()==
null
){
user
.
setOffice
(
UserUtils
.
getUser
().
getOffice
());
}
model
.
addAttribute
(
"user"
,
user
);
model
.
addAttribute
(
"allRoles"
,
systemService
.
findAllRole
());
return
"modules/sys/userForm"
;
}
@RequiresPermissions
(
value
={
"sys:user:add"
,
"sys:user:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
User
user
,
HttpServletRequest
request
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
// 修正引用赋值问题,不知道为何,Company和Office引用的一个实例地址,修改了一个,另外一个跟着修改。
user
.
setCompany
(
new
Office
(
request
.
getParameter
(
"company.id"
)));
user
.
setOffice
(
new
Office
(
request
.
getParameter
(
"office.id"
)));
// 如果新密码为空,则不更换密码
if
(
StringUtils
.
isNotBlank
(
user
.
getNewPassword
()))
{
user
.
setPassword
(
SystemService
.
entryptPassword
(
user
.
getNewPassword
()));
}
if
(!
beanValidator
(
model
,
user
)){
return
form
(
user
,
model
);
}
if
(!
"true"
.
equals
(
checkLoginName
(
user
.
getOldLoginName
(),
user
.
getLoginName
()))){
addMessage
(
model
,
"保存用户'"
+
user
.
getLoginName
()
+
"'失败,登录名已存在"
);
return
form
(
user
,
model
);
}
// 角色数据有效性验证,过滤不在授权内的角色
List
<
Role
>
roleList
=
Lists
.
newArrayList
();
List
<
String
>
roleIdList
=
user
.
getRoleIdList
();
for
(
Role
r
:
systemService
.
findAllRole
()){
if
(
roleIdList
.
contains
(
r
.
getId
())){
roleList
.
add
(
r
);
}
}
user
.
setRoleList
(
roleList
);
//生成用户二维码,使用登录名
String
realPath
=
Global
.
getUserfilesBaseDir
()
+
Global
.
USERFILES_BASE_URL
+
user
.
getId
()
+
"/qrcode/"
;
FileUtils
.
createDirectory
(
realPath
);
String
name
=
user
.
getId
()+
".png"
;
//encoderImgId此处二维码的图片名
String
filePath
=
realPath
+
name
;
//存放路径
//TwoDimensionCode.encoderQRCode(user.getLoginName(), filePath, "png");//执行生成二维码
user
.
setQrCode
(
request
.
getContextPath
()+
Global
.
USERFILES_BASE_URL
+
user
.
getId
()
+
"/qrcode/"
+
name
);
// 保存用户信息
systemService
.
saveUser
(
user
);
// 清除当前用户缓存
if
(
user
.
getLoginName
().
equals
(
UserUtils
.
getUser
().
getLoginName
())){
UserUtils
.
clearCache
();
//UserUtils.getCacheMap().clear();
}
addMessage
(
redirectAttributes
,
"保存用户'"
+
user
.
getLoginName
()
+
"'成功"
);
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
@RequiresPermissions
(
"sys:user:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
User
user
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
if
(
UserUtils
.
getUser
().
getId
().
equals
(
user
.
getId
())){
addMessage
(
redirectAttributes
,
"删除用户失败, 不允许删除当前用户"
);
}
else
if
(
User
.
isAdmin
(
user
.
getId
())){
addMessage
(
redirectAttributes
,
"删除用户失败, 不允许删除超级管理员用户"
);
}
else
{
systemService
.
deleteUser
(
user
);
addMessage
(
redirectAttributes
,
"删除用户成功"
);
}
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
/**
* 批量删除用户
*/
@RequiresPermissions
(
"sys:user:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
User
user
=
systemService
.
getUser
(
id
);
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
if
(
UserUtils
.
getUser
().
getId
().
equals
(
user
.
getId
())){
addMessage
(
redirectAttributes
,
"删除用户失败, 不允许删除当前用户"
);
}
else
if
(
User
.
isAdmin
(
user
.
getId
())){
addMessage
(
redirectAttributes
,
"删除用户失败, 不允许删除超级管理员用户"
);
}
else
{
systemService
.
deleteUser
(
user
);
addMessage
(
redirectAttributes
,
"删除用户成功"
);
}
}
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
/**
* 导出用户数据
* @param user
* @param request
* @param response
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"sys:user:export"
)
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
User
user
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"用户数据"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
User
>
page
=
systemService
.
findUser
(
new
Page
<
User
>(
request
,
response
,
-
1
),
user
);
new
ExportExcel
(
"用户数据"
,
User
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出用户失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
/**
* 导入用户数据
* @param file
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"sys:user:import"
)
@RequestMapping
(
value
=
"import"
,
method
=
RequestMethod
.
POST
)
public
String
importFile
(
MultipartFile
file
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
try
{
int
successNum
=
0
;
int
failureNum
=
0
;
StringBuilder
failureMsg
=
new
StringBuilder
();
ImportExcel
ei
=
new
ImportExcel
(
file
,
1
,
0
);
List
<
User
>
list
=
ei
.
getDataList
(
User
.
class
);
for
(
User
user
:
list
){
try
{
if
(
"true"
.
equals
(
checkLoginName
(
""
,
user
.
getLoginName
()))){
user
.
setPassword
(
SystemService
.
entryptPassword
(
"123456"
));
BeanValidators
.
validateWithException
(
validator
,
user
);
systemService
.
saveUser
(
user
);
successNum
++;
}
else
{
failureMsg
.
append
(
"<br/>登录名 "
+
user
.
getLoginName
()+
" 已存在; "
);
failureNum
++;
}
}
catch
(
ConstraintViolationException
ex
){
failureMsg
.
append
(
"<br/>登录名 "
+
user
.
getLoginName
()+
" 导入失败:"
);
List
<
String
>
messageList
=
BeanValidators
.
extractPropertyAndMessageAsList
(
ex
,
": "
);
for
(
String
message
:
messageList
){
failureMsg
.
append
(
message
+
"; "
);
failureNum
++;
}
}
catch
(
Exception
ex
)
{
failureMsg
.
append
(
"<br/>登录名 "
+
user
.
getLoginName
()+
" 导入失败:"
+
ex
.
getMessage
());
}
}
if
(
failureNum
>
0
){
failureMsg
.
insert
(
0
,
",失败 "
+
failureNum
+
" 条用户,导入信息如下:"
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条用户"
+
failureMsg
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入用户失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
/**
* 下载导入用户数据模板
* @param response
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"sys:user:import"
)
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"用户数据导入模板.xlsx"
;
List
<
User
>
list
=
Lists
.
newArrayList
();
list
.
add
(
UserUtils
.
getUser
());
new
ExportExcel
(
"用户数据"
,
User
.
class
,
2
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
adminPath
+
"/sys/user/list?repage"
;
}
/**
* 验证登录名是否有效
* @param oldLoginName
* @param loginName
* @return
*/
@ResponseBody
@RequiresPermissions
(
value
={
"sys:user:add"
,
"sys:user:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"checkLoginName"
)
public
String
checkLoginName
(
String
oldLoginName
,
String
loginName
)
{
if
(
loginName
!=
null
&&
loginName
.
equals
(
oldLoginName
))
{
return
"true"
;
}
else
if
(
loginName
!=
null
&&
systemService
.
getUserByLoginName
(
loginName
)
==
null
)
{
return
"true"
;
}
return
"false"
;
}
/**
* 用户信息显示
* @param user
* @param model
* @return
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"info"
)
public
String
info
(
HttpServletResponse
response
,
Model
model
)
{
User
currentUser
=
UserUtils
.
getUser
();
model
.
addAttribute
(
"user"
,
currentUser
);
model
.
addAttribute
(
"Global"
,
new
Global
());
return
"modules/sys/userInfo"
;
}
/**
* 用户信息显示编辑保存
* @param user
* @param model
* @return
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"infoEdit"
)
public
String
infoEdit
(
User
user
,
boolean
__ajax
,
HttpServletResponse
response
,
Model
model
)
{
User
currentUser
=
UserUtils
.
getUser
();
if
(
StringUtils
.
isNotBlank
(
user
.
getName
())){
if
(
sysConfigService
.
isDemoMode
()){
model
.
addAttribute
(
"message"
,
sysConfigService
.
isDemoModeDescription
());
return
"modules/sys/userInfo"
;
}
if
(
user
.
getName
()
!=
null
)
currentUser
.
setName
(
user
.
getName
());
if
(
user
.
getEmail
()
!=
null
)
currentUser
.
setEmail
(
user
.
getEmail
());
if
(
user
.
getPhone
()
!=
null
)
currentUser
.
setPhone
(
user
.
getPhone
());
if
(
user
.
getMobile
()
!=
null
)
currentUser
.
setMobile
(
user
.
getMobile
());
if
(
user
.
getRemarks
()
!=
null
)
currentUser
.
setRemarks
(
user
.
getRemarks
());
// if(user.getPhoto() !=null )
// currentUser.setPhoto(user.getPhoto());
systemService
.
updateUserInfo
(
currentUser
);
if
(
__ajax
){
//手机访问
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
true
);
j
.
setMsg
(
"修改个人资料成功!"
);
return
renderString
(
response
,
j
);
}
model
.
addAttribute
(
"user"
,
currentUser
);
model
.
addAttribute
(
"Global"
,
new
Global
());
model
.
addAttribute
(
"message"
,
"保存用户信息成功"
);
return
"modules/sys/userInfo"
;
}
model
.
addAttribute
(
"user"
,
currentUser
);
model
.
addAttribute
(
"Global"
,
new
Global
());
return
"modules/sys/userInfoEdit"
;
}
/**
* 用户头像显示编辑保存
* @param user
* @param model
* @return
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"imageEdit"
)
public
String
imageEdit
(
User
user
,
boolean
__ajax
,
HttpServletResponse
response
,
Model
model
)
{
User
currentUser
=
UserUtils
.
getUser
();
if
(
StringUtils
.
isNotBlank
(
user
.
getName
())){
if
(
sysConfigService
.
isDemoMode
()){
model
.
addAttribute
(
"message"
,
sysConfigService
.
isDemoModeDescription
());
return
"modules/sys/userInfo"
;
}
if
(
user
.
getPhoto
()
!=
null
)
currentUser
.
setPhoto
(
user
.
getPhoto
());
systemService
.
updateUserInfo
(
currentUser
);
if
(
__ajax
){
//手机访问
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
true
);
j
.
setMsg
(
"修改个人头像成功!"
);
return
renderString
(
response
,
j
);
}
model
.
addAttribute
(
"message"
,
"保存用户信息成功"
);
return
"modules/sys/userInfo"
;
}
model
.
addAttribute
(
"user"
,
currentUser
);
model
.
addAttribute
(
"Global"
,
new
Global
());
return
"modules/sys/userImageEdit"
;
}
/**
* 用户头像显示编辑保存
* @param user
* @param model
* @return
* @throws IOException
* @throws IllegalStateException
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"imageUpload"
)
public
String
imageUpload
(
HttpServletRequest
request
,
HttpServletResponse
response
,
MultipartFile
file
)
throws
IllegalStateException
,
IOException
{
User
currentUser
=
UserUtils
.
getUser
();
// 判断文件是否为空
if
(!
file
.
isEmpty
())
{
// 文件保存路径
String
realPath
=
Global
.
USERFILES_BASE_URL
+
UserUtils
.
getPrincipal
()
+
"/images/"
;
// 转存文件
FileUtils
.
createDirectory
(
Global
.
getUserfilesBaseDir
()+
realPath
);
File
files
=
new
File
(
Global
.
getUserfilesBaseDir
()
+
realPath
+
file
.
getOriginalFilename
());
/*file.transferTo(files); */
FileUtils
.
copyInputStreamToFile
(
file
.
getInputStream
(),
files
);
currentUser
.
setPhoto
(
request
.
getContextPath
()+
realPath
+
file
.
getOriginalFilename
());
systemService
.
updateUserInfo
(
currentUser
);
}
return
"modules/sys/userImageEdit"
;
}
/**
* 返回用户信息
* @return
*/
@RequiresPermissions
(
"user"
)
@ResponseBody
@RequestMapping
(
value
=
"infoData"
)
public
AjaxJson
infoData
()
{
AjaxJson
j
=
new
AjaxJson
();
j
.
setSuccess
(
true
);
j
.
setErrorCode
(
"-1"
);
j
.
setMsg
(
"获取个人信息成功!"
);
j
.
put
(
"data"
,
UserUtils
.
getUser
());
return
j
;
}
/**
* 修改个人用户密码
* @param oldPassword
* @param newPassword
* @param model
* @return
*/
@RequiresPermissions
(
"user"
)
@RequestMapping
(
value
=
"modifyPwd"
)
public
String
modifyPwd
(
String
oldPassword
,
String
newPassword
,
Model
model
)
{
User
user
=
UserUtils
.
getUser
();
if
(
StringUtils
.
isNotBlank
(
oldPassword
)
&&
StringUtils
.
isNotBlank
(
newPassword
)){
if
(
sysConfigService
.
isDemoMode
()){
model
.
addAttribute
(
"message"
,
sysConfigService
.
isDemoModeDescription
());
return
"modules/sys/userInfo"
;
}
if
(
SystemService
.
validatePassword
(
oldPassword
,
user
.
getPassword
())){
systemService
.
updatePasswordById
(
user
.
getId
(),
user
.
getLoginName
(),
newPassword
);
model
.
addAttribute
(
"message"
,
"修改密码成功"
);
}
else
{
model
.
addAttribute
(
"message"
,
"修改密码失败,旧密码错误"
);
}
return
"modules/sys/userInfo"
;
}
model
.
addAttribute
(
"user"
,
user
);
return
"modules/sys/userModifyPwd"
;
}
@RequiresPermissions
(
"user"
)
@ResponseBody
@RequestMapping
(
value
=
"treeData"
)
public
List
<
Map
<
String
,
Object
>>
treeData
(
@RequestParam
(
required
=
false
)
String
officeId
,
HttpServletResponse
response
)
{
List
<
Map
<
String
,
Object
>>
mapList
=
Lists
.
newArrayList
();
List
<
User
>
list
=
systemService
.
findUserByOfficeId
(
officeId
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
User
e
=
list
.
get
(
i
);
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"id"
,
"u_"
+
e
.
getId
());
map
.
put
(
"pId"
,
officeId
);
map
.
put
(
"name"
,
StringUtils
.
replace
(
e
.
getName
(),
" "
,
""
));
mapList
.
add
(
map
);
}
return
mapList
;
}
/**
* web端ajax验证用户名是否可用
* @param loginName
* @param response
* @return
*/
@ResponseBody
@RequestMapping
(
value
=
"validateLoginName"
)
public
boolean
validateLoginName
(
String
loginName
,
HttpServletResponse
response
)
{
User
user
=
userDao
.
findUniqueByProperty
(
"login_name"
,
loginName
);
if
(
user
==
null
){
return
true
;
}
else
{
return
false
;
}
}
/**
* web端ajax验证手机号是否可以注册(数据库中不存在)
*/
@ResponseBody
@RequestMapping
(
value
=
"validateMobile"
)
public
boolean
validateMobile
(
String
mobile
,
HttpServletResponse
response
,
Model
model
)
{
User
user
=
userDao
.
findUniqueByProperty
(
"mobile"
,
mobile
);
if
(
user
==
null
){
return
true
;
}
else
{
return
false
;
}
}
/**
* web端ajax验证手机号是否已经注册(数据库中已存在)
*/
@ResponseBody
@RequestMapping
(
value
=
"validateMobileExist"
)
public
boolean
validateMobileExist
(
String
mobile
,
HttpServletResponse
response
,
Model
model
)
{
User
user
=
userDao
.
findUniqueByProperty
(
"mobile"
,
mobile
);
if
(
user
!=
null
){
return
true
;
}
else
{
return
false
;
}
}
@ResponseBody
@RequestMapping
(
value
=
"resetPassword"
)
public
AjaxJson
resetPassword
(
String
mobile
,
HttpServletResponse
response
,
Model
model
)
{
AjaxJson
j
=
new
AjaxJson
();
if
(
userDao
.
findUniqueByProperty
(
"mobile"
,
mobile
)
==
null
){
j
.
setSuccess
(
false
);
j
.
setMsg
(
"手机号不存在!"
);
j
.
setErrorCode
(
"1"
);
return
j
;
}
User
user
=
userDao
.
findUniqueByProperty
(
"mobile"
,
mobile
);
String
newPassword
=
String
.
valueOf
((
int
)
(
Math
.
random
()
*
900000
+
100000
));
try
{
//SystemConfig config = systemConfigService.get("1");//获取短信配置的用户名和密码
//UserUtils.sendPass(config.getSmsName(), config.getSmsPassword(), mobile, newPassword);
String
result
=
SMSUtils
.
sendPass
(
mobile
,
newPassword
);
if
(!
result
.
equals
(
"100"
))
{
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"2"
);
j
.
setMsg
(
"短信发送失败,密码重置失败,错误代码:"
+
result
+
",请联系管理员。"
);
}
else
{
j
.
setSuccess
(
true
);
j
.
setErrorCode
(
"-1"
);
j
.
setMsg
(
"短信发送成功,密码重置成功!"
);
systemService
.
updatePasswordById
(
user
.
getId
(),
user
.
getLoginName
(),
newPassword
);
}
}
catch
(
IOException
e
)
{
j
.
setSuccess
(
false
);
j
.
setErrorCode
(
"3"
);
j
.
setMsg
(
"因未知原因导致短信发送失败,请联系管理员。"
);
}
return
j
;
}
// @InitBinder
// public void initBinder(WebDataBinder b) {
// b.registerCustomEditor(List.class, "roleList", new PropertyEditorSupport(){
// @Autowired
// private SystemService systemService;
// @Override
// public void setAsText(String text) throws IllegalArgumentException {
// String[] ids = StringUtils.split(text, ",");
// List<Role> roles = new ArrayList<Role>();
// for (String id : ids) {
// Role role = systemService.getRole(Long.valueOf(id));
// roles.add(role);
// }
// setValue(roles);
// }
// @Override
// public String getAsText() {
// return Collections3.extractToString((List) getValue(), "id", ",");
// }
// });
// }
}
JeeSpringCloud/src/main/java/com/jeespring/modules/test/dao/one/FormLeaveDao.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.jeespring.modules.test.dao.one
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.test.entity.one.FormLeave
;
/**
* 请假DAO接口
* @author JeeSpring
* @version 2018-10-12
*/
@Mapper
public
interface
FormLeaveDao
extends
InterfaceBaseDao
<
FormLeave
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/test/dao/onetomany/TestDataChild2Dao.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.jeespring.modules.test.dao.onetomany
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.test.entity.onetomany.TestDataChild2
;
/**
* 订票DAO接口
* @author JeeSpring
* @version 2018-10-12
*/
@Mapper
public
interface
TestDataChild2Dao
extends
InterfaceBaseDao
<
TestDataChild2
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/test/dao/onetomany/TestDataChild3Dao.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.jeespring.modules.test.dao.onetomany
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.test.entity.onetomany.TestDataChild3
;
/**
* 订票DAO接口
* @author JeeSpring
* @version 2018-10-12
*/
@Mapper
public
interface
TestDataChild3Dao
extends
InterfaceBaseDao
<
TestDataChild3
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/test/dao/onetomany/TestDataChildDao.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.jeespring.modules.test.dao.onetomany
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.test.entity.onetomany.TestDataChild
;
/**
* 订票DAO接口
* @author JeeSpring
* @version 2018-10-12
*/
@Mapper
public
interface
TestDataChildDao
extends
InterfaceBaseDao
<
TestDataChild
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/test/dao/onetomany/TestDataMainDao.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.jeespring.modules.test.dao.onetomany
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.test.entity.onetomany.TestDataMain
;
/**
* 订票DAO接口
* @author JeeSpring
* @version 2018-10-12
*/
@Mapper
public
interface
TestDataMainDao
extends
InterfaceBaseDao
<
TestDataMain
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/test/dao/tree/TestTreeDao.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.jeespring.modules.test.dao.tree
;
import
com.jeespring.common.persistence.TreeDao
;
import
com.jeespring.common.persistence.annotation.MyBatisDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.test.entity.tree.TestTree
;
/**
* 树DAO接口
* @author JeeSpring
* @version 2018-10-11
*/
@Mapper
public
interface
TestTreeDao
extends
TreeDao
<
TestTree
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/test/entity/one/FormLeave.java
0 → 100644
View file @
8b643e22
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.jeespring.modules.test.entity.one
;
import
com.jeespring.modules.sys.entity.User
;
import
javax.validation.constraints.NotNull
;
import
com.jeespring.modules.sys.entity.Office
;
import
com.jeespring.modules.sys.entity.Area
;
import
java.util.Date
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
com.jeespring.common.utils.excel.annotation.ExcelField
;
import
com.jeespring.modules.sys.utils.DictUtils
;
/**
* 请假Entity
* @author JeeSpring
* @version 2018-10-12
*/
public
class
FormLeave
extends
AbstractBaseEntity
<
FormLeave
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
com
.
jeespring
.
modules
.
sys
.
entity
.
User
user
;
// 员工
private
com
.
jeespring
.
modules
.
sys
.
entity
.
Office
office
;
// 归属部门
private
com
.
jeespring
.
modules
.
sys
.
entity
.
Area
area
;
// 归属区域
private
java
.
util
.
Date
beginDate
;
// 请假开始日期
private
java
.
util
.
Date
endDate
;
// 请假结束日期
public
FormLeave
()
{
super
();
}
public
FormLeave
(
String
id
){
super
(
id
);
}
@NotNull
(
message
=
"员工不能为空"
)
@ExcelField
(
title
=
"员工"
,
fieldType
=
User
.
class
,
value
=
"user.name"
,
align
=
2
,
sort
=
1
)
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
@NotNull
(
message
=
"归属部门不能为空"
)
@ExcelField
(
title
=
"归属部门"
,
fieldType
=
Office
.
class
,
value
=
"office.name"
,
align
=
2
,
sort
=
2
)
public
Office
getOffice
()
{
return
office
;
}
public
void
setOffice
(
Office
office
)
{
this
.
office
=
office
;
}
@ExcelField
(
title
=
"归属区域"
,
fieldType
=
Area
.
class
,
value
=
"area.name"
,
align
=
2
,
sort
=
3
)
public
Area
getArea
()
{
return
area
;
}
public
void
setArea
(
Area
area
)
{
this
.
area
=
area
;
}
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@NotNull
(
message
=
"请假开始日期不能为空"
)
@ExcelField
(
title
=
"请假开始日期"
,
align
=
2
,
sort
=
4
)
public
Date
getBeginDate
()
{
return
beginDate
;
}
public
void
setBeginDate
(
Date
beginDate
)
{
this
.
beginDate
=
beginDate
;
}
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@NotNull
(
message
=
"请假结束日期不能为空"
)
@ExcelField
(
title
=
"请假结束日期"
,
align
=
2
,
sort
=
5
)
public
Date
getEndDate
()
{
return
endDate
;
}
public
void
setEndDate
(
Date
endDate
)
{
this
.
endDate
=
endDate
;
}
}
\ No newline at end of file
Prev
1
…
15
16
17
18
19
20
Next
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