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

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

2. 修复前台自动申请友链失败的问题
3. 其他一些问题
上级 d646d560
......@@ -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);
}
......
......@@ -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) + ")";
}
}
......@@ -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);
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册