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

东莞seo关键词排名优化推广网站优化最为重要的内容是

东莞seo关键词排名优化推广,网站优化最为重要的内容是,网站推广专家,网站建设课程设计心得体会[公共字段自动填充] 核心:在切面类中捕获需要填充公共字段的 Mapper 方法,方法上使用注解加以标识,通过反射拿到需要填充的字段赋值方法,进行赋值操作 1、自定义注解 AutoFill Target(ElementType.METHOD) Retention(RetentionPo…

[公共字段自动填充]

核心:在切面类中捕获需要填充公共字段的 Mapper 方法,方法上使用注解加以标识,通过反射拿到需要填充的字段赋值方法,进行赋值操作

1、自定义注解 AutoFill

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface AutoFill {//数据库操作类型:UPDATE INSERTOperationType value();
}

2、枚举对象类

public enum OperationType {/*** 更新操作*/UPDATE,/*** 插入操作*/INSERT
}

3、自定义切面 AutoFillAspect

@Aspect
@Component
@Slf4j
public class AutoFillAspect {/*** 切入点*/@Pointcut("execution(* com.sky.mapper.*.*(..)) && @annotation(com.sky.annotation.AutoFill)")public void autoFillPointCut(){}/*** 前置通知,在通知中进行公共字段的赋值*/@Before("autoFillPointCut()")public void autoFill(JoinPoint joinPoint){log.info("开始进行公共字段自动填充...");//获取到当前被拦截的方法上的数据库操作类型MethodSignature signature = (MethodSignature) joinPoint.getSignature();//方法签名对象AutoFill autoFill = signature.getMethod().getAnnotation(AutoFill.class);//获得方法上的注解对象OperationType operationType = autoFill.value();//获得数据库操作类型//获取到当前被拦截的方法的参数--实体对象Object[] args = joinPoint.getArgs();if(args == null || args.length == 0){return;}//约定好放在第一个参数位置Object entity = args[0];//准备赋值的数据LocalDateTime now = LocalDateTime.now();Long currentId = BaseContext.getCurrentId();//就是获取修改人的id值,不同项目不同的获取方法//根据当前不同的操作类型,为对应的属性通过反射来赋值if(operationType == OperationType.INSERT){//为4个公共字段赋值try {Method setCreateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_CREATE_TIME, LocalDateTime.class);Method setCreateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_CREATE_USER, Long.class);Method setUpdateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_TIME, LocalDateTime.class);Method setUpdateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_USER, Long.class);//通过反射为对象属性赋值setCreateTime.invoke(entity,now);setCreateUser.invoke(entity,currentId);setUpdateTime.invoke(entity,now);setUpdateUser.invoke(entity,currentId);} catch (Exception e) {e.printStackTrace();}}else if(operationType == OperationType.UPDATE){//为2个公共字段赋值try {Method setUpdateTime = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_TIME, LocalDateTime.class);Method setUpdateUser = entity.getClass().getDeclaredMethod(AutoFillConstant.SET_UPDATE_USER, Long.class);//通过反射为对象属性赋值setUpdateTime.invoke(entity,now);setUpdateUser.invoke(entity,currentId);} catch (Exception e) {e.printStackTrace();}}}
}

4、在Mapper接口的方法上加入 AutoFill 注解

@Mapper
public interface CategoryMapper {/*** 插入数据* @param category*/@AutoFill(value = OperationType.INSERT)void insert(Category category);/*** 根据id修改分类* @param category*/@AutoFill(value = OperationType.UPDATE)void update(Category category);}
http://www.15wanjia.com/news/31085.html

相关文章:

  • frontpage网站建设论文足球世界排名
  • 上海这边敲墙拆旧做啥网站的比较多电商网站平台搭建
  • 企业网站的网络营销功能给网站做seo的价格
  • 贵阳网站建设专家海外推广运营
  • 漳州微信网站建设电话优化疫情二十条措施
  • 做网站的公司应该税率多少互联网广告怎么做
  • 网站的动态新闻数据库怎么做万网域名官网
  • 鞍山网站制作网站建设合同
  • wordpress好用的空间windows优化大师使用方法
  • qq小程序游戏入口seo排名优化怎样
  • 常州云计算网站建设磁力帝
  • 专业建站开发淘宝美工培训
  • 免费婚纱摄影网站模板软文推广的优点
  • 商城网站定制怎么做baidu优化
  • 网站php源码破解版seo高级优化技巧
  • 河南电力建设工程公司网站网站怎么才能被百度收录
  • 南阳做网站seo的站长统计app软件下载
  • 湖南疫情最新消息2019百度seo关键词排名优化教程
  • 我要浏览国外网站怎么做广告关键词有哪些
  • 项目网发布信息平台郑州seo优化顾问
  • 一个新的网站怎么做宣传软件开发一般需要多少钱
  • 网站备案号怎么制作网页推广
  • 网站怎么做数据接口短视频怎么赚钱
  • 网站备案需要哪些资料网站推广软件免费版
  • wordpress伪静态 404杭州seo排名费用
  • 昆明做百度网站电话网店培训班
  • 政府类网站建设总结wordpress建站公司
  • 成都高级网站建设百度百科词条入口
  • wordpress仿站实战教程今日武汉最新消息
  • 怎么建设好一个外贸购物网站免费网站搭建平台