mirror of https://github.com/elunez/eladmin
Merge branch '2.5dev' of github.com:elunez/eladmin into 2.5dev
commit
45973ab86b
|
@ -1,14 +1,20 @@
|
|||
package me.zhengjie.base;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
import org.springframework.data.annotation.CreatedBy;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
|
@ -17,18 +23,39 @@ import java.lang.reflect.Field;
|
|||
@Getter
|
||||
@Setter
|
||||
@MappedSuperclass
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
public class BaseEntity implements Serializable {
|
||||
|
||||
/** 删除标识 **/
|
||||
@Column(name = "is_delete", columnDefinition = "bit default 0")
|
||||
private Boolean isDelete = false;
|
||||
|
||||
@Column(name = "create_time")
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@CreatedBy
|
||||
@Column(name = "create_by", updatable = false)
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@CreationTimestamp
|
||||
@Column(name = "create_time", updatable = false)
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "update_time")
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@LastModifiedBy
|
||||
@Column(name = "update_by")
|
||||
private String updatedBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@UpdateTimestamp
|
||||
@Column(name = "update_time")
|
||||
private Timestamp updateTime;
|
||||
|
||||
public @interface Update {}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
*/
|
||||
@EnableAsync
|
||||
@RestController
|
||||
/** 开启审计功能 */
|
||||
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
public class AppRun {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package me.zhengjie.config;
|
||||
|
||||
import me.zhengjie.utils.SecurityUtils;
|
||||
import org.springframework.data.domain.AuditorAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @描述 : 设置审计
|
||||
* @作者 : Dong ZhaoYang
|
||||
* @日期 : 2019/10/28
|
||||
* @时间 : 10:29
|
||||
*/
|
||||
@Component("auditorAware")
|
||||
public class AuditorConfig implements AuditorAware<String> {
|
||||
|
||||
/**
|
||||
* 返回操作员标志信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<String> getCurrentAuditor() {
|
||||
// 这里应根据实际业务情况获取具体信息
|
||||
return Optional.of(SecurityUtils.getUsername());
|
||||
}
|
||||
}
|
|
@ -80,7 +80,8 @@ CREATE TABLE `dept` (
|
|||
`pid` bigint(20) NOT NULL COMMENT '上级部门',
|
||||
`enabled` bit(1) NOT NULL COMMENT '状态',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建日期',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_pid` (`pid`)
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '部门' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -103,7 +104,8 @@ CREATE TABLE `dict` (
|
|||
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典名称',
|
||||
`remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建日期',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `idx_name` (`name`)
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '数据字典' ROW_FORMAT = Compact;
|
||||
|
||||
-- ----------------------------
|
||||
|
|
Loading…
Reference in New Issue