提交 7f65b6ff 编写于 作者: Y yadong.zhang

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

2. 修复前台自动申请友链失败的问题
3. 其他一些问题
上级 d646d560
...@@ -90,6 +90,15 @@ _评论审核管理员_: 账号:comment-admin 密码:123456 ...@@ -90,6 +90,15 @@ _评论审核管理员_: 账号:comment-admin 密码:123456
### 更新日志 ### 更新日志
2018-05-25
**修改功能:**
1. 修复后台标签等分页失败的问题
2. 修复前台自动申请友链失败的问题
3. 其他一些问题
2018-05-22 2018-05-22
**修改功能:** **修改功能:**
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Article; import com.zyd.blog.business.entity.Article;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.entity.Config;
...@@ -64,7 +63,6 @@ public class RestArticleController { ...@@ -64,7 +63,6 @@ public class RestArticleController {
@RequiresPermissions("articles") @RequiresPermissions("articles")
@PostMapping("/list") @PostMapping("/list")
public PageResult list(ArticleConditionVO vo) { public PageResult list(ArticleConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Article> pageInfo = articleService.findPageBreakByCondition(vo); PageInfo<Article> pageInfo = articleService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Comment; import com.zyd.blog.business.entity.Comment;
import com.zyd.blog.business.entity.Config; import com.zyd.blog.business.entity.Config;
...@@ -65,7 +64,6 @@ public class RestCommentController { ...@@ -65,7 +64,6 @@ public class RestCommentController {
@RequiresPermissions("comments") @RequiresPermissions("comments")
@PostMapping("/list") @PostMapping("/list")
public PageResult list(CommentConditionVO vo) { public PageResult list(CommentConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Comment> pageInfo = commentService.findPageBreakByCondition(vo); PageInfo<Comment> pageInfo = commentService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Link; import com.zyd.blog.business.entity.Link;
import com.zyd.blog.business.enums.LinkSourceEnum; import com.zyd.blog.business.enums.LinkSourceEnum;
...@@ -56,7 +55,6 @@ public class RestLinkController { ...@@ -56,7 +55,6 @@ public class RestLinkController {
@PostMapping("/list") @PostMapping("/list")
public PageResult list(LinkConditionVO vo) { public PageResult list(LinkConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Link> pageInfo = linkService.findPageBreakByCondition(vo); PageInfo<Link> pageInfo = linkService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Notice; import com.zyd.blog.business.entity.Notice;
import com.zyd.blog.business.entity.User; import com.zyd.blog.business.entity.User;
...@@ -54,7 +53,6 @@ public class RestNoticeController { ...@@ -54,7 +53,6 @@ public class RestNoticeController {
@PostMapping("/list") @PostMapping("/list")
public PageResult list(NoticeConditionVO vo) { public PageResult list(NoticeConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Notice> pageInfo = noticeService.findPageBreakByCondition(vo); PageInfo<Notice> pageInfo = noticeService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Resources; import com.zyd.blog.business.entity.Resources;
import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.ResponseStatus;
...@@ -57,7 +56,6 @@ public class RestResourcesController { ...@@ -57,7 +56,6 @@ public class RestResourcesController {
@PostMapping("/list") @PostMapping("/list")
public PageResult getAll(ResourceConditionVO vo) { public PageResult getAll(ResourceConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Resources> pageInfo = resourcesService.findPageBreakByCondition(vo); PageInfo<Resources> pageInfo = resourcesService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Role; import com.zyd.blog.business.entity.Role;
import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.ResponseStatus;
...@@ -60,7 +59,6 @@ public class RestRoleController { ...@@ -60,7 +59,6 @@ public class RestRoleController {
@PostMapping("/list") @PostMapping("/list")
public PageResult getAll(RoleConditionVO vo) { public PageResult getAll(RoleConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Role> pageInfo = roleService.findPageBreakByCondition(vo); PageInfo<Role> pageInfo = roleService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Tags; import com.zyd.blog.business.entity.Tags;
import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.ResponseStatus;
...@@ -51,7 +50,6 @@ public class RestTagController { ...@@ -51,7 +50,6 @@ public class RestTagController {
@PostMapping("/list") @PostMapping("/list")
public PageResult list(TagsConditionVO vo) { public PageResult list(TagsConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Tags> pageInfo = tagsService.findPageBreakByCondition(vo); PageInfo<Tags> pageInfo = tagsService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.Template; import com.zyd.blog.business.entity.Template;
import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.ResponseStatus;
...@@ -51,7 +50,6 @@ public class RestTemplateController { ...@@ -51,7 +50,6 @@ public class RestTemplateController {
@PostMapping("/list") @PostMapping("/list")
public PageResult list(TemplateConditionVO vo) { public PageResult list(TemplateConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Template> pageInfo = templateService.findPageBreakByCondition(vo); PageInfo<Template> pageInfo = templateService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -51,7 +51,6 @@ public class RestTypeController { ...@@ -51,7 +51,6 @@ public class RestTypeController {
@PostMapping("/list") @PostMapping("/list")
public PageResult list(TypeConditionVO vo) { public PageResult list(TypeConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<Type> pageInfo = typeService.findPageBreakByCondition(vo); PageInfo<Type> pageInfo = typeService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.UpdateRecorde; import com.zyd.blog.business.entity.UpdateRecorde;
import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.ResponseStatus;
...@@ -51,7 +50,6 @@ public class RestUpdateController { ...@@ -51,7 +50,6 @@ public class RestUpdateController {
@PostMapping("/list") @PostMapping("/list")
public PageResult list(UpdateRecordeConditionVO vo) { public PageResult list(UpdateRecordeConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<UpdateRecorde> pageInfo = updateRecordeService.findPageBreakByCondition(vo); PageInfo<UpdateRecorde> pageInfo = updateRecordeService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
*/ */
package com.zyd.blog.controller; package com.zyd.blog.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.zyd.blog.business.entity.User; import com.zyd.blog.business.entity.User;
import com.zyd.blog.business.enums.ResponseStatus; import com.zyd.blog.business.enums.ResponseStatus;
...@@ -56,7 +55,6 @@ public class RestUserController { ...@@ -56,7 +55,6 @@ public class RestUserController {
@PostMapping("/list") @PostMapping("/list")
public PageResult list(UserConditionVO vo) { public PageResult list(UserConditionVO vo) {
PageHelper.startPage(vo.getPageNumber() - 1, vo.getPageSize());
PageInfo<User> pageInfo = userService.findPageBreakByCondition(vo); PageInfo<User> pageInfo = userService.findPageBreakByCondition(vo);
return ResultUtil.tablePage(pageInfo); return ResultUtil.tablePage(pageInfo);
} }
......
...@@ -21,6 +21,7 @@ package com.zyd.blog.business.aspect; ...@@ -21,6 +21,7 @@ package com.zyd.blog.business.aspect;
import com.zyd.blog.business.annotation.RedisCache; import com.zyd.blog.business.annotation.RedisCache;
import com.zyd.blog.framework.property.AppProperties; import com.zyd.blog.framework.property.AppProperties;
import com.zyd.blog.util.CacheKeyUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature; import org.aspectj.lang.Signature;
...@@ -31,12 +32,9 @@ import org.aspectj.lang.reflect.MethodSignature; ...@@ -31,12 +32,9 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
/** /**
* Redis业务层数据缓存 * Redis业务层数据缓存
...@@ -75,41 +73,24 @@ public class RedisCacheAspect { ...@@ -75,41 +73,24 @@ public class RedisCacheAspect {
if (!currentMethod.isAnnotationPresent(RedisCache.class)) { if (!currentMethod.isAnnotationPresent(RedisCache.class)) {
throw new RuntimeException("未指定RedisChache注解!"); throw new RuntimeException("未指定RedisChache注解!");
} }
// 获取拦截方法的参数 StringBuilder key = new StringBuilder(point.getTarget().getClass().getName());
String className = point.getTarget().getClass().getName();
String methodName = currentMethod.getName();
// 获取操作名称 // 获取操作名称
RedisCache cache = currentMethod.getAnnotation(RedisCache.class); RedisCache cache = currentMethod.getAnnotation(RedisCache.class);
boolean flush = cache.flush(); if (cache.flush()) {
StringBuilder key = new StringBuilder(); log.info("{}*-清空缓存", key);
//类名 + 方法名 Set<String> keys = redisTemplate.keys(key.toString() + "*");
key.append(className).append(".").append(methodName); redisTemplate.delete(keys);
if (flush) {
log.info("{}-清空缓存", key.toString());
Set<String> keys = redisTemplate.keys(className + "*");
if (!CollectionUtils.isEmpty(keys)) {
redisTemplate.delete(keys);
}
log.info("Clear all the cached query result from redis"); log.info("Clear all the cached query result from redis");
return point.proceed(); return point.proceed();
} }
long expire = cache.expire(); key.append(".").append(currentMethod.getName());
TimeUnit unit = cache.unit(); key.append(CacheKeyUtil.getMethodParamsKey(point.getArgs())).append(cache.key());
Object[] params = point.getArgs(); String realKey = key.toString();
if (StringUtils.isEmpty(cache.key())) {
if (null != params && params.length > 0) {
for (Object obj : params) {
key.append(obj.toString());
}
}
} else {
key.append(cache.key());
}
// 缓存存在 // 缓存存在
boolean hasKey = redisTemplate.hasKey(key.toString()); boolean hasKey = redisTemplate.hasKey(realKey);
if (hasKey) { if (hasKey) {
try { try {
log.info("{}从缓存中获取数据", key.toString()); log.info("{}从缓存中获取数据", realKey);
return redisTemplate.opsForValue().get(key); return redisTemplate.opsForValue().get(key);
} catch (Exception e) { } catch (Exception e) {
log.error("从缓存中获取数据失败!", e); log.error("从缓存中获取数据失败!", e);
...@@ -118,9 +99,9 @@ public class RedisCacheAspect { ...@@ -118,9 +99,9 @@ public class RedisCacheAspect {
// 先执行业务 // 先执行业务
Object result = point.proceed(); Object result = point.proceed();
// 向Redis中添加数据,有效时间是30天 // 向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("Put query result to redis");
log.info("{}从数据库中获取数据", key.toString()); log.info("{}从数据库中获取数据", realKey);
return result; return result;
} }
} }
...@@ -87,7 +87,6 @@ public class BizCommentServiceImpl implements BizCommentService { ...@@ -87,7 +87,6 @@ public class BizCommentServiceImpl implements BizCommentService {
* @return * @return
*/ */
@Override @Override
// @RedisCache
public PageInfo<Comment> findPageBreakByCondition(CommentConditionVO vo) { public PageInfo<Comment> findPageBreakByCondition(CommentConditionVO vo) {
PageHelper.startPage(vo.getPageNumber(), vo.getPageSize()); PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
List<BizComment> list = bizCommentMapper.findPageBreakByCondition(vo); List<BizComment> list = bizCommentMapper.findPageBreakByCondition(vo);
......
...@@ -59,7 +59,6 @@ public class BizTagsServiceImpl implements BizTagsService{ ...@@ -59,7 +59,6 @@ public class BizTagsServiceImpl implements BizTagsService{
* @return * @return
*/ */
@Override @Override
@RedisCache
public PageInfo<Tags>findPageBreakByCondition(TagsConditionVO vo){ public PageInfo<Tags>findPageBreakByCondition(TagsConditionVO vo){
PageHelper.startPage(vo.getPageNumber(),vo.getPageSize()); PageHelper.startPage(vo.getPageNumber(),vo.getPageSize());
List<BizTags>list=bizTagsMapper.findPageBreakByCondition(vo); List<BizTags>list=bizTagsMapper.findPageBreakByCondition(vo);
......
...@@ -72,7 +72,6 @@ public class SysLinkServiceImpl implements SysLinkService { ...@@ -72,7 +72,6 @@ public class SysLinkServiceImpl implements SysLinkService {
* @return * @return
*/ */
@Override @Override
@RedisCache
public PageInfo<Link> findPageBreakByCondition(LinkConditionVO vo) { public PageInfo<Link> findPageBreakByCondition(LinkConditionVO vo) {
PageHelper.startPage(vo.getPageNumber(), vo.getPageSize()); PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
List<SysLink> list = sysLinkMapper.findPageBreakByCondition(vo); List<SysLink> list = sysLinkMapper.findPageBreakByCondition(vo);
...@@ -172,11 +171,6 @@ public class SysLinkServiceImpl implements SysLinkService { ...@@ -172,11 +171,6 @@ public class SysLinkServiceImpl implements SysLinkService {
throw new ZhydLinkException("贵站暂未添加本站友情链接!请先添加本站友链后重新提交申请!"); throw new ZhydLinkException("贵站暂未添加本站友情链接!请先添加本站友链后重新提交申请!");
} }
// if (LinksUtil.checkFavicon(link.getFavicon())) {
// bo.setFavicon(link.getFavicon());
// } else {
// bo.setFavicon(link.getFavicon());
// }
link.setSource(LinkSourceEnum.AUTOMATIC); link.setSource(LinkSourceEnum.AUTOMATIC);
link.setStatus(true); link.setStatus(true);
if(!StringUtils.isEmpty(link.getEmail())){ 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) + ")";
}
}
...@@ -73,7 +73,7 @@ public class RestClientUtil { ...@@ -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) { public static String request(String method, String urlString, Map<String, Object> params, String encode, Map<String, String> requestHeader) {
// 解决因jdk版本问题造成的SSL请求失败的问题 // 解决因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; final HttpURLConnection connection;
try { try {
connection = openConnection(urlString); connection = openConnection(urlString);
......
...@@ -48,7 +48,9 @@ ...@@ -48,7 +48,9 @@
AND t.home_page_display = #{homePageDisplay} AND t.home_page_display = #{homePageDisplay}
</if> </if>
ORDER BY ORDER BY
(t. STATUS > 0) DESC, t. STATUS ASC (t. STATUS > 0) DESC,
t. STATUS ASC,
t.create_time DESC
</select> </select>
</mapper> </mapper>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册