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
JeeSpringCloudV3.0
Commits
e344509c
Commit
e344509c
authored
Oct 22, 2018
by
HuangBingGui
Browse files
删除目录JeeSpringCloud
parent
51016ad9
Changes
393
Show whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
13 of 393+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/security/UsernamePasswordToken.java
deleted
100644 → 0
View file @
51016ad9
/**
* Copyright © 2012-2016 <a href="https://github.com/HuangBingGui/jeespring">jeespring</a> All rights reserved.
*/
package
com.jeespring.modules.sys.security
;
/**
* 用户和密码(包含验证码)令牌类
* @author 黄炳桂 516821420@qq.com
* @version 2013-5-19
*/
public
class
UsernamePasswordToken
extends
org
.
apache
.
shiro
.
authc
.
UsernamePasswordToken
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
captcha
;
private
boolean
mobileLogin
;
public
UsernamePasswordToken
()
{
super
();
}
public
UsernamePasswordToken
(
String
username
,
char
[]
password
,
boolean
rememberMe
,
String
host
,
String
captcha
,
boolean
mobileLogin
)
{
super
(
username
,
password
,
rememberMe
,
host
);
this
.
captcha
=
captcha
;
this
.
mobileLogin
=
mobileLogin
;
}
public
String
getCaptcha
()
{
return
captcha
;
}
public
void
setCaptcha
(
String
captcha
)
{
this
.
captcha
=
captcha
;
}
public
boolean
isMobileLogin
()
{
return
mobileLogin
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/AreaService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.service.TreeService
;
import
com.jeespring.modules.sys.dao.AreaDao
;
import
com.jeespring.modules.sys.entity.Area
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 区域Service
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
AreaService
extends
TreeService
<
AreaDao
,
Area
>
{
public
List
<
Area
>
findAll
(){
return
UserUtils
.
getAreaList
();
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
Area
area
)
{
super
.
save
(
area
);
UserUtils
.
removeCache
(
UserUtils
.
CACHE_AREA_LIST
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
Area
area
)
{
super
.
delete
(
area
);
UserUtils
.
removeCache
(
UserUtils
.
CACHE_AREA_LIST
);
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/DictService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.utils.CacheUtils
;
import
com.jeespring.common.service.AbstractBaseService
;
import
com.jeespring.modules.sys.dao.DictDao
;
import
com.jeespring.modules.sys.entity.Dict
;
import
com.jeespring.modules.sys.utils.DictUtils
;
/**
* 字典Service
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
DictService
extends
AbstractBaseService
<
DictDao
,
Dict
>
{
/**
* 查询字段类型列表
* @return
*/
public
List
<
String
>
findTypeList
(){
return
dao
.
findTypeList
(
new
Dict
());
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
Dict
dict
)
{
super
.
save
(
dict
);
CacheUtils
.
remove
(
DictUtils
.
CACHE_DICT_MAP
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
Dict
dict
)
{
super
.
delete
(
dict
);
CacheUtils
.
remove
(
DictUtils
.
CACHE_DICT_MAP
);
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/LogService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.modules.sys.dao.LogDao
;
import
com.jeespring.modules.sys.entity.Log
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractBaseService
;
import
com.jeespring.common.utils.DateUtils
;
/**
* 日志Service
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
LogService
extends
AbstractBaseService
<
LogDao
,
Log
>
{
@Autowired
private
LogDao
logDao
;
public
Page
<
Log
>
findPage
(
Page
<
Log
>
page
,
Log
log
)
{
// 设置默认时间范围,默认当前月
if
(
log
.
getBeginDate
()
==
null
){
log
.
setBeginDate
(
DateUtils
.
setDays
(
DateUtils
.
parseDate
(
DateUtils
.
getDate
()),
1
));
}
if
(
log
.
getEndDate
()
==
null
){
log
.
setEndDate
(
DateUtils
.
addMonths
(
log
.
getBeginDate
(),
1
));
}
return
super
.
findPage
(
page
,
log
);
}
/**
* 删除全部数据
* @param entity
*/
@Transactional
(
readOnly
=
false
)
public
void
empty
(){
logDao
.
empty
();
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/OfficeService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.service.TreeService
;
import
com.jeespring.modules.sys.dao.OfficeDao
;
import
com.jeespring.modules.sys.entity.Office
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 机构Service
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
OfficeService
extends
TreeService
<
OfficeDao
,
Office
>
{
public
List
<
Office
>
findAll
(){
return
UserUtils
.
getOfficeList
();
}
public
List
<
Office
>
findList
(
Boolean
isAll
){
if
(
isAll
!=
null
&&
isAll
){
return
UserUtils
.
getOfficeAllList
();
}
else
{
return
UserUtils
.
getOfficeList
();
}
}
@Transactional
(
readOnly
=
true
)
public
List
<
Office
>
findList
(
Office
office
){
office
.
setParentIds
(
office
.
getParentIds
()+
"%"
);
return
dao
.
findByParentIdsLike
(
office
);
}
@Transactional
(
readOnly
=
true
)
public
Office
getByCode
(
String
code
){
return
dao
.
getByCode
(
code
);
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
Office
office
)
{
super
.
save
(
office
);
UserUtils
.
removeCache
(
UserUtils
.
CACHE_OFFICE_LIST
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
Office
office
)
{
super
.
delete
(
office
);
UserUtils
.
removeCache
(
UserUtils
.
CACHE_OFFICE_LIST
);
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/SysConfigService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.List
;
import
com.jeespring.common.config.Global
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractBaseService
;
import
com.jeespring.modules.sys.entity.SysConfig
;
import
com.jeespring.modules.sys.dao.SysConfigDao
;
import
com.alibaba.fastjson.JSON
;
import
com.jeespring.common.redis.RedisUtils
;
/**
* 系统配置Service
* @author 黄炳桂 516821420@qq.com
* @version 2017-11-17
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
SysConfigService
extends
AbstractBaseService
<
SysConfigDao
,
SysConfig
>
{
/**
* redis caches
*/
@Autowired
private
RedisUtils
redisUtils
;
public
SysConfig
get
(
String
id
)
{
//获取缓存数据
SysConfig
sysConfig
=(
SysConfig
)
redisUtils
.
get
(
RedisUtils
.
getIdKey
(
SysConfigService
.
class
.
getName
(),
id
));
if
(
sysConfig
!=
null
)
return
sysConfig
;
//获取数据库数据
sysConfig
=
super
.
get
(
id
);
//设置缓存数据
redisUtils
.
set
(
RedisUtils
.
getIdKey
(
SysConfigService
.
class
.
getName
(),
id
),
sysConfig
);
return
sysConfig
;
}
public
SysConfig
findListFirst
(
SysConfig
sysConfig
)
{;
//获取数据库数据
List
<
SysConfig
>
sysConfigList
=
super
.
findList
(
sysConfig
);
if
(
sysConfigList
.
size
()>
0
)
sysConfig
=
sysConfigList
.
get
(
0
);
return
sysConfig
;
}
public
SysConfig
findListFirstCache
(
SysConfig
sysConfig
)
{
//获取缓存数据
String
findListFirstKey
=
RedisUtils
.
getFindListFirstKey
(
SysConfigService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysConfig
));
SysConfig
sysConfigRedis
=(
SysConfig
)
redisUtils
.
get
(
findListFirstKey
);
if
(
sysConfigRedis
!=
null
)
return
sysConfigRedis
;
//获取数据库数据
List
<
SysConfig
>
tfTicketList
=
super
.
findList
(
sysConfig
);
if
(
tfTicketList
.
size
()>
0
)
sysConfig
=
tfTicketList
.
get
(
0
);
else
sysConfig
=
new
SysConfig
();
//设置缓存数据
redisUtils
.
set
(
findListFirstKey
,
sysConfig
);
return
sysConfig
;
}
public
List
<
SysConfig
>
findList
(
SysConfig
sysConfig
)
{
//获取缓存数据
String
findListKey
=
RedisUtils
.
getFindListKey
(
SysConfigService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysConfig
));
List
<
SysConfig
>
sysConfigList
=(
List
<
SysConfig
>)
redisUtils
.
get
(
findListKey
);
if
(
sysConfigList
!=
null
)
return
sysConfigList
;
//获取数据库数据
sysConfigList
=
super
.
findList
(
sysConfig
);
//设置缓存数据
redisUtils
.
set
(
findListKey
,
sysConfigList
);
return
sysConfigList
;
}
public
Page
<
SysConfig
>
findPage
(
Page
<
SysConfig
>
page
,
SysConfig
sysConfig
)
{
//获取缓存数据
String
findPageKey
=
RedisUtils
.
getFindPageKey
(
SysConfigService
.
class
.
getName
(),
JSON
.
toJSONString
(
page
)+
JSON
.
toJSONString
(
sysConfig
));
Page
<
SysConfig
>
pageReuslt
=(
Page
<
SysConfig
>)
redisUtils
.
get
(
findPageKey
);
if
(
pageReuslt
!=
null
)
return
pageReuslt
;
//获取数据库数据
pageReuslt
=
super
.
findPage
(
page
,
sysConfig
);
//设置缓存数据
redisUtils
.
set
(
findPageKey
,
pageReuslt
);
return
pageReuslt
;
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
SysConfig
sysConfig
)
{
//保存数据库记录
super
.
save
(
sysConfig
);
//设置清除缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysConfigService
.
class
.
getName
(),
sysConfig
.
getId
()));
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysConfigService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysConfigService
.
class
.
getName
()));
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
SysConfig
sysConfig
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysConfigService
.
class
.
getName
(),
sysConfig
.
getId
()));
//删除数据库记录
super
.
delete
(
sysConfig
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysConfigService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysConfigService
.
class
.
getName
()));
}
@Transactional
(
readOnly
=
false
)
public
void
deleteByLogic
(
SysConfig
sysConfig
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysConfigService
.
class
.
getName
(),
sysConfig
.
getId
()));
//逻辑删除数据库记录
super
.
deleteByLogic
(
sysConfig
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysConfigService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysConfigService
.
class
.
getName
()));
}
/**
* 是否是演示模式,演示模式下不能修改用户、角色、密码、菜单、授权
*/
public
Boolean
isDemoMode
()
{
SysConfig
sysConfig
=
new
SysConfig
();
sysConfig
.
setType
(
"demoMode"
);
sysConfig
=
this
.
findListFirstCache
(
sysConfig
);
if
(
sysConfig
.
getValue
().
equals
(
"true"
)
&&
Global
.
isDemoMode
())
return
true
;
return
false
;
}
public
String
isDemoModeDescription
()
{
SysConfig
sysConfig
=
new
SysConfig
();
sysConfig
.
setType
(
"demoMode"
);
sysConfig
=
this
.
findListFirstCache
(
sysConfig
);
if
(
sysConfig
==
null
)
return
Global
.
isDemoModeDescription
();
return
sysConfig
.
getDescription
();
}
public
String
systemMode
(){
if
(
this
.
isDemoMode
())
return
"演示版"
;
return
"正式版"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/SysConfigTreeService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.service.TreeService
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.sys.entity.SysConfigTree
;
import
com.jeespring.modules.sys.dao.SysConfigTreeDao
;
/**
* 系统配置Service
* @author JeeSpring
* @version 2018-08-22
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
SysConfigTreeService
extends
TreeService
<
SysConfigTreeDao
,
SysConfigTree
>
{
public
SysConfigTree
get
(
String
id
)
{
return
super
.
get
(
id
);
}
public
List
<
SysConfigTree
>
findList
(
SysConfigTree
sysConfig
)
{
if
(
StringUtils
.
isNotBlank
(
sysConfig
.
getParentIds
())){
sysConfig
.
setParentIds
(
","
+
sysConfig
.
getParentIds
()+
","
);
}
return
super
.
findList
(
sysConfig
);
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
SysConfigTree
sysConfig
)
{
super
.
save
(
sysConfig
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
SysConfigTree
sysConfig
)
{
super
.
delete
(
sysConfig
);
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/SysDictTreeService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.service.TreeService
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.sys.entity.SysDictTree
;
import
com.jeespring.modules.sys.dao.SysDictTreeDao
;
/**
* 数据字典Service
* @author JeeSpring
* @version 2018-08-22
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
SysDictTreeService
extends
TreeService
<
SysDictTreeDao
,
SysDictTree
>
{
public
SysDictTree
get
(
String
id
)
{
return
super
.
get
(
id
);
}
public
List
<
SysDictTree
>
findList
(
SysDictTree
sysDict
)
{
if
(
StringUtils
.
isNotBlank
(
sysDict
.
getParentIds
())){
sysDict
.
setParentIds
(
","
+
sysDict
.
getParentIds
()+
","
);
}
return
super
.
findList
(
sysDict
);
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
SysDictTree
sysDict
)
{
super
.
save
(
sysDict
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
SysDictTree
sysDict
)
{
super
.
delete
(
sysDict
);
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/SysUserOnlineService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.Date
;
import
java.util.List
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.monitor.entity.OnlineSession
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractBaseService
;
import
com.jeespring.modules.sys.entity.SysUserOnline
;
import
com.jeespring.modules.sys.dao.SysUserOnlineDao
;
import
com.alibaba.fastjson.JSON
;
import
com.jeespring.common.redis.RedisUtils
;
import
com.jeespring.common.security.MD5Tools
;
/**
* 在线用户记录Service
* @author JeeSpring
* @version 2018-08-16
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
SysUserOnlineService
extends
AbstractBaseService
<
SysUserOnlineDao
,
SysUserOnline
>
{
/**
* redis caches
*/
@Autowired
private
RedisUtils
redisUtils
;
@Value
(
"${spring.redis.run}"
)
String
redisRun
;
/**
* 同步session到数据库的周期 单位为毫秒(默认1分钟)
*/
@Value
(
"${shiro.session.dbSyncPeriod}"
)
private
int
dbSyncPeriod
=
1
;
/**
* 上次同步数据库的时间戳
*/
private
static
final
String
LAST_SYNC_DB_TIMESTAMP
=
SysUserOnlineService
.
class
.
getName
()
+
"LAST_SYNC_DB_TIMESTAMP"
;
public
SysUserOnline
get
(
String
id
)
{
//获取数据库数据
SysUserOnline
sysUserOnline
=
super
.
get
(
id
);
return
sysUserOnline
;
}
public
SysUserOnline
getCache
(
String
id
)
{
//获取缓存数据
SysUserOnline
sysUserOnline
=(
SysUserOnline
)
redisUtils
.
get
(
RedisUtils
.
getIdKey
(
SysUserOnlineService
.
class
.
getName
(),
id
));
if
(
sysUserOnline
!=
null
)
return
sysUserOnline
;
//获取数据库数据
sysUserOnline
=
super
.
get
(
id
);
//设置缓存数据
redisUtils
.
set
(
RedisUtils
.
getIdKey
(
SysUserOnlineService
.
class
.
getName
(),
id
),
sysUserOnline
);
return
sysUserOnline
;
}
public
List
<
SysUserOnline
>
total
(
SysUserOnline
sysUserOnline
)
{
//获取数据库数据
List
<
SysUserOnline
>
sysUserOnlineList
=
super
.
total
(
sysUserOnline
);
return
sysUserOnlineList
;
}
public
List
<
SysUserOnline
>
totalCache
(
SysUserOnline
sysUserOnline
)
{
//获取缓存数据
String
totalKey
=
RedisUtils
.
getTotalKey
(
SysUserOnlineService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysUserOnline
));
List
<
SysUserOnline
>
sysUserOnlineList
=(
List
<
SysUserOnline
>)
redisUtils
.
get
(
totalKey
);
if
(
sysUserOnlineList
!=
null
)
return
sysUserOnlineList
;
//获取数据库数据
sysUserOnlineList
=
super
.
total
(
sysUserOnline
);
//设置缓存数据
redisUtils
.
set
(
totalKey
,
sysUserOnlineList
);
return
sysUserOnlineList
;
}
public
List
<
SysUserOnline
>
findList
(
SysUserOnline
sysUserOnline
)
{
//获取数据库数据
List
<
SysUserOnline
>
sysUserOnlineList
=
super
.
findList
(
sysUserOnline
);
//设置缓存数据
return
sysUserOnlineList
;
}
public
List
<
SysUserOnline
>
findListCache
(
SysUserOnline
sysUserOnline
)
{
//获取缓存数据
String
findListKey
=
RedisUtils
.
getFindListKey
(
SysUserOnlineService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysUserOnline
));
List
<
SysUserOnline
>
sysUserOnlineList
=(
List
<
SysUserOnline
>)
redisUtils
.
get
(
findListKey
);
if
(
sysUserOnlineList
!=
null
)
return
sysUserOnlineList
;
//获取数据库数据
sysUserOnlineList
=
super
.
findList
(
sysUserOnline
);
//设置缓存数据
redisUtils
.
set
(
findListKey
,
sysUserOnlineList
);
return
sysUserOnlineList
;
}
public
SysUserOnline
findListFirst
(
SysUserOnline
sysUserOnline
)
{;
//获取数据库数据
List
<
SysUserOnline
>
sysUserOnlineList
=
super
.
findList
(
sysUserOnline
);
if
(
sysUserOnlineList
.
size
()>
0
)
sysUserOnline
=
sysUserOnlineList
.
get
(
0
);
return
sysUserOnline
;
}
public
SysUserOnline
findListFirstCache
(
SysUserOnline
sysUserOnline
)
{
//获取缓存数据
String
findListFirstKey
=
RedisUtils
.
getFindListFirstKey
(
SysUserOnlineService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysUserOnline
));
SysUserOnline
sysUserOnlineRedis
=(
SysUserOnline
)
redisUtils
.
get
(
findListFirstKey
);
if
(
sysUserOnlineRedis
!=
null
)
return
sysUserOnlineRedis
;
//获取数据库数据
List
<
SysUserOnline
>
sysUserOnlineList
=
super
.
findList
(
sysUserOnline
);
if
(
sysUserOnlineList
.
size
()>
0
)
sysUserOnline
=
sysUserOnlineList
.
get
(
0
);
else
sysUserOnline
=
new
SysUserOnline
();
//设置缓存数据
redisUtils
.
set
(
findListFirstKey
,
sysUserOnline
);
return
sysUserOnline
;
}
public
Page
<
SysUserOnline
>
findPage
(
Page
<
SysUserOnline
>
page
,
SysUserOnline
sysUserOnline
)
{
//获取数据库数据
Page
<
SysUserOnline
>
pageReuslt
=
super
.
findPage
(
page
,
sysUserOnline
);
return
pageReuslt
;
}
@Transactional
(
readOnly
=
false
)
public
Page
<
SysUserOnline
>
findPageCache
(
Page
<
SysUserOnline
>
page
,
SysUserOnline
sysUserOnline
)
{
//获取缓存数据
String
findPageKey
=
RedisUtils
.
getFindPageKey
(
SysUserOnlineService
.
class
.
getName
(),
JSON
.
toJSONString
(
page
)+
JSON
.
toJSONString
(
sysUserOnline
));
Page
<
SysUserOnline
>
pageReuslt
=(
Page
<
SysUserOnline
>)
redisUtils
.
get
(
findPageKey
);
if
(
pageReuslt
!=
null
)
return
pageReuslt
;
//获取数据库数据
pageReuslt
=
super
.
findPage
(
page
,
sysUserOnline
);
for
(
SysUserOnline
item:
pageReuslt
.
getList
())
{
if
(
redisRun
.
equals
(
"true"
)){
try
{
if
(!
redisUtils
.
exists
(
RedisUtils
.
SHIRO_REDIS
+
":"
+
item
.
getId
())){
item
.
setStatus
(
OnlineSession
.
OnlineStatus
.
off_line
.
toString
());
super
.
save
(
item
);
}
}
catch
(
Exception
e
){}
}
}
//设置缓存数据
redisUtils
.
set
(
findPageKey
,
pageReuslt
);
return
pageReuslt
;
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
SysUserOnline
sysUserOnline
)
{
//保存数据库记录
super
.
save
(
sysUserOnline
);
//设置清除缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysUserOnlineService
.
class
.
getName
(),
sysUserOnline
.
getId
()));
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysUserOnlineService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysUserOnlineService
.
class
.
getName
()));
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
SysUserOnline
sysUserOnline
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysUserOnlineService
.
class
.
getName
(),
sysUserOnline
.
getId
()));
//删除数据库记录
super
.
delete
(
sysUserOnline
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysUserOnlineService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysUserOnlineService
.
class
.
getName
()));
}
@Transactional
(
readOnly
=
false
)
public
void
deleteByLogic
(
SysUserOnline
sysUserOnline
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysUserOnlineService
.
class
.
getName
(),
sysUserOnline
.
getId
()));
//逻辑删除数据库记录
super
.
deleteByLogic
(
sysUserOnline
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysUserOnlineService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysUserOnlineService
.
class
.
getName
()));
}
/**
* 更新会话;如更新会话最后访问时间/停止会话/设置超时时间/设置移除属性等会调用
*/
@Transactional
(
readOnly
=
false
)
public
void
syncToDb
(
OnlineSession
onlineSession
)
{
Date
lastSyncTimestamp
=
(
Date
)
onlineSession
.
getAttribute
(
LAST_SYNC_DB_TIMESTAMP
);
if
(
lastSyncTimestamp
!=
null
)
{
boolean
needSync
=
true
;
long
deltaTime
=
onlineSession
.
getLastAccessTime
().
getTime
()
-
lastSyncTimestamp
.
getTime
();
if
(
deltaTime
<
dbSyncPeriod
*
60
*
1000
)
{
// 时间差不足 无需同步
needSync
=
false
;
}
boolean
isGuest
=
onlineSession
.
getUserId
()
==
null
||
onlineSession
.
getUserId
()
==
""
;
// session 数据变更了 同步
if
(
isGuest
==
false
&&
onlineSession
.
isAttributeChanged
())
{
needSync
=
true
;
}
if
(
needSync
==
false
)
{
return
;
}
}
onlineSession
.
setAttribute
(
LAST_SYNC_DB_TIMESTAMP
,
onlineSession
.
getLastAccessTime
());
// 更新完后 重置标识
if
(
onlineSession
.
isAttributeChanged
())
{
onlineSession
.
resetAttributeChanged
();
}
try
{
SysUserOnline
sysUserOnline
=
SysUserOnline
.
fromOnlineSession
(
onlineSession
);
SysUserOnline
sysUserOnlineDb
=
this
.
get
(
sysUserOnline
.
getId
());
if
(
sysUserOnlineDb
==
null
){
sysUserOnline
.
setIsNewRecord
(
true
);
}
else
{
sysUserOnline
.
setStartTimestsamp
(
sysUserOnlineDb
.
getStartTimestsamp
());
}
if
(
StringUtils
.
isEmpty
(
sysUserOnline
.
getDeptName
())){
User
user
=
UserUtils
.
getByLoginName
(
sysUserOnline
.
getLoginName
());
if
(
user
.
getCompany
()!=
null
&&
user
.
getOffice
()!=
null
)
sysUserOnline
.
setDeptName
(
user
.
getCompany
().
getName
()+
"-"
+
user
.
getOffice
().
getName
());
else
if
(
user
.
getCompany
()!=
null
)
sysUserOnline
.
setDeptName
(
user
.
getCompany
().
getName
());
else
if
(
user
.
getOffice
()!=
null
)
sysUserOnline
.
setDeptName
(
user
.
getOffice
().
getName
());
}
this
.
save
(
sysUserOnline
);
}
catch
(
Exception
e
){
//System.out.println(e.getMessage());
}
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/SystemConfigService.java
deleted
100644 → 0
View file @
51016ad9
/**
* Copyright © 2015-2020 <a href="http://www.jeespring.org/">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.sys.service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractBaseService
;
import
com.jeespring.modules.sys.entity.SystemConfig
;
import
com.jeespring.modules.sys.dao.SystemConfigDao
;
/**
* 系统配置Service
* @author liugf
* @version 2016-02-07
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
SystemConfigService
extends
AbstractBaseService
<
SystemConfigDao
,
SystemConfig
>
{
public
SystemConfig
get
(
String
id
)
{
return
super
.
get
(
id
);
}
public
List
<
SystemConfig
>
findList
(
SystemConfig
systemConfig
)
{
return
super
.
findList
(
systemConfig
);
}
public
Page
<
SystemConfig
>
findPage
(
Page
<
SystemConfig
>
page
,
SystemConfig
systemConfig
)
{
return
super
.
findPage
(
page
,
systemConfig
);
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
SystemConfig
systemConfig
)
{
super
.
save
(
systemConfig
);
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
SystemConfig
systemConfig
)
{
super
.
delete
(
systemConfig
);
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/service/SystemService.java
deleted
100644 → 0
View file @
51016ad9
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.service
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.shiro.session.Session
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.utils.CacheUtils
;
import
com.jeespring.common.utils.Encodes
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.security.Digests
;
import
com.jeespring.common.security.shiro.session.SessionDAO
;
import
com.jeespring.common.service.AbstractService
;
import
com.jeespring.common.service.ServiceException
;
import
com.jeespring.modules.sys.dao.MenuDao
;
import
com.jeespring.modules.sys.dao.RoleDao
;
import
com.jeespring.modules.sys.dao.UserDao
;
import
com.jeespring.modules.sys.entity.Menu
;
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.security.SystemAuthorizingRealm
;
import
com.jeespring.modules.sys.utils.LogUtils
;
import
com.jeespring.modules.sys.utils.UserUtils
;
/**
* 系统管理,安全相关实体的管理类,包括用户、角色、菜单.
* @author 黄炳桂 516821420@qq.com
* @version 2013-12-05
*/
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
SystemService
extends
AbstractService
implements
InitializingBean
{
public
static
final
String
HASH_ALGORITHM
=
"SHA-1"
;
public
static
final
int
HASH_INTERATIONS
=
1024
;
public
static
final
int
SALT_SIZE
=
8
;
@Autowired
private
UserDao
userDao
;
@Autowired
private
RoleDao
roleDao
;
@Autowired
private
MenuDao
menuDao
;
@Autowired
private
SessionDAO
sessionDao
;
@Autowired
private
SystemAuthorizingRealm
systemRealm
;
public
SessionDAO
getSessionDao
()
{
return
sessionDao
;
}
//-- User Service --//
/**
* 获取用户
* @param id
* @return
*/
public
User
getUser
(
String
id
)
{
return
UserUtils
.
get
(
id
);
}
/**
* 根据登录名获取用户
* @param loginName
* @return
*/
public
User
getUserByLoginName
(
String
loginName
)
{
return
UserUtils
.
getByLoginName
(
loginName
);
}
public
Page
<
User
>
findUser
(
Page
<
User
>
page
,
User
user
)
{
// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL)
user
.
getSqlMap
().
put
(
"dsf"
,
dataScopeFilter
(
user
.
getCurrentUser
(),
"o"
,
"a"
));
// 设置分页参数
user
.
setPage
(
page
);
// 执行分页查询
page
.
setList
(
userDao
.
findList
(
user
));
return
page
;
}
/**
* 无分页查询人员列表
* @param user
* @return
*/
public
List
<
User
>
findUser
(
User
user
){
// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL)
user
.
getSqlMap
().
put
(
"dsf"
,
dataScopeFilter
(
user
.
getCurrentUser
(),
"o"
,
"a"
));
List
<
User
>
list
=
userDao
.
findList
(
user
);
return
list
;
}
/**
* 通过部门ID获取用户列表,仅返回用户id和name(树查询用户时用)
* @param user
* @return
*/
@SuppressWarnings
(
"unchecked"
)
public
List
<
User
>
findUserByOfficeId
(
String
officeId
)
{
List
<
User
>
list
=
(
List
<
User
>)
CacheUtils
.
get
(
UserUtils
.
USER_CACHE
,
UserUtils
.
USER_CACHE_LIST_BY_OFFICE_ID_
+
officeId
);
if
(
list
==
null
){
User
user
=
new
User
();
user
.
setOffice
(
new
Office
(
officeId
));
list
=
userDao
.
findUserByOfficeId
(
user
);
CacheUtils
.
put
(
UserUtils
.
USER_CACHE
,
UserUtils
.
USER_CACHE_LIST_BY_OFFICE_ID_
+
officeId
,
list
);
}
return
list
;
}
@Transactional
(
readOnly
=
false
)
public
void
saveUser
(
User
user
)
{
if
(
StringUtils
.
isBlank
(
user
.
getId
())){
user
.
preInsert
();
userDao
.
insert
(
user
);
}
else
{
// 清除原用户机构用户缓存
User
oldUser
=
userDao
.
get
(
user
.
getId
());
if
(
oldUser
.
getOffice
()
!=
null
&&
oldUser
.
getOffice
().
getId
()
!=
null
){
CacheUtils
.
remove
(
UserUtils
.
USER_CACHE
,
UserUtils
.
USER_CACHE_LIST_BY_OFFICE_ID_
+
oldUser
.
getOffice
().
getId
());
}
// 更新用户数据
user
.
preUpdate
();
userDao
.
update
(
user
);
}
if
(
StringUtils
.
isNotBlank
(
user
.
getId
())){
// 更新用户与角色关联
userDao
.
deleteUserRole
(
user
);
if
(
user
.
getRoleList
()
!=
null
&&
user
.
getRoleList
().
size
()
>
0
){
userDao
.
insertUserRole
(
user
);
}
else
{
throw
new
ServiceException
(
user
.
getLoginName
()
+
"没有设置角色!"
);
}
// 清除用户缓存
UserUtils
.
clearCache
(
user
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
}
}
@Transactional
(
readOnly
=
false
)
public
void
updateUserInfo
(
User
user
)
{
user
.
preUpdate
();
userDao
.
updateUserInfo
(
user
);
// 清除用户缓存
UserUtils
.
clearCache
(
user
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
}
@Transactional
(
readOnly
=
false
)
public
void
deleteUser
(
User
user
)
{
userDao
.
delete
(
user
);
// 清除用户缓存
UserUtils
.
clearCache
(
user
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
}
@Transactional
(
readOnly
=
false
)
public
void
updatePasswordById
(
String
id
,
String
loginName
,
String
newPassword
)
{
User
user
=
new
User
(
id
);
user
.
setPassword
(
entryptPassword
(
newPassword
));
userDao
.
updatePasswordById
(
user
);
// 清除用户缓存
user
.
setLoginName
(
loginName
);
UserUtils
.
clearCache
(
user
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
}
@Transactional
(
readOnly
=
false
)
public
void
updateUserLoginInfo
(
User
user
)
{
// 保存上次登录信息
user
.
setOldLoginIp
(
user
.
getLoginIp
());
user
.
setOldLoginDate
(
user
.
getLoginDate
());
// 更新本次登录信息
user
.
setLoginIp
(
UserUtils
.
getSession
().
getHost
());
user
.
setLoginDate
(
new
Date
());
userDao
.
updateLoginInfo
(
user
);
}
/**
* 生成安全的密码,生成随机的16位salt并经过1024次 sha-1 hash
*/
public
static
String
entryptPassword
(
String
plainPassword
)
{
byte
[]
salt
=
Digests
.
generateSalt
(
SALT_SIZE
);
byte
[]
hashPassword
=
Digests
.
sha1
(
plainPassword
.
getBytes
(),
salt
,
HASH_INTERATIONS
);
return
Encodes
.
encodeHex
(
salt
)+
Encodes
.
encodeHex
(
hashPassword
);
}
/**
* 验证密码
* @param plainPassword 明文密码
* @param password 密文密码
* @return 验证成功返回true
*/
public
static
boolean
validatePassword
(
String
plainPassword
,
String
password
)
{
byte
[]
salt
=
Encodes
.
decodeHex
(
password
.
substring
(
0
,
16
));
byte
[]
hashPassword
=
Digests
.
sha1
(
plainPassword
.
getBytes
(),
salt
,
HASH_INTERATIONS
);
return
password
.
equals
(
Encodes
.
encodeHex
(
salt
)+
Encodes
.
encodeHex
(
hashPassword
));
}
/**
* 获得活动会话
* @return
*/
public
Collection
<
Session
>
getActiveSessions
(){
return
sessionDao
.
getActiveSessions
(
false
);
}
//-- Role Service --//
public
Role
getRole
(
String
id
)
{
return
roleDao
.
get
(
id
);
}
public
Role
getRoleByName
(
String
name
)
{
Role
r
=
new
Role
();
r
.
setName
(
name
);
return
roleDao
.
getByName
(
r
);
}
public
Role
getRoleByEnname
(
String
enname
)
{
Role
r
=
new
Role
();
r
.
setEnname
(
enname
);
return
roleDao
.
getByEnname
(
r
);
}
public
List
<
Role
>
findRole
(
Role
role
){
return
roleDao
.
findList
(
role
);
}
public
List
<
Role
>
findAllRole
(){
return
UserUtils
.
getRoleList
();
}
@Transactional
(
readOnly
=
false
)
public
void
saveRole
(
Role
role
)
{
if
(
StringUtils
.
isBlank
(
role
.
getId
())){
role
.
preInsert
();
roleDao
.
insert
(
role
);
}
else
{
role
.
preUpdate
();
roleDao
.
update
(
role
);
}
// 更新角色与菜单关联
roleDao
.
deleteRoleMenu
(
role
);
if
(
role
.
getMenuList
().
size
()
>
0
){
roleDao
.
insertRoleMenu
(
role
);
}
// 更新角色与部门关联
roleDao
.
deleteRoleOffice
(
role
);
if
(
role
.
getOfficeList
().
size
()
>
0
){
roleDao
.
insertRoleOffice
(
role
);
}
// 清除用户角色缓存
UserUtils
.
removeCache
(
UserUtils
.
CACHE_ROLE_LIST
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
}
@Transactional
(
readOnly
=
false
)
public
void
deleteRole
(
Role
role
)
{
roleDao
.
delete
(
role
);
// 清除用户角色缓存
UserUtils
.
removeCache
(
UserUtils
.
CACHE_ROLE_LIST
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
}
@Transactional
(
readOnly
=
false
)
public
Boolean
outUserInRole
(
Role
role
,
User
user
)
{
List
<
Role
>
roles
=
user
.
getRoleList
();
for
(
Role
e
:
roles
){
if
(
e
.
getId
().
equals
(
role
.
getId
())){
roles
.
remove
(
e
);
saveUser
(
user
);
return
true
;
}
}
return
false
;
}
@Transactional
(
readOnly
=
false
)
public
User
assignUserToRole
(
Role
role
,
User
user
)
{
if
(
user
==
null
){
return
null
;
}
List
<
String
>
roleIds
=
user
.
getRoleIdList
();
if
(
roleIds
.
contains
(
role
.
getId
()))
{
return
null
;
}
user
.
getRoleList
().
add
(
role
);
saveUser
(
user
);
return
user
;
}
//-- Menu Service --//
public
Menu
getMenu
(
String
id
)
{
return
menuDao
.
get
(
id
);
}
public
List
<
Menu
>
findAllMenu
(){
return
UserUtils
.
getMenuList
();
}
@Transactional
(
readOnly
=
false
)
public
void
saveMenu
(
Menu
menu
)
{
// 获取父节点实体
menu
.
setParent
(
this
.
getMenu
(
menu
.
getParent
().
getId
()));
// 获取修改前的parentIds,用于更新子节点的parentIds
String
oldParentIds
=
menu
.
getParentIds
();
// 设置新的父节点串
menu
.
setParentIds
(
menu
.
getParent
().
getParentIds
()+
menu
.
getParent
().
getId
()+
","
);
// 保存或更新实体
if
(
StringUtils
.
isBlank
(
menu
.
getId
())){
menu
.
preInsert
();
menuDao
.
insert
(
menu
);
}
else
{
menu
.
preUpdate
();
menuDao
.
update
(
menu
);
}
// 更新子节点 parentIds
Menu
m
=
new
Menu
();
m
.
setParentIds
(
"%,"
+
menu
.
getId
()+
",%"
);
List
<
Menu
>
list
=
menuDao
.
findByParentIdsLike
(
m
);
for
(
Menu
e
:
list
){
e
.
setParentIds
(
e
.
getParentIds
().
replace
(
oldParentIds
,
menu
.
getParentIds
()));
menuDao
.
updateParentIds
(
e
);
}
// 清除用户菜单缓存
UserUtils
.
removeCache
(
UserUtils
.
CACHE_MENU_LIST
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
// 清除日志相关缓存
CacheUtils
.
remove
(
LogUtils
.
CACHE_MENU_NAME_PATH_MAP
);
}
@Transactional
(
readOnly
=
false
)
public
void
updateMenuSort
(
Menu
menu
)
{
menuDao
.
updateSort
(
menu
);
// 清除用户菜单缓存
UserUtils
.
removeCache
(
UserUtils
.
CACHE_MENU_LIST
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
// 清除日志相关缓存
CacheUtils
.
remove
(
LogUtils
.
CACHE_MENU_NAME_PATH_MAP
);
}
@Transactional
(
readOnly
=
false
)
public
void
deleteMenu
(
Menu
menu
)
{
menuDao
.
delete
(
menu
);
// 清除用户菜单缓存
UserUtils
.
removeCache
(
UserUtils
.
CACHE_MENU_LIST
);
// // 清除权限缓存
// systemRealm.clearAllCachedAuthorizationInfo();
// 清除日志相关缓存
CacheUtils
.
remove
(
LogUtils
.
CACHE_MENU_NAME_PATH_MAP
);
}
/**
* 获取Key加载信息
*/
public
static
boolean
printKeyLoadMessage
(){
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"\r\n======================================================================\r\n"
);
sb
.
append
(
"\r\n 欢迎使用 "
+
Global
.
getConfig
(
"productName"
)+
" - Powered By http://www.jeespring.org\r\n"
);
sb
.
append
(
"\r\n======================================================================\r\n"
);
System
.
out
.
println
(
sb
.
toString
());
return
true
;
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
// TODO Auto-generated method stub
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/utils/DictUtils.java
deleted
100644 → 0
View file @
51016ad9
/**
* Copyright © 2012-2016 <a href="https://github.com/HuangBingGui/jeespring">jeespring</a> All rights reserved.
*/
package
com.jeespring.modules.sys.utils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.mapper.JsonMapper
;
import
com.jeespring.common.utils.CacheUtils
;
import
com.jeespring.common.utils.SpringContextHolder
;
import
com.jeespring.modules.sys.dao.DictDao
;
import
com.jeespring.modules.sys.entity.Dict
;
/**
* 字典工具类
* @author 黄炳桂 516821420@qq.com
* @version 2013-5-29
*/
public
class
DictUtils
{
private
static
DictDao
dictDao
=
SpringContextHolder
.
getBean
(
DictDao
.
class
);
public
static
final
String
CACHE_DICT_MAP
=
"dictMap"
;
public
static
String
getDictLabel
(
String
value
,
String
type
,
String
defaultValue
){
if
(
StringUtils
.
isNotBlank
(
type
)
&&
StringUtils
.
isNotBlank
(
value
)){
for
(
Dict
dict
:
getDictList
(
type
)){
if
(
type
.
equals
(
dict
.
getType
())
&&
value
.
equals
(
dict
.
getValue
())){
return
dict
.
getLabel
();
}
}
}
return
defaultValue
;
}
public
static
String
getDictLabel
(
Long
value
,
String
type
,
String
defaultValue
){
if
(
value
==
null
)
return
""
;
return
getDictLabel
(
value
.
toString
(),
type
,
defaultValue
);
}
public
static
String
getDictPicture
(
String
value
,
String
type
,
String
defaultValue
){
if
(
StringUtils
.
isNotBlank
(
type
)
&&
StringUtils
.
isNotBlank
(
value
)){
for
(
Dict
dict
:
getDictList
(
type
)){
if
(
type
.
equals
(
dict
.
getType
())
&&
value
.
equals
(
dict
.
getValue
())){
return
dict
.
getPicture
();
}
}
}
return
defaultValue
;
}
public
static
String
getDictPicture
(
Long
value
,
String
type
,
String
defaultValue
){
if
(
value
==
null
)
return
""
;
return
getDictPicture
(
value
.
toString
(),
type
,
defaultValue
);
}
public
static
String
getDictLabels
(
String
values
,
String
type
,
String
defaultValue
){
if
(
StringUtils
.
isNotBlank
(
type
)
&&
StringUtils
.
isNotBlank
(
values
)){
List
<
String
>
valueList
=
Lists
.
newArrayList
();
for
(
String
value
:
StringUtils
.
split
(
values
,
","
)){
valueList
.
add
(
getDictLabel
(
value
,
type
,
defaultValue
));
}
return
StringUtils
.
join
(
valueList
,
","
);
}
return
defaultValue
;
}
public
static
String
getDictValue
(
String
label
,
String
type
,
String
defaultLabel
){
if
(
StringUtils
.
isNotBlank
(
type
)
&&
StringUtils
.
isNotBlank
(
label
)){
for
(
Dict
dict
:
getDictList
(
type
)){
if
(
type
.
equals
(
dict
.
getType
())
&&
label
.
equals
(
dict
.
getLabel
())){
return
dict
.
getValue
();
}
}
}
return
defaultLabel
;
}
public
static
List
<
Dict
>
getDictList
(
String
type
){
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
List
<
Dict
>>
dictMap
=
(
Map
<
String
,
List
<
Dict
>>)
CacheUtils
.
get
(
CACHE_DICT_MAP
);
if
(
dictMap
==
null
){
dictMap
=
Maps
.
newHashMap
();
for
(
Dict
dict
:
dictDao
.
findAllList
(
new
Dict
())){
List
<
Dict
>
dictList
=
dictMap
.
get
(
dict
.
getType
());
if
(
dictList
!=
null
){
dictList
.
add
(
dict
);
}
else
{
dictMap
.
put
(
dict
.
getType
(),
Lists
.
newArrayList
(
dict
));
}
}
CacheUtils
.
put
(
CACHE_DICT_MAP
,
dictMap
);
}
List
<
Dict
>
dictList
=
dictMap
.
get
(
type
);
if
(
dictList
==
null
){
dictList
=
Lists
.
newArrayList
();
}
//if(dictList!=null && dictList.size()!=0 && "".equals(dictList.get(dictList.size()-1).getValue())){
// dictList.remove(dictList.size()-1);
//}
return
dictList
;
}
//增加全部项
public
static
List
<
Dict
>
getDictListAddAll
(
String
type
){
List
<
Dict
>
dictListResult
=
new
ArrayList
<
Dict
>();
List
<
Dict
>
dictList
=
getDictList
(
type
);
dictListResult
.
addAll
(
dictList
);
//if(dictList!=null && "".equals(dictList.get(dictList.size()-1).getValue())){
// return dictList;
//}
Dict
dict
=
new
Dict
();
dict
.
setValue
(
""
);
dict
.
setLabel
(
"全部"
);
dictListResult
.
add
(
dict
);
return
dictListResult
;
}
/**
* 返回字典列表(JSON)
* @param type
* @return
*/
public
static
String
getDictListJson
(
String
type
){
return
JsonMapper
.
toJsonString
(
getDictList
(
type
));
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/utils/LogUtils.java
deleted
100644 → 0
View file @
51016ad9
/**
* Copyright © 2012-2016 <a href="https://github.com/HuangBingGui/jeespring">jeespring</a> All rights reserved.
*/
package
com.jeespring.modules.sys.utils
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.sys.entity.Log
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.interceptor.InterceptorLogEntity
;
import
com.jeespring.modules.sys.interceptor.LogThread
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.BufferedReader
;
import
java.util.Date
;
import
java.util.Map
;
/**
* 字典工具类
*
* @author 黄炳桂 516821420@qq.com
* @version 2014-11-7
*/
public
class
LogUtils
{
public
static
final
String
CACHE_MENU_NAME_PATH_MAP
=
"menuNamePathMap"
;
/**
* 保存日志
*/
public
static
void
saveLog
(
HttpServletRequest
request
,
String
title
)
{
saveLog
(
request
,
null
,
null
,
title
);
}
/**
* 保存日志
*/
public
static
void
saveLog
(
HttpServletRequest
request
,
Object
handler
,
Exception
ex
,
String
title
)
{
User
user
=
UserUtils
.
getUser
();
if
(
user
!=
null
&&
user
.
getId
()
!=
null
)
{
Log
log
=
new
Log
();
log
.
setTitle
(
title
);
log
.
setType
(
ex
==
null
?
Log
.
TYPE_ACCESS
:
Log
.
TYPE_EXCEPTION
);
log
.
setRemoteAddr
(
StringUtils
.
getRemoteAddr
(
request
));
log
.
setUserAgent
(
request
.
getHeader
(
"user-agent"
));
log
.
setRequestUri
(
request
.
getRequestURI
());
log
.
setParams
(
getParameterString
(
request
));
log
.
setMethod
(
request
.
getMethod
());
log
.
setCreateBy
(
user
);
log
.
setUpdateBy
(
user
);
log
.
setUpdateDate
(
new
Date
());
log
.
setCreateDate
(
new
Date
());
// 异步保存日志
try
{
InterceptorLogEntity
entiry
=
new
InterceptorLogEntity
(
log
,
handler
,
ex
);
LogThread
.
interceptorLogQueue
.
put
(
entiry
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
System
.
out
);
}
}
}
public
static
String
getParameterString
(
HttpServletRequest
request
){
if
(
request
.
getQueryString
()!=
null
){
if
(
request
.
getQueryString
().
length
()>
0
){
return
request
.
getQueryString
();
}
}
Map
map
=
request
.
getParameterMap
();
java
.
util
.
Enumeration
enumx
=
request
.
getParameterNames
();
String
result
=
""
;
while
(
enumx
.
hasMoreElements
()){
String
paramName
=(
String
)
enumx
.
nextElement
();
String
[]
values
=
request
.
getParameterValues
(
paramName
);
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++){
result
+=
paramName
+
"="
+
values
[
i
]+
"&"
;
}
}
if
(
result
==
""
)
{
try
{
BufferedReader
br
=
request
.
getReader
();
String
str
=
""
;
while
((
str
=
br
.
readLine
())
!=
null
)
{
result
+=
str
;
}
}
catch
(
Exception
e
){}
}
return
result
;
}
}
Prev
1
…
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