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

自做网站视频灰色关键词排名代发

自做网站视频,灰色关键词排名代发,网页设计平面设计,开发安卓app实现思路 首先自定义参数注解,然后根据AOP思想,找到该注解作用的切点,也就是mapper层对于mapper层的接口在执行前都会执行该aop操作:获取到对于的方法对象,根据方法对象获取参数列表,根据参数列表判断某个…
实现思路

首先自定义参数注解,然后根据AOP思想,找到该注解作用的切点,也就是mapper层对于mapper层的接口在执行前都会执行该aop操作:获取到对于的方法对象,根据方法对象获取参数列表,根据参数列表判断某个参数上是否加有自定义的注解,如果有则读取注解中的value值,并通过传入对象的引用拿到该对象,此时判断该对象的id值是否位空,如果为空则生成全局唯一id并赋值

代码实现
package com.cloud.cloud_oj_learn.aspects;import com.cloud.cloud_oj_common.annotations.GenerateId;
import com.cloud.cloud_oj_common.enums.Keys;
import jakarta.annotation.Resource;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;/*** Created with IntelliJ IDEA.* Description:* User: PG* Date: 2024-04-16* Time: 18:49*/
@Aspect
@Component
public class GenerateIdAspect {@Resourceprivate StringRedisTemplate stringRedisTemplate;// 初始时间戳private static final long BEGIN_TIME = 1640995200L;// 序列化位数private static final int BITE = 32;public Long getNext(String tableName) {// 1.生成时间戳LocalDateTime now = LocalDateTime.now();long nowSecond = now.toEpochSecond(ZoneOffset.UTC);long timestamp = nowSecond - BEGIN_TIME;// 2,生成序列化号String date = now.format(DateTimeFormatter.ofPattern("yyyy:MM:dd"));long count = stringRedisTemplate.opsForValue().increment(Keys.GENERATE_ID.getKey() + tableName + ":" + date);// 3.拼接  返回return Long.valueOf(timestamp << BITE | count);}@Before("execution(* com.cloud.cloud_oj_learn.mapper.*.*(..))")public void before(JoinPoint joinPoint) {// 获取方法签名MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();// 获取方法对象Method method = methodSignature.getMethod();// 获取方法参数值数组Object[] args = joinPoint.getArgs();// 获取方法注解Annotation[][] parameterAnnotations = method.getParameterAnnotations();for (int i = 0; i < parameterAnnotations.length; i++) {for (Annotation annotation : parameterAnnotations[i]) {if (annotation instanceof GenerateId) {try {// 获取参数对象Object arg = args[i];// 获取这个对象的类文件Class<?> clazz = arg.getClass();// 获取这个对象的id属性Field idField = clazz.getDeclaredField("id");// 设置字段修改权限idField.setAccessible(true);// 获取注解上的value值String value = ((GenerateId) annotation).value();// 获取该value对应的下一个idLong nextId = getNext(value);// 判断是否为空, 如果为空就赋值 if (idField.get(arg) == null) {idField.set(arg, nextId);}} catch (NoSuchFieldException | IllegalAccessException e) {throw new RuntimeException(e);}}}}}}

图示

http://www.ritt.cn/news/8633.html

相关文章:

  • 网站建设业务的延伸性百度高级搜索网址
  • 网站首页的布局设计游戏推广员怎么做
  • 什么企业做网站比较方便呢百度云网站入口
  • 张家港建设银行网站爱站网 关键词挖掘工具
  • 郑州最新发布信息网站seo公司
  • 网站换ip注意南昌网站开发公司
  • 给博彩做网站手机网站建设
  • 上海品划网站建设有限公司推广软件
  • 深圳集团网站建设汕头seo
  • 做婚庆网站图片下载百度客户端电脑版下载
  • 给人做logo的网站最新新闻实时新闻
  • 响应式营销网站阿里巴巴官网
  • 中小企业网站建设案例百度推广客服投诉电话
  • 中国建设人才信息网运营推广seo招聘
  • 湖南省网站集约化建设实施方案网络推广培训去哪里好
  • 注册域名哪个网站好竞价软件哪个好
  • 什么是无主体新增网站seo短视频入口
  • 做网站图片教程百度广告点击软件源码
  • wordpress阿里云域名转移志鸿优化设计电子版
  • 旅游网站制作 价格网络宣传的方法有哪些
  • 直接做的黄页视频网站百度推广客户端手机版下载
  • html 音乐网站简述网站制作的步骤
  • 网站建设费用的会计分录成都有实力的seo团队
  • 怎么下载网站的视频中国移动有免费的视频app
  • 深圳网站设计制作网络推广公司是干什么
  • 比较好的平面设计网站最快新闻资讯在哪看
  • 推荐几个响应式网站做参考广告推广免费
  • 长春网站建设推荐网诚传媒长春seo技术
  • 景区门户网站建设方案深圳网络推广公司
  • 广西城乡建设网站免费seo营销软件