entity-bizlog-spring-boot-starter

一个OLTP数据库JPA日志拦截记录的springboot框架

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

cn.idugou.bizlog
ArtifactId

ArtifactId

entity-bizlog-spring-boot-starter
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

entity-bizlog-spring-boot-starter
一个OLTP数据库JPA日志拦截记录的springboot框架
Project URL

Project URL

https://github.com/hjjoe1213123/entity-bizlog-spring-boot-starter
Source Code Management

Source Code Management

https://github.com/hjjoe1213123/entity-bizlog-spring-boot-starter

Download entity-bizlog-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/cn.idugou.bizlog/entity-bizlog-spring-boot-starter/ -->
<dependency>
    <groupId>cn.idugou.bizlog</groupId>
    <artifactId>entity-bizlog-spring-boot-starter</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/cn.idugou.bizlog/entity-bizlog-spring-boot-starter/
implementation 'cn.idugou.bizlog:entity-bizlog-spring-boot-starter:1.0.1'
// https://jarcasting.com/artifacts/cn.idugou.bizlog/entity-bizlog-spring-boot-starter/
implementation ("cn.idugou.bizlog:entity-bizlog-spring-boot-starter:1.0.1")
'cn.idugou.bizlog:entity-bizlog-spring-boot-starter:jar:1.0.1'
<dependency org="cn.idugou.bizlog" name="entity-bizlog-spring-boot-starter" rev="1.0.1">
  <artifact name="entity-bizlog-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.idugou.bizlog', module='entity-bizlog-spring-boot-starter', version='1.0.1')
)
libraryDependencies += "cn.idugou.bizlog" % "entity-bizlog-spring-boot-starter" % "1.0.1"
[cn.idugou.bizlog/entity-bizlog-spring-boot-starter "1.0.1"]

Dependencies

runtime (6)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-data-jpa jar
org.springframework.boot : spring-boot-starter-web jar
org.springframework.boot : spring-boot-starter-aop jar
org.reflections : reflections jar 0.9.12
com.google.code.findbugs : jsr305 jar 3.0.2
org.apache.commons : commons-lang3 jar 3.12.0

test (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-test jar

Project Modules

There are no modules declared in this project.

工程简介

一个OLTP数据库JPA日志拦截记录的springboot框架

开发计划

  1. 2021/04/15 1.0.1 实现日式文件打印变更 --已实现
  2. 2021/05/05 1.0.2 实现NoSQL数据库存储变更记录 --实现中

#快速开始

1、pom添加

<dependency>
  <groupId>cn.idugou.bizlog</groupId>
  <artifactId>entity-bizlog-spring-boot-starter</artifactId>
  <version>1.0.1</version>
</dependency>

2、实体类添加相应注解

@Data
@Accessors(chain = true)
@EntityListeners(EntityLogListener.class) //必要
@Entity //必要
@Table(name = "sms_topic_user") //必要
public class SmsTopicUser implements Serializable {
    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Version
    private Long version;

    private Date createTime;

    private Date updateTime;

    private Long topicId;

    private Long umsUserId;

    private String queueCode;
}

3、操作方法添加注解

@Service
public class SmsTopicUserServiceImpl implements SmsTopicUserService {
    @EntityLog("新增") //必要
    @Override
    @Transactional
    public void save() {
        SmsTopicUser topicUser = new SmsTopicUser();
        topicUser.setCreateTime(new Date())
                .setUpdateTime(new Date())
                .setQueueCode("ABCDEFG")
                .setTopicId(1L)
                .setUmsUserId(1L);
        smsTopicUserRepository.save(topicUser);

        System.out.println(topicUser.toString());
    }
}

4、启动类添加注解

@EnableJpaRepositories(basePackages = {"com.example.bizlogtest.dao"}) //必要
@EntityScan(basePackages = {"com.example.bizlogtest.entity"}) //必要
@EnableJpaAuditing //必要
@EnableEntitylog //必要
@SpringBootApplication
public class BizlogtestApplication {

    public static void main(String[] args) {
        SpringApplication.run(BizlogtestApplication.class, args);
    }

}

#效果展示

2021-04-15 19:38:48.420  INFO 15584 --- [nio-8080-exec-1] c.i.bizlog.listener.EntityLogService     : EntityLogDTO(tableName=sms_topic_user, tableDesc=sms_topic_user, value=新增, ip=127.0.0.1, operateTime=Thu Apr 15 19:38:48 CST 2021, sessionId=15b4b203-cf21-4797-a51a-2ebfde78e1d2, logType=INSERT, userId=null, username=null, nickname=null, rowId=1, version=1, oldValue=null, newValue=SmsTopicUser(id=1, version=0, createTime=Thu Apr 15 19:38:48 CST 2021, updateTime=Thu Apr 15 19:38:48 CST 2021, topicId=1, umsUserId=1, queueCode=ABCDEFG), columnLogMap=null)

Versions

Version
1.0.1