| | |
| | | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; |
| | | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
| | | import com.example.security.UserContext; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | return new MetaObjectHandler() { |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | String username = UserContext.getCurrentUsername(); |
| | | this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictInsertFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictInsertFill(metaObject, "deleted", Integer.class, 0); |
| | | this.strictInsertFill(metaObject, "version", Integer.class, 1); |
| | | this.strictInsertFill(metaObject, "createBy", String.class, username != null ? username : "系统"); |
| | | this.strictInsertFill(metaObject, "updateBy", String.class, username != null ? username : "系统"); |
| | | } |
| | | |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | String username = UserContext.getCurrentUsername(); |
| | | this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now()); |
| | | this.strictUpdateFill(metaObject, "updateBy", String.class, username != null ? username : "系统"); |
| | | } |
| | | }; |
| | | } |