Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
智布道
OneBlog
提交
7f65b6ff
O
OneBlog
项目概览
智布道
/
OneBlog
9 个月 前同步成功
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneBlog
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7f65b6ff
编写于
5月 25, 2018
作者:
Y
yadong.zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. 修复后台标签等分页失败的问题
2. 修复前台自动申请友链失败的问题 3. 其他一些问题
上级
d646d560
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
429 addition
and
415 deletion
+429
-415
README.md
README.md
+9
-0
blog-admin/src/main/java/com/zyd/blog/controller/RestArticleController.java
...n/java/com/zyd/blog/controller/RestArticleController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestCommentController.java
...n/java/com/zyd/blog/controller/RestCommentController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestLinkController.java
...main/java/com/zyd/blog/controller/RestLinkController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestNoticeController.java
...in/java/com/zyd/blog/controller/RestNoticeController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestResourcesController.java
...java/com/zyd/blog/controller/RestResourcesController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestRoleController.java
...main/java/com/zyd/blog/controller/RestRoleController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestTagController.java
.../main/java/com/zyd/blog/controller/RestTagController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestTemplateController.java
.../java/com/zyd/blog/controller/RestTemplateController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestTypeController.java
...main/java/com/zyd/blog/controller/RestTypeController.java
+0
-1
blog-admin/src/main/java/com/zyd/blog/controller/RestUpdateController.java
...in/java/com/zyd/blog/controller/RestUpdateController.java
+0
-2
blog-admin/src/main/java/com/zyd/blog/controller/RestUserController.java
...main/java/com/zyd/blog/controller/RestUserController.java
+0
-2
blog-core/src/main/java/com/zyd/blog/business/aspect/RedisCacheAspect.java
...n/java/com/zyd/blog/business/aspect/RedisCacheAspect.java
+13
-32
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizCommentServiceImpl.java
...zyd/blog/business/service/impl/BizCommentServiceImpl.java
+0
-1
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizTagsServiceImpl.java
...om/zyd/blog/business/service/impl/BizTagsServiceImpl.java
+0
-1
blog-core/src/main/java/com/zyd/blog/business/service/impl/SysLinkServiceImpl.java
...om/zyd/blog/business/service/impl/SysLinkServiceImpl.java
+0
-6
blog-core/src/main/java/com/zyd/blog/util/CacheKeyUtil.java
blog-core/src/main/java/com/zyd/blog/util/CacheKeyUtil.java
+43
-0
blog-core/src/main/java/com/zyd/blog/util/RestClientUtil.java
...-core/src/main/java/com/zyd/blog/util/RestClientUtil.java
+1
-1
blog-core/src/main/resources/mybatis/SysLinkMapper.xml
blog-core/src/main/resources/mybatis/SysLinkMapper.xml
+3
-1
blog-web/src/main/resources/static/js/zhyd.comment.js
blog-web/src/main/resources/static/js/zhyd.comment.js
+360
-352
未找到文件。
README.md
浏览文件 @
7f65b6ff
...
...
@@ -90,6 +90,15 @@ _评论审核管理员_: 账号:comment-admin 密码:123456
### 更新日志
2018-05-25
**修改功能:**
1.
修复后台标签等分页失败的问题
2.
修复前台自动申请友链失败的问题
3.
其他一些问题
2018-05-22
**修改功能:**
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestArticleController.java
浏览文件 @
7f65b6ff
...
...
@@ -20,7 +20,6 @@
package
com.zyd.blog.controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Article
;
import
com.zyd.blog.business.entity.Config
;
...
...
@@ -64,7 +63,6 @@ public class RestArticleController {
@RequiresPermissions
(
"articles"
)
@PostMapping
(
"/list"
)
public
PageResult
list
(
ArticleConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Article
>
pageInfo
=
articleService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestCommentController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Comment
;
import
com.zyd.blog.business.entity.Config
;
...
...
@@ -65,7 +64,6 @@ public class RestCommentController {
@RequiresPermissions
(
"comments"
)
@PostMapping
(
"/list"
)
public
PageResult
list
(
CommentConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Comment
>
pageInfo
=
commentService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestLinkController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Link
;
import
com.zyd.blog.business.enums.LinkSourceEnum
;
...
...
@@ -56,7 +55,6 @@ public class RestLinkController {
@PostMapping
(
"/list"
)
public
PageResult
list
(
LinkConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Link
>
pageInfo
=
linkService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestNoticeController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Notice
;
import
com.zyd.blog.business.entity.User
;
...
...
@@ -54,7 +53,6 @@ public class RestNoticeController {
@PostMapping
(
"/list"
)
public
PageResult
list
(
NoticeConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Notice
>
pageInfo
=
noticeService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestResourcesController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Resources
;
import
com.zyd.blog.business.enums.ResponseStatus
;
...
...
@@ -57,7 +56,6 @@ public class RestResourcesController {
@PostMapping
(
"/list"
)
public
PageResult
getAll
(
ResourceConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Resources
>
pageInfo
=
resourcesService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestRoleController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Role
;
import
com.zyd.blog.business.enums.ResponseStatus
;
...
...
@@ -60,7 +59,6 @@ public class RestRoleController {
@PostMapping
(
"/list"
)
public
PageResult
getAll
(
RoleConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Role
>
pageInfo
=
roleService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestTagController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Tags
;
import
com.zyd.blog.business.enums.ResponseStatus
;
...
...
@@ -51,7 +50,6 @@ public class RestTagController {
@PostMapping
(
"/list"
)
public
PageResult
list
(
TagsConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Tags
>
pageInfo
=
tagsService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestTemplateController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.Template
;
import
com.zyd.blog.business.enums.ResponseStatus
;
...
...
@@ -51,7 +50,6 @@ public class RestTemplateController {
@PostMapping
(
"/list"
)
public
PageResult
list
(
TemplateConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Template
>
pageInfo
=
templateService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestTypeController.java
浏览文件 @
7f65b6ff
...
...
@@ -51,7 +51,6 @@ public class RestTypeController {
@PostMapping
(
"/list"
)
public
PageResult
list
(
TypeConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
Type
>
pageInfo
=
typeService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestUpdateController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.UpdateRecorde
;
import
com.zyd.blog.business.enums.ResponseStatus
;
...
...
@@ -51,7 +50,6 @@ public class RestUpdateController {
@PostMapping
(
"/list"
)
public
PageResult
list
(
UpdateRecordeConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
UpdateRecorde
>
pageInfo
=
updateRecordeService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-admin/src/main/java/com/zyd/blog/controller/RestUserController.java
浏览文件 @
7f65b6ff
...
...
@@ -19,7 +19,6 @@
*/
package
com.zyd.blog.controller
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.zyd.blog.business.entity.User
;
import
com.zyd.blog.business.enums.ResponseStatus
;
...
...
@@ -56,7 +55,6 @@ public class RestUserController {
@PostMapping
(
"/list"
)
public
PageResult
list
(
UserConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
()
-
1
,
vo
.
getPageSize
());
PageInfo
<
User
>
pageInfo
=
userService
.
findPageBreakByCondition
(
vo
);
return
ResultUtil
.
tablePage
(
pageInfo
);
}
...
...
blog-core/src/main/java/com/zyd/blog/business/aspect/RedisCacheAspect.java
浏览文件 @
7f65b6ff
...
...
@@ -21,6 +21,7 @@ package com.zyd.blog.business.aspect;
import
com.zyd.blog.business.annotation.RedisCache
;
import
com.zyd.blog.framework.property.AppProperties
;
import
com.zyd.blog.util.CacheKeyUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.Signature
;
...
...
@@ -31,12 +32,9 @@ import org.aspectj.lang.reflect.MethodSignature;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Method
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
/**
* Redis业务层数据缓存
...
...
@@ -75,41 +73,24 @@ public class RedisCacheAspect {
if
(!
currentMethod
.
isAnnotationPresent
(
RedisCache
.
class
))
{
throw
new
RuntimeException
(
"未指定RedisChache注解!"
);
}
// 获取拦截方法的参数
String
className
=
point
.
getTarget
().
getClass
().
getName
();
String
methodName
=
currentMethod
.
getName
();
StringBuilder
key
=
new
StringBuilder
(
point
.
getTarget
().
getClass
().
getName
());
// 获取操作名称
RedisCache
cache
=
currentMethod
.
getAnnotation
(
RedisCache
.
class
);
boolean
flush
=
cache
.
flush
();
StringBuilder
key
=
new
StringBuilder
();
//类名 + 方法名
key
.
append
(
className
).
append
(
"."
).
append
(
methodName
);
if
(
flush
)
{
log
.
info
(
"{}-清空缓存"
,
key
.
toString
());
Set
<
String
>
keys
=
redisTemplate
.
keys
(
className
+
"*"
);
if
(!
CollectionUtils
.
isEmpty
(
keys
))
{
redisTemplate
.
delete
(
keys
);
}
if
(
cache
.
flush
())
{
log
.
info
(
"{}*-清空缓存"
,
key
);
Set
<
String
>
keys
=
redisTemplate
.
keys
(
key
.
toString
()
+
"*"
);
redisTemplate
.
delete
(
keys
);
log
.
info
(
"Clear all the cached query result from redis"
);
return
point
.
proceed
();
}
long
expire
=
cache
.
expire
();
TimeUnit
unit
=
cache
.
unit
();
Object
[]
params
=
point
.
getArgs
();
if
(
StringUtils
.
isEmpty
(
cache
.
key
()))
{
if
(
null
!=
params
&&
params
.
length
>
0
)
{
for
(
Object
obj
:
params
)
{
key
.
append
(
obj
.
toString
());
}
}
}
else
{
key
.
append
(
cache
.
key
());
}
key
.
append
(
"."
).
append
(
currentMethod
.
getName
());
key
.
append
(
CacheKeyUtil
.
getMethodParamsKey
(
point
.
getArgs
())).
append
(
cache
.
key
());
String
realKey
=
key
.
toString
();
// 缓存存在
boolean
hasKey
=
redisTemplate
.
hasKey
(
key
.
toString
()
);
boolean
hasKey
=
redisTemplate
.
hasKey
(
realKey
);
if
(
hasKey
)
{
try
{
log
.
info
(
"{}从缓存中获取数据"
,
key
.
toString
()
);
log
.
info
(
"{}从缓存中获取数据"
,
realKey
);
return
redisTemplate
.
opsForValue
().
get
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
"从缓存中获取数据失败!"
,
e
);
...
...
@@ -118,9 +99,9 @@ public class RedisCacheAspect {
// 先执行业务
Object
result
=
point
.
proceed
();
// 向Redis中添加数据,有效时间是30天
redisTemplate
.
opsForValue
().
set
(
key
.
toString
(),
result
,
expire
,
unit
);
redisTemplate
.
opsForValue
().
set
(
realKey
,
result
,
cache
.
expire
(),
cache
.
unit
()
);
log
.
info
(
"Put query result to redis"
);
log
.
info
(
"{}从数据库中获取数据"
,
key
.
toString
()
);
log
.
info
(
"{}从数据库中获取数据"
,
realKey
);
return
result
;
}
}
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizCommentServiceImpl.java
浏览文件 @
7f65b6ff
...
...
@@ -87,7 +87,6 @@ public class BizCommentServiceImpl implements BizCommentService {
* @return
*/
@Override
// @RedisCache
public
PageInfo
<
Comment
>
findPageBreakByCondition
(
CommentConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
(),
vo
.
getPageSize
());
List
<
BizComment
>
list
=
bizCommentMapper
.
findPageBreakByCondition
(
vo
);
...
...
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizTagsServiceImpl.java
浏览文件 @
7f65b6ff
...
...
@@ -59,7 +59,6 @@ public class BizTagsServiceImpl implements BizTagsService{
* @return
*/
@Override
@RedisCache
public
PageInfo
<
Tags
>
findPageBreakByCondition
(
TagsConditionVO
vo
){
PageHelper
.
startPage
(
vo
.
getPageNumber
(),
vo
.
getPageSize
());
List
<
BizTags
>
list
=
bizTagsMapper
.
findPageBreakByCondition
(
vo
);
...
...
blog-core/src/main/java/com/zyd/blog/business/service/impl/SysLinkServiceImpl.java
浏览文件 @
7f65b6ff
...
...
@@ -72,7 +72,6 @@ public class SysLinkServiceImpl implements SysLinkService {
* @return
*/
@Override
@RedisCache
public
PageInfo
<
Link
>
findPageBreakByCondition
(
LinkConditionVO
vo
)
{
PageHelper
.
startPage
(
vo
.
getPageNumber
(),
vo
.
getPageSize
());
List
<
SysLink
>
list
=
sysLinkMapper
.
findPageBreakByCondition
(
vo
);
...
...
@@ -172,11 +171,6 @@ public class SysLinkServiceImpl implements SysLinkService {
throw
new
ZhydLinkException
(
"贵站暂未添加本站友情链接!请先添加本站友链后重新提交申请!"
);
}
// if (LinksUtil.checkFavicon(link.getFavicon())) {
// bo.setFavicon(link.getFavicon());
// } else {
// bo.setFavicon(link.getFavicon());
// }
link
.
setSource
(
LinkSourceEnum
.
AUTOMATIC
);
link
.
setStatus
(
true
);
if
(!
StringUtils
.
isEmpty
(
link
.
getEmail
())){
...
...
blog-core/src/main/java/com/zyd/blog/util/CacheKeyUtil.java
0 → 100644
浏览文件 @
7f65b6ff
/**
* MIT License
* Copyright (c) 2018 yadong.zhang
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package
com.zyd.blog.util
;
import
com.alibaba.fastjson.JSON
;
import
org.springframework.util.StringUtils
;
/**
* 缓存key相关的工具类
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2018/5/25 10:23
* @since 1.0
*/
public
class
CacheKeyUtil
{
public
static
String
getMethodParamsKey
(
Object
...
obj
)
{
if
(
StringUtils
.
isEmpty
(
obj
))
{
return
""
;
}
return
"("
+
JSON
.
toJSONString
(
obj
)
+
")"
;
}
}
blog-core/src/main/java/com/zyd/blog/util/RestClientUtil.java
浏览文件 @
7f65b6ff
...
...
@@ -73,7 +73,7 @@ public class RestClientUtil {
*/
public
static
String
request
(
String
method
,
String
urlString
,
Map
<
String
,
Object
>
params
,
String
encode
,
Map
<
String
,
String
>
requestHeader
)
{
// 解决因jdk版本问题造成的SSL请求失败的问题
java
.
lang
.
System
.
setProperty
(
"https.protocols"
,
"TLSv1,TLSv1.1,TLSv1.2"
);
System
.
setProperty
(
"https.protocols"
,
"TLSv1,TLSv1.1,TLSv1.2"
);
final
HttpURLConnection
connection
;
try
{
connection
=
openConnection
(
urlString
);
...
...
blog-core/src/main/resources/mybatis/SysLinkMapper.xml
浏览文件 @
7f65b6ff
...
...
@@ -48,7 +48,9 @@
AND t.home_page_display = #{homePageDisplay}
</if>
ORDER BY
(t. STATUS > 0) DESC, t. STATUS ASC
(t. STATUS > 0) DESC,
t. STATUS ASC,
t.create_time DESC
</select>
</mapper>
blog-web/src/main/resources/static/js/zhyd.comment.js
浏览文件 @
7f65b6ff
...
...
@@ -49,399 +49,407 @@
* 'redo' // 重复
*
*/
$
(
function
(){
var
_form
=
{
valid
:
function
(
form
){
var
valid
=
true
;
$
(
form
).
find
(
"
small
"
).
each
(
function
(){
if
(
$
(
this
).
attr
(
"
data-bv-result
"
)
==
"
INVALID
"
){
valid
=
false
;
}
});
return
valid
;
}
};
$
.
extend
({
comment
:
{
detailKey
:
'
comment-detail
'
,
menus
:
[
'
code
'
,
'
bold
'
,
'
italic
'
,
'
underline
'
,
'
image
'
,
'
link
'
,
'
list
'
,
'
quote
'
,
'
emoticon
'
],
sid
:
0
,
_commentDetailModal
:
''
,
_detailForm
:
''
,
_detailFormBtn
:
''
,
_closeBtn
:
''
,
_commentPid
:
''
,
_commentPlace
:
''
,
_commentPost
:
''
,
_cancelReply
:
''
,
_commentReply
:
''
,
initDom
:
function
()
{
$
.
comment
.
_commentDetailModal
=
$
(
'
#comment-detail-modal
'
);
$
.
comment
.
_detailForm
=
$
(
'
#detail-form
'
);
$
.
comment
.
_detailFormBtn
=
$
(
'
#detail-form-btn
'
);
$
.
comment
.
_closeBtn
=
$
(
'
#comment-detail-modal .close
'
);
$
.
comment
.
_commentPid
=
$
(
'
#comment-pid
'
);
$
.
comment
.
_commentPlace
=
$
(
'
#comment-place
'
);
$
.
comment
.
_commentPost
=
$
(
'
#comment-post
'
);
$
.
comment
.
_cancelReply
=
$
(
'
#cancel-reply
'
);
$
.
comment
.
_commentReply
=
$
(
'
.comment-reply
'
);
},
init
:
function
(
options
)
{
var
$box
=
$
(
'
#comment-box
'
);
if
(
!
$box
||
!
$box
[
0
])
{
return
;
}
var
op
=
$
.
extend
({
menus
:
$
.
comment
.
menus
,
customMenu
:
true
},
options
);
var
detailInfoJson
=
$
.
tool
.
parseFormSerialize
(
localStorage
.
getItem
(
this
.
detailKey
));
var
currentUser
=
''
;
if
(
detailInfoJson
){
currentUser
=
'
<small> - 欢迎回来,<a href="
'
+
detailInfoJson
.
url
+
'
" target="_blank" rel="external nofollow">
'
+
filterXSS
(
detailInfoJson
.
nickname
)
+
'
<i class="fa fa-smile-o"></i></a></small>
'
;
}
var
commentBox
=
'
<div id="comment-place">
'
+
'
<div class="comment-post" id="comment-post" style="position: relative">
'
+
'
<h4 class="bottom-line"><i class="fa fa-commenting-o fa-fw icon"></i><strong>发表评论</strong>
'
+
currentUser
+
'
</h4>
'
+
'
<div class="cancel-reply" id="cancel-reply" style="display: none;"><a href="javascript:void(0);" onclick="$.comment.cancelReply(this)" rel="external nofollow"><i class="fa fa-share"></i>取消回复</a></div>
'
+
'
<form class="form-horizontal" role="form" id="comment-form">
'
+
'
<input type="hidden" name="pid" id="comment-pid" value="0" size="22" tabindex="1">
'
+
'
<textarea id="comment_content" name="content" style="display: none"></textarea>
'
+
'
<div id="editor" style="width: 100%;height: 150px;"></div>
'
+
'
<div style="position: absolute;right: 10px;bottom: 65px;font-size: 14px;font-weight: 700;color: #ececec;">张亚东博客<br>https://www.zhyd.me<br>讲文明、要和谐</div>
'
+
'
<a id="comment-form-btn" type="button" data-loading-text="正在提交评论..." class="btn btn-default btn-block">提交评论</a>
'
+
'
</form></div></div>
'
;
$box
.
html
(
commentBox
);
// 初始化并缓存常用的dom元素
$
.
comment
.
initDom
();
// 创建编辑框
$
.
comment
.
createEdit
(
op
);
$
.
comment
.
loadCommentList
(
$box
);
$
.
comment
.
initValidatorPlugin
();
},
createEdit
:
function
(
options
)
{
var
$selector
=
'
#editor
'
;
var
E
=
window
.
wangEditor
;
var
editor
=
new
E
(
$selector
);
if
(
options
.
customMenu
){
editor
.
customConfig
.
menus
=
options
.
menus
;
}
/*!
* BootstrapValidator (http://bootstrapvalidator.com)
* The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
*
* @version v0.5.1-dev, built on 2014-07-23 6:05:15 AM
* @author https://twitter.com/nghuuphuoc
* @copyright (c) 2013 - 2014 Nguyen Huu Phuoc
* @license MIT
*/
var
_form
=
{
valid
:
function
(
form
){
var
valid
=
true
;
$
(
form
).
find
(
"
small
"
).
each
(
function
(){
if
(
$
(
this
).
attr
(
"
data-bv-result
"
)
==
"
INVALID
"
){
valid
=
false
;
}
});
return
valid
;
}
};
$
.
extend
({
comment
:
{
detailKey
:
'
comment-detail
'
,
menus
:
[
'
code
'
,
'
bold
'
,
'
italic
'
,
'
underline
'
,
'
image
'
,
'
link
'
,
'
list
'
,
'
quote
'
,
'
emoticon
'
],
sid
:
0
,
_commentDetailModal
:
''
,
_detailForm
:
''
,
_detailFormBtn
:
''
,
_closeBtn
:
''
,
_commentPid
:
''
,
_commentPlace
:
''
,
_commentPost
:
''
,
_cancelReply
:
''
,
_commentReply
:
''
,
initDom
:
function
()
{
$
.
comment
.
_commentDetailModal
=
$
(
'
#comment-detail-modal
'
);
$
.
comment
.
_detailForm
=
$
(
'
#detail-form
'
);
$
.
comment
.
_detailFormBtn
=
$
(
'
#detail-form-btn
'
);
$
.
comment
.
_closeBtn
=
$
(
'
#comment-detail-modal .close
'
);
$
.
comment
.
_commentPid
=
$
(
'
#comment-pid
'
);
$
.
comment
.
_commentPlace
=
$
(
'
#comment-place
'
);
$
.
comment
.
_commentPost
=
$
(
'
#comment-post
'
);
$
.
comment
.
_cancelReply
=
$
(
'
#cancel-reply
'
);
$
.
comment
.
_commentReply
=
$
(
'
.comment-reply
'
);
},
init
:
function
(
options
)
{
var
$box
=
$
(
'
#comment-box
'
);
if
(
!
$box
||
!
$box
[
0
])
{
return
;
}
var
op
=
$
.
extend
({
menus
:
$
.
comment
.
menus
,
customMenu
:
true
},
options
);
var
detailInfoJson
=
$
.
tool
.
parseFormSerialize
(
localStorage
.
getItem
(
this
.
detailKey
));
var
currentUser
=
''
;
if
(
detailInfoJson
){
currentUser
=
'
<small> - 欢迎回来,<a href="
'
+
detailInfoJson
.
url
+
'
" target="_blank" rel="external nofollow">
'
+
filterXSS
(
detailInfoJson
.
nickname
)
+
'
<i class="fa fa-smile-o"></i></a></small>
'
;
}
var
commentBox
=
'
<div id="comment-place">
'
+
'
<div class="comment-post" id="comment-post" style="position: relative">
'
+
'
<h4 class="bottom-line"><i class="fa fa-commenting-o fa-fw icon"></i><strong>发表评论</strong>
'
+
currentUser
+
'
</h4>
'
+
'
<div class="cancel-reply" id="cancel-reply" style="display: none;"><a href="javascript:void(0);" onclick="$.comment.cancelReply(this)" rel="external nofollow"><i class="fa fa-share"></i>取消回复</a></div>
'
+
'
<form class="form-horizontal" role="form" id="comment-form">
'
+
'
<input type="hidden" name="pid" id="comment-pid" value="0" size="22" tabindex="1">
'
+
'
<textarea id="comment_content" name="content" style="display: none"></textarea>
'
+
'
<div id="editor" style="width: 100%;height: 150px;"></div>
'
+
'
<div style="position: absolute;right: 10px;bottom: 65px;font-size: 14px;font-weight: 700;color: #ececec;">张亚东博客<br>https://www.zhyd.me<br>讲文明、要和谐</div>
'
+
'
<a id="comment-form-btn" type="button" data-loading-text="正在提交评论..." class="btn btn-default btn-block">提交评论</a>
'
+
'
</form></div></div>
'
;
$box
.
html
(
commentBox
);
// 初始化并缓存常用的dom元素
$
.
comment
.
initDom
();
// 创建编辑框
$
.
comment
.
createEdit
(
op
);
$
.
comment
.
loadCommentList
(
$box
);
$
.
comment
.
initValidatorPlugin
();
},
createEdit
:
function
(
options
)
{
var
$selector
=
'
#editor
'
;
var
E
=
window
.
wangEditor
;
var
editor
=
new
E
(
$selector
);
if
(
options
.
customMenu
){
editor
.
customConfig
.
menus
=
options
.
menus
;
}
// debug模式下,有 JS 错误会以throw Error方式提示出来
editor
.
customConfig
.
debug
=
false
;
// debug模式下,有 JS 错误会以throw Error方式提示出来
editor
.
customConfig
.
debug
=
false
;
// 关闭粘贴样式的过滤
editor
.
customConfig
.
pasteFilterStyle
=
false
;
// 插入网络图片的回调
editor
.
customConfig
.
linkImgCallback
=
function
(
url
)
{
// console.log(url) // url 即插入图片的地址
};
editor
.
customConfig
.
zIndex
=
100
;
var
$content
=
$
(
'
#comment_content
'
);
editor
.
customConfig
.
onchange
=
function
(
html
)
{
// 让编辑器始终处于最底部
// var $dom = document.getElementsByClassName("w-e-text")[0];
// $dom.scrollTop = $dom.scrollHeight;
// 监控变化,同步更新到 textarea
$content
.
val
(
filterXSS
(
html
));
};
editor
.
create
();
$content
.
val
(
editor
.
txt
.
html
());
E
.
fullscreen
.
init
(
$selector
);
},
loadCommentList
:
function
(
box
,
pageNumber
)
{
var
sid
=
box
.
attr
(
"
data-id
"
);
// 该属性为了静态页面中防止请求服务器特加的属性,实际可能不用。
var
autoLoad
=
box
.
attr
(
"
data-auto-load
"
);
if
(
autoLoad
&&
autoLoad
==
"
false
"
){
return
false
;
}
if
(
!
sid
){
throw
"
未指定sid!
"
;
}
this
.
sid
=
sid
;
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/comments
"
,
data
:
{
sid
:
sid
,
pageNumber
:
pageNumber
||
1
},
success
:
function
(
json
)
{
$
.
alert
.
ajaxSuccess
(
json
);
// 加载 评论列表 start
var
commentList
=
json
.
data
.
commentList
;
var
commentListBox
=
''
;
if
(
!
commentList
){
// 关闭粘贴样式的过滤
editor
.
customConfig
.
pasteFilterStyle
=
false
;
// 插入网络图片的回调
editor
.
customConfig
.
linkImgCallback
=
function
(
url
)
{
// console.log(url) // url 即插入图片的地址
};
editor
.
customConfig
.
zIndex
=
100
;
var
$content
=
$
(
'
#comment_content
'
);
editor
.
customConfig
.
onchange
=
function
(
html
)
{
// 让编辑器始终处于最底部
// var $dom = document.getElementsByClassName("w-e-text")[0];
// $dom.scrollTop = $dom.scrollHeight;
// 监控变化,同步更新到 textarea
$content
.
val
(
filterXSS
(
html
));
};
editor
.
create
();
$content
.
val
(
editor
.
txt
.
html
());
E
.
fullscreen
.
init
(
$selector
);
},
loadCommentList
:
function
(
box
,
pageNumber
)
{
var
sid
=
box
.
attr
(
"
data-id
"
);
// 该属性为了静态页面中防止请求服务器特加的属性,实际可能不用。
var
autoLoad
=
box
.
attr
(
"
data-auto-load
"
);
if
(
autoLoad
&&
autoLoad
==
"
false
"
){
return
false
;
}
if
(
!
sid
){
throw
"
未指定sid!
"
;
}
this
.
sid
=
sid
;
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/comments
"
,
data
:
{
sid
:
sid
,
pageNumber
:
pageNumber
||
1
},
success
:
function
(
json
)
{
$
.
alert
.
ajaxSuccess
(
json
);
// 加载 评论列表 start
var
commentList
=
json
.
data
.
commentList
;
var
commentListBox
=
''
;
if
(
!
commentList
){
commentListBox
=
'
<div class="commentList">
'
+
'
<h4 class="bottom-line"><i class="fa fa-comments-o fa-fw icon"></i><strong><em>0</em> 条评论</strong></h4>
'
+
'
<ul class="comment">
'
;
commentListBox
+=
'
<li><div class="list-comment-empty-w fade-in">
'
+
'
<div class="empty-prompt-w">
'
+
'
<span class="prompt-null-w">还没有评论,快来抢沙发吧!</span>
'
+
'
</div>
'
+
'
</div></li>
'
;
// 加载 评论列表 end
commentListBox
+=
'
</ul></div>
'
;
$
(
commentListBox
).
appendTo
(
box
);
}
else
{
// 首次加载-刷新页面后第一次加载,此时没有点击加载更多进行分页
if
(
!
pageNumber
)
{
commentListBox
=
'
<div class="commentList">
'
+
'
<h
4 class="bottom-line"><i class="fa fa-comments-o fa-fw icon"></i><strong><em>0</em> 条评论</strong></h4
>
'
+
'
<h
5 class="bottom-line"><i class="fa fa-comments-o fa-fw icon"></i><strong><em>
'
+
json
.
data
.
total
+
'
</em> 条评论</strong></h5
>
'
+
'
<ul class="comment">
'
;
}
for
(
var
i
=
0
,
len
=
commentList
.
length
;
i
<
len
;
i
++
){
var
comment
=
commentList
[
i
];
var
userUrl
=
comment
.
url
||
"
javascript:void(0)
"
;
var
parent
=
comment
.
parent
;
var
parentQuote
=
parent
?
'
<a href="#comment-
'
+
parent
.
id
+
'
" class="comment-quote">@
'
+
parent
.
nickname
+
'
</a><div style="background-color: #f5f5f5;padding: 5px;margin: 5px;border-radius: 4px;"><i class="fa fa-quote-left"></i><p></p><div style="padding-left: 10px;">
'
+
filterXSS
(
parent
.
content
)
+
'
</div></div>
'
:
''
;
commentListBox
+=
'
<li>
'
+
'
<div class="comment-body fade-in" id="comment-
'
+
comment
.
id
+
'
">
'
+
'
<div class="cheader">
'
+
'
<div class="user-img"><img class="userImage" src="
'
+
comment
.
avatar
+
'
" onerror="this.src=
\'
'
+
appConfig
.
staticPath
+
'
/img/user.png
\'
"></div>
'
+
'
<div class="user-info">
'
+
'
<div class="nickname">
'
+
'
<a target="_blank" href="
'
+
userUrl
+
'
" rel="external nofollow"><strong>
'
+
comment
.
nickname
+
'
</strong></a>
'
+
'
</div>
'
+
'
<div class="timer">
'
+
'
<i class="fa fa-clock-o fa-fw"></i>
'
+
comment
.
createTimeString
+
'
<i class="fa fa-map-marker fa-fw"></i>
'
+
comment
.
address
+
'
</div>
'
+
'
</div>
'
+
'
</div>
'
+
'
<div class="content">
'
+
parentQuote
+
'
<div>
'
+
filterXSS
(
comment
.
content
)
+
'
</div></div>
'
+
'
<div class="sign">
'
+
'
<i class="icons os-
'
+
comment
.
osShortName
+
'
"></i>
'
+
comment
.
os
+
'
<i class="sepa"></i>
'
+
'
<i class="icons browser-
'
+
comment
.
browserShortName
+
'
"></i>
'
+
comment
.
browser
+
'
<i class="sepa"></i>
'
+
'
<a href="javascript:void(0);" class="comment-up" onclick="$.comment.praise(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-thumbs-o-up"></i>赞(<span class="count">
'
+
comment
.
support
+
'
</span>)<i class="sepa"></i></a>
'
+
'
<a href="javascript:void(0);" class="comment-down" onclick="$.comment.step(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-thumbs-o-down"></i>踩(<span class="count">
'
+
comment
.
oppose
+
'
</span>)<i class="sepa"></i></a>
'
+
'
<a href="javascript:void(0);" class="comment-reply" onclick="$.comment.reply(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-reply"></i>回复</a>
'
+
'
<a href="javascript:void(0);" class="comment-flag hide" onclick="$.comment.report(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-flag"></i>举报</a>
'
+
'
</div>
'
+
'
</div>
'
+
'
</li>
'
;
}
// 如果存在下一页,则显示加载按钮
if
(
json
.
data
.
hasNextPage
){
commentListBox
+=
'
<li><div class="list-comment-empty-w fade-in">
'
+
'
<div class="empty-prompt-w">
'
+
'
<span class="prompt-null-w
">还没有评论,快来抢沙发吧!
</span>
'
+
'
<span class="prompt-null-w
pointer load-more">加载更多 <i class="fa fa-angle-double-down"></i>
</span>
'
+
'
</div>
'
+
'
</div></li>
'
;
// 加载 评论列表 end
}
// 加载 评论列表 end
if
(
!
pageNumber
)
{
// 首次加载-刷新页面后第一次加载,此时没有点击加载更多进行分页
commentListBox
+=
'
</ul></div>
'
;
$
(
commentListBox
).
appendTo
(
box
);
}
else
{
// 首次加载-刷新页面后第一次加载,此时没有点击加载更多进行分页
if
(
!
pageNumber
)
{
commentListBox
=
'
<div class="commentList">
'
+
'
<h5 class="bottom-line"><i class="fa fa-comments-o fa-fw icon"></i><strong><em>
'
+
json
.
data
.
total
+
'
</em> 条评论</strong></h5>
'
+
'
<ul class="comment">
'
;
}
for
(
var
i
=
0
,
len
=
commentList
.
length
;
i
<
len
;
i
++
){
var
comment
=
commentList
[
i
];
var
userUrl
=
comment
.
url
||
"
javascript:void(0)
"
;
var
parent
=
comment
.
parent
;
var
parentQuote
=
parent
?
'
<a href="#comment-
'
+
parent
.
id
+
'
" class="comment-quote">@
'
+
parent
.
nickname
+
'
</a><div style="background-color: #f5f5f5;padding: 5px;margin: 5px;border-radius: 4px;"><i class="fa fa-quote-left"></i><p></p><div style="padding-left: 10px;">
'
+
filterXSS
(
parent
.
content
)
+
'
</div></div>
'
:
''
;
commentListBox
+=
'
<li>
'
+
'
<div class="comment-body fade-in" id="comment-
'
+
comment
.
id
+
'
">
'
+
'
<div class="cheader">
'
+
'
<div class="user-img"><img class="userImage" src="
'
+
comment
.
avatar
+
'
" onerror="this.src=
\'
'
+
appConfig
.
staticPath
+
'
/img/user.png
\'
"></div>
'
+
'
<div class="user-info">
'
+
'
<div class="nickname">
'
+
'
<a target="_blank" href="
'
+
userUrl
+
'
" rel="external nofollow"><strong>
'
+
comment
.
nickname
+
'
</strong></a>
'
+
'
</div>
'
+
'
<div class="timer">
'
+
'
<i class="fa fa-clock-o fa-fw"></i>
'
+
comment
.
createTimeString
+
'
<i class="fa fa-map-marker fa-fw"></i>
'
+
comment
.
address
+
'
</div>
'
+
'
</div>
'
+
'
</div>
'
+
'
<div class="content">
'
+
parentQuote
+
'
<div>
'
+
filterXSS
(
comment
.
content
)
+
'
</div></div>
'
+
'
<div class="sign">
'
+
'
<i class="icons os-
'
+
comment
.
osShortName
+
'
"></i>
'
+
comment
.
os
+
'
<i class="sepa"></i>
'
+
'
<i class="icons browser-
'
+
comment
.
browserShortName
+
'
"></i>
'
+
comment
.
browser
+
'
<i class="sepa"></i>
'
+
'
<a href="javascript:void(0);" class="comment-up" onclick="$.comment.praise(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-thumbs-o-up"></i>赞(<span class="count">
'
+
comment
.
support
+
'
</span>)<i class="sepa"></i></a>
'
+
'
<a href="javascript:void(0);" class="comment-down" onclick="$.comment.step(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-thumbs-o-down"></i>踩(<span class="count">
'
+
comment
.
oppose
+
'
</span>)<i class="sepa"></i></a>
'
+
'
<a href="javascript:void(0);" class="comment-reply" onclick="$.comment.reply(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-reply"></i>回复</a>
'
+
'
<a href="javascript:void(0);" class="comment-flag hide" onclick="$.comment.report(
'
+
comment
.
id
+
'
, this)"><i class="fa fa-flag"></i>举报</a>
'
+
'
</div>
'
+
'
</div>
'
+
'
</li>
'
;
}
// 如果存在下一页,则显示加载按钮
if
(
json
.
data
.
hasNextPage
){
commentListBox
+=
'
<li><div class="list-comment-empty-w fade-in">
'
+
'
<div class="empty-prompt-w">
'
+
'
<span class="prompt-null-w pointer load-more">加载更多 <i class="fa fa-angle-double-down"></i></span>
'
+
'
</div>
'
+
'
</div></li>
'
;
}
// 加载 评论列表 end
// 点击加载更多时,列表追加到ul中
$
(
commentListBox
).
appendTo
(
$
(
"
.comment
"
));
}
if
(
!
pageNumber
)
{
// 首次加载-刷新页面后第一次加载,此时没有点击加载更多进行分页
commentListBox
+=
'
</ul></div>
'
;
$
(
commentListBox
).
appendTo
(
box
);
}
else
{
// 点击加载更多时,列表追加到ul中
$
(
commentListBox
).
appendTo
(
$
(
"
.comment
"
));
// 加载更多按钮
$
(
"
.load-more
"
).
click
(
function
()
{
$
(
this
).
parents
(
'
li
'
).
hide
();
$
.
comment
.
loadCommentList
(
box
,
json
.
data
.
nextPage
)
});
}
},
error
:
$
.
alert
.
ajaxError
});
},
initValidatorPlugin
:
function
()
{
$
.
comment
.
_detailForm
.
bootstrapValidator
({
message
:
"
输入值无效
"
,
feedbackIcons
:
{
valid
:
"
fa fa-check
"
,
invalid
:
"
fa fa-remove
"
,
validating
:
"
fa fa-refresh
"
},
fields
:
{
nickname
:
{
validators
:
{
notEmpty
:
{
message
:
"
昵称必填
"
}
// 加载更多按钮
$
(
"
.load-more
"
).
click
(
function
()
{
$
(
this
).
parents
(
'
li
'
).
hide
();
$
.
comment
.
loadCommentList
(
box
,
json
.
data
.
nextPage
)
});
}
},
error
:
$
.
alert
.
ajaxError
});
},
initValidatorPlugin
:
function
()
{
$
.
comment
.
_detailForm
.
bootstrapValidator
({
message
:
"
输入值无效
"
,
feedbackIcons
:
{
valid
:
"
fa fa-check
"
,
invalid
:
"
fa fa-remove
"
,
validating
:
"
fa fa-refresh
"
},
fields
:
{
nickname
:
{
validators
:
{
notEmpty
:
{
message
:
"
昵称必填
"
}
}
},
url
:
{
validators
:
{
uri
:
{
message
:
"
URL地址不正确
"
}
url
:
{
validators
:
{
uri
:
{
message
:
"
URL地址不正确
"
}
}
,
email
:
{
validators
:
{
emailAddres
s
:
{
message
:
"
邮箱地址不正确
"
}
}
},
email
:
{
validator
s
:
{
emailAddress
:
{
message
:
"
邮箱地址不正确
"
}
}
}
});
},
submit
:
function
(
target
)
{
var
$this
=
$
(
target
);
$this
.
button
(
'
loading
'
);
var
detail
=
localStorage
.
getItem
(
this
.
detailKey
);
var
data
=
$
(
"
#comment-form
"
).
serialize
();
if
(
!
detail
){
}
else
{
var
detailInfoJson
=
$
.
tool
.
parseFormSerialize
(
detail
);
$
.
comment
.
_detailForm
.
find
(
"
input
"
).
each
(
function
()
{
var
$this
=
$
(
this
);
var
inputName
=
$this
.
attr
(
"
name
"
);
if
(
detailInfoJson
[
inputName
]){
$this
.
val
(
detailInfoJson
[
inputName
]);
}
});
var
$img
=
$
.
comment
.
_detailForm
.
find
(
'
img
'
);
$img
.
attr
(
'
src
'
,
detailInfoJson
.
avatar
);
$img
.
removeClass
(
'
hide
'
);
}
this
.
_commentDetailModal
.
modal
(
'
show
'
);
this
.
_closeBtn
.
unbind
(
'
click
'
);
this
.
_closeBtn
.
click
(
function
()
{
setTimeout
(
function
()
{
$this
.
html
(
"
<i class='fa fa-close'></i>取消操作...
"
);
setTimeout
(
function
()
{
$this
.
button
(
'
reset
'
);
},
1000
);
},
500
);
});
// 模态框抖动
this
.
_commentDetailModal
.
find
(
'
.modal-content
'
).
addClass
(
"
shake
"
);
$
.
comment
.
_detailForm
.
find
(
"
input[name=qq]
"
).
unbind
(
'
change
'
);
$
.
comment
.
_detailForm
.
find
(
"
input[name=qq]
"
).
change
(
function
()
{
});
},
submit
:
function
(
target
)
{
var
$this
=
$
(
target
);
$this
.
button
(
'
loading
'
);
var
detail
=
localStorage
.
getItem
(
this
.
detailKey
);
var
data
=
$
(
"
#comment-form
"
).
serialize
();
if
(
!
detail
){
}
else
{
var
detailInfoJson
=
$
.
tool
.
parseFormSerialize
(
detail
);
$
.
comment
.
_detailForm
.
find
(
"
input
"
).
each
(
function
()
{
var
$this
=
$
(
this
);
var
qq
=
$this
.
val
();
var
$nextImg
=
$this
.
next
(
'
img
'
);
if
(
qq
){
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/qq/
"
+
qq
,
success
:
function
(
json
)
{
$
.
alert
.
ajaxSuccess
(
json
);
var
data
=
json
.
data
;
$
.
comment
.
_detailForm
.
find
(
"
input
"
).
each
(
function
()
{
var
$this
=
$
(
this
);
var
inputName
=
$this
.
attr
(
"
name
"
);
if
(
data
[
inputName
]){
$this
.
val
(
data
[
inputName
]);
}
});
$nextImg
.
attr
(
'
src
'
,
data
.
avatar
);
$nextImg
.
removeClass
(
'
hide
'
);
},
error
:
$
.
alert
.
ajaxError
});
}
else
{
$nextImg
.
addClass
(
'
hide
'
);
}
});
// 提交评论
this
.
_detailFormBtn
.
unbind
(
'
click
'
);
this
.
_detailFormBtn
.
click
(
function
()
{
$
.
comment
.
_detailForm
.
bootstrapValidator
(
"
validate
"
);
if
(
_form
.
valid
(
$
.
comment
.
_detailForm
))
{
data
=
data
+
"
&
"
+
$
.
comment
.
_detailForm
.
serialize
();
localStorage
.
setItem
(
$
.
comment
.
detailKey
,
$
.
comment
.
_detailForm
.
serialize
());
submitForm
(
data
);
var
inputName
=
$this
.
attr
(
"
name
"
);
if
(
detailInfoJson
[
inputName
]){
$this
.
val
(
detailInfoJson
[
inputName
]);
}
});
var
$img
=
$
.
comment
.
_detailForm
.
find
(
'
img
'
);
$img
.
attr
(
'
src
'
,
detailInfoJson
.
avatar
);
$img
.
removeClass
(
'
hide
'
);
function
submitForm
(
data
)
{
$
.
comment
.
_detailFormBtn
.
button
(
'
loading
'
);
}
this
.
_commentDetailModal
.
modal
(
'
show
'
);
this
.
_closeBtn
.
unbind
(
'
click
'
);
this
.
_closeBtn
.
click
(
function
()
{
setTimeout
(
function
()
{
$this
.
html
(
"
<i class='fa fa-close'></i>取消操作...
"
);
setTimeout
(
function
()
{
$this
.
button
(
'
reset
'
);
},
1000
);
},
500
);
});
// 模态框抖动
this
.
_commentDetailModal
.
find
(
'
.modal-content
'
).
addClass
(
"
shake
"
);
$
.
comment
.
_detailForm
.
find
(
"
input[name=qq]
"
).
unbind
(
'
change
'
);
$
.
comment
.
_detailForm
.
find
(
"
input[name=qq]
"
).
change
(
function
()
{
var
$this
=
$
(
this
);
var
qq
=
$this
.
val
();
var
$nextImg
=
$this
.
next
(
'
img
'
);
if
(
qq
){
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/comment
"
,
data
:
data
+
'
&sid=
'
+
$
.
comment
.
sid
,
url
:
"
/api/qq/
"
+
qq
,
success
:
function
(
json
)
{
$
.
comment
.
_detailFormBtn
.
button
(
'
reset
'
);
$
.
alert
.
ajaxSuccess
(
json
);
$
.
comment
.
_commentDetailModal
.
modal
(
'
hide
'
);
setTimeout
(
function
()
{
$this
.
html
(
"
<i class='fa fa-check'></i>
"
+
json
.
message
);
setTimeout
(
function
()
{
$this
.
button
(
'
reset
'
);
window
.
location
.
reload
();
},
3000
);
},
1000
);
var
data
=
json
.
data
;
$
.
comment
.
_detailForm
.
find
(
"
input
"
).
each
(
function
()
{
var
$this
=
$
(
this
);
var
inputName
=
$this
.
attr
(
"
name
"
);
if
(
data
[
inputName
]){
$this
.
val
(
data
[
inputName
]);
}
});
$nextImg
.
attr
(
'
src
'
,
data
.
avatar
);
$nextImg
.
removeClass
(
'
hide
'
);
},
error
:
function
(
data
)
{
$
.
alert
.
ajaxError
();
$this
.
button
(
'
reset
'
);
}
error
:
$
.
alert
.
ajaxError
});
}
else
{
$nextImg
.
addClass
(
'
hide
'
);
}
},
reply
:
function
(
pid
,
target
)
{
this
.
_commentPid
.
val
(
pid
);
this
.
_cancelReply
.
show
();
this
.
_commentPost
.
find
(
'
h5 i
'
).
addClass
(
"
shake
"
);
$
(
target
).
hide
();
$
(
target
).
parents
(
'
.comment-body
'
).
append
(
this
.
_commentPost
);
},
cancelReply
:
function
(
target
)
{
this
.
_commentPid
.
val
(
""
);
this
.
_cancelReply
.
hide
();
$
(
target
).
parents
(
"
.comment-body
"
).
find
(
'
.comment-reply
'
).
show
();
this
.
_commentPost
.
find
(
'
h5 i
'
).
addClass
(
"
shake
"
);
this
.
_commentPlace
.
append
(
this
.
_commentPost
);
},
/* 赞 */
praise
:
function
(
pid
,
target
)
{
$
.
bubble
.
unbind
();
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/doSupport/
"
+
pid
,
success
:
function
(
json
)
{
$
.
alert
.
ajaxSuccess
(
json
);
if
(
json
.
status
==
200
){
$
(
target
).
effectBubble
({
y
:
-
80
,
className
:
'
thumb-bubble
'
,
fontSize
:
1
,
content
:
'
<i class="fa fa-smile-o"></i>+1
'
});
var
oldCount
=
$
(
target
).
find
(
'
span.count
'
).
text
();
$
(
target
).
find
(
'
span.count
'
).
text
(
parseInt
(
oldCount
)
+
1
);
}
$
.
bubble
.
init
();
},
error
:
function
()
{
$
.
alert
.
ajaxError
();
$
.
bubble
.
init
();
}
});
},
/* 踩 */
step
:
function
(
pid
,
target
)
{
$
.
bubble
.
unbind
();
});
// 提交评论
this
.
_detailFormBtn
.
unbind
(
'
click
'
);
this
.
_detailFormBtn
.
click
(
function
()
{
$
.
comment
.
_detailForm
.
bootstrapValidator
(
"
validate
"
);
if
(
_form
.
valid
(
$
.
comment
.
_detailForm
))
{
data
=
data
+
"
&
"
+
$
.
comment
.
_detailForm
.
serialize
();
localStorage
.
setItem
(
$
.
comment
.
detailKey
,
$
.
comment
.
_detailForm
.
serialize
());
submitForm
(
data
);
}
});
function
submitForm
(
data
)
{
$
.
comment
.
_detailFormBtn
.
button
(
'
loading
'
);
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/doOppose/
"
+
pid
,
url
:
"
/api/comment
"
,
data
:
data
+
'
&sid=
'
+
$
.
comment
.
sid
,
success
:
function
(
json
)
{
$
.
comment
.
_detailFormBtn
.
button
(
'
reset
'
);
$
.
alert
.
ajaxSuccess
(
json
);
if
(
json
.
status
==
200
){
$
(
target
).
effectBubble
({
y
:
-
80
,
className
:
'
thumb-bubble
'
,
fontSize
:
1
,
content
:
'
<i class="fa fa-meh-o"></i>+1
'
});
var
oldCount
=
$
(
target
).
find
(
'
span.count
'
).
text
();
$
(
target
).
find
(
'
span.count
'
).
text
(
parseInt
(
oldCount
)
+
1
);
}
$
.
bubble
.
init
();
$
.
comment
.
_commentDetailModal
.
modal
(
'
hide
'
);
setTimeout
(
function
()
{
$this
.
html
(
"
<i class='fa fa-check'></i>
"
+
json
.
message
);
setTimeout
(
function
()
{
$this
.
button
(
'
reset
'
);
window
.
location
.
reload
();
},
3000
);
},
1000
);
},
error
:
function
()
{
error
:
function
(
data
)
{
$
.
alert
.
ajaxError
();
$
.
bubble
.
init
(
);
$
this
.
button
(
'
reset
'
);
}
});
},
/* 举报 */
report
:
function
(
pid
,
target
)
{
}
},
reply
:
function
(
pid
,
target
)
{
this
.
_commentPid
.
val
(
pid
);
this
.
_cancelReply
.
show
();
this
.
_commentPost
.
find
(
'
h5 i
'
).
addClass
(
"
shake
"
);
$
(
target
).
hide
();
$
(
target
).
parents
(
'
.comment-body
'
).
append
(
this
.
_commentPost
);
},
cancelReply
:
function
(
target
)
{
this
.
_commentPid
.
val
(
""
);
this
.
_cancelReply
.
hide
();
$
(
target
).
parents
(
"
.comment-body
"
).
find
(
'
.comment-reply
'
).
show
();
this
.
_commentPost
.
find
(
'
h5 i
'
).
addClass
(
"
shake
"
);
this
.
_commentPlace
.
append
(
this
.
_commentPost
);
},
/* 赞 */
praise
:
function
(
pid
,
target
)
{
$
.
bubble
.
unbind
();
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/doSupport/
"
+
pid
,
success
:
function
(
json
)
{
$
.
alert
.
ajaxSuccess
(
json
);
if
(
json
.
status
==
200
){
$
(
target
).
effectBubble
({
y
:
-
80
,
className
:
'
thumb-bubble
'
,
fontSize
:
1
,
content
:
'
<i class="fa fa-smile-o"></i>+1
'
});
var
oldCount
=
$
(
target
).
find
(
'
span.count
'
).
text
();
$
(
target
).
find
(
'
span.count
'
).
text
(
parseInt
(
oldCount
)
+
1
);
}
$
.
bubble
.
init
();
},
error
:
function
()
{
$
.
alert
.
ajaxError
();
$
.
bubble
.
init
();
}
});
},
/* 踩 */
step
:
function
(
pid
,
target
)
{
$
.
bubble
.
unbind
();
$
.
ajax
({
type
:
"
post
"
,
url
:
"
/api/doOppose/
"
+
pid
,
success
:
function
(
json
)
{
$
.
alert
.
ajaxSuccess
(
json
);
if
(
json
.
status
==
200
){
$
(
target
).
effectBubble
({
y
:
-
80
,
className
:
'
thumb-bubble
'
,
fontSize
:
1
,
content
:
'
<i class="fa fa-meh-o"></i>+1
'
});
var
oldCount
=
$
(
target
).
find
(
'
span.count
'
).
text
();
$
(
target
).
find
(
'
span.count
'
).
text
(
parseInt
(
oldCount
)
+
1
);
}
$
.
bubble
.
init
();
},
error
:
function
()
{
$
.
alert
.
ajaxError
();
$
.
bubble
.
init
();
}
});
},
/* 举报 */
report
:
function
(
pid
,
target
)
{
}
});
}
});
$
(
function
(){
$
.
comment
.
init
({
customMenu
:
true
});
$
(
"
#comment-form-btn
"
).
click
(
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录