Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JeeSpringCloud
Commits
08c32267
Commit
08c32267
authored
Dec 13, 2018
by
Sun
Browse files
no commit message
parent
e9629e7a
Changes
412
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
12 of 412+
files are displayed.
Plain diff
Email patch
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyRecordDao.java
0 → 100644
View file @
08c32267
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.oa.dao
;
import
java.util.List
;
import
com.jeespring.common.persistence.InterfaceBaseDao
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.jeespring.modules.oa.entity.OaNotifyRecord
;
/**
* 通知通告记录DAO接口
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Mapper
public
interface
OaNotifyRecordDao
extends
InterfaceBaseDao
<
OaNotifyRecord
>
{
/**
* 插入通知记录
* @param oaNotifyRecordList
* @return
*/
int
insertAll
(
List
<
OaNotifyRecord
>
oaNotifyRecordList
);
/**
* 根据通知ID删除通知记录
* @param oaNotifyId 通知ID
* @return
*/
int
deleteByOaNotifyId
(
String
oaNotifyId
);
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotify.java
0 → 100644
View file @
08c32267
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.oa.entity
;
import
java.util.List
;
import
org.hibernate.validator.constraints.Length
;
import
com.google.common.collect.Lists
;
import
com.jeespring.common.utils.Collections3
;
import
com.jeespring.common.utils.IdGen
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
com.jeespring.modules.sys.entity.User
;
/**
* 通知通告Entity
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
public
class
OaNotify
extends
AbstractBaseEntity
<
OaNotify
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
type
;
// 类型
private
String
title
;
// 标题
private
String
content
;
// 类型
private
String
files
;
// 附件
private
String
status
;
// 状态
private
String
readNum
;
// 已读
private
String
unReadNum
;
// 未读
private
boolean
isSelf
;
// 是否只查询自己的通知
private
String
readFlag
;
// 本人阅读状态
private
List
<
OaNotifyRecord
>
oaNotifyRecordList
=
Lists
.
newArrayList
();
public
OaNotify
()
{
super
();
}
public
OaNotify
(
String
id
){
super
(
id
);
}
@Length
(
min
=
0
,
max
=
200
,
message
=
"标题长度必须介于 0 和 200 之间"
)
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
@Length
(
min
=
0
,
max
=
1
,
message
=
"类型长度必须介于 0 和 1 之间"
)
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
@Length
(
min
=
0
,
max
=
1
,
message
=
"状态长度必须介于 0 和 1 之间"
)
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
@Length
(
min
=
0
,
max
=
2000
,
message
=
"附件长度必须介于 0 和 2000 之间"
)
public
String
getFiles
()
{
return
files
;
}
public
void
setFiles
(
String
files
)
{
this
.
files
=
files
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getReadNum
()
{
return
readNum
;
}
public
void
setReadNum
(
String
readNum
)
{
this
.
readNum
=
readNum
;
}
public
String
getUnReadNum
()
{
return
unReadNum
;
}
public
void
setUnReadNum
(
String
unReadNum
)
{
this
.
unReadNum
=
unReadNum
;
}
public
List
<
OaNotifyRecord
>
getOaNotifyRecordList
()
{
return
oaNotifyRecordList
;
}
public
void
setOaNotifyRecordList
(
List
<
OaNotifyRecord
>
oaNotifyRecordList
)
{
this
.
oaNotifyRecordList
=
oaNotifyRecordList
;
}
/**
* 获取通知发送记录用户ID
* @return
*/
public
String
getOaNotifyRecordIds
()
{
return
Collections3
.
extractToString
(
oaNotifyRecordList
,
"user.id"
,
","
)
;
}
/**
* 设置通知发送记录用户ID
* @return
*/
public
void
setOaNotifyRecordIds
(
String
oaNotifyRecord
)
{
this
.
oaNotifyRecordList
=
Lists
.
newArrayList
();
for
(
String
id
:
StringUtils
.
split
(
oaNotifyRecord
,
","
)){
OaNotifyRecord
entity
=
new
OaNotifyRecord
();
entity
.
setId
(
IdGen
.
uuid
());
entity
.
setOaNotify
(
this
);
entity
.
setUser
(
new
User
(
id
));
entity
.
setReadFlag
(
"0"
);
this
.
oaNotifyRecordList
.
add
(
entity
);
}
}
/**
* 获取通知发送记录用户Name
* @return
*/
public
String
getOaNotifyRecordNames
()
{
return
Collections3
.
extractToString
(
oaNotifyRecordList
,
"user.name"
,
","
)
;
}
/**
* 设置通知发送记录用户Name
* @return
*/
public
void
setOaNotifyRecordNames
(
String
oaNotifyRecord
)
{
// 什么也不做
}
public
boolean
isSelf
()
{
return
isSelf
;
}
public
void
setSelf
(
boolean
isSelf
)
{
this
.
isSelf
=
isSelf
;
}
public
String
getReadFlag
()
{
return
readFlag
;
}
public
void
setReadFlag
(
String
readFlag
)
{
this
.
readFlag
=
readFlag
;
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotifyRecord.java
0 → 100644
View file @
08c32267
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.oa.entity
;
import
org.hibernate.validator.constraints.Length
;
import
com.jeespring.common.persistence.AbstractBaseEntity
;
import
com.jeespring.modules.sys.entity.User
;
import
java.util.Date
;
/**
* 通知通告记录Entity
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
public
class
OaNotifyRecord
extends
AbstractBaseEntity
<
OaNotifyRecord
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
OaNotify
oaNotify
;
// 通知通告ID
private
User
user
;
// 接受人
private
String
readFlag
;
// 阅读标记(0:未读;1:已读)
private
Date
readDate
;
// 阅读时间
public
OaNotifyRecord
()
{
super
();
}
public
OaNotifyRecord
(
String
id
){
super
(
id
);
}
public
OaNotifyRecord
(
OaNotify
oaNotify
){
this
.
oaNotify
=
oaNotify
;
}
public
OaNotify
getOaNotify
()
{
return
oaNotify
;
}
public
void
setOaNotify
(
OaNotify
oaNotify
)
{
this
.
oaNotify
=
oaNotify
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
@Length
(
min
=
0
,
max
=
1
,
message
=
"阅读标记(0:未读;1:已读)长度必须介于 0 和 1 之间"
)
public
String
getReadFlag
()
{
return
readFlag
;
}
public
void
setReadFlag
(
String
readFlag
)
{
this
.
readFlag
=
readFlag
;
}
public
Date
getReadDate
()
{
return
readDate
;
}
public
void
setReadDate
(
Date
readDate
)
{
this
.
readDate
=
readDate
;
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/OaNotifyService.java
0 → 100644
View file @
08c32267
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.oa.service
;
import
java.util.Date
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.service.AbstractBaseService
;
import
com.jeespring.modules.oa.dao.OaNotifyDao
;
import
com.jeespring.modules.oa.dao.OaNotifyRecordDao
;
import
com.jeespring.modules.oa.entity.OaNotify
;
import
com.jeespring.modules.oa.entity.OaNotifyRecord
;
/**
* 通知通告Service
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Service
@Transactional
(
readOnly
=
true
)
public
class
OaNotifyService
extends
AbstractBaseService
<
OaNotifyDao
,
OaNotify
>
{
@Autowired
private
OaNotifyRecordDao
oaNotifyRecordDao
;
@Override
public
OaNotify
get
(
String
id
)
{
OaNotify
entity
=
dao
.
get
(
id
);
return
entity
;
}
/**
* 获取通知发送记录
* @param oaNotify
* @return
*/
public
OaNotify
getRecordList
(
OaNotify
oaNotify
)
{
oaNotify
.
setOaNotifyRecordList
(
oaNotifyRecordDao
.
findList
(
new
OaNotifyRecord
(
oaNotify
)));
return
oaNotify
;
}
public
Page
<
OaNotify
>
find
(
Page
<
OaNotify
>
page
,
OaNotify
oaNotify
)
{
oaNotify
.
setPage
(
page
);
page
.
setList
(
dao
.
findList
(
oaNotify
));
return
page
;
}
/**
* 获取通知数目
* @param oaNotify
* @return
*/
public
Long
findCount
(
OaNotify
oaNotify
)
{
return
dao
.
findCount
(
oaNotify
);
}
@Override
@Transactional
(
readOnly
=
false
)
public
void
save
(
OaNotify
oaNotify
)
{
super
.
save
(
oaNotify
);
// 更新发送接受人记录
oaNotifyRecordDao
.
deleteByOaNotifyId
(
oaNotify
.
getId
());
if
(
oaNotify
.
getOaNotifyRecordList
().
size
()
>
0
){
oaNotifyRecordDao
.
insertAll
(
oaNotify
.
getOaNotifyRecordList
());
}
}
/**
* 更新阅读状态
*/
@Transactional
(
readOnly
=
false
)
public
void
updateReadFlag
(
OaNotify
oaNotify
)
{
OaNotifyRecord
oaNotifyRecord
=
new
OaNotifyRecord
(
oaNotify
);
oaNotifyRecord
.
setUser
(
oaNotifyRecord
.
getCurrentUser
());
oaNotifyRecord
.
setReadDate
(
new
Date
());
oaNotifyRecord
.
setReadFlag
(
"1"
);
oaNotifyRecordDao
.
update
(
oaNotifyRecord
);
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/OaNotifyController.java
0 → 100644
View file @
08c32267
/**
* * Copyright © 2015-2020 <a href="https://gitee.com/JeeHuangBingGui/JeeSpring">JeeSpring</a> All rights reserved..
*/
package
com.jeespring.modules.oa.web
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
com.jeespring.common.utils.StringUtils
;
import
com.jeespring.common.persistence.Page
;
import
com.jeespring.common.web.AbstractBaseController
;
import
com.jeespring.modules.oa.entity.OaNotify
;
import
com.jeespring.modules.oa.service.OaNotifyService
;
/**
* 通知通告Controller
* @author 黄炳桂 516821420@qq.com
* @version 2014-05-16
*/
@Controller
@RequestMapping
(
value
=
"${adminPath}/oa/oaNotify"
)
public
class
OaNotifyController
extends
AbstractBaseController
{
@Autowired
private
OaNotifyService
oaNotifyService
;
@ModelAttribute
public
OaNotify
get
(
@RequestParam
(
required
=
false
)
String
id
)
{
OaNotify
entity
=
null
;
if
(
StringUtils
.
isNotBlank
(
id
)){
entity
=
oaNotifyService
.
get
(
id
);
}
if
(
entity
==
null
){
entity
=
new
OaNotify
();
}
return
entity
;
}
@RequiresPermissions
(
"oa:oaNotify:list"
)
@RequestMapping
(
value
=
{
"list"
,
""
})
public
String
list
(
OaNotify
oaNotify
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
throws
Exception
{
Page
<
OaNotify
>
page
=
new
Page
<
OaNotify
>();
page
=
oaNotifyService
.
find
(
new
Page
<
OaNotify
>(
request
,
response
),
oaNotify
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/oa/oaNotifyList"
;
}
/**
* 查看,增加,编辑报告表单页面
*/
@RequiresPermissions
(
value
={
"oa:oaNotify:view"
,
"oa:oaNotify:add"
,
"oa:oaNotify:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"form"
)
public
String
form
(
OaNotify
oaNotify
,
Model
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
model
.
addAttribute
(
"action"
,
request
.
getParameter
(
"action"
));
if
(
StringUtils
.
isNotBlank
(
oaNotify
.
getId
())){
oaNotify
=
oaNotifyService
.
getRecordList
(
oaNotify
);
}
model
.
addAttribute
(
"oaNotify"
,
oaNotify
);
return
"modules/oa/oaNotifyForm"
;
}
@RequiresPermissions
(
value
={
"oa:oaNotify:add"
,
"oa:oaNotify:edit"
},
logical
=
Logical
.
OR
)
@RequestMapping
(
value
=
"save"
)
public
String
save
(
OaNotify
oaNotify
,
Model
model
,
HttpServletRequest
request
,
HttpServletResponse
response
,
RedirectAttributes
redirectAttributes
)
{
if
(!
beanValidator
(
model
,
oaNotify
)){
return
form
(
oaNotify
,
model
,
request
,
response
);
}
// 如果是修改,则状态为已发布,则不能再进行操作
if
(
StringUtils
.
isNotBlank
(
oaNotify
.
getId
())){
OaNotify
e
=
oaNotifyService
.
get
(
oaNotify
.
getId
());
if
(
"1"
.
equals
(
e
.
getStatus
())){
addMessage
(
redirectAttributes
,
"已发布,不能操作!"
);
return
"redirect:"
+
adminPath
+
"/oa/oaNotify/?repage"
;
}
}
oaNotifyService
.
save
(
oaNotify
);
addMessage
(
redirectAttributes
,
"保存通知'"
+
oaNotify
.
getTitle
()
+
"'成功"
);
return
"redirect:"
+
adminPath
+
"/oa/oaNotify/?repage"
;
}
@RequiresPermissions
(
"oa:oaNotify:del"
)
@RequestMapping
(
value
=
"delete"
)
public
String
delete
(
OaNotify
oaNotify
,
RedirectAttributes
redirectAttributes
)
{
oaNotifyService
.
delete
(
oaNotify
);
addMessage
(
redirectAttributes
,
"删除通知成功"
);
return
"redirect:"
+
adminPath
+
"/oa/oaNotify/?repage"
;
}
@RequiresPermissions
(
"oa:oaNotify:del"
)
@RequestMapping
(
value
=
"deleteAll"
)
public
String
deleteAll
(
String
ids
,
RedirectAttributes
redirectAttributes
)
{
String
[]
idArray
=
ids
.
split
(
","
);
long
successCount
=
0
,
failureCount
=
0
;
String
failureMsg
=
""
;
for
(
String
id
:
idArray
){
OaNotify
oaNotify
=
oaNotifyService
.
get
(
id
);
if
(
oaNotify
==
null
){
failureCount
++;
failureMsg
+=
"id:"
+
id
+
",查询数据为空;"
;
continue
;
}
oaNotifyService
.
delete
(
oaNotifyService
.
get
(
id
));
successCount
++;
}
addMessage
(
redirectAttributes
,
"删除通知成功条数:"
+
successCount
+
",删除通知失败条数:"
+
failureCount
+
",失败信息:"
+
failureMsg
+
""
);
return
"redirect:"
+
adminPath
+
"/oa/oaNotify/?repage"
;
}
/**
* 我的通知列表
* @throws Exception
*/
@RequestMapping
(
value
=
"self"
)
public
String
selfList
(
OaNotify
oaNotify
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
throws
Exception
{
oaNotify
.
setSelf
(
true
);
Page
<
OaNotify
>
page
=
new
Page
<
OaNotify
>();
page
=
oaNotifyService
.
find
(
new
Page
<
OaNotify
>(
request
,
response
),
oaNotify
);
model
.
addAttribute
(
"page"
,
page
);
return
"modules/oa/oaNotifyList"
;
}
/**
* 我的通知列表-数据
*/
@RequiresPermissions
(
"oa:oaNotify:view"
)
@RequestMapping
(
value
=
"selfData"
)
@ResponseBody
public
Page
<
OaNotify
>
listData
(
OaNotify
oaNotify
,
HttpServletRequest
request
,
HttpServletResponse
response
,
Model
model
)
{
oaNotify
.
setSelf
(
true
);
Page
<
OaNotify
>
page
=
oaNotifyService
.
find
(
new
Page
<
OaNotify
>(
request
,
response
),
oaNotify
);
return
page
;
}
/**
* 查看我的通知,重定向在当前页面打开
*/
@RequestMapping
(
value
=
"view"
)
public
String
view
(
OaNotify
oaNotify
,
Model
model
)
{
if
(
StringUtils
.
isNotBlank
(
oaNotify
.
getId
())){
oaNotifyService
.
updateReadFlag
(
oaNotify
);
oaNotify
=
oaNotifyService
.
getRecordList
(
oaNotify
);
model
.
addAttribute
(
"oaNotify"
,
oaNotify
);
return
"modules/oa/oaNotifyForm"
;
}
return
"redirect:"
+
adminPath
+
"/oa/oaNotify/self?repage"
;
}
/**
* 查看我的通知-数据
*/
@RequestMapping
(
value
=
"viewData"
)
@ResponseBody
public
OaNotify
viewData
(
OaNotify
oaNotify
,
Model
model
)
{
if
(
StringUtils
.
isNotBlank
(
oaNotify
.
getId
())){
oaNotifyService
.
updateReadFlag
(
oaNotify
);
return
oaNotify
;
}
return
null
;
}
/**
* 查看我的通知-发送记录
*/
@RequestMapping
(
value
=
"viewRecordData"
)
@ResponseBody
public
OaNotify
viewRecordData
(
OaNotify
oaNotify
,
Model
model
)
{
if
(
StringUtils
.
isNotBlank
(
oaNotify
.
getId
())){
oaNotify
=
oaNotifyService
.
getRecordList
(
oaNotify
);
return
oaNotify
;
}
return
null
;
}
/**
* 获取我的通知数目
*/
@RequestMapping
(
value
=
"self/count"
)
@ResponseBody
public
String
selfCount
(
OaNotify
oaNotify
,
Model
model
)
{
oaNotify
.
setSelf
(
true
);
oaNotify
.
setReadFlag
(
"0"
);
return
String
.
valueOf
(
oaNotifyService
.
findCount
(
oaNotify
));
}
}
\ No newline at end of file
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/entity/TokenInfo.java
0 → 100644
View file @
08c32267
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/jeespring-framework/src/main/java/com/jeespring/modules/oauth/rest/oauthRestController.java
0 → 100644
View file @
08c32267
/**
* * 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/jeespring-framework/src/main/java/com/jeespring/modules/oauth/service/OauthService.java
0 → 100644
View file @
08c32267
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/jeespring-framework/src/main/java/com/jeespring/modules/pay/pay.txt
0 → 100644
View file @
08c32267
JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringScheduledTaskService.java
0 → 100644
View file @
08c32267
package
com.jeespring.modules.scheduling
;
import
com.jeespring.common.utils.SendMailUtil
;
//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/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringTaskSchedulerConfig.java
0 → 100644
View file @
08c32267
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/jeespring-framework/src/main/java/com/jeespring/modules/server/dao/SysServerDao.java
0 → 100644
View file @
08c32267
/**
* * 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
Prev
1
…
17
18
19
20
21
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