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
d5ba54ba
Commit
d5ba54ba
authored
Nov 12, 2018
by
Huang
Browse files
no commit message
parent
da9d3b1b
Changes
399
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
19 of 399+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/src/main/java/com/jeespring/modules/oa/web/TestAuditController.java
0 → 100644
View file @
d5ba54ba
/**
* Copyright © 2012-2016 <a href="https://gitee.com/JeeHuangBingGui/jeeSpringCloud">JeeSpring</a> All rights reserved.
*/
package
com.jeespring.modules.oa.web
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.utils.UserUtils
;
import
com.jeespring.modules.oa.entity.TestAudit
;
import
com.jeespring.modules.oa.service.TestAuditService
;
/**
* 审批Controller
* @author thinkgem
* @version 2014-05-16
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/oa/testAudit"
)
public
class
TestAuditController
extends
AbstractBaseController
{
@Autowired
private
TestAuditService
testAuditService
;
@ModelAttribute
public
TestAudit
get
(
@RequestParam
(
required
=
false
)
String
id
){
//,
// @RequestParam(value="act.procInsId", required=false) String procInsId) {
TestAudit
testAudit
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
testAudit
=
testAuditService
.
get
(
id
);
// }else if (StringUtils.isNotBlank(procInsId)){
// testAudit = testAuditService.getByProcInsId(procInsId);
}
if
(
testAudit
==
null
){
testAudit
=
new
TestAudit
();
}
return
testAudit
;
}
@RequiresPermissions
(
"oa:testAudit:view"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
TestAudit
testAudit
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
User
user
=
UserUtils
.
getUser
();
if
(!
user
.
isAdmin
()){
testAudit
.
setCreateBy
(
user
);
}
Page
<
TestAudit
>
page
=
testAuditService
.
findPage
(
new
Page
<
TestAudit
>(
request
,
response
),
testAudit
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/oa/testAuditList"
;
}
/**
* 申请单填写
* @param testAudit
* @param model
* @return
*/
@RequiresPermissions
(
"oa:testAudit:view"
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
TestAudit
testAudit
,
Model
model
)
{
String
view
=
"testAuditForm"
;
// 查看审批申请单
if
(
StringUtils
.
isNotBlank
(
testAudit
.
getId
())){
//.getAct().getProcInsId())){
// 环节编号
String
taskDefKey
=
testAudit
.
getAct
().
getTaskDefKey
();
// 查看工单
if
(
testAudit
.
getAct
().
isFinishTask
()){
view
=
"testAuditView"
;
}
// 修改环节
else
if
(
"modify"
.
equals
(
taskDefKey
)){
view
=
"testAuditForm"
;
}
// 审核环节
else
if
(
"audit"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
// String formKey = "/oa/testAudit";
// return "redirect:" + ActUtils.getFormUrl(formKey, testAudit.getAct());
}
// 审核环节2
else
if
(
"audit2"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
// 审核环节3
else
if
(
"audit3"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
// 审核环节4
else
if
(
"audit4"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
// 兑现环节
else
if
(
"apply_end"
.
equals
(
taskDefKey
)){
view
=
"testAuditAudit"
;
}
}
model
.
addAttribute
(
"testAudit"
,
testAudit
);
return
"modules/oa/"
+
view
;
}
/**
* 申请单保存/修改
* @param testAudit
* @param model
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"oa:testAudit:edit"
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
TestAudit
testAudit
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(!
beanValidator
(
model
,
testAudit
)){
return
form
(
testAudit
,
model
);
}
testAuditService
.
save
(
testAudit
);
addMessage
(
redirectAttributes
,
"提交审批'"
+
testAudit
.
getUser
().
getName
()
+
"'成功"
);
return
"redirect:"
+
adminPath
+
"/act/task/todo/"
;
}
/**
* 工单执行(完成任务)
* @param testAudit
* @param model
* @return
*/
@RequiresPermissions
(
"oa:testAudit:edit"
)
@RequestMapping
(
value
=
"saveAudit"
)
public
String
saveAudit
(
TestAudit
testAudit
,
Model
model
)
{
if
(
StringUtils
.
isBlank
(
testAudit
.
getAct
().
getFlag
())
||
StringUtils
.
isBlank
(
testAudit
.
getAct
().
getComment
())){
addMessage
(
model
,
"请填写审核意见。"
);
return
form
(
testAudit
,
model
);
}
testAuditService
.
auditSave
(
testAudit
);
return
"redirect:"
+
adminPath
+
"/act/task/todo/"
;
}
/**
* 删除工单
* @param id
* @param redirectAttributes
* @return
*/
@RequiresPermissions
(
"oa:testAudit:edit"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
TestAudit
testAudit
,
RedirectAttributes
redirectAttributes
)
{
testAuditService
.
delete
(
testAudit
);
addMessage
(
redirectAttributes
,
"删除审批成功"
);
return
"redirect:"
+
adminPath
+
"/oa/testAudit/?repage"
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/oauth/entity/TokenInfo.java
0 → 100644
View file @
d5ba54ba
package
com.jeespring.modules.oauth.entity
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
java.io.Serializable
;
import
java.util.Date
;
public
class
TokenInfo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
token
;
private
Date
tokenDate
;
private
String
oauthId
;
private
String
oauthSecret
;
private
String
ip
;
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
Date
getTokenDate
()
{
return
tokenDate
;
}
public
void
setTokenDate
(
Date
tokenDate
)
{
this
.
tokenDate
=
tokenDate
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getOauthId
()
{
return
oauthId
;
}
public
void
setOauthId
(
String
oauthId
)
{
this
.
oauthId
=
oauthId
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getOauthSecret
()
{
return
oauthSecret
;
}
public
void
setOauthSecret
(
String
oauthSecret
)
{
this
.
oauthSecret
=
oauthSecret
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getIp
()
{
return
ip
;
}
public
void
setIp
(
String
ip
)
{
this
.
ip
=
ip
;
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/oauth/rest/oauthRestController.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.oauth.rest
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.web.Result
;
import
com.jeespring.common.web.ResultFactory
;
import
com.jeespring.modules.oauth.service.OauthService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* 系统配置Controller
* @author 黄炳桂 516821420@qq.com
* @version 2017-11-17
*/
@RestController
@RequestMapping
(
value
=
"/rest/oauth"
)
@Api
(
value
=
"Oauth平台授权接口(分布式)"
,
description
=
"Oauth平台授权接口(分布式)"
)
public
class
oauthRestController
extends
AbstractBaseController
{
@Autowired
private
OauthService
oauthService
;
@RequestMapping
(
value
=
{
"test"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"token test平台授权测试接口(Content-Type为text/html)"
,
notes
=
"token test平台授权测试接口(Content-Type为text/html)"
)
public
Result
test
()
{
return
ResultFactory
.
getSuccessResult
(
"测试成功!"
);
}
@RequestMapping
(
value
=
{
"token"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"token平台授权接口(Content-Type为text/html)"
,
notes
=
"token平台授权接口(Content-Type为text/html)"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"oauthId"
,
value
=
"客户id"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
),
@ApiImplicitParam
(
name
=
"oauthSecret"
,
value
=
"客户密钥"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
)
})
public
Result
tokenRequestParam
(
@RequestParam
(
required
=
false
)
String
oauthId
,
@RequestParam
(
required
=
false
)
String
oauthSecret
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
return
oauthService
.
token
(
oauthId
,
oauthSecret
,
request
.
getRemoteAddr
());
}
@RequestMapping
(
value
=
{
"token/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"系统配置信息(Content-Type为application/json)"
,
notes
=
"系统配置信息(Content-Type为application/json)"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"oauthId"
,
value
=
"客户id"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"body"
),
@ApiImplicitParam
(
name
=
"oauthSecret"
,
value
=
"客户密钥"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"body"
)
})
public
Result
tokenJsonRequestBody
(
@RequestBody
String
oauthId
,
@RequestBody
String
oauthSecret
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
return
oauthService
.
token
(
oauthId
,
oauthSecret
,
request
.
getRemoteAddr
());
}
@RequestMapping
(
value
=
{
"checkToken"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"checkToken平台Token检查接口(Content-Type为text/html)"
,
notes
=
"checkToken平台Token检查接口(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"token"
,
value
=
"token"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"query"
)
public
Result
checkTokenRequestParam
(
@RequestParam
(
required
=
false
)
String
token
,
HttpServletRequest
request
,
HttpServletResponse
response
){
return
oauthService
.
checkToken
(
token
,
request
.
getRemoteAddr
());
}
@RequestMapping
(
value
=
{
"checkToken/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"checkToken平台Token检查接口(Content-Type为application/json)"
,
notes
=
"checkToken平台Token检查接口(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"token"
,
value
=
"token"
,
required
=
false
,
dataType
=
"String"
,
paramType
=
"body"
)
public
Result
checkTokenRequestBody
(
@RequestBody
(
required
=
false
)
String
token
,
HttpServletRequest
request
,
HttpServletResponse
response
){
return
oauthService
.
checkToken
(
token
,
request
.
getRemoteAddr
());
}
@RequestMapping
(
value
=
{
"faild"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"授权平台接口失败(Content-Type为application/html)"
,
notes
=
"授权平台接口失败(Content-Type为application/html)"
)
public
Result
faild
(
HttpServletRequest
request
,
HttpServletResponse
response
){
return
ResultFactory
.
getErrorResult
(
"oauth token授权失败!"
);
}
@RequestMapping
(
value
=
{
"apiTimeLimiFaild"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"授权平台调用次数失败(Content-Type为application/html)"
,
notes
=
"授权平台调用次数失败(Content-Type为application/html)"
)
public
Result
apiTimeLimiFaild
(
HttpServletRequest
request
,
HttpServletResponse
response
){
String
apiTimeLimi
=
request
.
getParameter
(
"apiTimeLimi"
);
if
(
apiTimeLimi
==
null
)
{
apiTimeLimi
=
""
;
}
return
ResultFactory
.
getErrorResult
(
"调用失败,接口允许最多调用"
+
apiTimeLimi
+
"次数!15分钟后解锁!"
);
}
@RequestMapping
(
value
=
{
"userOnlineAmountFaild"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"在线用户数量已满失败(Content-Type为application/html)"
,
notes
=
"在线用户数量已满失败(Content-Type为application/html)"
)
public
Result
userOnlineAmountFaild
(
HttpServletRequest
request
,
HttpServletResponse
response
){
return
oauthService
.
userOnlineAmount
();
}
@RequestMapping
(
value
=
{
"userOnlineAmount"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"在线用户数量(Content-Type为application/html)"
,
notes
=
"在线用户数量(Content-Type为application/html)"
)
public
Result
userOnlineAmount
(
HttpServletRequest
request
,
HttpServletResponse
response
){
return
oauthService
.
userOnlineAmount
();
}
@RequestMapping
(
value
=
{
"getApiTimeLimi"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"授权平台调用次数(Content-Type为application/html)"
,
notes
=
"授权平台调用次数(Content-Type为application/html)"
)
public
Result
getApiTimeLimi
(
HttpServletRequest
request
,
HttpServletResponse
response
){
return
oauthService
.
getApiTimeLimi
(
request
.
getRemoteAddr
());
}
@RequestMapping
(
value
=
{
"getApiTime"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"调用次数(Content-Type为application/html)"
,
notes
=
"调用次数(Content-Type为application/html)"
)
public
Result
getApiTime
(
HttpServletRequest
request
,
HttpServletResponse
response
){
return
oauthService
.
getApiTime
();
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/oauth/service/OauthService.java
0 → 100644
View file @
d5ba54ba
package
com.jeespring.modules.oauth.service
;
import
com.jeespring.common.redis.RedisUtils
;
import
com.jeespring.common.utils.IdGen
;
import
com.jeespring.common.web.Result
;
import
com.jeespring.common.web.ResultFactory
;
import
com.jeespring.modules.sys.dao.UserDao
;
import
com.jeespring.modules.sys.entity.SysConfig
;
import
com.jeespring.modules.oauth.entity.TokenInfo
;
import
com.jeespring.modules.sys.entity.User
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
io.swagger.models.auth.In
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.session.Session
;
import
org.apache.shiro.subject.Subject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
@Service
public
class
OauthService
{
@Autowired
private
UserDao
userDao
;
@Autowired
private
SysConfigService
sysConfigService
;
@Autowired
private
RedisUtils
redisUtils
;
public
boolean
isOauthOpen
(){
SysConfig
sysConfigOauth
=
new
SysConfig
();
sysConfigOauth
.
setType
(
"oauthOpen"
);
SysConfig
sysConfigsOauth
=
sysConfigService
.
findListFirstCache
(
sysConfigOauth
);
if
(
"true"
.
equals
(
sysConfigsOauth
.
getValue
()))
{
return
true
;
}
return
false
;
}
public
Result
token
(
String
oauthId
,
String
oauthSecret
,
String
ip
){
if
(
oauthId
==
null
||
oauthSecret
==
null
)
{
return
ResultFactory
.
getErrorResult
(
"授权ID和授权密钥不能为空!"
);
}
String
tokenTime
=
"360000"
;
String
tokenRedis
=
String
.
valueOf
(
redisUtils
.
get
(
oauthId
));
if
(
tokenRedis
!=
null
){
TokenInfo
tokenInfoRedis
=(
TokenInfo
)
redisUtils
.
get
(
tokenRedis
);
redisUtils
.
remove
(
oauthId
);
redisUtils
.
remove
(
tokenInfoRedis
.
getToken
());
redisUtils
.
remove
(
ip
);
redisUtils
.
set
(
tokenInfoRedis
.
getToken
(),
tokenInfoRedis
,
Long
.
valueOf
(
tokenTime
));
redisUtils
.
set
(
oauthId
,
tokenInfoRedis
.
getToken
(),
Long
.
valueOf
(
tokenTime
));
redisUtils
.
set
(
ip
,
tokenInfoRedis
.
getToken
(),
Long
.
valueOf
(
tokenTime
));
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
tokenInfoRedis
);
return
result
;
}
SysConfig
sysConfigTokenTime
=
new
SysConfig
();
sysConfigTokenTime
.
setType
(
"tokenTime"
);
List
<
SysConfig
>
sysConfigsTokenTimes
=
sysConfigService
.
findList
(
sysConfigTokenTime
);
if
(
sysConfigsTokenTimes
.
size
()>
0
){
tokenTime
=
sysConfigsTokenTimes
.
get
(
0
).
getValue
();
}
User
user
=
new
User
();
user
.
setOauthId
(
oauthId
);
user
.
setOauthSecret
(
oauthSecret
);
List
<
User
>
users
=
userDao
.
findList
(
user
);
SysConfig
sysConfigOauthId
=
new
SysConfig
();
sysConfigOauthId
.
setType
(
"oauthId"
);
List
<
SysConfig
>
sysConfigsOauthId
=
sysConfigService
.
findList
(
sysConfigOauthId
);
SysConfig
sysConfigOauthSecret
=
new
SysConfig
();
sysConfigOauthSecret
.
setType
(
"oauthSecret"
);
List
<
SysConfig
>
sysConfigsOauthSecret
=
sysConfigService
.
findList
(
sysConfigOauthSecret
);
if
(
sysConfigsOauthId
.
size
()>
0
&&
sysConfigsOauthSecret
.
size
()>
0
&&
(!
sysConfigsOauthId
.
get
(
0
).
getValue
().
equals
(
oauthId
)
||
!
sysConfigsOauthSecret
.
get
(
0
).
getValue
().
equals
(
oauthSecret
))){
return
ResultFactory
.
getErrorResult
(
"授权ID和授权密钥不正确!"
);
}
if
(
sysConfigsOauthId
.
size
()==
0
&&
sysConfigsOauthSecret
.
size
()==
0
&&
users
.
size
()!=
1
){
return
ResultFactory
.
getErrorResult
(
"授权ID和授权密钥不正确!"
);
}
Result
result
=
ResultFactory
.
getSuccessResult
();
TokenInfo
tokenInfo
=
new
TokenInfo
();
tokenInfo
.
setToken
(
IdGen
.
uuid
());
tokenInfo
.
setTokenDate
(
new
Date
());
tokenInfo
.
setOauthId
(
oauthId
);
tokenInfo
.
setOauthSecret
(
oauthSecret
);
tokenInfo
.
setIp
(
ip
);
result
.
setResultObject
(
tokenInfo
);
redisUtils
.
set
(
tokenInfo
.
getToken
(),
tokenInfo
,
Long
.
valueOf
(
tokenTime
));
redisUtils
.
set
(
oauthId
,
tokenInfo
.
getToken
(),
Long
.
valueOf
(
tokenTime
));
redisUtils
.
set
(
ip
,
tokenInfo
.
getToken
(),
Long
.
valueOf
(
tokenTime
));
return
result
;
}
public
Result
checkToken
(
String
token
,
String
ip
){
String
tokenRedis
=
String
.
valueOf
(
redisUtils
.
get
(
ip
));
if
(
token
==
null
&&
tokenRedis
==
null
){
return
ResultFactory
.
getErrorResult
(
"token不能为空!"
);
}
if
(
token
==
null
&&
tokenRedis
!=
null
){
TokenInfo
tokenInfoRedis
=(
TokenInfo
)
redisUtils
.
get
(
tokenRedis
);
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
tokenInfoRedis
);
return
result
;
}
SysConfig
sysConfigOauth
=
new
SysConfig
();
sysConfigOauth
.
setType
(
"oauthOpen"
);
List
<
SysConfig
>
sysConfigsOauth
=
sysConfigService
.
findList
(
sysConfigOauth
);
if
(
sysConfigsOauth
.
size
()<=
0
){
Result
result
=
ResultFactory
.
getErrorResult
(
"oauth权限服务未开启!"
);
result
.
setResultCode
(
100
);
return
result
;
}
if
(
sysConfigsOauth
.
get
(
0
).
getValue
()==
"false"
){
Result
result
=
ResultFactory
.
getErrorResult
(
"oauth权限服务未开启!"
);
result
.
setResultCode
(
100
);
return
result
;
}
TokenInfo
tokenInfo
=(
TokenInfo
)
redisUtils
.
get
(
token
);
if
(
tokenInfo
==
null
){
return
ResultFactory
.
getErrorResult
(
"Token不正确!"
);
}
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
tokenInfo
);
return
result
;
}
public
Result
userOnlineAmount
(){
SysConfig
userOnlineAmount
=
new
SysConfig
();
userOnlineAmount
.
setType
(
"userOnlineAmount"
);
userOnlineAmount
=
sysConfigService
.
findListFirstCache
(
userOnlineAmount
);
int
countShiro
=
redisUtils
.
getCountShiro
();
Subject
subject
=
SecurityUtils
.
getSubject
();
String
key
=
null
;
if
(
subject
!=
null
&&
subject
.
getSession
()
!=
null
)
{
key
=
redisUtils
.
SHIRO_REDIS
+
":"
+
subject
.
getSession
().
getId
().
toString
();
}
if
(
Integer
.
valueOf
(
userOnlineAmount
.
getValue
())<
countShiro
&&
key
!=
null
){
redisUtils
.
remove
(
key
);
return
ResultFactory
.
getErrorResult
(
"在线控制:在线"
+
countShiro
+
"人/总控制"
+
userOnlineAmount
.
getValue
()+
"人"
);
}
if
(!
redisUtils
.
exists
(
key
)){
return
ResultFactory
.
getErrorResult
(
"在线控制:在线"
+
countShiro
+
"人/总控制"
+
userOnlineAmount
.
getValue
()+
"人"
);
}
return
ResultFactory
.
getSuccessResult
(
"在线控制:在线"
+
countShiro
+
"人/总控制"
+
userOnlineAmount
.
getValue
()+
"人"
);
}
public
Result
getApiTimeLimi
(
String
ip
){
String
redisKey
=
"ApiTimeLimi_"
+
ip
;
SysConfig
apiTimeLimi
=
new
SysConfig
();
apiTimeLimi
.
setType
(
"apiTimeLimi"
);
apiTimeLimi
=
sysConfigService
.
findListFirstCache
(
apiTimeLimi
);
Object
result
=
redisUtils
.
get
(
redisKey
);
if
(
result
==
null
){
return
ResultFactory
.
getSuccessResult
(
"/"
+
apiTimeLimi
.
getValue
());
}
return
ResultFactory
.
getSuccessResult
(
result
+
"/"
+
apiTimeLimi
.
getValue
());
}
public
Result
getApiTime
(){
String
redisKeyDay
=
"ApiTimeDate"
;
String
redisKeyMonth
=
"ApiTimeMonth"
;
Object
apiTimeDay
=
redisUtils
.
get
(
redisKeyDay
);
Object
apiTimeMonth
=
redisUtils
.
get
(
redisKeyMonth
);
if
(
apiTimeDay
==
null
)
{
apiTimeDay
=
"0"
;
}
if
(
apiTimeMonth
==
null
)
{
apiTimeMonth
=
"0"
;
}
return
ResultFactory
.
getSuccessResult
(
"Day:"
+
apiTimeDay
+
" Time;Month:"
+
apiTimeMonth
+
" Time"
);
}
public
Result
setApiTime
(){
String
redisKeyDay
=
"ApiTimeDate"
;
String
redisKeyMonth
=
"ApiTimeMonth"
;
Object
apiTimeDay
=
redisUtils
.
get
(
redisKeyDay
);
Object
apiTimeMonth
=
redisUtils
.
get
(
redisKeyMonth
);
Long
apiTimeDayLong
=
0L
;
Long
apiTimeMonthLong
=
0L
;
if
(
apiTimeDay
==
null
)
{
apiTimeDay
=
0
;
}
if
(
apiTimeMonth
==
null
)
{
apiTimeMonth
=
0
;
}
if
(
apiTimeDay
!=
null
){
apiTimeDayLong
=
Long
.
valueOf
(
apiTimeDay
.
toString
());
apiTimeDayLong
=
apiTimeDayLong
+
1
;
}
if
(
apiTimeMonth
!=
null
){
apiTimeMonthLong
=
Long
.
valueOf
(
apiTimeMonth
.
toString
());
apiTimeMonthLong
=
apiTimeMonthLong
+
1
;
}
redisUtils
.
set
(
redisKeyDay
,
apiTimeDayLong
,
1L
,
TimeUnit
.
DAYS
);
redisUtils
.
set
(
redisKeyMonth
,
apiTimeMonthLong
,
30L
,
TimeUnit
.
DAYS
);
return
ResultFactory
.
getSuccessResult
(
"Day:"
+
apiTimeDayLong
+
" Time;Month:"
+
apiTimeMonthLong
+
" Time"
);
}
public
Result
ApiTimeLimi
(
String
ip
){
String
redisKey
=
"ApiTimeLimi_"
+
ip
;
Object
apiTime
=
redisUtils
.
get
(
redisKey
);
if
(
apiTime
==
null
){
apiTime
=
0
;
}
Object
apiTimeLongRedis
=
redisUtils
.
get
(
redisKey
);
Long
apiTimeLong
=
0L
;
if
(
apiTimeLongRedis
!=
null
){
apiTimeLong
=
Long
.
valueOf
(
apiTimeLongRedis
.
toString
());
}
Long
apiTimeLongSysConfig
=
0L
;
apiTimeLong
+=
1
;
SysConfig
apiTimeLimi
=
new
SysConfig
();
apiTimeLimi
.
setType
(
"apiTimeLimi"
);
List
<
SysConfig
>
apiTimeLimis
=
sysConfigService
.
findList
(
apiTimeLimi
);
if
(
apiTimeLimis
.
size
()>
0
){
apiTimeLongSysConfig
=
Long
.
valueOf
(
apiTimeLimis
.
get
(
0
).
getValue
());
}
if
(
"-1"
.
equals
(
apiTimeLongSysConfig
)){
apiTimeLongSysConfig
=
100000000L
;
}
if
(
apiTimeLimis
.
size
()==
0
){
apiTimeLongSysConfig
=
10000L
;
}
if
(
apiTime
!=
null
&&
apiTimeLongSysConfig
>
apiTimeLong
){
redisUtils
.
remove
(
redisKey
);
}
if
(
apiTimeLongSysConfig
<=
apiTimeLong
){
Result
result
=
ResultFactory
.
getErrorResult
(
"调用失败,接口允许最多调用"
+
apiTimeLongSysConfig
+
"次!"
);
result
.
setResultObject
(
apiTimeLongSysConfig
);
return
result
;
}
redisUtils
.
set
(
redisKey
,
apiTimeLong
);
return
ResultFactory
.
getSuccessResult
();
}
}
JeeSpringCloud/src/main/java/com/jeespring/modules/pay/pay.txt
0 → 100644
View file @
d5ba54ba
JeeSpringCloud/src/main/java/com/jeespring/modules/scheduling/JeeSpringScheduledTaskService.java
0 → 100644
View file @
d5ba54ba
package
com.jeespring.modules.scheduling
;
import
com.jeespring.common.utils.SendMailUtil
;
import
com.jeespring.modules.activeMQ.JeeSpringProducer
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.jms.Destination
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
//@Service("jeeSpringScheduledTaskService")
@Component
public
class
JeeSpringScheduledTaskService
{
//@Autowired
//private XXXService xxxxService;
private
static
final
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
@Autowired
private
JeeSpringProducer
jeeSpringProducer
;
//每个10s执行一次任务
@Scheduled
(
fixedRate
=
600000
)
public
void
run
(){
//xxxxService.method();
//System.out.println(dateFormat.format(new Date()) + " | " + "com.jeespring.modules.scheduling:每隔60s执行一次任务");
}
//每个2s执行一次任务#朝九晚七工作时间内每五分钟
@Scheduled
(
cron
=
"0 0/10 9-19 * * ?"
)
public
void
run2
(){
//System.out.println(dateFormat.format(new Date()) + " | " + "com.jeespring.modules.scheduling:朝九晚七工作时间内每十分钟执行一次任务");
//jeeSpringProducer.sendMessageA( "ActiveMQ JeeSpringProducer queueA。");
//jeeSpringProducer.sendMessageB("ActiveMQ JeeSpringProducer queueB。");
}
//每天15点29分执行该任务
@Scheduled
(
cron
=
"0 29 15 ? * *"
)
public
void
run3
()
{
//System.out.println(dateFormat.format(new Date()) + " | " + "com.jeespring.modules.scheduling:每天在指定时间执行任务");
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/scheduling/JeeSpringTaskSchedulerConfig.java
0 → 100644
View file @
d5ba54ba
package
com.jeespring.modules.scheduling
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@Configuration
@ComponentScan
(
"com.jeespring.modules.scheduling"
)
@EnableScheduling
public
class
JeeSpringTaskSchedulerConfig
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/server/dao/SysServerDao.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.server.dao
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.server.entity.SysServer
;
/**
* 服务器监控DAO接口
* @author JeeSpring
* @version 2018-08-20
*/
@Mapper
public
interface
SysServerDao
extends
InterfaceBaseDao
<
SysServer
>
{
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/server/entity/SysServer.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.server.entity
;
import
org.hibernate.validator.constraints.Length
;
import
javax.validation.constraints.NotNull
;
import
java.util.Date
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
com.jeespring.common.utils.excel.annotation.ExcelField
;
import
com.jeespring.modules.sys.utils.DictUtils
;
/**
* 服务器监控Entity
* @author JeeSpring
* @version 2018-08-20
*/
public
class
SysServer
extends
AbstractBaseEntity
<
SysServer
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
serverNumber
;
// 服务器编号
private
String
serverAddress
;
// 服务器监控地址
private
String
name
;
// 名称
private
String
label
;
// 标签名
private
String
picture
;
// 图片
private
String
type
;
// 类型
private
String
typeLabel
;
// 类型Label
private
String
typePicture
;
// 类型Picture
private
Long
sort
;
// 排序(升序)
private
String
description
;
// 描述
private
String
html
;
// 备注信息
private
String
status
;
// 在线状态on_line在线off_line离线
private
String
statusLabel
;
// 在线状态on_line在线off_line离线Label
private
String
statusPicture
;
// 在线状态on_line在线off_line离线Picture
private
java
.
util
.
Date
beginCreateDate
;
// 开始 创建时间
private
java
.
util
.
Date
endCreateDate
;
// 结束 创建时间
private
java
.
util
.
Date
beginUpdateDate
;
// 开始 更新时间
private
java
.
util
.
Date
endUpdateDate
;
// 结束 更新时间
public
SysServer
()
{
super
();
}
public
SysServer
(
String
id
){
super
(
id
);
}
@Length
(
min
=
0
,
max
=
255
,
message
=
"服务器编号长度必须介于 0 和 255 之间"
)
@ExcelField
(
title
=
"服务器编号"
,
align
=
2
,
sort
=
1
)
public
String
getServerNumber
()
{
return
serverNumber
;
}
public
void
setServerNumber
(
String
serverNumber
)
{
this
.
serverNumber
=
serverNumber
;
}
@Length
(
min
=
0
,
max
=
100
,
message
=
"服务器监控地址长度必须介于 0 和 100 之间"
)
@ExcelField
(
title
=
"服务器监控地址"
,
align
=
2
,
sort
=
2
)
public
String
getServerAddress
()
{
return
serverAddress
;
}
public
void
setServerAddress
(
String
serverAddress
)
{
this
.
serverAddress
=
serverAddress
;
}
@Length
(
min
=
0
,
max
=
255
,
message
=
"名称长度必须介于 0 和 255 之间"
)
@ExcelField
(
title
=
"名称"
,
align
=
2
,
sort
=
3
)
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
@Length
(
min
=
0
,
max
=
50
,
message
=
"标签名长度必须介于 0 和 50 之间"
)
@ExcelField
(
title
=
"标签名"
,
align
=
2
,
sort
=
4
)
public
String
getLabel
()
{
return
label
;
}
public
void
setLabel
(
String
label
)
{
this
.
label
=
label
;
}
@Length
(
min
=
0
,
max
=
100
,
message
=
"图片长度必须介于 0 和 100 之间"
)
@ExcelField
(
title
=
"图片"
,
align
=
2
,
sort
=
5
)
public
String
getPicture
()
{
return
picture
;
}
public
void
setPicture
(
String
picture
)
{
this
.
picture
=
picture
;
}
@Length
(
min
=
0
,
max
=
50
,
message
=
"类型长度必须介于 0 和 50 之间"
)
@ExcelField
(
title
=
"类型"
,
dictType
=
"server_type"
,
align
=
2
,
sort
=
6
)
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getTypeLabel
()
{
return
DictUtils
.
getDictLabel
(
type
,
"server_type"
,
""
);
}
public
String
getTypePicture
()
{
return
DictUtils
.
getDictPicture
(
type
,
"server_type"
,
""
);
}
@NotNull
(
message
=
"排序(升序)不能为空"
)
@ExcelField
(
title
=
"排序(升序)"
,
align
=
2
,
sort
=
7
)
public
Long
getSort
()
{
return
sort
;
}
public
void
setSort
(
Long
sort
)
{
this
.
sort
=
sort
;
}
@Length
(
min
=
0
,
max
=
100
,
message
=
"描述长度必须介于 0 和 100 之间"
)
@ExcelField
(
title
=
"描述"
,
align
=
2
,
sort
=
8
)
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
@ExcelField
(
title
=
"备注信息"
,
align
=
2
,
sort
=
10
)
public
String
getHtml
()
{
return
html
;
}
public
void
setHtml
(
String
html
)
{
this
.
html
=
html
;
}
@Length
(
min
=
0
,
max
=
10
,
message
=
"在线状态on_line在线off_line离线长度必须介于 0 和 10 之间"
)
@ExcelField
(
title
=
"在线状态on_line在线off_line离线"
,
dictType
=
"on_line_status"
,
align
=
2
,
sort
=
11
)
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStatusLabel
()
{
return
DictUtils
.
getDictLabel
(
status
,
"on_line_status"
,
""
);
}
public
String
getStatusPicture
()
{
return
DictUtils
.
getDictPicture
(
status
,
"on_line_status"
,
""
);
}
public
Date
getBeginCreateDate
()
{
return
beginCreateDate
;
}
public
void
setBeginCreateDate
(
Date
beginCreateDate
)
{
this
.
beginCreateDate
=
beginCreateDate
;
}
public
Date
getEndCreateDate
()
{
return
endCreateDate
;
}
public
void
setEndCreateDate
(
Date
endCreateDate
)
{
this
.
endCreateDate
=
endCreateDate
;
}
public
Date
getBeginUpdateDate
()
{
return
beginUpdateDate
;
}
public
void
setBeginUpdateDate
(
Date
beginUpdateDate
)
{
this
.
beginUpdateDate
=
beginUpdateDate
;
}
public
Date
getEndUpdateDate
()
{
return
endUpdateDate
;
}
public
void
setEndUpdateDate
(
Date
endUpdateDate
)
{
this
.
endUpdateDate
=
endUpdateDate
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/server/rest/SysServerRestController.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.server.rest
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.jeespring.modules.server.service.ISysServerService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.ui.Model
;
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.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.modules.server.entity.SysServer
;
import
com.jeespring.modules.server.service.SysServerService
;
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.ApiOperation
;
import
org.springframework.web.bind.annotation.*
;
/**
* 服务器监控Controller
* @author JeeSpring
* @version 2018-08-20
*/
@RestController
@RequestMapping
(
value
=
"/rest/sys/sysServer"
)
@Api
(
value
=
"服务器监控接口"
,
description
=
"服务器监控接口"
)
public
class
SysServerRestController
extends
AbstractBaseController
{
@Autowired
private
ISysServerService
sysServerService
;
@RequestMapping
(
value
=
{
"run"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"服务器运行状态(Content-Type为text/html)"
,
notes
=
"服务器运行状态(Content-Type为text/html)"
)
public
String
run
()
{
return
"OK"
;
}
/**
* 服务器监控信息
*/
@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
)
{
SysServer
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
sysServerService
.
getCache
(
id
);
//entity = sysServerService.get(id);
}
if
(
entity
==
null
){
entity
=
new
SysServer
();
}
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
entity
);
return
result
;
}
/**
* 服务器监控列表(不包含页信息)
*/
//RequiresPermissions("sys:sysServer:findList")
@RequestMapping
(
value
=
{
"findList"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"服务器监控列表(不包含页信息)(Content-Type为text/html)"
,
notes
=
"服务器监控列表(不包含页信息)(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"query"
)
public
Result
findListRequestParam
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
return
findList
(
sysServer
,
model
);
}
@RequestMapping
(
value
=
{
"findList/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"服务器监控列表(不包含页信息)(Content-Type为application/json)"
,
notes
=
"服务器监控列表(不包含页信息)(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"body"
)
public
Result
findListRequestBody
(
@RequestBody
SysServer
sysServer
,
Model
model
)
{
return
findList
(
sysServer
,
model
);
}
private
Result
findList
(
SysServer
sysServer
,
Model
model
)
{
List
<
SysServer
>
list
=
sysServerService
.
findListCache
(
sysServer
);
//List<SysServer> list = sysServerService.findList(sysServer);
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
list
);
return
result
;
}
/**
* 服务器监控列表(包含页信息)
*/
//RequiresPermissions("sys:sysServer:list")
@RequestMapping
(
value
=
{
"list"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"服务器监控列表(包含页信息)(Content-Type为text/html)"
,
notes
=
"服务器监控列表(包含页信息)(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"query"
)
public
Result
listRequestParam
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
return
list
(
sysServer
,
model
);
}
@RequestMapping
(
value
=
{
"list/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"服务器监控列表(包含页信息)(Content-Type为application/json)"
,
notes
=
"服务器监控列表(包含页信息)(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"body"
)
public
Result
listRequestBody
(
@RequestBody
SysServer
sysServer
,
Model
model
)
{
return
list
(
sysServer
,
model
);
}
private
Result
list
(
SysServer
sysServer
,
Model
model
)
{
Page
<
SysServer
>
page
=
sysServerService
.
findPageCache
(
new
Page
<
SysServer
>(
sysServer
.
getPageNo
(),
sysServer
.
getPageSize
(),
sysServer
.
getOrderBy
()),
sysServer
);
//Page<SysServer> page = sysServerService.findPage(new Page<SysServer>(sysServer.getPageNo(),sysServer.getPageSize(),sysServer.getOrderBy()), sysServer);
Result
result
=
ResultFactory
.
getSuccessResult
();
result
.
setResultObject
(
page
);
return
result
;
}
/**
* 服务器监控获取列表第一条记录
*/
//RequiresPermissions("sys:sysServer:listFrist")
@RequestMapping
(
value
=
{
"listFrist"
},
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"服务器监控获取列表第一条记录(Content-Type为text/html)"
,
notes
=
"服务器监控获取列表第一条记录(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"query"
)
public
Result
listFristRequestParam
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
return
listFrist
(
sysServer
,
model
);
}
@RequestMapping
(
value
=
{
"listFrist/json"
},
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"服务器监控获取列表第一条记录(Content-Type为application/json)"
,
notes
=
"服务器监控获取列表第一条记录(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"body"
)
public
Result
listFristRequestBody
(
@RequestBody
SysServer
sysServer
,
Model
model
)
{
return
listFrist
(
sysServer
,
model
);
}
private
Result
listFrist
(
SysServer
sysServer
,
Model
model
)
{
Page
<
SysServer
>
page
=
sysServerService
.
findPageCache
(
new
Page
<
SysServer
>(
sysServer
.
getPageNo
(),
sysServer
.
getPageSize
(),
sysServer
.
getOrderBy
()),
sysServer
);
//Page<SysServer> page = sysServerService.findPage(new Page<SysServer>(sysServer.getPageNo(),sysServer.getPageSize(),sysServer.getOrderBy()), sysServer);
Result
result
=
ResultFactory
.
getSuccessResult
();
if
(
page
.
getList
().
size
()>
0
){
result
.
setResultObject
(
page
.
getList
().
get
(
0
));
}
else
{
result
=
ResultFactory
.
getErrorResult
(
"没有记录!"
);
}
return
result
;
}
/**
* 保存服务器监控
*/
//RequiresPermissions(value={"sys:sysServer:add","sys:sysServer: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
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"query"
)
public
Result
saveRequestParam
(
SysServer
sysServer
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
return
save
(
sysServer
,
model
,
redirectAttributes
);
}
@RequestMapping
(
value
=
"save/json"
,
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"保存服务器监控(Content-Type为application/json)"
,
notes
=
"保存服务器监控(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"body"
)
public
Result
saveRequestBody
(
@RequestBody
SysServer
sysServer
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
return
save
(
sysServer
,
model
,
redirectAttributes
);
}
private
Result
save
(
SysServer
sysServer
,
Model
model
,
RedirectAttributes
redirectAttributes
)
{
if
(!
beanValidator
(
model
,
sysServer
)){
Result
result
=
ResultFactory
.
getErrorResult
(
"数据验证失败"
);
}
sysServerService
.
save
(
sysServer
);
Result
result
=
ResultFactory
.
getSuccessResult
(
"保存服务器监控成功"
);
return
result
;
}
/**
* 删除服务器监控
*/
//RequiresPermissions("sys:sysServer:del")
@RequestMapping
(
value
=
"delete"
,
method
={
RequestMethod
.
POST
,
RequestMethod
.
GET
})
@ApiOperation
(
value
=
"删除服务器监控(Content-Type为text/html)"
,
notes
=
"删除服务器监控(Content-Type为text/html)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"query"
)
public
Result
deleteRequestParam
(
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
return
delete
(
sysServer
,
redirectAttributes
);
}
@RequestMapping
(
value
=
"delete/json"
,
method
={
RequestMethod
.
POST
})
@ApiOperation
(
value
=
"删除服务器监控(Content-Type为application/json)"
,
notes
=
"删除服务器监控(Content-Type为application/json)"
)
@ApiImplicitParam
(
name
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"body"
)
public
Result
deleteRequestBody
(
@RequestBody
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
return
delete
(
sysServer
,
redirectAttributes
);
}
private
Result
delete
(
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
sysServerService
.
delete
(
sysServer
);
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
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"query"
)
public
Result
deleteByLogicRequestParam
(
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
return
deleteByLogic
(
sysServer
,
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
=
"sysServer"
,
value
=
"服务器监控"
,
dataType
=
"SysServer"
,
paramType
=
"body"
)
public
Result
deleteByLogicRequestBody
(
@RequestBody
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
return
deleteByLogic
(
sysServer
,
redirectAttributes
);
}
private
Result
deleteByLogic
(
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
sysServerService
.
deleteByLogic
(
sysServer
);
Result
result
=
ResultFactory
.
getSuccessResult
(
"删除服务器监控成功"
);
return
result
;
}
/**
* 批量删除服务器监控
*/
//RequiresPermissions("sys:sysServer: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
){
sysServerService
.
delete
(
sysServerService
.
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
){
sysServerService
.
deleteByLogic
(
sysServerService
.
get
(
id
));
}
Result
result
=
ResultFactory
.
getSuccessResult
(
"删除服务器监控成功"
);
return
result
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/server/service/ISysServerService.java
0 → 100644
View file @
d5ba54ba
package
com.jeespring.modules.server.service
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.common.persistence.InterfaceBaseService
;
import
com.jeespring.modules.server.entity.SysServer
;
public
interface
ISysServerService
extends
InterfaceBaseService
<
SysServer
>
{
}
JeeSpringCloud/src/main/java/com/jeespring/modules/server/service/SysServerService.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.server.service
;
import
java.util.List
;
//import org.springframework.stereotype.Service;
import
org.apache.ibatis.annotations.Param
;
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.server.entity.SysServer
;
import
com.jeespring.modules.server.dao.SysServerDao
;
import
com.alibaba.fastjson.JSON
;
import
com.jeespring.common.redis.RedisUtils
;
import
com.alibaba.dubbo.config.annotation.Service
;
/**
* 服务器监控Service
* @author JeeSpring
* @version 2018-08-20
*/
//启用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
SysServerService
extends
AbstractBaseService
<
SysServerDao
,
SysServer
>
implements
ISysServerService
{
/**
* redis caches
*/
@Autowired
private
RedisUtils
redisUtils
;
@Override
public
SysServer
get
(
String
id
)
{
//获取数据库数据
SysServer
sysServer
=
super
.
get
(
id
);
return
sysServer
;
}
@Override
public
SysServer
getCache
(
String
id
)
{
//获取缓存数据
SysServer
sysServer
=(
SysServer
)
redisUtils
.
get
(
RedisUtils
.
getIdKey
(
SysServerService
.
class
.
getName
(),
id
));
if
(
sysServer
!=
null
)
{
return
sysServer
;
}
//获取数据库数据
sysServer
=
super
.
get
(
id
);
//设置缓存数据
redisUtils
.
set
(
RedisUtils
.
getIdKey
(
SysServerService
.
class
.
getName
(),
id
),
sysServer
);
return
sysServer
;
}
@Override
public
List
<
SysServer
>
total
(
SysServer
sysServer
)
{
//获取数据库数据
List
<
SysServer
>
sysServerList
=
super
.
total
(
sysServer
);
return
sysServerList
;
}
@Override
public
List
<
SysServer
>
totalCache
(
SysServer
sysServer
)
{
//获取缓存数据
String
totalKey
=
RedisUtils
.
getTotalKey
(
SysServerService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysServer
));
List
<
SysServer
>
sysServerList
=(
List
<
SysServer
>)
redisUtils
.
get
(
totalKey
);
if
(
sysServerList
!=
null
)
{
return
sysServerList
;
}
//获取数据库数据
sysServerList
=
super
.
total
(
sysServer
);
//设置缓存数据
redisUtils
.
set
(
totalKey
,
sysServerList
);
return
sysServerList
;
}
@Override
public
List
<
SysServer
>
findList
(
SysServer
sysServer
)
{
//获取数据库数据
List
<
SysServer
>
sysServerList
=
super
.
findList
(
sysServer
);
//设置缓存数据
return
sysServerList
;
}
@Override
public
List
<
SysServer
>
findListCache
(
SysServer
sysServer
)
{
//获取缓存数据
String
findListKey
=
RedisUtils
.
getFindListKey
(
SysServerService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysServer
));
List
<
SysServer
>
sysServerList
=(
List
<
SysServer
>)
redisUtils
.
get
(
findListKey
);
if
(
sysServerList
!=
null
)
{
return
sysServerList
;
}
//获取数据库数据
sysServerList
=
super
.
findList
(
sysServer
);
//设置缓存数据
redisUtils
.
set
(
findListKey
,
sysServerList
);
return
sysServerList
;
}
public
SysServer
findListFirst
(
SysServer
sysServer
)
{;
//获取数据库数据
List
<
SysServer
>
sysServerList
=
super
.
findList
(
sysServer
);
if
(
sysServerList
.
size
()>
0
)
{
sysServer
=
sysServerList
.
get
(
0
);
}
return
sysServer
;
}
public
SysServer
findListFirstCache
(
SysServer
sysServer
)
{
//获取缓存数据
String
findListFirstKey
=
RedisUtils
.
getFindListFirstKey
(
SysServerService
.
class
.
getName
(),
JSON
.
toJSONString
(
sysServer
));
SysServer
sysServerRedis
=(
SysServer
)
redisUtils
.
get
(
findListFirstKey
);
if
(
sysServerRedis
!=
null
)
{
return
sysServerRedis
;
}
//获取数据库数据
List
<
SysServer
>
sysServerList
=
super
.
findList
(
sysServer
);
if
(
sysServerList
.
size
()>
0
)
{
sysServer
=
sysServerList
.
get
(
0
);
}
else
{
sysServer
=
new
SysServer
();
}
//设置缓存数据
redisUtils
.
set
(
findListFirstKey
,
sysServer
);
return
sysServer
;
}
@Override
public
Page
<
SysServer
>
findPage
(
Page
<
SysServer
>
page
,
SysServer
sysServer
)
{
//获取数据库数据
Page
<
SysServer
>
pageReuslt
=
super
.
findPage
(
page
,
sysServer
);
return
pageReuslt
;
}
@Override
public
Page
<
SysServer
>
findPageCache
(
Page
<
SysServer
>
page
,
SysServer
sysServer
)
{
//获取缓存数据
String
findPageKey
=
RedisUtils
.
getFindPageKey
(
SysServerService
.
class
.
getName
(),
JSON
.
toJSONString
(
page
)+
JSON
.
toJSONString
(
sysServer
));
Page
<
SysServer
>
pageReuslt
=(
Page
<
SysServer
>)
redisUtils
.
get
(
findPageKey
);
if
(
pageReuslt
!=
null
)
{
return
pageReuslt
;
}
//获取数据库数据
pageReuslt
=
super
.
findPage
(
page
,
sysServer
);
//设置缓存数据
redisUtils
.
set
(
findPageKey
,
pageReuslt
);
return
pageReuslt
;
}
@Override
@Transactional
(
readOnly
=
false
)
public
void
save
(
SysServer
sysServer
)
{
//保存数据库记录
super
.
save
(
sysServer
);
//设置清除缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysServerService
.
class
.
getName
(),
sysServer
.
getId
()));
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysServerService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysServerService
.
class
.
getName
()));
}
@Override
@Transactional
(
readOnly
=
false
)
public
void
delete
(
SysServer
sysServer
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysServerService
.
class
.
getName
(),
sysServer
.
getId
()));
//删除数据库记录
super
.
delete
(
sysServer
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysServerService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysServerService
.
class
.
getName
()));
}
@Override
@Transactional
(
readOnly
=
false
)
public
void
deleteByLogic
(
SysServer
sysServer
)
{
//清除记录缓存数据
redisUtils
.
remove
(
RedisUtils
.
getIdKey
(
SysServerService
.
class
.
getName
(),
sysServer
.
getId
()));
//逻辑删除数据库记录
super
.
deleteByLogic
(
sysServer
);
//清除列表和页面缓存数据
redisUtils
.
removePattern
(
RedisUtils
.
getFindListKeyPattern
(
SysServerService
.
class
.
getName
()));
redisUtils
.
removePattern
(
RedisUtils
.
getFinPageKeyPattern
(
SysServerService
.
class
.
getName
()));
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/server/web/SysServerController.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.server.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
com.jeespring.modules.server.service.ISysServerService
;
import
com.jeespring.modules.sys.service.SysConfigService
;
import
org.apache.shiro.authz.annotation.Logical
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.DateUtils
;
import
com.jeespring.common.config.Global
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.utils.excel.ExportExcel
;
import
com.jeespring.common.utils.excel.ImportExcel
;
import
com.jeespring.modules.server.entity.SysServer
;
import
com.jeespring.modules.server.service.SysServerService
;
import
com.alibaba.dubbo.config.annotation.Reference
;
/**
* 服务器监控Controller
* @author JeeSpring
* @version 2018-08-20
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/sys/sysServer"
)
public
class
SysServerController
extends
AbstractBaseController
{
//调用dubbo服务器是,要去掉下面注解
//@Reference(version = "1.0.0")
@Autowired
private
ISysServerService
sysServerService
;
@Autowired
private
SysConfigService
sysConfigService
;
@ModelAttribute
public
SysServer
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
SysServer
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
sysServerService
.
getCache
(
id
);
//entity = sysServerService.get(id);
}
if
(
entity
==
null
){
entity
=
new
SysServer
();
}
return
entity
;
}
/**
* 服务器监控统计页面
*/
@RequiresPermissions
(
"sys:sysServer:total"
)
@RequestMapping
(
value
=
{
"total"
})
public
String
totalView
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
total
(
sysServer
,
request
,
response
,
model
);
return
"modules/sys/sysServerTotal"
;
}
private
void
total
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
if
(
StringUtils
.
isEmpty
(
sysServer
.
getTotalType
())){
sysServer
.
setTotalType
(
"%Y-%m-%d"
);
}
//X轴的数据
List
<
String
>
xAxisData
=
new
ArrayList
<
String
>();
//Y轴的数据
Map
<
String
,
List
<
Double
>>
yAxisData
=
new
HashMap
<
String
,
List
<
Double
>>();
List
<
Double
>
countList
=
new
ArrayList
<
Double
>();
List
<
Double
>
sumList
=
new
ArrayList
<
Double
>();
if
(
sysServer
.
getOrderBy
()==
""
){
sysServer
.
setOrderBy
(
"totalDate"
);
}
List
<
SysServer
>
list
=
sysServerService
.
totalCache
(
sysServer
);
//List<SysServer> list = sysServerService.total(sysServer);
model
.
addAttribute
(
"list"
,
list
);
for
(
SysServer
sysServerItem:
list
){
//x轴数据
xAxisData
.
add
(
sysServerItem
.
getTotalDate
());
countList
.
add
(
Double
.
valueOf
(
sysServerItem
.
getTotalCount
()));
}
yAxisData
.
put
(
"数量"
,
countList
);
request
.
setAttribute
(
"xAxisData"
,
xAxisData
);
request
.
setAttribute
(
"yAxisData"
,
yAxisData
);
model
.
addAttribute
(
"sumTotalCount"
,
list
.
stream
().
mapToInt
(
SysServer:
:
getTotalCount
).
sum
());
//饼图数据
Map
<
String
,
Object
>
orientData
=
new
HashMap
<
String
,
Object
>();
for
(
SysServer
sysServerItem:
list
){
orientData
.
put
(
sysServerItem
.
getTotalDate
(),
sysServerItem
.
getTotalCount
());
}
model
.
addAttribute
(
"orientData"
,
orientData
);
}
@RequiresPermissions
(
"sys:sysServer:total"
)
@RequestMapping
(
value
=
{
"totalMap"
})
public
String
totalMap
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
if
(
StringUtils
.
isEmpty
(
sysServer
.
getTotalType
())){
sysServer
.
setTotalType
(
"%Y-%m-%d"
);
}
List
<
SysServer
>
list
=
sysServerService
.
totalCache
(
sysServer
);
//List<SysServer> list = sysServerService.total(sysServer);
model
.
addAttribute
(
"sumTotalCount"
,
list
.
stream
().
mapToInt
(
SysServer:
:
getTotalCount
).
sum
());
model
.
addAttribute
(
"list"
,
list
);
return
"modules/sys/sysServerTotalMap"
;
}
/**
* 服务器监控列表页面
*/
@RequiresPermissions
(
"sys:sysServer:list"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysServer
>
page
=
sysServerService
.
findPageCache
(
new
Page
<
SysServer
>(
request
,
response
),
sysServer
);
//Page<SysServer> page = sysServerService.findPage(new Page<SysServer>(request, response), sysServer);
model
.
addAttribute
(
"page"
,
page
);
sysServer
.
setOrderBy
(
"totalDate"
);
total
(
sysServer
,
request
,
response
,
model
);
return
"modules/sys/sysServerList"
;
}
/**
* 服务器监控列表页面
*/
@RequiresPermissions
(
"sys:sysServer:list"
)
@RequestMapping
(
value
=
{
"listVue"
})
public
String
listVue
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysServer
>
page
=
sysServerService
.
findPageCache
(
new
Page
<
SysServer
>(
request
,
response
),
sysServer
);
//Page<SysServer> page = sysServerService.findPage(new Page<SysServer>(request, response), sysServer);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/sysServerListVue"
;
}
/**
* 服务器监控列表页面
*/
//RequiresPermissions("sys:sysServer:select")
@RequestMapping
(
value
=
{
"select"
})
public
String
select
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
Page
<
SysServer
>
page
=
sysServerService
.
findPageCache
(
new
Page
<
SysServer
>(
request
,
response
),
sysServer
);
//Page<SysServer> page = sysServerService.findPage(new Page<SysServer>(request, response), sysServer);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/sys/sysServerSelect"
;
}
/**
* 查看,增加,编辑服务器监控表单页面
*/
@RequiresPermissions
(
value
={
"sys:sysServer:view"
,
"sys:sysServer:add"
,
"sys:sysServer:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
SysServer
sysServer
,
Model
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
model
.
addAttribute
(
"action"
,
request
.
getParameter
(
"action"
));
model
.
addAttribute
(
"sysServer"
,
sysServer
);
if
(
request
.
getParameter
(
"ViewFormType"
)!=
null
&&
"FormTwo"
.
equals
(
request
.
getParameter
(
"ViewFormType"
)))
{
return
"modules/sys/sysServerFormTwo"
;
}
return
"modules/sys/sysServerForm"
;
}
/**
* 保存服务器监控
*/
@RequiresPermissions
(
value
={
"sys:sysServer:add"
,
"sys:sysServer:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
SysServer
sysServer
,
Model
model
,
RedirectAttributes
redirectAttributes
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysServer/?repage"
;
}
if
(!
beanValidator
(
model
,
sysServer
)){
return
form
(
sysServer
,
model
,
request
,
response
);
}
sysServerService
.
save
(
sysServer
);
addMessage
(
redirectAttributes
,
"保存服务器监控成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
/**
* 删除服务器监控
*/
@RequiresPermissions
(
"sys:sysServer:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysServer/?repage"
;
}
sysServerService
.
delete
(
sysServer
);
addMessage
(
redirectAttributes
,
"删除服务器监控成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
/**
* 删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions
(
value
={
"sys:sysServer:del"
,
"sys:sysServer:delByLogic"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"deleteByLogic"
)
public
String
deleteByLogic
(
SysServer
sysServer
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysServer/?repage"
;
}
sysServerService
.
deleteByLogic
(
sysServer
);
addMessage
(
redirectAttributes
,
"逻辑删除服务器监控成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
/**
* 批量删除服务器监控
*/
@RequiresPermissions
(
"sys:sysServer:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysServer/?repage"
;
}
String
[]
idArray
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
sysServerService
.
delete
(
sysServerService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除服务器监控成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
/**
* 批量删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏)
*/
@RequiresPermissions
(
value
={
"sys:sysServer:del"
,
"sys:sysServer:delByLogic"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"deleteAllByLogic"
)
public
String
deleteAllByLogic
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
if
(
sysConfigService
.
isDemoMode
()){
addMessage
(
redirectAttributes
,
sysConfigService
.
isDemoModeDescription
());
return
"redirect:"
+
adminPath
+
"/sys/sysServer/?repage"
;
}
String
[]
idArray
=
ids
.
split
(
","
);
for
(
String
id
:
idArray
){
sysServerService
.
deleteByLogic
(
sysServerService
.
get
(
id
));
}
addMessage
(
redirectAttributes
,
"删除服务器监控成功"
);
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
/**
* 导出excel文件
*/
@RequiresPermissions
(
"sys:sysServer:export"
)
@RequestMapping
(
value
=
"export"
,
method
=
RequestMethod
.
POST
)
public
String
exportFile
(
SysServer
sysServer
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"服务器监控"
+
DateUtils
.
getDate
(
"yyyyMMddHHmmss"
)+
".xlsx"
;
Page
<
SysServer
>
page
=
sysServerService
.
findPage
(
new
Page
<
SysServer
>(
request
,
response
,
-
1
),
sysServer
);
new
ExportExcel
(
"服务器监控"
,
SysServer
.
class
).
setDataList
(
page
.
getList
()).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导出服务器监控记录失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
/**
* 导入Excel数据
*/
@RequiresPermissions
(
"sys:sysServer: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
<
SysServer
>
list
=
ei
.
getDataList
(
SysServer
.
class
);
for
(
SysServer
sysServer
:
list
){
sysServerService
.
save
(
sysServer
);
}
addMessage
(
redirectAttributes
,
"已成功导入 "
+
successNum
+
" 条服务器监控记录"
);
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入服务器监控失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
/**
* 下载导入服务器监控数据模板
*/
@RequiresPermissions
(
"sys:sysServer:import"
)
@RequestMapping
(
value
=
"import/template"
)
public
String
importFileTemplate
(
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
try
{
String
fileName
=
"服务器监控数据导入模板.xlsx"
;
List
<
SysServer
>
list
=
Lists
.
newArrayList
();
new
ExportExcel
(
"服务器监控数据"
,
SysServer
.
class
,
1
).
setDataList
(
list
).
write
(
response
,
fileName
).
dispose
();
return
null
;
}
catch
(
Exception
e
)
{
addMessage
(
redirectAttributes
,
"导入模板下载失败!失败信息:"
+
e
.
getMessage
());
}
return
"redirect:"
+
Global
.
getAdminPath
()+
"/sys/sysServer/?repage"
;
}
}
\ No newline at end of file
JeeSpringCloud/src/main/java/com/jeespring/modules/shopping/shopping.txt
0 → 100644
View file @
d5ba54ba
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/dao/AreaDao.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.dao
;
import
com.jeespring.common.persistence.TreeDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.sys.entity.Area
;
/**
* 区域DAO接口
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Mapper
public
interface
AreaDao
extends
TreeDao
<
Area
>
{
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/dao/DictDao.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.dao
;
import
java.util.List
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.sys.entity.Dict
;
/**
* 字典DAO接口
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Mapper
public
interface
DictDao
extends
InterfaceBaseDao
<
Dict
>
{
List
<
String
>
findTypeList
(
Dict
dict
);
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/dao/LogDao.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.dao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.modules.sys.entity.Log
;
/**
* 日志DAO接口
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Mapper
public
interface
LogDao
extends
InterfaceBaseDao
<
Log
>
{
void
empty
();
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/dao/MenuDao.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.dao
;
import
java.util.List
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
com.jeespring.modules.sys.entity.Menu
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 菜单DAO接口
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Mapper
public
interface
MenuDao
extends
InterfaceBaseDao
<
Menu
>
{
List
<
Menu
>
findByParentIdsLike
(
Menu
menu
);
List
<
Menu
>
findByUserId
(
Menu
menu
);
int
updateParentIds
(
Menu
menu
);
int
updateSort
(
Menu
menu
);
}
JeeSpringCloud/src/main/java/com/jeespring/modules/sys/dao/OfficeDao.java
0 → 100644
View file @
d5ba54ba
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.sys.dao
;
import
com.jeespring.common.persistence.TreeDao
;
import
com.jeespring.modules.sys.entity.Office
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* 机构DAO接口
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Mapper
public
interface
OfficeDao
extends
TreeDao
<
Office
>
{
Office
getByCode
(
String
code
);
}
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