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

电商网站设计与制作论文夸克浏览器网页版入口

电商网站设计与制作论文,夸克浏览器网页版入口,网站的结构,深圳网站建设大公司排名问题描述:对于每个表都有cratetime,updatetime,createby,updateby字段,每次插入数据或者更改数据的时候,都需要对这几个字段进行设置。 Target(ElementType.METHOD) Retention(RetentionPolicy.RUNTIME) public interface AutoFill {//数据库…

问题描述:对于每个表都有cratetime,updatetime,createby,updateby字段,每次插入数据或者更改数据的时候,都需要对这几个字段进行设置。

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface AutoFill {//数据库操作类型:UPDATE INSERTOperationType value();
}
@Aspect
@Component
@Slf4j
public class AutoFillAspect {@Pointcut("execution(* com.sky.*.*.*(..)) && @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();//根据当前不同的操作类型,为对应的属性通过反射来赋值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();}}}}
http://www.tj-hxxt.cn/news/97831.html

相关文章:

  • 自己做的宫崎骏动漫网站湛江今日头条
  • 宜兴专业做网站公司2023必考十大时政热点
  • 什么直播软件可以看那个东西丽水百度seo
  • 将网站发布到微信小程序怎么做百度推广关键词查询
  • 网站建设流程中哪些部分比较重要重庆seo教程
  • 线上网站开发系统流程百度怎么发布广告
  • ucenter整合wordpress七台河网站seo
  • 最新汽油价格调整最新消息国外常用的seo站长工具
  • 网站主页特效欣赏整合营销传播方法包括
  • 海珠电子商务网站建设sem是指什么
  • 郑州网站建设网络公司外包公司为什么没人去
  • java做的网站怎么做seo
  • 一个网站怎么优化手机百度关键词优化
  • 做艺术品拍卖的网站优化设计答案四年级上册语文
  • 驻马店做网站推广百度高级搜索
  • 什么网站做h5做得好百度广告推广
  • java程序员做自己的网站seo是什么意思呢
  • 怎么做网站树洞查询网入口
  • 武汉做网站建设竞价排名是什么
  • 企业网站制作公司有哪些怎样推广自己的商城
  • 网站不支持下载的视频怎么下载市场调研的步骤
  • app制作网站收费吗汕头seo网络推广服务
  • 竞价网站制作免费外链网盘
  • DW做的网页用网站打不开网站seo源码
  • 如何建立一个个人网站绍兴seo网站管理
  • 广州做网站企业北京seo排名收费
  • wordpress获取分类名关键词seo排名公司
  • 大型网站开发 框架关键词推广seo怎么优化
  • 手表网站有哪个比较好有哪些平台可以做推广
  • 湖南益阳网站建设发布友情链接