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
dd7c8801
Commit
dd7c8801
authored
Oct 15, 2018
by
HuangBingGui
Browse files
no commit message
parent
1119316e
Changes
400
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 400+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/src/main/java/com/company/project/modules/ylttrip/rest/TfTicketRestController.java
0 → 100644
View file @
dd7c8801
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.company.project.modules.ylttrip.rest
;
import
java.util.List
;
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.company.project.modules.ylttrip.entity.TfTicket
;
import
com.company.project.modules.ylttrip.service.ITfTicketService
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.jeespring.common.web.Result
;
import
com.jeespring.common.web.ResultFactory
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
/**
* 订单Controller
* @author JeeSpring
* @version 2018-10-12
*/
@RestController
@RequestMapping
(
value
=
"/rest/ylttrip/tfTicket"
)
@Api
(
value
=
"订单接口"
,
description
=
"订单接口"
)
public
class
TfTicketRestController
extends
AbstractBaseController
{
@Autowired
private
ITfTicketService
tfTicketService
;
/**
* 订单信息
*/
@RequestMapping
(
value
=
{
"get"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"订单信息(Content-Type为text/html)"
,
notes
=
"订单信息(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"订单id"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
)
public
Result
getRequestParam
(
@RequestParam
(
required
=
false
)
String
id
)
{
return
get
(
id
);
}
@RequestMapping
(
value
=
{
"get/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"订单信息(Content-Type为application/json)"
,
notes
=
"订单信息(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"订单id"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"body"
)
public
Result
getRequestBody
(
@RequestBody
(
required
=
false
)
String
id
)
{
return
get
(
id
);
}
private
Result
get
(
String
id
)
{
TfTicket
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
tfTicketService
.
getCache
(
id
);
//entity = tfTicketService.get(id);
}
if
(
entity
==
null
){
entity
=
new
TfTicket
();
}
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
entity
);
return
result
;
}
/**
* 订单列表(不包含页信息)
*/
//RequiresPermissions("ylttrip:tfTicket:findList")
@RequestMapping
(
value
=
{
"findList"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"订单列表(不包含页信息)(Content-Type为text/html)"
,
notes
=
"订单列表(不包含页信息)(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"query"
)
public
Result
findListRequestParam
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
return
findList
(
tfTicket
,
model
);
}
@RequestMapping
(
value
=
{
"findList/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"订单列表(不包含页信息)(Content-Type为application/json)"
,
notes
=
"订单列表(不包含页信息)(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"body"
)
public
Result
findListRequestBody
(
@RequestBody
TfTicket
tfTicket
,
Model
model
)
{
return
findList
(
tfTicket
,
model
);
}
private
Result
findList
(
TfTicket
tfTicket
,
Model
model
)
{
List
<
TfTicket
>
list
=
tfTicketService
.
findListCache
(
tfTicket
);
//List<TfTicket> list = tfTicketService.findList(tfTicket);
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
list
);
return
result
;
}
/**
* 订单列表(包含页信息)
*/
//RequiresPermissions("ylttrip:tfTicket:list")
@RequestMapping
(
value
=
{
"list"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"订单列表(包含页信息)(Content-Type为text/html)"
,
notes
=
"订单列表(包含页信息)(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"query"
)
public
Result
listRequestParam
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
return
list
(
tfTicket
,
model
);
}
@RequestMapping
(
value
=
{
"list/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"订单列表(包含页信息)(Content-Type为application/json)"
,
notes
=
"订单列表(包含页信息)(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"body"
)
public
Result
listRequestBody
(
@RequestBody
TfTicket
tfTicket
,
Model
model
)
{
return
list
(
tfTicket
,
model
);
}
private
Result
list
(
TfTicket
tfTicket
,
Model
model
)
{
Page
<
TfTicket
>
page
=
tfTicketService
.
findPageCache
(
new
Page
<
TfTicket
>(
tfTicket
.
getPageNo
(),
tfTicket
.
getPageSize
(),
tfTicket
.
getOrderBy
()),
tfTicket
);
//Page<TfTicket> page = tfTicketService.findPage(new Page<TfTicket>(tfTicket.getPageNo(),tfTicket.getPageSize(),tfTicket.getOrderBy()), tfTicket);
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
page
);
return
result
;
}
/**
* 订单获取列表第一条记录
*/
//RequiresPermissions("ylttrip:tfTicket:listFrist")
@RequestMapping
(
value
=
{
"listFrist"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"订单获取列表第一条记录(Content-Type为text/html)"
,
notes
=
"订单获取列表第一条记录(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"query"
)
public
Result
listFristRequestParam
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
return
listFrist
(
tfTicket
,
model
);
}
@RequestMapping
(
value
=
{
"listFrist/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"订单获取列表第一条记录(Content-Type为application/json)"
,
notes
=
"订单获取列表第一条记录(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"body"
)
public
Result
listFristRequestBody
(
@RequestBody
TfTicket
tfTicket
,
Model
model
)
{
return
listFrist
(
tfTicket
,
model
);
}
private
Result
listFrist
(
TfTicket
tfTicket
,
Model
model
)
{
Page
<
TfTicket
>
page
=
tfTicketService
.
findPageCache
(
new
Page
<
TfTicket
>(
tfTicket
.
getPageNo
(),
tfTicket
.
getPageSize
(),
tfTicket
.
getOrderBy
()),
tfTicket
);
//Page<TfTicket> page = tfTicketService.findPage(new Page<TfTicket>(tfTicket.getPageNo(),tfTicket.getPageSize(),tfTicket.getOrderBy()), tfTicket);
Result
result
=
ResultFactory
.
getSuccessResult
();
if
(
page
.
getList
().
size
()>
0
){
result
.
setResultObject
(
page
.
getList
().
get
(
0
));
}
else
{
result
=
ResultFactory
.
getErrorResult
(
"没有记录!"
);
}
return
result
;
}
/**
* 保存订单
*/
//RequiresPermissions(value={"ylttrip:tfTicket:add","ylttrip:tfTicket:edit"},logical=Logical.OR)
@RequestMapping
(
value
=
"save"
,
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"保存订单(Content-Type为text/html)"
,
notes
=
"保存订单(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"query"
)
public
Result
saveRequestParam
(
TfTicket
tfTicket
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
return
save
(
tfTicket
,
model
,
redirectAttributes
);
}
@RequestMapping
(
value
=
"save/json"
,
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"保存订单(Content-Type为application/json)"
,
notes
=
"保存订单(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"body"
)
public
Result
saveRequestBody
(
@RequestBody
TfTicket
tfTicket
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
return
save
(
tfTicket
,
model
,
redirectAttributes
);
}
private
Result
save
(
TfTicket
tfTicket
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(!
beanValidator
(
model
,
tfTicket
)){
Result
result
=
ResultFactory
.
getErrorResult
(
"数据验证失败"
);
}
tfTicketService
.
save
(
tfTicket
);
Result
result
=
ResultFactory
.
getSuccessResult
(
"保存订单成功"
);
return
result
;
}
/**
* 删除订单
*/
//RequiresPermissions("ylttrip:tfTicket:del")
@RequestMapping
(
value
=
"delete"
,
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"删除订单(Content-Type为text/html)"
,
notes
=
"删除订单(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"query"
)
public
Result
deleteRequestParam
(
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
return
delete
(
tfTicket
,
redirectAttributes
);
}
@RequestMapping
(
value
=
"delete/json"
,
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"删除订单(Content-Type为application/json)"
,
notes
=
"删除订单(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"body"
)
public
Result
deleteRequestBody
(
@RequestBody
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
return
delete
(
tfTicket
,
redirectAttributes
);
}
private
Result
delete
(
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
tfTicketService
.
delete
(
tfTicket
);
Result
result
=
ResultFactory
.
getSuccessResult
(
"删除订单成功"
);
return
result
;
}
/**
* 删除订单(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping
(
value
=
"deleteByLogic"
,
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"逻辑删除订单(Content-Type为text/html)"
,
notes
=
"逻辑删除订单(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"query"
)
public
Result
deleteByLogicRequestParam
(
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
return
deleteByLogic
(
tfTicket
,
redirectAttributes
);
}
/**
* 删除订单(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping
(
value
=
"deleteByLogic/json"
,
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"逻辑删除订单(Content-Type为application/json)"
,
notes
=
"逻辑删除订单(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"tfTicket"
,
value
=
"订单"
,
dataType
=
"TfTicket"
,
paramType
=
"body"
)
public
Result
deleteByLogicRequestBody
(
@RequestBody
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
return
deleteByLogic
(
tfTicket
,
redirectAttributes
);
}
private
Result
deleteByLogic
(
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
tfTicketService
.
deleteByLogic
(
tfTicket
);
Result
result
=
ResultFactory
.
getSuccessResult
(
"删除订单成功"
);
return
result
;
}
/**
* 批量删除订单
*/
//RequiresPermissions("ylttrip:tfTicket:del")
@RequestMapping
(
value
=
"deleteAll"
,
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"批量删除订单(Content-Type为text/html)"
,
notes
=
"批量删除订单(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"订单ids,用,隔开"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
)
public
Result
deleteAllRequestParam
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
return
deleteAll
(
ids
,
redirectAttributes
);
}
@RequestMapping
(
value
=
"deleteAll/json"
,
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"批量删除订单(Content-Type为application/json)"
,
notes
=
"批量删除订单(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"订单ids,用,隔开"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"body"
)
public
Result
deleteAllRequestBody
(
@RequestBody
String
ids
,
RedirectAttributes
redirectAttributes
)
{
return
deleteAll
(
ids
,
redirectAttributes
);
}
private
Result
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
tfTicketService
.
delete
(
tfTicketService
.
get
(
id
));
}
Result
result
=
ResultFactory
.
getSuccessResult
(
"删除订单成功"
);
return
result
;
}
/**
* 批量删除订单(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping
(
value
=
"deleteAllByLogic"
,
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"逻辑批量删除订单(Content-Type为text/html)"
,
notes
=
"逻辑批量删除订单(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"订单ids,用,隔开"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
)
public
Result
deleteAllByLogicRequestParam
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
return
deleteAllByLogic
(
ids
,
redirectAttributes
);
}
/**
* 批量删除订单(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequestMapping
(
value
=
"deleteAllByLogic/json"
,
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"逻辑批量删除订单(Content-Type为application/json)"
,
notes
=
"逻辑批量删除订单(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"订单ids,用,隔开"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"body"
)
public
Result
deleteAllByLogicRequestBody
(
@RequestBody
String
ids
,
RedirectAttributes
redirectAttributes
)
{
return
deleteAllByLogic
(
ids
,
redirectAttributes
);
}
private
Result
deleteAllByLogic
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
tfTicketService
.
deleteByLogic
(
tfTicketService
.
get
(
id
));
}
Result
result
=
ResultFactory
.
getSuccessResult
(
"删除订单成功"
);
return
result
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/company/project/modules/ylttrip/service/ITfTicketService.java
0 → 100644
View file @
dd7c8801
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.company.project.modules.ylttrip.service
;
import
com.jeespring.common.persistence.InterfaceBaseService
;
import
com.jeespring.modules.server.entity.SysServer
;
import
com.company.project.modules.ylttrip.entity.TfTicket
;
/**
* I订单Service
* @author JeeSpring
* @version 2018-10-12
*/
public
interface
ITfTicketService
extends
InterfaceBaseService
<
TfTicket
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/company/project/modules/ylttrip/service/TfTicketService.java
0 → 100644
View file @
dd7c8801
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.company.project.modules.ylttrip.service
;
import
java.util.List
;
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.company.project.modules.ylttrip.entity.TfTicket
;
import
com.company.project.modules.ylttrip.dao.TfTicketDao
;
import
com.company.project.modules.ylttrip.service.ITfTicketService
;
import
com.alibaba.fastjson.JSON
;
import
com.jeespring.common.redis.RedisUtils
;
import
com.jeespring.common.security.MD5Tools
;
//import com.alibaba.dubbo.config.annotation.Service;
import
com.jeespring.common.config.Global
;
/**
* 订单Service
* @author JeeSpring
* @version 2018-10-12
*/
//启用dubbo服务器时,要去掉下面注解
//com.alibaba.dubbo.config.annotation.Service(interfaceClass = ISysServerService.class,version = "1.0.0", timeout = 60000)
@org
.
springframework
.
stereotype
.
Service
@Transactional
(
readOnly
=
true
)
public
class
TfTicketService
extends
AbstractBaseService
<
TfTicketDao
,
TfTicket
>
implements
ITfTicketService
{
/**
* redis caches
*/
@Autowired
private
RedisUtils
redisUtils
;
public
TfTicket
get
(
String
id
)
{
//获取数据库数据
TfTicket
tfTicket
=
super
.
get
(
id
);
return
tfTicket
;
}
public
TfTicket
getCache
(
String
id
)
{
//获取缓存数据
TfTicket
tfTicket
=(
TfTicket
)
redisUtils
.
get
(
RedisUtils
.
getIdKey
(
TfTicketService
.
class
.
getName
(),
id
));
if
(
tfTicket
!=
null
)
return
tfTicket
;
//获取数据库数据
tfTicket
=
super
.
get
(
id
);
//设置缓存数据
redisUtils
.
set
(
RedisUtils
.
getIdKey
(
TfTicketService
.
class
.
getName
(),
id
),
tfTicket
);
return
tfTicket
;
}
public
List
<
TfTicket
>
total
(
TfTicket
tfTicket
)
{
//获取数据库数据
List
<
TfTicket
>
tfTicketList
=
super
.
total
(
tfTicket
);
return
tfTicketList
;
}
public
List
<
TfTicket
>
totalCache
(
TfTicket
tfTicket
)
{
//获取缓存数据
String
totalKey
=
RedisUtils
.
getTotalKey
(
TfTicketService
.
class
.
getName
(),
JSON
.
toJSONString
(
tfTicket
));
List
<
TfTicket
>
tfTicketList
=(
List
<
TfTicket
>)
redisUtils
.
get
(
totalKey
);
if
(
tfTicketList
!=
null
)
return
tfTicketList
;
//获取数据库数据
tfTicketList
=
super
.
total
(
tfTicket
);
//设置缓存数据
redisUtils
.
set
(
totalKey
,
tfTicketList
);
return
tfTicketList
;
}
public
List
<
TfTicket
>
findList
(
TfTicket
tfTicket
)
{
//获取数据库数据
List
<
TfTicket
>
tfTicketList
=
super
.
findList
(
tfTicket
);
//设置缓存数据
return
tfTicketList
;
}
public
List
<
TfTicket
>
findListCache
(
TfTicket
tfTicket
)
{
//获取缓存数据
String
findListKey
=
RedisUtils
.
getFindListKey
(
TfTicketService
.
class
.
getName
(),
JSON
.
toJSONString
(
tfTicket
));
List
<
TfTicket
>
tfTicketList
=(
List
<
TfTicket
>)
redisUtils
.
get
(
findListKey
);
if
(
tfTicketList
!=
null
)
return
tfTicketList
;
//获取数据库数据
tfTicketList
=
super
.
findList
(
tfTicket
);
//设置缓存数据
redisUtils
.
set
(
findListKey
,
tfTicketList
);
return
tfTicketList
;
}
public
TfTicket
findListFirst
(
TfTicket
tfTicket
)
{;
//获取数据库数据
List
<
TfTicket
>
tfTicketList
=
super
.
findList
(
tfTicket
);
if
(
tfTicketList
.
size
()>
0
)
tfTicket
=
tfTicketList
.
get
(
0
);
return
tfTicket
;
}
public
TfTicket
findListFirstCache
(
TfTicket
tfTicket
)
{
//获取缓存数据
String
findListFirstKey
=
RedisUtils
.
getFindListFirstKey
(
TfTicketService
.
class
.
getName
(),
JSON
.
toJSONString
(
tfTicket
));
TfTicket
tfTicketRedis
=(
TfTicket
)
redisUtils
.
get
(
findListFirstKey
);
if
(
tfTicketRedis
!=
null
)
return
tfTicketRedis
;
//获取数据库数据
List
<
TfTicket
>
tfTicketList
=
super
.
findList
(
tfTicket
);
if
(
tfTicketList
.
size
()>
0
)
tfTicket
=
tfTicketList
.
get
(
0
);
else
tfTicket
=
new
TfTicket
();
//设置缓存数据
redisUtils
.
set
(
findListFirstKey
,
tfTicket
);
return
tfTicket
;
}
public
Page
<
TfTicket
>
findPage
(
Page
<
TfTicket
>
page
,
TfTicket
tfTicket
)
{
//获取数据库数据
Page
<
TfTicket
>
pageReuslt
=
super
.
findPage
(
page
,
tfTicket
);
return
pageReuslt
;
}
public
Page
<
TfTicket
>
findPageCache
(
Page
<
TfTicket
>
page
,
TfTicket
tfTicket
)
{
//获取缓存数据
String
findPageKey
=
RedisUtils
.
getFindPageKey
(
TfTicketService
.
class
.
getName
(),
JSON
.
toJSONString
(
page
)+
JSON
.
toJSONString
(
tfTicket
));
Page
<
TfTicket
>
pageReuslt
=(
Page
<
TfTicket
>)
redisUtils
.
get
(
findPageKey
);
if
(
pageReuslt
!=
null
)
return
pageReuslt
;
//获取数据库数据
pageReuslt
=
super
.
findPage
(
page
,
tfTicket
);
//设置缓存数据
redisUtils
.
set
(
findPageKey
,
pageReuslt
);
return
pageReuslt
;
}
@Transactional
(
readOnly
=
false
)
public
void
save
(
TfTicket
tfTicket
)
{
//保存数据库记录
super
.
save
(
tfTicket
);
//设置清除缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
TfTicketService
.
class
.
getName
(),
tfTicket
.
getId
()));
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
TfTicketService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
TfTicketService
.
class
.
getName
()));
}
@Transactional
(
readOnly
=
false
)
public
void
delete
(
TfTicket
tfTicket
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
TfTicketService
.
class
.
getName
(),
tfTicket
.
getId
()));
//删除数据库记录
super
.
delete
(
tfTicket
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
TfTicketService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
TfTicketService
.
class
.
getName
()));
}
@Transactional
(
readOnly
=
false
)
public
void
deleteByLogic
(
TfTicket
tfTicket
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
TfTicketService
.
class
.
getName
(),
tfTicket
.
getId
()));
//逻辑删除数据库记录
super
.
deleteByLogic
(
tfTicket
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
TfTicketService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
TfTicketService
.
class
.
getName
()));
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/company/project/modules/ylttrip/web/TfTicketController.java
0 → 100644
View file @
dd7c8801
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpringCloud</a> All rights reserved..
*/
package
com.company.project.modules.ylttrip.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.company.project.modules.ylttrip.entity.TfTicket
;
import
com.company.project.modules.ylttrip.service.TfTicketService
;
import
com.company.project.modules.ylttrip.service.ITfTicketService
;
import
com.alibaba.dubbo.config.annotation.Reference
;
/**
* 订单Controller
* @author JeeSpring
* @version 2018-10-12
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/ylttrip/tfTicket"
)
public
class
TfTicketController
extends
AbstractBaseController
{
//调用dubbo服务器是,要去Reference注解,注解Autowired
//@Reference(version = "1.0.0")
@Autowired
private
ITfTicketService
tfTicketService
;
@ModelAttribute
public
TfTicket
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
TfTicket
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
tfTicketService
.
getCache
(
id
);
//entity = tfTicketService.get(id);
}
if
(
entity
==
null
){
entity
=
new
TfTicket
();
}
return
entity
;
}
/**
* 订单统计页面
*/
@RequiresPermissions
(
"ylttrip:tfTicket:total"
)
@RequestMapping
(
value
=
{
"total"
})
public
String
totalView
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
total
(
tfTicket
,
request
,
response
,
model
);
return
"modules/ylttrip/tfTicketTotal"
;
}
private
void
total
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
if
(
StringUtils
.
isEmpty
(
tfTicket
.
getTotalType
())){
tfTicket
.
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
>();
List
<
Double
>
sumGoodsNumList
=
new
ArrayList
<
Double
>();
List
<
Double
>
sumPriceList
=
new
ArrayList
<
Double
>();
List
<
Double
>
sumSalePriceList
=
new
ArrayList
<
Double
>();
if
(
tfTicket
.
getOrderBy
()==
""
){
tfTicket
.
setOrderBy
(
"totalDate"
);
}
List
<
TfTicket
>
list
=
tfTicketService
.
totalCache
(
tfTicket
);
//List<TfTicket> list = tfTicketService.total(tfTicket);
model
.
addAttribute
(
"list"
,
list
);
for
(
TfTicket
tfTicketItem:
list
){
//x轴数据
xAxisData
.
add
(
tfTicketItem
.
getTotalDate
());
countList
.
add
(
Double
.
valueOf
(
tfTicketItem
.
getTotalCount
()));
if
(
tfTicketItem
.
getSumGoodsNum
()!=
null
)
sumGoodsNumList
.
add
(
Double
.
valueOf
(
tfTicketItem
.
getSumGoodsNum
()));
else
tfTicketItem
.
setSumGoodsNum
(
0
D
);
if
(
tfTicketItem
.
getSumPrice
()!=
null
)
sumPriceList
.
add
(
Double
.
valueOf
(
tfTicketItem
.
getSumPrice
()));
else
tfTicketItem
.
setSumPrice
(
0
D
);
if
(
tfTicketItem
.
getSumSalePrice
()!=
null
)
sumSalePriceList
.
add
(
Double
.
valueOf
(
tfTicketItem
.
getSumSalePrice
()));
else
tfTicketItem
.
setSumSalePrice
(
0
D
);
}
yAxisData
.
put
(
"数量"
,
countList
);
yAxisData
.
put
(
"商品数量"
,
sumGoodsNumList
);
yAxisData
.
put
(
"商品单价"
,
sumPriceList
);
yAxisData
.
put
(
"订单金额"
,
sumSalePriceList
);
request
.
setAttribute
(
"xAxisData"
,
xAxisData
);
request
.
setAttribute
(
"yAxisData"
,
yAxisData
);
model
.
addAttribute
(
"sumTotalCount"
,
list
.
stream
().
mapToInt
(
TfTicket:
:
getTotalCount
).
sum
());
model
.
addAttribute
(
"sumGoodsNum"
,
list
.
stream
().
mapToDouble
(
TfTicket:
:
getSumGoodsNum
).
sum
());
model
.
addAttribute
(
"sumPrice"
,
list
.
stream
().
mapToDouble
(
TfTicket:
:
getSumPrice
).
sum
());
model
.
addAttribute
(
"sumSalePrice"
,
list
.
stream
().
mapToDouble
(
TfTicket:
:
getSumSalePrice
).
sum
());
//饼图数据
Map
<
String
,
Object
>
orientData
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
orientDataSumGoodsNum
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
orientDataSumPrice
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
orientDataSumSalePrice
=
new
HashMap
<
String
,
Object
>();
for
(
TfTicket
tfTicketItem:
list
){
orientData
.
put
(
tfTicketItem
.
getTotalDate
(),
tfTicketItem
.
getTotalCount
());
orientDataSumGoodsNum
.
put
(
tfTicketItem
.
getTotalDate
(),
Double
.
valueOf
(
tfTicketItem
.
getSumGoodsNum
()));
orientDataSumPrice
.
put
(
tfTicketItem
.
getTotalDate
(),
Double
.
valueOf
(
tfTicketItem
.
getSumPrice
()));
orientDataSumSalePrice
.
put
(
tfTicketItem
.
getTotalDate
(),
Double
.
valueOf
(
tfTicketItem
.
getSumSalePrice
()));
}
model
.
addAttribute
(
"orientData"
,
orientData
);
model
.
addAttribute
(
"orientDataSumGoodsNum"
,
orientDataSumGoodsNum
);
model
.
addAttribute
(
"orientDataSumPrice"
,
orientDataSumPrice
);
model
.
addAttribute
(
"orientDataSumSalePrice"
,
orientDataSumSalePrice
);
}
@RequiresPermissions
(
"ylttrip:tfTicket:total"
)
@RequestMapping
(
value
=
{
"totalMap"
})
public
String
totalMap
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
if
(
StringUtils
.
isEmpty
(
tfTicket
.
getTotalType
())){
tfTicket
.
setTotalType
(
"%Y-%m-%d"
);
}
List
<
TfTicket
>
list
=
tfTicketService
.
totalCache
(
tfTicket
);
//List<TfTicket> list = tfTicketService.total(tfTicket);
model
.
addAttribute
(
"sumTotalCount"
,
list
.
stream
().
mapToInt
(
TfTicket:
:
getTotalCount
).
sum
());
model
.
addAttribute
(
"sumGoodsNum"
,
list
.
stream
().
mapToDouble
(
TfTicket:
:
getSumGoodsNum
).
sum
());
model
.
addAttribute
(
"sumPrice"
,
list
.
stream
().
mapToDouble
(
TfTicket:
:
getSumPrice
).
sum
());
model
.
addAttribute
(
"sumSalePrice"
,
list
.
stream
().
mapToDouble
(
TfTicket:
:
getSumSalePrice
).
sum
());
model
.
addAttribute
(
"list"
,
list
);
return
"modules/ylttrip/tfTicketTotalMap"
;
}
/**
* 订单列表页面
*/
@RequiresPermissions
(
"ylttrip:tfTicket:list"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
TfTicket
>
page
=
tfTicketService
.
findPageCache
(
new
Page
<
TfTicket
>(
request
,
response
),
tfTicket
);
//Page<TfTicket> page = tfTicketService.findPage(new Page<TfTicket>(request, response), tfTicket);
model
.
addAttribute
(
"page"
,
page
);
tfTicket
.
setOrderBy
(
"totalDate"
);
total
(
tfTicket
,
request
,
response
,
model
);
return
"modules/ylttrip/tfTicketList"
;
}
/**
* 订单列表页面
*/
@RequiresPermissions
(
"ylttrip:tfTicket:list"
)
@RequestMapping
(
value
=
{
"listVue"
})
public
String
listVue
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
TfTicket
>
page
=
tfTicketService
.
findPageCache
(
new
Page
<
TfTicket
>(
request
,
response
),
tfTicket
);
//Page<TfTicket> page = tfTicketService.findPage(new Page<TfTicket>(request, response), tfTicket);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/ylttrip/tfTicketListVue"
;
}
/**
* 订单列表页面
*/
//RequiresPermissions("ylttrip:tfTicket:select")
@RequestMapping
(
value
=
{
"select"
})
public
String
select
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
TfTicket
>
page
=
tfTicketService
.
findPageCache
(
new
Page
<
TfTicket
>(
request
,
response
),
tfTicket
);
//Page<TfTicket> page = tfTicketService.findPage(new Page<TfTicket>(request, response), tfTicket);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/ylttrip/tfTicketSelect"
;
}
/**
* 查看,增加,编辑订单表单页面
*/
@RequiresPermissions
(
value
={
"ylttrip:tfTicket:view"
,
"ylttrip:tfTicket:add"
,
"ylttrip:tfTicket:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
TfTicket
tfTicket
,
Model
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
model
.
addAttribute
(
"action"
,
request
.
getParameter
(
"action"
));
model
.
addAttribute
(
"tfTicket"
,
tfTicket
);
if
(
request
.
getParameter
(
"ViewFormType"
)!=
null
&&
request
.
getParameter
(
"ViewFormType"
).
equals
(
"FormTwo"
))
return
"modules/ylttrip/tfTicketFormTwo"
;
return
"modules/ylttrip/tfTicketForm"
;
}
/**
* 保存订单
*/
@RequiresPermissions
(
value
={
"ylttrip:tfTicket:add"
,
"ylttrip:tfTicket:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
TfTicket
tfTicket
,
Model
model
,
RedirectAttributes
redirectAttributes
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(!
beanValidator
(
model
,
tfTicket
)){
return
form
(
tfTicket
,
model
,
request
,
response
);
}
tfTicketService
.
save
(
tfTicket
);
addMessage
(
redirectAttributes
,
"保存订单成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
/**
* 删除订单
*/
@RequiresPermissions
(
"ylttrip:tfTicket:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
tfTicketService
.
delete
(
tfTicket
);
addMessage
(
redirectAttributes
,
"删除订单成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
/**
* 删除订单(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions
(
value
={
"ylttrip:tfTicket:del"
,
"ylttrip:tfTicket:delByLogic"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"deleteByLogic"
)
public
String
deleteByLogic
(
TfTicket
tfTicket
,
RedirectAttributes
redirectAttributes
)
{
tfTicketService
.
deleteByLogic
(
tfTicket
);
addMessage
(
redirectAttributes
,
"逻辑删除订单成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
/**
* 批量删除订单
*/
@RequiresPermissions
(
"ylttrip:tfTicket:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
tfTicketService
.
delete
(
tfTicketService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除订单成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
/**
* 批量删除订单(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions
(
value
={
"ylttrip:tfTicket:del"
,
"ylttrip:tfTicket:delByLogic"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"deleteAllByLogic"
)
public
String
deleteAllByLogic
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
idArray
[]
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
tfTicketService
.
deleteByLogic
(
tfTicketService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除订单成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
/**
* 导出excel文件
*/
@RequiresPermissions
(
"ylttrip:tfTicket:export"
)
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
TfTicket
tfTicket
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"订单"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
TfTicket
>
page
=
tfTicketService
.
findPage
(
new
Page
<
TfTicket
>(
request
,
response
,
-
1
),
tfTicket
);
new
ExportExcel
(
"订单"
,
TfTicket
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出订单记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
/**
* 导入Excel数据
*/
@RequiresPermissions
(
"ylttrip:tfTicket: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
<
TfTicket
>
list
=
ei
.
getDataList
(
TfTicket
.
class
);
for
(
TfTicket
tfTicket
:
list
){
tfTicketService
.
save
(
tfTicket
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条订单记录"
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入订单失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
/**
* 下载导入订单数据模板
*/
@RequiresPermissions
(
"ylttrip:tfTicket:import"
)
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"订单数据导入模板.xlsx"
;
List
<
TfTicket
>
list
=
Lists
.
newArrayList
();
new
ExportExcel
(
"订单数据"
,
TfTicket
.
class
,
1
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/ylttrip/tfTicket/?repage"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/company/project/project.txt
0 → 100644
View file @
dd7c8801
JeeSpringCloud/src/main/java/com/jeespring/common/annotation/FieldName.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.annotation
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* bean中文名注解
*/
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
FieldName
{
String
value
();
}
JeeSpringCloud/src/main/java/com/jeespring/common/beanvalidator/AddGroup.java
0 → 100644
View file @
dd7c8801
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.common.beanvalidator
;
/**
* 添加Bean验证组
* @author 黄炳桂 516821420@qq.com
*
*/
public
interface
AddGroup
{
}
JeeSpringCloud/src/main/java/com/jeespring/common/beanvalidator/DefaultGroup.java
0 → 100644
View file @
dd7c8801
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.common.beanvalidator
;
/**
* 默认Bean验证组
* @author 黄炳桂 516821420@qq.com
*/
public
interface
DefaultGroup
{
}
JeeSpringCloud/src/main/java/com/jeespring/common/beanvalidator/EditGroup.java
0 → 100644
View file @
dd7c8801
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.common.beanvalidator
;
/**
* 编辑Bena验证组
* @author 黄炳桂 516821420@qq.com
*/
public
interface
EditGroup
{
}
JeeSpringCloud/src/main/java/com/jeespring/common/config/Global.java
0 → 100644
View file @
dd7c8801
/**
* Copyright © 2012-2016 <a href="https://github.com/HuangBingGui/jeespring">jeespring</a> All rights reserved.
*/
package
com.jeespring.common.config
;
import
com.ckfinder.connector.ServletContextFactory
;
import
com.google.common.collect.Maps
;
import
com.jeespring.common.utils.PropertiesLoader
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.sys.entity.SysConfig
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.apache.ibatis.io.Resources
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.bind.RelaxedPropertyResolver
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Properties
;
/**
* 全局配置类
*
* @author 黄炳桂 516821420@qq.com
* @version 2014-06-25
*/
public
class
Global
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
Global
.
class
);
static
RelaxedPropertyResolver
resolver
;
/**
* 当前对象实例
*/
private
static
Global
global
=
new
Global
();
/**
* 保存全局属性值
*/
private
static
Map
<
String
,
String
>
map
=
Maps
.
newHashMap
();
/**
* 属性文件加载对象
*/
private
static
PropertiesLoader
loader
=
new
PropertiesLoader
(
"bootstrap.yml"
);
/**
* 显示/隐藏
*/
public
static
final
String
SHOW
=
"1"
;
public
static
final
String
HIDE
=
"0"
;
/**
* 是/否
*/
public
static
final
String
YES
=
"1"
;
public
static
final
String
NO
=
"0"
;
/**
* 对/错
*/
public
static
final
String
TRUE
=
"true"
;
public
static
final
String
FALSE
=
"false"
;
/**
* 上传文件基础虚拟路径
*/
public
static
final
String
USERFILES_BASE_URL
=
"/userfiles/"
;
/**
* 获取当前对象实例
*/
public
static
Global
getInstance
()
{
return
global
;
}
/**
* 获取配置
* ${fns:getConfig('adminPath')}
*/
public
static
String
getConfig
(
String
key
)
{
String
value
=
map
.
get
(
key
);
if
(
value
==
null
)
{
try
{
value
=
resolver
.
getProperty
(
key
);
if
(
StringUtils
.
isBlank
(
value
))
throw
new
RuntimeException
(
"value null"
);
map
.
put
(
key
,
value
);
}
catch
(
Exception
e
)
{
value
=
loader
.
getProperty
(
key
);
map
.
put
(
key
,
value
!=
null
?
value
:
StringUtils
.
EMPTY
);
}
}
return
value
;
}
public
static
String
getConfig
(
String
key
,
String
value
){
String
result
=
getConfig
(
key
);
if
(
result
==
StringUtils
.
EMPTY
){
return
value
;
}
return
result
;
}
/**
* 获取管理端根路径
*/
public
static
String
getAdminPath
()
{
return
getConfig
(
"adminPath"
);
}
/**
* 获取前端根路径
*/
public
static
String
getFrontPath
()
{
return
getConfig
(
"frontPath"
);
}
/**
* 获取URL后缀
*/
public
static
String
getUrlSuffix
()
{
return
getConfig
(
"urlSuffix"
);
}
/**
* 是否是演示模式,演示模式下不能修改用户、角色、密码、菜单、授权
*/
public
static
Boolean
isDemoMode
()
{
String
dm
=
getConfig
(
"demoMode"
);
return
"true"
.
equals
(
dm
)
||
"1"
.
equals
(
dm
);
}
public
static
String
isDemoModeDescription
()
{
String
dmd
=
getConfig
(
"demoModeDescription"
);
if
(
dmd
==
null
){
return
"演示版启用为系统能正常演示,暂时不允许操作!"
;
}
return
dmd
;
}
public
static
Boolean
isDubbo
()
{
String
dm
=
getConfig
(
"dubbo.run"
);
return
"true"
.
equals
(
dm
)
||
"1"
.
equals
(
dm
);
}
/**
* 获取上传文件的根目录
*
* @return
*/
public
static
String
getUserfilesBaseDir
()
{
String
dir
=
getConfig
(
"userfiles.basedir"
);
if
(
StringUtils
.
isBlank
(
dir
))
{
try
{
dir
=
ServletContextFactory
.
getServletContext
().
getRealPath
(
"/"
);
}
catch
(
Exception
e
)
{
return
""
;
}
}
if
(!
dir
.
endsWith
(
"/"
))
{
dir
+=
"/"
;
}
return
dir
;
}
public
static
String
getJdbcType
()
{
if
(
map
.
containsKey
(
"spring.datasource.url"
))
return
map
.
get
(
"spring.datasource.url"
);
try
{
String
url
=
resolver
.
getProperty
(
"spring.datasource.url"
);
String
type
=
getDbType
(
url
);
map
.
put
(
"spring.datasource.url"
,
type
);
return
type
;
}
catch
(
Exception
e
)
{
logger
.
error
(
"get jdbcType error"
,
e
);
}
logger
.
error
(
"return the defaut jdbc type is mysql"
);
return
"mysql"
;
}
private
static
String
getDbType
(
String
rawUrl
)
{
return
rawUrl
==
null
?
null
:
(!
rawUrl
.
startsWith
(
"jdbc:derby:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:derby:"
)
?
(!
rawUrl
.
startsWith
(
"jdbc:mysql:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:cobar:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:mysql:"
)
?
(
rawUrl
.
startsWith
(
"jdbc:mariadb:"
)
?
"mariadb"
:
(!
rawUrl
.
startsWith
(
"jdbc:oracle:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:oracle:"
)
?
(
rawUrl
.
startsWith
(
"jdbc:alibaba:oracle:"
)
?
"AliOracle"
:
(!
rawUrl
.
startsWith
(
"jdbc:microsoft:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:microsoft:"
)
?
(!
rawUrl
.
startsWith
(
"jdbc:sqlserver:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:sqlserver:"
)
?
(!
rawUrl
.
startsWith
(
"jdbc:sybase:Tds:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:sybase:"
)
?
(!
rawUrl
.
startsWith
(
"jdbc:jtds:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:jtds:"
)
?
(!
rawUrl
.
startsWith
(
"jdbc:fake:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:mock:"
)
?
(!
rawUrl
.
startsWith
(
"jdbc:postgresql:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:postgresql:"
)
?
(
rawUrl
.
startsWith
(
"jdbc:edb:"
)
?
"edb"
:
(!
rawUrl
.
startsWith
(
"jdbc:hsqldb:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:hsqldb:"
)
?
(
rawUrl
.
startsWith
(
"jdbc:odps:"
)
?
"odps"
:
(
rawUrl
.
startsWith
(
"jdbc:db2:"
)
?
"db2"
:
(
rawUrl
.
startsWith
(
"jdbc:sqlite:"
)
?
"sqlite"
:
(
rawUrl
.
startsWith
(
"jdbc:ingres:"
)
?
"ingres"
:
(!
rawUrl
.
startsWith
(
"jdbc:h2:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:h2:"
)
?
(
rawUrl
.
startsWith
(
"jdbc:mckoi:"
)
?
"mckoi"
:
(
rawUrl
.
startsWith
(
"jdbc:cloudscape:"
)
?
"cloudscape"
:
(!
rawUrl
.
startsWith
(
"jdbc:informix-sqli:"
)
&&
!
rawUrl
.
startsWith
(
"jdbc:log4jdbc:informix-sqli:"
)
?
(
rawUrl
.
startsWith
(
"jdbc:timesten:"
)
?
"timesten"
:
(
rawUrl
.
startsWith
(
"jdbc:as400:"
)
?
"as400"
:
(
rawUrl
.
startsWith
(
"jdbc:sapdb:"
)
?
"sapdb"
:
(
rawUrl
.
startsWith
(
"jdbc:JSQLConnect:"
)
?
"JSQLConnect"
:
(
rawUrl
.
startsWith
(
"jdbc:JTurbo:"
)
?
"JTurbo"
:
(
rawUrl
.
startsWith
(
"jdbc:firebirdsql:"
)
?
"firebirdsql"
:
(
rawUrl
.
startsWith
(
"jdbc:interbase:"
)
?
"interbase"
:
(
rawUrl
.
startsWith
(
"jdbc:pointbase:"
)
?
"pointbase"
:
(
rawUrl
.
startsWith
(
"jdbc:edbc:"
)
?
"edbc"
:
(
rawUrl
.
startsWith
(
"jdbc:mimer:multi1:"
)
?
"mimer"
:
(
rawUrl
.
startsWith
(
"jdbc:dm:"
)
?
"dm"
:
(
rawUrl
.
startsWith
(
"jdbc:kingbase:"
)
?
"kingbase"
:
(
rawUrl
.
startsWith
(
"jdbc:log4jdbc:"
)
?
"log4jdbc"
:
(
rawUrl
.
startsWith
(
"jdbc:hive:"
)
?
"hive"
:
(
rawUrl
.
startsWith
(
"jdbc:hive2:"
)
?
"hive"
:
(
rawUrl
.
startsWith
(
"jdbc:phoenix:"
)
?
"phoenix"
:
null
))))))))))))))))
:
"informix"
)))
:
"h2"
)))))
:
"hsql"
))
:
"postgresql"
)
:
"mock"
)
:
"jtds"
)
:
"sybase"
)
:
"sqlserver"
)
:
"sqlserver"
))
:
"oracle"
))
:
"mysql"
)
:
"derby"
);
}
/**
* 获取工程路径
* @return
*/
public
static
String
getProjectPath
(){
// 如果配置了工程路径,则直接返回,否则自动获取。
String
projectPath
=
Global
.
getConfig
(
"projectPath"
);
if
(
StringUtils
.
isNotBlank
(
projectPath
)){
return
projectPath
;
}
try
{
File
file
=
new
DefaultResourceLoader
().
getResource
(
""
).
getFile
();
if
(
file
!=
null
){
while
(
true
){
File
f
=
new
File
(
file
.
getPath
()
+
File
.
separator
+
"src"
+
File
.
separator
+
"main"
);
if
(
f
==
null
||
f
.
exists
()){
break
;
}
if
(
file
.
getParentFile
()
!=
null
){
file
=
file
.
getParentFile
();
}
else
{
break
;
}
}
projectPath
=
file
.
toString
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
projectPath
;
}
/**
* 写入properties信息
*
* @param key
* 名称
* @param value
* 值
*/
public
static
void
modifyConfig
(
String
key
,
String
value
)
{
try
{
// 从输入流中读取属性列表(键和元素对)
Properties
prop
=
getProperties
();
prop
.
setProperty
(
key
,
value
);
String
path
=
Global
.
class
.
getResource
(
"/jeespring.properties"
).
getPath
();
FileOutputStream
outputFile
=
new
FileOutputStream
(
path
);
prop
.
store
(
outputFile
,
"modify"
);
outputFile
.
close
();
outputFile
.
flush
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* (注意:加载的是src下的文件,如果在某个包下.请把包名加上)
* 返回 Properties
* @return
*/
public
static
Properties
getProperties
(){
Properties
prop
=
new
Properties
();
try
{
Reader
reader
=
Resources
.
getResourceAsReader
(
"/jeespring.properties"
);
prop
.
load
(
reader
);
}
catch
(
Exception
e
)
{
return
null
;
}
return
prop
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/common/config/ScheduleConfig.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.quartz.SchedulerFactoryBean
;
import
javax.sql.DataSource
;
import
java.util.Properties
;
/**
* 定时任务配置
*
* @author JeeSpring
*
*/
@Configuration
public
class
ScheduleConfig
{
@Bean
public
SchedulerFactoryBean
schedulerFactoryBean
(
DataSource
dataSource
)
{
SchedulerFactoryBean
factory
=
new
SchedulerFactoryBean
();
factory
.
setDataSource
(
dataSource
);
// quartz参数
Properties
prop
=
new
Properties
();
prop
.
put
(
"org.quartz.scheduler.instanceName"
,
"RuoyiScheduler"
);
prop
.
put
(
"org.quartz.scheduler.instanceId"
,
"AUTO"
);
// 线程池配置
prop
.
put
(
"org.quartz.threadPool.class"
,
"org.quartz.simpl.SimpleThreadPool"
);
prop
.
put
(
"org.quartz.threadPool.threadCount"
,
"20"
);
prop
.
put
(
"org.quartz.threadPool.threadPriority"
,
"5"
);
// JobStore配置
prop
.
put
(
"org.quartz.jobStore.class"
,
"org.quartz.impl.jdbcjobstore.JobStoreTX"
);
// 集群配置
prop
.
put
(
"org.quartz.jobStore.isClustered"
,
"true"
);
prop
.
put
(
"org.quartz.jobStore.clusterCheckinInterval"
,
"15000"
);
prop
.
put
(
"org.quartz.jobStore.maxMisfiresToHandleAtATime"
,
"1"
);
prop
.
put
(
"org.quartz.jobStore.txIsolationLevelSerializable"
,
"true"
);
prop
.
put
(
"org.quartz.jobStore.misfireThreshold"
,
"12000"
);
prop
.
put
(
"org.quartz.jobStore.tablePrefix"
,
"QRTZ_"
);
factory
.
setQuartzProperties
(
prop
);
factory
.
setSchedulerName
(
"RuoyiScheduler"
);
// 延时启动
factory
.
setStartupDelay
(
1
);
factory
.
setApplicationContextSchedulerContextKey
(
"applicationContextKey"
);
// 可选,QuartzScheduler
// 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
factory
.
setOverwriteExistingJobs
(
true
);
// 设置自动启动,默认为true
factory
.
setAutoStartup
(
true
);
return
factory
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/common/config/ShiroConfig.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.config
;
import
com.jeespring.common.filter.LogoutFilter
;
import
com.jeespring.common.filter.OnlineSessionFilter
;
import
com.jeespring.common.redis.RedisUtils
;
import
com.jeespring.common.security.shiro.session.CacheSessionDAO
;
import
com.jeespring.common.security.shiro.session.SessionManager
;
import
com.jeespring.modules.sys.dao.OnlineSessionDAO
;
import
com.jeespring.modules.sys.dao.OnlineSessionFactory
;
import
com.jeespring.modules.sys.security.FormAuthenticationFilter
;
import
com.jeespring.modules.sys.security.SystemAuthorizingRealm
;
import
net.sf.ehcache.CacheManager
;
import
org.apache.shiro.cache.ehcache.EhCacheManager
;
import
org.apache.shiro.spring.LifecycleBeanPostProcessor
;
import
org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor
;
import
org.apache.shiro.spring.web.ShiroFilterFactoryBean
;
import
org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter
;
import
org.apache.shiro.web.mgt.DefaultWebSecurityManager
;
import
org.apache.shiro.web.servlet.SimpleCookie
;
import
org.crazycake.shiro.RedisCacheManager
;
import
org.crazycake.shiro.RedisManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.bind.RelaxedPropertyResolver
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.DependsOn
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.filter.DelegatingFilterProxy
;
import
com.jeespring.common.filter.SyncOnlineSessionFilter
;
import
javax.servlet.Filter
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* shiro的控制类
* 下面方法的顺序不能乱
* Created by zhao.weiwei
* create on 2017/1/11 10:59
* the email is zhao.weiwei@jyall.com.
*/
@Component
public
class
ShiroConfig
{
/**
* 日志对象
*/
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
RedisUtils
.
class
);
@Autowired
public
OnlineSessionDAO
sessionDAO
;
@Autowired
public
OnlineSessionFactory
sessionFactory
;
// Session超时时间,单位为毫秒(默认30分钟)
@Value
(
"${shiro.session.expireTime}"
)
private
int
expireTime
;
//启动shiro redis缓存,单点登录
//@Value("${shiro.redis}")
//private String shiroRedis;
// 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟
@Value
(
"${shiro.session.validationInterval}"
)
private
int
validationInterval
;
// 验证码开关
@Value
(
"${shiro.user.captchaEbabled}"
)
private
boolean
captchaEbabled
;
// 验证码类型
@Value
(
"${shiro.user.captchaType}"
)
private
String
captchaType
;
// 设置Cookie的域名
@Value
(
"${shiro.cookie.domain}"
)
private
String
domain
;
// 设置cookie的有效访问路径
@Value
(
"${shiro.cookie.path}"
)
private
String
path
;
// 设置HttpOnly属性
@Value
(
"${shiro.cookie.httpOnly}"
)
private
boolean
httpOnly
;
// 设置Cookie的过期时间,秒为单位
@Value
(
"${shiro.cookie.maxAge}"
)
private
int
maxAge
;
// 登录地址
@Value
(
"${shiro.user.loginUrl}"
)
private
String
loginUrl
=
"/admin/login"
;
// 权限认证失败地址
@Value
(
"${shiro.user.unauthorizedUrl}"
)
private
String
unauthorizedUrl
;
/**
* 全局的环境变量的设置
* shiro的拦截
*
* @param environment
* @param adminPath
* @return
*/
@Bean
(
name
=
"shiroFilterChainDefinitions"
)
public
String
shiroFilterChainDefinitions
(
Environment
environment
,
@Value
(
"${adminPath}"
)
String
adminPath
,
@Value
(
"${frontPath}"
)
String
frontPath
)
{
Global
.
resolver
=
new
RelaxedPropertyResolver
(
environment
);
StringBuilder
string
=
new
StringBuilder
();
string
.
append
(
"/static/** = anon\n"
);
string
.
append
(
"/staticViews/** = anon\n"
);
string
.
append
(
"/jeeSpringStatic/** = anon\n"
);
string
.
append
(
"/userfiles/** = anon\n"
);
string
.
append
(
"/rest/** = anon\n"
);
string
.
append
(
frontPath
+
"/** = anon\n"
);
string
.
append
(
adminPath
+
"/basic = basic\n"
);
string
.
append
(
adminPath
+
"/login = authc\n"
);
string
.
append
(
adminPath
+
"/loginBase = anon\n"
);
string
.
append
(
adminPath
+
"/logout = logout\n"
);
string
.
append
(
adminPath
+
"/register = anon\n"
);
string
.
append
(
adminPath
+
"/sys/register/registerUser = anon\n"
);
string
.
append
(
adminPath
+
"/sys/user/validateLoginName = anon\n"
);
string
.
append
(
adminPath
+
"/sys/user/validateMobile = anon\n"
);
string
.
append
(
adminPath
+
"/** = user\n"
);
string
.
append
(
"/ReportServer/** = user"
);
return
string
.
toString
();
}
@Bean
(
name
=
"basicHttpAuthenticationFilter"
)
public
BasicHttpAuthenticationFilter
casFilter
(
@Value
(
"${adminPath:/a}"
)
String
adminPath
)
{
BasicHttpAuthenticationFilter
basicHttpAuthenticationFilter
=
new
BasicHttpAuthenticationFilter
();
basicHttpAuthenticationFilter
.
setLoginUrl
(
adminPath
+
"/login"
);
return
basicHttpAuthenticationFilter
;
}
@Bean
(
name
=
"shiroFilter"
)
public
ShiroFilterFactoryBean
shiroFilterFactoryBean
(
@Value
(
"${adminPath:/a}"
)
String
adminPath
,
BasicHttpAuthenticationFilter
basicHttpAuthenticationFilter
,
FormAuthenticationFilter
formAuthenticationFilter
,
DefaultWebSecurityManager
securityManager
,
@Qualifier
(
"shiroFilterChainDefinitions"
)
String
shiroFilterChainDefinitions
)
{
Map
<
String
,
Filter
>
filters
=
new
HashMap
<>();
filters
.
put
(
"basic"
,
basicHttpAuthenticationFilter
);
filters
.
put
(
"authc"
,
formAuthenticationFilter
);
filters
.
put
(
"syncOnlineSession"
,
syncOnlineSessionFilter
());
//filters.put("onlineSession", onlineSessionFilter());
filters
.
put
(
"logout"
,
logoutFilter
());
ShiroFilterFactoryBean
bean
=
new
ShiroFilterFactoryBean
();
bean
.
setFilters
(
filters
);
bean
.
setSecurityManager
(
securityManager
);
bean
.
setLoginUrl
(
adminPath
+
"/login"
);
bean
.
setSuccessUrl
(
adminPath
+
"?login"
);
// Shiro过滤器配置
bean
.
setFilterChainDefinitions
(
shiroFilterChainDefinitions
);
return
bean
;
}
@Bean
(
name
=
"shiroCacheManager"
)
public
EhCacheManager
shiroCacheManager
(
CacheManager
manager
)
{
EhCacheManager
ehCacheManager
=
new
EhCacheManager
();
ehCacheManager
.
setCacheManager
(
manager
);
return
ehCacheManager
;
}
//@Bean(name = "redisCacheManager")
public
RedisCacheManager
redisCacheManager
(
String
redisHostName
,
String
reidsPassword
,
int
reidsPort
,
int
expireTimeShiro
)
{
RedisCacheManager
redisCacheManager
=
new
RedisCacheManager
();
RedisManager
redisManager
=
new
RedisManager
();
redisManager
.
setHost
(
redisHostName
);
redisManager
.
setPassword
(
reidsPassword
);
redisManager
.
setPort
(
reidsPort
);
redisManager
.
setExpire
(
expireTimeShiro
);
redisCacheManager
.
setRedisManager
(
redisManager
);
return
redisCacheManager
;
}
@Bean
(
name
=
"sessionManager"
)
public
SessionManager
sessionManager
(
CacheSessionDAO
dao
)
{
SessionManager
sessionManager
=
new
SessionManager
();
sessionManager
.
setSessionDAO
(
dao
);
// 设置全局session超时时间
sessionManager
.
setGlobalSessionTimeout
(
86400000
);
// 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟
sessionManager
.
setSessionValidationInterval
(
1800000
);
sessionManager
.
setSessionValidationSchedulerEnabled
(
true
);
sessionManager
.
setSessionIdCookie
(
new
SimpleCookie
(
"com.jeespring.session.id"
));
sessionManager
.
setSessionIdCookieEnabled
(
true
);
// 删除过期的session
sessionManager
.
setDeleteInvalidSessions
(
true
);
// 去掉 JSESSIONID
sessionManager
.
setSessionIdUrlRewritingEnabled
(
true
);
// 是否定时检查session
sessionManager
.
setSessionValidationSchedulerEnabled
(
true
);
// 自定义SessionDao
//sessionManager.setSessionDAO(sessionDAO());
// 自定义sessionFactory
//sessionManager.setSessionFactory(sessionFactory());
return
sessionManager
;
}
@Bean
(
name
=
"securityManager"
)
public
DefaultWebSecurityManager
defaultWebSecurityManager
(
SystemAuthorizingRealm
systemAuthorizingRealm
,
SessionManager
sessionManager
,
EhCacheManager
ehCacheManager
,
@Value
(
"${spring.redis.run}"
)
String
redisRun
,
@Value
(
"${spring.redis.hostName}"
)
String
redisHostName
,
@Value
(
"${spring.redis.password}"
)
String
reidsPassword
,
@Value
(
"${spring.redis.port}"
)
int
redisPort
,
@Value
(
"${spring.redis.expireTimeShiro}"
)
int
expireTimeShiro
,
@Value
(
"${shiro.redis}"
)
String
shiroRedis
)
{
DefaultWebSecurityManager
defaultWebSecurityManager
=
new
DefaultWebSecurityManager
();
defaultWebSecurityManager
.
setSessionManager
(
sessionManager
);
if
(
redisRun
.
equals
(
"true"
)
&&
"true"
.
equals
(
shiroRedis
)){
try
{
// 加入缓存管理器
defaultWebSecurityManager
.
setCacheManager
(
redisCacheManager
(
redisHostName
,
reidsPassword
,
redisPort
,
expireTimeShiro
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"RedisUtils run:"
+
RedisUtils
.
RUN_MESSAGE
+
e
.
getMessage
(),
RedisUtils
.
RUN_MESSAGE
+
e
.
getMessage
());
defaultWebSecurityManager
.
setCacheManager
(
ehCacheManager
);
}
}
else
{
// 加入缓存管理器
defaultWebSecurityManager
.
setCacheManager
(
ehCacheManager
);
}
defaultWebSecurityManager
.
setRealm
(
systemAuthorizingRealm
);
return
defaultWebSecurityManager
;
}
@Bean
public
AuthorizationAttributeSourceAdvisor
authorizationAttributeSourceAdvisor
(
DefaultWebSecurityManager
defaultWebSecurityManager
)
{
AuthorizationAttributeSourceAdvisor
authorizationAttributeSourceAdvisor
=
new
AuthorizationAttributeSourceAdvisor
();
authorizationAttributeSourceAdvisor
.
setSecurityManager
(
defaultWebSecurityManager
);
return
authorizationAttributeSourceAdvisor
;
}
@Bean
public
FilterRegistrationBean
filterRegistrationBean
()
{
FilterRegistrationBean
filterRegistration
=
new
FilterRegistrationBean
();
filterRegistration
.
setFilter
(
new
DelegatingFilterProxy
(
"shiroFilter"
));
filterRegistration
.
addInitParameter
(
"targetFilterLifecycle"
,
"true"
);
filterRegistration
.
setEnabled
(
true
);
filterRegistration
.
addUrlPatterns
(
"/*"
);
return
filterRegistration
;
}
@Bean
(
name
=
"lifecycleBeanPostProcessor"
)
public
LifecycleBeanPostProcessor
lifecycleBeanPostProcessor
()
{
return
new
LifecycleBeanPostProcessor
();
}
@Bean
@DependsOn
(
"lifecycleBeanPostProcessor"
)
public
DefaultAdvisorAutoProxyCreator
defaultAdvisorAutoProxyCreator
()
{
DefaultAdvisorAutoProxyCreator
defaultAdvisorAutoProxyCreator
=
new
DefaultAdvisorAutoProxyCreator
();
defaultAdvisorAutoProxyCreator
.
setProxyTargetClass
(
true
);
return
defaultAdvisorAutoProxyCreator
;
}
/**
* 自定义在线用户处理过滤器
*/
public
OnlineSessionFilter
onlineSessionFilter
()
{
OnlineSessionFilter
onlineSessionFilter
=
new
OnlineSessionFilter
();
//onlineSessionFilter.setLoginUrl(loginUrl);
return
onlineSessionFilter
;
}
/**
* 自定义在线用户同步过滤器
*/
@Bean
public
SyncOnlineSessionFilter
syncOnlineSessionFilter
()
{
SyncOnlineSessionFilter
syncOnlineSessionFilter
=
new
SyncOnlineSessionFilter
();
return
syncOnlineSessionFilter
;
}
public
LogoutFilter
logoutFilter
()
{
LogoutFilter
logoutFilter
=
new
LogoutFilter
();
logoutFilter
.
setLoginUrl
(
loginUrl
);
return
logoutFilter
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/common/constant/Constants.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.constant
;
/**
* 通用常量信息
*
* @author JeeSpring
*/
public
class
Constants
{
/**
* UTF-8 字符集
*/
public
static
final
String
UTF8
=
"UTF-8"
;
/**
* 通用成功标识
*/
public
static
final
String
SUCCESS
=
"0"
;
/**
* 通用失败标识
*/
public
static
final
String
FAIL
=
"1"
;
/**
* 登录成功
*/
public
static
final
String
LOGIN_SUCCESS
=
"Success"
;
/**
* 注销
*/
public
static
final
String
LOGOUT
=
"Logout"
;
/**
* 登录失败
*/
public
static
final
String
LOGIN_FAIL
=
"Error"
;
/**
* 自动去除表前缀
*/
public
static
String
AUTO_REOMVE_PRE
=
"true"
;
/**
* 当前记录起始索引
*/
public
static
String
PAGE_NUM
=
"pageNum"
;
/**
* 每页显示记录数
*/
public
static
String
PAGE_SIZE
=
"pageSize"
;
/**
* 排序列
*/
public
static
String
ORDER_BY_COLUMN
=
"orderByColumn"
;
/**
* 排序的方向 "desc" 或者 "asc".
*/
public
static
String
IS_ASC
=
"isAsc"
;
}
JeeSpringCloud/src/main/java/com/jeespring/common/constant/ScheduleConstants.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.constant
;
/**
* 任务调度通用常量
*
* @author JeeSpring
*/
public
interface
ScheduleConstants
{
public
static
final
String
TASK_CLASS_NAME
=
"__TASK_CLASS_NAME__"
;
public
static
final
String
TASK_PROPERTIES
=
"__TASK_PROPERTIES__"
;
/** 默认 */
public
static
final
String
MISFIRE_DEFAULT
=
"0"
;
/** 立即触发执行 */
public
static
final
String
MISFIRE_IGNORE_MISFIRES
=
"1"
;
/** 触发一次执行 */
public
static
final
String
MISFIRE_FIRE_AND_PROCEED
=
"2"
;
/** 不触发立即执行 */
public
static
final
String
MISFIRE_DO_NOTHING
=
"3"
;
public
enum
Status
{
/**
* 正常
*/
NORMAL
(
"0"
),
/**
* 暂停
*/
PAUSE
(
"1"
);
private
String
value
;
private
Status
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getValue
()
{
return
value
;
}
}
}
JeeSpringCloud/src/main/java/com/jeespring/common/constant/ShiroConstants.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.constant
;
/**
* Shiro通用常量
*
* @author JeeSpring
*/
public
interface
ShiroConstants
{
/**
* 当前登录的用户
*/
public
static
final
String
CURRENT_USER
=
"currentUser"
;
/**
* 用户名
*/
public
static
final
String
CURRENT_USERNAME
=
"username"
;
/**
* 消息key
*/
public
static
String
MESSAGE
=
"message"
;
/**
* 错误key
*/
public
static
String
ERROR
=
"errorMsg"
;
/**
* 编码格式
*/
public
static
String
ENCODING
=
"UTF-8"
;
/**
* 当前在线会话
*/
public
String
ONLINE_SESSION
=
"online_session"
;
/**
* 验证码key
*/
public
static
final
String
CURRENT_CAPTCHA
=
"captcha"
;
/**
* 验证码开关
*/
public
static
final
String
CURRENT_EBABLED
=
"captchaEbabled"
;
/**
* 验证码开关
*/
public
static
final
String
CURRENT_TYPE
=
"captchaType"
;
/**
* 验证码
*/
public
static
final
String
CURRENT_VALIDATECODE
=
"validateCode"
;
/**
* 验证码错误
*/
public
static
final
String
CAPTCHA_ERROR
=
"captchaError"
;
}
JeeSpringCloud/src/main/java/com/jeespring/common/druid/DruidConfiguration.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.druid
;
import
java.sql.SQLException
;
import
javax.sql.DataSource
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
com.alibaba.druid.pool.DruidDataSource
;
/**
*
* 描述:如果不使用代码手动初始化DataSource的话,监控界面的SQL监控会没有数据("是spring boot的bug???")
* @author chhliu
* 创建时间:2017年2月9日 下午10:33:08
* @version 1.2.0
*/
@Configuration
public
class
DruidConfiguration
{
@Value
(
"${spring.datasource.url}"
)
private
String
dbUrl
;
@Value
(
"${spring.datasource.username}"
)
private
String
username
;
@Value
(
"${spring.datasource.password}"
)
private
String
password
;
@Value
(
"${spring.datasource.driverClassName}"
)
private
String
driverClassName
;
@Value
(
"${spring.datasource.initialSize}"
)
private
int
initialSize
;
@Value
(
"${spring.datasource.minIdle}"
)
private
int
minIdle
;
@Value
(
"${spring.datasource.maxActive}"
)
private
int
maxActive
;
@Value
(
"${spring.datasource.maxWait}"
)
private
int
maxWait
;
@Value
(
"${spring.datasource.timeBetweenEvictionRunsMillis}"
)
private
int
timeBetweenEvictionRunsMillis
;
@Value
(
"${spring.datasource.minEvictableIdleTimeMillis}"
)
private
int
minEvictableIdleTimeMillis
;
@Value
(
"${spring.datasource.validationQuery}"
)
private
String
validationQuery
;
@Value
(
"${spring.datasource.testWhileIdle}"
)
private
boolean
testWhileIdle
;
@Value
(
"${spring.datasource.testOnBorrow}"
)
private
boolean
testOnBorrow
;
@Value
(
"${spring.datasource.testOnReturn}"
)
private
boolean
testOnReturn
;
@Value
(
"${spring.datasource.poolPreparedStatements}"
)
private
boolean
poolPreparedStatements
;
@Value
(
"${spring.datasource.maxPoolPreparedStatementPerConnectionSize}"
)
private
int
maxPoolPreparedStatementPerConnectionSize
;
@Value
(
"${spring.datasource.filters}"
)
private
String
filters
;
@Value
(
"${spring.datasource.connectionProperties}"
)
private
String
connectionProperties
;
@Value
(
"${spring.datasource.useGlobalDataSourceStat}"
)
private
boolean
useGlobalDataSourceStat
;
@Bean
//声明其为Bean实例
@Primary
//在同样的DataSource中,首先使用被标注的DataSource
public
DataSource
dataSource
(){
DruidDataSource
datasource
=
new
DruidDataSource
();
datasource
.
setUrl
(
this
.
dbUrl
);
datasource
.
setUsername
(
username
);
datasource
.
setPassword
(
password
);
datasource
.
setDriverClassName
(
driverClassName
);
//configuration
datasource
.
setInitialSize
(
initialSize
);
datasource
.
setMinIdle
(
minIdle
);
datasource
.
setMaxActive
(
maxActive
);
datasource
.
setMaxWait
(
maxWait
);
datasource
.
setTimeBetweenEvictionRunsMillis
(
timeBetweenEvictionRunsMillis
);
datasource
.
setMinEvictableIdleTimeMillis
(
minEvictableIdleTimeMillis
);
datasource
.
setValidationQuery
(
validationQuery
);
datasource
.
setTestWhileIdle
(
testWhileIdle
);
datasource
.
setTestOnBorrow
(
testOnBorrow
);
datasource
.
setTestOnReturn
(
testOnReturn
);
datasource
.
setPoolPreparedStatements
(
poolPreparedStatements
);
datasource
.
setMaxPoolPreparedStatementPerConnectionSize
(
maxPoolPreparedStatementPerConnectionSize
);
datasource
.
setUseGlobalDataSourceStat
(
useGlobalDataSourceStat
);
try
{
datasource
.
setFilters
(
filters
);
}
catch
(
SQLException
e
)
{
System
.
err
.
println
(
"druid configuration initialization filter: "
+
e
);
}
datasource
.
setConnectionProperties
(
connectionProperties
);
return
datasource
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/common/druid/DruidStatFilter.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.druid
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.annotation.WebInitParam
;
import
com.alibaba.druid.support.http.WebStatFilter
;
/**
* Druid的StatFilter
*
* @author 单红宇(365384722)
* @myblog http://blog.csdn.net/catoop/
* @create 2016年3月17日
*/
@WebFilter
(
filterName
=
"druidWebStatFilter"
,
urlPatterns
=
"/*"
,
initParams
={
@WebInitParam
(
name
=
"exclusions"
,
value
=
"*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
)
// 忽略资源
})
public
class
DruidStatFilter
extends
WebStatFilter
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/common/druid/DruidStatViewServlet.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.druid
;
import
javax.servlet.annotation.WebInitParam
;
import
javax.servlet.annotation.WebServlet
;
import
com.alibaba.druid.support.http.StatViewServlet
;
/**
* StatViewServlet
*
* @author 单红宇(365384722)
* @myblog http://blog.csdn.net/catoop/
* @create 2016年3月17日
*/
@SuppressWarnings
(
"serial"
)
@WebServlet
(
urlPatterns
=
"/druid/*"
,
initParams
={
@WebInitParam
(
name
=
"allow"
,
value
=
"192.168.16.110,127.0.0.1"
),
// IP白名单 (没有配置或者为空,则允许所有访问)
@WebInitParam
(
name
=
"deny"
,
value
=
"192.168.16.111"
),
// IP黑名单 (存在共同时,deny优先于allow)
//WebInitParam(name="loginUsername",value="shanhy"),// 用户名
//WebInitParam(name="loginPassword",value="shanhypwd"),// 密码
@WebInitParam
(
name
=
"resetEnable"
,
value
=
"false"
)
// 禁用HTML页面上的“Reset All”功能
})
public
class
DruidStatViewServlet
extends
StatViewServlet
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/common/exception/job/TaskException.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.exception.job
;
/**
* 计划策略异常
*
* @author JeeSpring
*/
public
class
TaskException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1L
;
private
Code
code
;
public
TaskException
(
String
msg
,
Code
code
)
{
this
(
msg
,
code
,
null
);
}
public
TaskException
(
String
msg
,
Code
code
,
Exception
nestedEx
)
{
super
(
msg
,
nestedEx
);
this
.
code
=
code
;
}
public
Code
getCode
()
{
return
code
;
}
public
enum
Code
{
TASK_EXISTS
,
NO_TASK_EXISTS
,
TASK_ALREADY_STARTED
,
UNKNOWN
,
CONFIG_ERROR
,
TASK_NODE_NOT_AVAILABLE
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/common/filter/JeesiteFileUploadFilter.java
0 → 100644
View file @
dd7c8801
package
com.jeespring.common.filter
;
import
com.ckfinder.connector.FileUploadFilter
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.annotation.WebInitParam
;
/**
* Created by zhao.weiwei
* create on 2017/1/10 12:23
* the email is zhao.weiwei@jyall.com.
*/
@WebFilter
(
urlPatterns
=
"/static/ckfinder/core/connector/java/connector.java"
,
initParams
=
{
@WebInitParam
(
name
=
"sessionCookieName"
,
value
=
"JSESSIONID"
),
@WebInitParam
(
name
=
"sessionParameterName"
,
value
=
"jsessionid"
)
})
public
class
JeesiteFileUploadFilter
extends
FileUploadFilter
{
}
Prev
1
2
3
4
5
6
7
…
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