文章管理点击量查询逻辑更改

This commit is contained in:
zkr_liushenlu 2021-04-07 17:01:09 +08:00
parent 52634eda67
commit 59c998e8dd
4 changed files with 21 additions and 18 deletions

View File

@ -14,7 +14,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@ -304,7 +303,6 @@ public class ArticleManageController extends BaseController {
* 保存(更新)文章静态页面 @Title: updateArticle @Description: TODO() @param @return * 保存(更新)文章静态页面 @Title: updateArticle @Description: TODO() @param @return
* 参数 @return Message 返回类型 @throws * 参数 @return Message 返回类型 @throws
*/ */
@CrossOrigin(allowCredentials = "true", allowedHeaders = "*", origins = "*", maxAge = 1800)
@RequestMapping("/updateArticle") @RequestMapping("/updateArticle")
@ResponseBody @ResponseBody
public Message updateArticle(HttpServletRequest request, HttpServletResponse response) { public Message updateArticle(HttpServletRequest request, HttpServletResponse response) {

View File

@ -1017,7 +1017,7 @@
cache: false, cache: false,
success: function (data) { success: function (data) {
if (data.result) { if (data.result) {
$.modal.open('文章预览', data.object.editUrl) $.modal.open('文章预览', data.object.editUrl + '?l=1')
} else { } else {
$.modal.alertError("预览失败,请稍后重试!"); $.modal.alertError("预览失败,请稍后重试!");

View File

@ -269,6 +269,7 @@ public class ShiroConfig
// Shiro连接约束配置即过滤链的定义 // Shiro连接约束配置即过滤链的定义
LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>(); LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
// 对静态资源设置匿名访问 // 对静态资源设置匿名访问
filterChainDefinitionMap.put("/article/updateArticle", "anon");
filterChainDefinitionMap.put("/favicon.ico**", "anon"); filterChainDefinitionMap.put("/favicon.ico**", "anon");
filterChainDefinitionMap.put("/ruoyi.png**", "anon"); filterChainDefinitionMap.put("/ruoyi.png**", "anon");
filterChainDefinitionMap.put("/css/**", "anon"); filterChainDefinitionMap.put("/css/**", "anon");

View File

@ -3,6 +3,8 @@ package com.ruoyi.framework.interceptor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@ -13,40 +15,42 @@ import com.ruoyi.common.utils.ServletUtils;
/** /**
* 防止重复提交拦截器 * 防止重复提交拦截器
* *
* @author ruoyi * @author ruoyi
*/ */
@Component @Component
public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter {
{
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
{ response.setHeader("Access-control-Allow-Origin", request.getHeader("Origin"));
if (handler instanceof HandlerMethod) response.setHeader("Access-Control-Allow-Credentials", "true");
{ response.setHeader("Access-Control-Allow-Headers", request.getHeader("Access-Control-Request-Headers"));
response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT");
if ("OPTIONS".equals(request.getMethod())) {
response.setStatus(HttpStatus.OK.value());
return false;
}
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler; HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod(); Method method = handlerMethod.getMethod();
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
if (annotation != null) if (annotation != null) {
{ if (this.isRepeatSubmit(request)) {
if (this.isRepeatSubmit(request))
{
AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试"); AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试");
ServletUtils.renderString(response, JSON.marshal(ajaxResult)); ServletUtils.renderString(response, JSON.marshal(ajaxResult));
return false; return false;
} }
} }
return true; return true;
} } else {
else
{
return super.preHandle(request, response, handler); return super.preHandle(request, response, handler);
} }
} }
/** /**
* 验证是否重复提交由子类实现具体的防重复提交的规则 * 验证是否重复提交由子类实现具体的防重复提交的规则
* *
* @param request * @param request
* @return * @return
* @throws Exception * @throws Exception