1.日志切面定义
@Aspect @Component public class LogAspect { @Around(value =
"@annotation(log)") public Object log(ProceedingJoinPoint joinPoint, Log log)
throws Throwable { Object result = joinPoint.proceed(); //do something else
Map<String,Object> map = new HashMap<>(); map.put("userDo",result); Object id =
new SimpleTemplateEngine().createTemplate(log.id()).make(map); Object content =
new SimpleTemplateEngine().createTemplate(log.content()).make(map); return
result; } }
2.日志注解定义
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME) @Inherited @Documented public @interface
Log { String id() default ""; String content() default ""; }
3.实体类定义
@Data public class UserDo { private Long id; private String userName; private
int age; }
4.接口和实现定义
public interface UserService { UserDo add(UserDo userDo); } @Component public
class UserServiceImpl implements UserService { @Override @Log(id =
"${userDo.id}", content = "${userDo}") public UserDo add(UserDo userDo) {
userDo.setId(1L); userDo.setUserName("张三"); userDo.setAge(18); return userDo; }
}
 

技术
©2020 ioDraw All rights reserved
python简单小游戏代码-10分钟用Python编写一个贪吃蛇小游戏,简单Linux之父:C++语言很烂 不会改用其重写Linux内核webpack配置postcss-loader无效简单的学生成绩管理系统歌词格式转化,trc转lrcGO语言学习笔记【webpack】DLL plugin原理分析伪造ACK实现TCP数据注入调研组织结构图消息称华为招聘半导体设备人才 网友:光刻机是刚需