当前位置: 首页 > news >正文

如何增加网站索引量律师建网站

如何增加网站索引量,律师建网站,seo现在还有前景吗,网站模板用什么做文章目录 依赖注解aophelperTest 免责声明#xff1a;本人无意侵权#xff0c;奈何找不到原文作者#xff0c;也找不到网址#xff0c;于是自己记录一下#xff0c;如果有侵权之嫌#xff0c;请联系我删除文章 依赖 !-- https://mvnrepository.com/artifact/com.goo… 文章目录 依赖注解aophelperTest 免责声明本人无意侵权奈何找不到原文作者也找不到网址于是自己记录一下如果有侵权之嫌请联系我删除文章 依赖 !-- https://mvnrepository.com/artifact/com.google.guava/guava --dependencygroupIdcom.google.guava/groupIdartifactIdguava/artifactIdversion32.1.3-jre/version/dependency注解 import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target;Target(value ElementType.METHOD) Retention(value RetentionPolicy.RUNTIME) public interface RateConfigAnno {String limitType();double limitCount() default 5d; }aop import cn.hutool.core.thread.ThreadUtil; import com.alibaba.fastjson2.JSONObject; import com.google.common.util.concurrent.RateLimiter; import com.tjbchtyw.tjflowcontrol.annocation.RateConfigAnno; import com.tjbchtyw.tjflowcontrol.helper.RateLimitHelper; import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServletResponse; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes;import java.io.IOException; import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.util.Objects;Aspect Component public class GuavaLimitAop {private static final Logger logger LoggerFactory.getLogger(GuavaLimitAop.class);Before(annotation(com.tjbchtyw.tjflowcontrol.annocation.RateConfigAnno))public void limit(JoinPoint joinPoint) {//1、获取当前的调用方法Method currentMethod getCurrentMethod(joinPoint);if (Objects.isNull(currentMethod)) {return;}//2、从方法注解定义上获取限流的类型String limitType currentMethod.getAnnotation(RateConfigAnno.class).limitType();double limitCount currentMethod.getAnnotation(RateConfigAnno.class).limitCount();//使用guava的令牌桶算法获取一个令牌获取不到先等待RateLimiter rateLimiter RateLimitHelper.getRateLimiter(limitType, limitCount);// boolean b true;boolean pass rateLimiter.tryAcquire();if (pass) {System.out.println(获取到令牌);}else {//重试 仅测试用 有优化方案可以放在评论区for (int i 0; i 5; i) {ThreadUtil.safeSleep(1000);System.out.println(第 (i 1) 次获取令牌);if(rateLimiter.tryAcquire()) break;if(i 4){System.out.println(在第 (i 1) 次后未获取到令牌 开始限流);HttpServletResponse resp ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse();JSONObject jsonObjectnew JSONObject();jsonObject.put(success,false);jsonObject.put(msg,限流中);try {output(resp, jsonObject.toJSONString());}catch (Exception e){logger.error(error,e:{},e);}}}}}private Method getCurrentMethod(JoinPoint joinPoint) {Method[] methods joinPoint.getTarget().getClass().getMethods();Method target null;for (Method method : methods) {if (method.getName().equals(joinPoint.getSignature().getName())) {target method;break;}}return target;}public void output(HttpServletResponse response, String msg) throws IOException {response.setContentType(application/json;charsetUTF-8);ServletOutputStream outputStream null;try {outputStream response.getOutputStream();outputStream.write(msg.getBytes(StandardCharsets.UTF_8));} catch (IOException e) {e.printStackTrace();} finally {outputStream.flush();outputStream.close();}} }helper import com.google.common.util.concurrent.RateLimiter;import java.util.HashMap; import java.util.Map;public class RateLimitHelper {private RateLimitHelper(){}private static final MapString,RateLimiter rateMap new HashMap();public static RateLimiter getRateLimiter(String limitType, double limitCount ){RateLimiter rateLimiter rateMap.get(limitType);if(rateLimiter null){rateLimiter RateLimiter.create(limitCount);rateMap.put(limitType,rateLimiter);}return rateLimiter;}}Test RestControllerTag(name 测试Controller, description 这是描述)RequestMapping(/pred-api)public class FlowController {AutowiredFlowContext flowContext;PostMapping(/pdf/test)//Count 限制次数RateConfigAnno(limitType makePdf,limitCount 15)Operation(summary 限流接口)public String flowCont(Parameter(name pdfParam, description 参数对象,type标识执行不同的策略) RequestBody Param Param) {return test;}}
http://www.pierceye.com/news/63715/

相关文章:

  • 平江高端网站建设绍兴哪些公司做网站
  • 网站建设技术服务协议网站建设所需硬件参数
  • 重庆建网站企业有哪些怎么把网站做seo到首页
  • 搜书网站 怎么做安徽城乡建设厅官方网站
  • 洛阳建站洛阳市网站建设wordpress茶叶主题
  • 网站导航栏按钮企业网站建设渠道
  • 西安市建设局网站邯郸做网站代理
  • 个人网站推荐免费电气网站设计
  • 一起做网店官方网站公司网站的定义
  • 青海城乡建设部网站首页八零云自助建站免费建站平台
  • 网站建设兼职平台邢台市住建局
  • 网站项目实施方案腾讯云服务器搭建WordPress
  • 简述网站设计基本流程动态站 网站地图怎么做
  • 完整网站建设案例教程网页设计企业宣传网站
  • 阿里巴巴网站做销售方案重庆响应式网站建设
  • 网站注销申请表离职模板网
  • 河南做网站推广哪个好建设pc 移动网站
  • 专做排名的网站电商网站 外包
  • 我的世界是谁做的视频网站导购网站一站式建站
  • 免费的写作网站物联网的含义是什么意思
  • 有了网站模板 还要怎样做网页设计在哪里接单
  • 建设网站需要什么基础知识莆田网站开发公司电话
  • 怎么把asp网站改成php太原关键词排名推广
  • 域名解析站长工具建筑工程网价是什么意思
  • 阿里云建站售前咨询2023年ppt模板免费
  • 文昌湖城乡建设局网站织梦高端大气网站模板
  • 网站免费空间哪个好更改wordpress语言设置
  • 建站小软件山西网站制作工具
  • 上海网站原型设计wordpress 点赞 ajax
  • 手机个人简历模板下载网站模板wordpress 3.3.1漏洞