提交 4f0b8a91 编写于 作者: Y yadong.zhang

1. 修复后台标签等分页失败的问题

2. 修复前台自动申请友链失败的问题
3. 其他一些问题
上级 4df2aa18
......@@ -90,6 +90,15 @@ _评论审核管理员_: 账号:comment-admin 密码:123456
### 更新日志
2018-05-25
**修改功能:**
1. 修复后台标签等分页失败的问题
2. 修复前台自动申请友链失败的问题
3. 其他一些问题
2018-05-22
**修改功能:**
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -51,8 +51,8 @@
pagination: true, //是否显示分页(*)
sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*)
pageList: [10, 20, 30, 50, 100], //可供选择的每页的行数(*)
pageSize: 20, //每页的记录行数(*)
pageList: [20, 40, 50, 100, 150], //可供选择的每页的行数(*)
search: true, //是否启用搜索框 根据sidePagination选择从前后台搜索
strictSearch: true, //设置为 true启用 全匹配搜索,否则为模糊搜索
searchOnEnterKey: true, // 设置为 true时,按回车触发搜索方法,否则自动触发搜索方法
......@@ -65,7 +65,7 @@
// exportDataType: "basic", //basic', 'all', 'selected'.
// clickToSelect: true, //是否启用点击选中行
// singleSelect: true,
// height: 505, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
height: 440, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
onEditableSave: function (field, row, oldValue, $el) {
if (options.updateUrl) {
$.ajax({
......
<#include "layout/header.ftl"/>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12">
<div class="x_panel">
<div class="x_title">
<h2>Checkbox Operation</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i
class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Settings 1</a>
</li>
<li><a href="#">Settings 2</a>
</li>
</ul>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<ul id="treeDemo" class="ztree"></ul>
</div>
</div>
</div>
</div>
</div>
<#include "layout/footer.ftl"/>
<SCRIPT type="text/javascript">
var setting = {
check: {
enable: true,
chkboxType: {"Y": "ps", "N": "ps"},
chkStyle: "checkbox"
},
data: {
simpleData: {
enable: true
}
},
callback: {
onCheck: onCheck
}
};
var tree = "";
//查询菜单信息
$.post('/getZtree', {rid: 1}, function (zNodes) {
for (var i = 0; i < zNodes.length; i++) {
if (zNodes[i].pId) {
zNodes[i].checked = true;
} else {
//zNodes[i].icon = "/images/532.ico";//设置图标
}
}
tree = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
tree.expandAll(true);//全部展开
}, 'json');
function onCheck(event, treeId, treeNode) {
console.log(treeNode.tId + ", " + treeNode.name + "," + treeNode.checked);
var treeObj = $.fn.zTree.getZTreeObj(treeId);
var nodes = treeObj.getCheckedNodes(true);
var ids = new Array();
for (var i = 0; i < nodes.length; i++) {
//获取选中节点的值
ids.push(nodes[i].id);
}
console.log(ids);
ajaxSubmit(0, ids);
}
//角色-菜单信息入库
function ajaxSubmit(rid, idstr) {
console.log("保存角色信息...");
// $.post("/roleMenu/bindSaveInfoEvent.jhtml", {"roleId": rid, "ids": idstr}, function (obj) {
// }, 'json');
}
</SCRIPT>
\ No newline at end of file
......@@ -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;
}
}
......@@ -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);
......
......@@ -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);
......
......@@ -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())){
......
/**
* 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) + ")";
}
}
......@@ -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>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册