From e7d33b67912a22dcd400d455df6fa8ee879cec65 Mon Sep 17 00:00:00 2001 From: Kerwin <37063904+zhuangchong@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:55:00 +0800 Subject: [PATCH] fix create time and modify time not in effect (#3885) --- .../base/domain/router/RouterTree.java | 2 - .../base/mybatis/entity/BaseEntity.java | 40 ++++++++++++++ .../handler/DefaultBaseFieldHandler.java | 55 +++++++++++++++++++ .../console/core/entity/AlertConfig.java | 14 ++--- .../console/core/entity/ExternalLink.java | 13 ++--- .../console/core/entity/FlinkGateWay.java | 10 ++-- .../console/core/entity/Project.java | 10 ++-- .../console/core/entity/Resource.java | 12 ++-- .../console/core/entity/SparkApplication.java | 8 +-- .../console/core/entity/Variable.java | 12 ++-- .../console/core/entity/YarnQueue.java | 13 ++--- .../SparkApplicationManageServiceImpl.java | 5 -- .../service/impl/ExternalLinkServiceImpl.java | 5 -- .../core/service/impl/ProjectServiceImpl.java | 4 -- .../console/system/entity/AccessToken.java | 12 ++-- .../console/system/entity/Member.java | 15 ++--- .../console/system/entity/Menu.java | 15 ++--- .../console/system/entity/Role.java | 15 ++--- .../console/system/entity/Team.java | 15 ++--- .../console/system/entity/User.java | 11 ++-- .../security/impl/AuthenticatorImpl.java | 5 -- .../service/impl/AccessTokenServiceImpl.java | 5 -- .../service/impl/MemberServiceImpl.java | 4 -- .../system/service/impl/RoleServiceImpl.java | 5 -- .../system/service/impl/TeamServiceImpl.java | 5 -- .../system/service/impl/UserServiceImpl.java | 4 -- 26 files changed, 156 insertions(+), 158 deletions(-) create mode 100644 streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/entity/BaseEntity.java create mode 100644 streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/handler/DefaultBaseFieldHandler.java diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/router/RouterTree.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/router/RouterTree.java index bd94bb9d63..de51493211 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/router/RouterTree.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/domain/router/RouterTree.java @@ -81,8 +81,6 @@ public RouterTree(Menu menu) { this.setTitle(menu.getMenuName()); this.setIcon(menu.getIcon()); this.setComponent(menu.getComponent()); - this.setCreateTime(menu.getCreateTime()); - this.setModifyTime(menu.getModifyTime()); this.setPath(menu.getPath()); this.setOrder(menu.getOrderNum()); this.setPermission(menu.getPerms()); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/entity/BaseEntity.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/entity/BaseEntity.java new file mode 100644 index 0000000000..787734a2b1 --- /dev/null +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/entity/BaseEntity.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.streampark.console.base.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** Base entity. */ +@Data +public abstract class BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** create time */ + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + /** modify time */ + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date modifyTime; +} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/handler/DefaultBaseFieldHandler.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/handler/DefaultBaseFieldHandler.java new file mode 100644 index 0000000000..8934458206 --- /dev/null +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/mybatis/handler/DefaultBaseFieldHandler.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.streampark.console.base.mybatis.handler; + +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + +import org.apache.ibatis.reflection.MetaObject; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.Optional; + +/** Automatically generate common basic field values when adding and modifying data. */ +@Component +public class DefaultBaseFieldHandler implements MetaObjectHandler { + + @Override + public void insertFill(MetaObject metaObject) { + baseEntity(metaObject).ifPresent(entity -> { + entity.setCreateTime(new Date()); + entity.setModifyTime(new Date()); + }); + + } + + @Override + public void updateFill(MetaObject metaObject) { + baseEntity(metaObject).ifPresent(entity -> entity.setModifyTime(new Date())); + } + + private Optional baseEntity(MetaObject metaObject) { + return Optional.ofNullable(metaObject) + .map(MetaObject::getOriginalObject) + .filter(BaseEntity.class::isInstance) + .map(BaseEntity.class::cast); + } + +} diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/AlertConfig.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/AlertConfig.java index 477ad3ae5d..993a582b8d 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/AlertConfig.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/AlertConfig.java @@ -17,6 +17,7 @@ package org.apache.streampark.console.core.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; import org.apache.streampark.console.base.util.JacksonUtils; import org.apache.streampark.console.core.bean.AlertConfigParams; @@ -25,16 +26,15 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.core.JsonProcessingException; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; -import java.io.Serializable; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_alert_config") @Slf4j -public class AlertConfig implements Serializable { +public class AlertConfig extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -62,12 +62,6 @@ public class AlertConfig implements Serializable { /** lark alert parameters */ private String larkParams; - /** create time */ - private Date createTime; - - /** modify time */ - private Date modifyTime; - public static AlertConfig of(AlertConfigParams params) { if (params == null) { return null; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ExternalLink.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ExternalLink.java index 8ee5631b18..984d0b211f 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ExternalLink.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/ExternalLink.java @@ -17,20 +17,21 @@ package org.apache.streampark.console.core.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; -import java.io.Serializable; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_external_link") -public class ExternalLink implements Serializable { +public class ExternalLink extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -48,8 +49,4 @@ public class ExternalLink implements Serializable { @TableField(exist = false) private String renderedLinkUrl; - - private Date createTime; - - private Date modifyTime; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkGateWay.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkGateWay.java index 4e79c2750f..1085d2f4bc 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkGateWay.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/FlinkGateWay.java @@ -17,20 +17,21 @@ package org.apache.streampark.console.core.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; import org.apache.streampark.console.core.enums.GatewayTypeEnum; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_flink_gateway") -public class FlinkGateWay { +public class FlinkGateWay extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -45,7 +46,4 @@ public class FlinkGateWay { @NotBlank(message = "{required}") private String address; - private Date createTime; - - private Date modifyTime; } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java index 7a2fdea781..98005c6735 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java @@ -23,6 +23,7 @@ import org.apache.streampark.common.util.AssertUtils; import org.apache.streampark.common.util.Utils; import org.apache.streampark.console.base.exception.ApiDetailException; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; import org.apache.streampark.console.base.util.GitUtils; import org.apache.streampark.console.base.util.WebUtils; import org.apache.streampark.console.core.enums.GitAuthorizedErrorEnum; @@ -37,12 +38,12 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.eclipse.jgit.lib.Constants; import java.io.File; import java.io.IOException; -import java.io.Serializable; import java.util.Arrays; import java.util.Date; import java.util.Iterator; @@ -52,8 +53,9 @@ @Slf4j @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_flink_project") -public class Project implements Serializable { +public class Project extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -99,10 +101,6 @@ public class Project implements Serializable { /** 1) flink 2) spark */ private Integer type; - private Date createTime; - - private Date modifyTime; - private transient String module; private transient String dateFrom; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Resource.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Resource.java index 3ce933b6bd..b15a04018e 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Resource.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Resource.java @@ -17,6 +17,7 @@ package org.apache.streampark.console.core.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; import org.apache.streampark.console.core.enums.EngineTypeEnum; import org.apache.streampark.console.core.enums.ResourceTypeEnum; @@ -26,16 +27,15 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_resource") -public class Resource implements Serializable { +public class Resource extends BaseEntity { private static final long serialVersionUID = 1L; @@ -75,10 +75,6 @@ public class Resource implements Serializable { @NotNull(message = "{required}") private Long teamId; - private Date createTime; - - private Date modifyTime; - private transient String connector; public void setResourcePath(String resourcePath) { diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java index 5eb2dc8f73..9c4be43e56 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/SparkApplication.java @@ -25,6 +25,7 @@ import org.apache.streampark.common.enums.SparkExecutionMode; import org.apache.streampark.common.enums.StorageType; import org.apache.streampark.common.fs.FsOperator; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; import org.apache.streampark.console.base.util.JacksonUtils; import org.apache.streampark.console.core.bean.AppControl; import org.apache.streampark.console.core.bean.Dependency; @@ -51,7 +52,6 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import java.io.Serializable; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -62,7 +62,7 @@ @Data @TableName("t_spark_app") @Slf4j -public class SparkApplication implements Serializable { +public class SparkApplication extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -202,12 +202,8 @@ public class SparkApplication implements Serializable { private String description; - private Date createTime; - private Date optionTime; - private Date modifyTime; - /** 1: cicd (build from csv) 2: upload (upload local jar job) */ private Integer resourceFrom; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java index b9539e545e..86e0d186fe 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Variable.java @@ -18,22 +18,22 @@ package org.apache.streampark.console.core.entity; import org.apache.streampark.common.Constant; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_variable") -public class Variable implements Serializable { +public class Variable extends BaseEntity { private static final long serialVersionUID = 1L; @@ -60,10 +60,6 @@ public class Variable implements Serializable { private Boolean desensitization; - private Date createTime; - - private Date modifyTime; - public void dataMasking() { if (desensitization) { this.setVariableValue(Constant.DEFAULT_DATAMASK_STRING); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/YarnQueue.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/YarnQueue.java index bac3f0203e..bd4368bb94 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/YarnQueue.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/YarnQueue.java @@ -17,6 +17,8 @@ package org.apache.streampark.console.core.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.FieldStrategy; import com.baomidou.mybatisplus.annotation.IdType; @@ -24,13 +26,12 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; - -import java.io.Serializable; -import java.util.Date; +import lombok.EqualsAndHashCode; @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_yarn_queue") -public class YarnQueue implements Serializable { +public class YarnQueue extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -44,10 +45,6 @@ public class YarnQueue implements Serializable { @TableField(updateStrategy = FieldStrategy.IGNORED) private String description; - private Date createTime; - - private Date modifyTime; - private transient String createTimeFrom; private transient String createTimeTo; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java index e7a4729fb2..b5c3f0d615 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/application/impl/SparkApplicationManageServiceImpl.java @@ -275,8 +275,6 @@ public boolean create(SparkApplication appParam) { appParam.setState(FlinkAppStateEnum.ADDED.getValue()); appParam.setRelease(ReleaseStateEnum.NEED_RELEASE.get()); appParam.setOptionState(OptionStateEnum.NONE.getValue()); - appParam.setCreateTime(new Date()); - appParam.setModifyTime(new Date()); appParam.setDefaultModeIngress(settingService.getIngressModeDefault()); boolean success = validateQueueIfNeeded(appParam); @@ -362,8 +360,6 @@ public Long copy(SparkApplication appParam) { newApp.setState(FlinkAppStateEnum.ADDED.getValue()); newApp.setRelease(ReleaseStateEnum.NEED_RELEASE.get()); newApp.setOptionState(OptionStateEnum.NONE.getValue()); - newApp.setCreateTime(new Date()); - newApp.setModifyTime(new Date()); newApp.setHotParams(oldApp.getHotParams()); newApp.setJar(oldApp.getJar()); @@ -465,7 +461,6 @@ public boolean update(SparkApplication appParam) { application.setK8sHadoopIntegration(appParam.getK8sHadoopIntegration()); // changes to the following parameters do not affect running tasks - application.setModifyTime(new Date()); application.setDescription(appParam.getDescription()); application.setAlertId(appParam.getAlertId()); application.setRestartSize(appParam.getRestartSize()); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ExternalLinkServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ExternalLinkServiceImpl.java index 649dedbb1a..0550cb0c4c 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ExternalLinkServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ExternalLinkServiceImpl.java @@ -34,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.PropertyPlaceholderHelper; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -54,9 +53,6 @@ public void create(ExternalLink externalLink) { if (!this.check(externalLink)) { return; } - Date date = new Date(); - externalLink.setCreateTime(date); - externalLink.setModifyTime(date); externalLink.setId(null); this.save(externalLink); } @@ -66,7 +62,6 @@ public void update(ExternalLink externalLink) { if (!this.check(externalLink)) { return; } - externalLink.setModifyTime(new Date()); baseMapper.updateById(externalLink); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java index 067ef01631..3723266905 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java @@ -67,7 +67,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -118,9 +117,6 @@ public RestResponse create(Project project) { throw new ApiAlertException("Project github/gitlab password decrypt failed"); } } - Date date = new Date(); - project.setCreateTime(date); - project.setModifyTime(date); boolean status = save(project); if (status) { diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/AccessToken.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/AccessToken.java index 98e6e6e17c..b17f242231 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/AccessToken.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/AccessToken.java @@ -17,22 +17,24 @@ package org.apache.streampark.console.system.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import java.io.Serializable; import java.util.Date; @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_access_token") -public class AccessToken implements Serializable { +public class AccessToken extends BaseEntity { - private static final long serialVersionUID = 1L; public static final String DEFAULT_EXPIRE_TIME = "9999-01-01 00:00:00"; public static final String IS_API_TOKEN = "is_api_token"; @@ -56,10 +58,6 @@ public class AccessToken implements Serializable { private String description; - private Date createTime; - - private Date modifyTime; - private transient String username; private transient String userStatus; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Member.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Member.java index 882950f36a..83f37d27d6 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Member.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Member.java @@ -17,19 +17,18 @@ package org.apache.streampark.console.system.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; - -import java.io.Serializable; -import java.util.Date; +import lombok.EqualsAndHashCode; @TableName("t_member") @Data -public class Member implements Serializable { - - private static final long serialVersionUID = 1L; +@EqualsAndHashCode(callSuper = true) +public class Member extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -40,10 +39,6 @@ public class Member implements Serializable { private Long roleId; - private Date createTime; - - private Date modifyTime; - private transient String userName; private transient String roleName; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Menu.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Menu.java index f423874857..5bf14b67d6 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Menu.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Menu.java @@ -17,22 +17,21 @@ package org.apache.streampark.console.system.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_menu") -public class Menu implements Serializable { - - private static final long serialVersionUID = 1L; +public class Menu extends BaseEntity { public static final String TYPE_MENU = "0"; @@ -63,10 +62,6 @@ public class Menu implements Serializable { private Double orderNum; - private Date createTime; - - private Date modifyTime; - private boolean display; private transient String createTimeFrom; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Role.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Role.java index 7330158320..3d3944fda9 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Role.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Role.java @@ -17,22 +17,21 @@ package org.apache.streampark.console.system.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_role") -public class Role implements Serializable { - - private static final long serialVersionUID = 1L; +public class Role extends BaseEntity { @TableId(type = IdType.AUTO) private Long roleId; @@ -44,10 +43,6 @@ public class Role implements Serializable { @Size(max = 255, message = "{noMoreThan}") private String description; - private Date createTime; - - private Date modifyTime; - private transient String createTimeFrom; private transient String createTimeTo; private transient String menuId; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Team.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Team.java index 5712a7b95b..53f2f83e10 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Team.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/Team.java @@ -17,21 +17,20 @@ package org.apache.streampark.console.system.entity; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.Size; -import java.io.Serializable; -import java.util.Date; - @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_team") -public class Team implements Serializable { - - private static final long serialVersionUID = 1L; +public class Team extends BaseEntity { @TableId(type = IdType.AUTO) private Long id; @@ -41,10 +40,6 @@ public class Team implements Serializable { private String description; - private Date createTime; - - private Date modifyTime; - private transient String createTimeFrom; private transient String createTimeTo; diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/User.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/User.java index 55237c9632..c348439356 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/User.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/entity/User.java @@ -18,6 +18,7 @@ package org.apache.streampark.console.system.entity; import org.apache.streampark.common.Constant; +import org.apache.streampark.console.base.mybatis.entity.BaseEntity; import org.apache.streampark.console.core.enums.LoginTypeEnum; import org.apache.streampark.console.core.enums.UserTypeEnum; @@ -25,19 +26,19 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; -import java.io.Serializable; import java.util.Date; @Data +@EqualsAndHashCode(callSuper = true) @TableName("t_user") -public class User implements Serializable { +public class User extends BaseEntity { - private static final long serialVersionUID = 1L; /** user status */ public static final String STATUS_VALID = "1"; @@ -70,10 +71,6 @@ public class User implements Serializable { @NotBlank(message = "{required}") private String status; - private Date createTime; - - private Date modifyTime; - private Date lastLoginTime; @NotBlank(message = "{required}") diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java index 8ab91f3a55..5d783d8359 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/security/impl/AuthenticatorImpl.java @@ -30,8 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Date; - @Component public class AuthenticatorImpl implements Authenticator { @@ -117,9 +115,6 @@ private User ssoAuthenticate(String username) throws Exception { private User newUserCreate(LoginTypeEnum loginTypeEnum, String username) throws Exception { User newUser = new User(); - Date date = new Date(); - newUser.setCreateTime(date); - newUser.setModifyTime(date); newUser.setUsername(username); newUser.setNickName(username); newUser.setLoginType(loginTypeEnum); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java index 29b03261a1..12c2fe6eae 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/AccessTokenServiceImpl.java @@ -40,7 +40,6 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import java.util.Date; import java.util.List; @Slf4j @@ -75,9 +74,6 @@ public RestResponse create(Long userId, String description) { accessToken.setUserId(user.getUserId()); accessToken.setDescription(description); - Date date = new Date(); - accessToken.setCreateTime(date); - accessToken.setModifyTime(date); accessToken.setStatus(AccessToken.STATUS_ENABLE); this.save(accessToken); @@ -119,7 +115,6 @@ public RestResponse toggleToken(Long tokenId) { AccessToken updateObj = new AccessToken(); updateObj.setStatus(status); updateObj.setId(tokenId); - updateObj.setModifyTime(new Date()); return RestResponse.success(this.updateById(updateObj)); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MemberServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MemberServiceImpl.java index adefb56e60..fec9f83538 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MemberServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/MemberServiceImpl.java @@ -40,7 +40,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; -import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -134,9 +133,6 @@ public void createMember(Member member) { member.setId(null); member.setUserId(user.getUserId()); - Date date = new Date(); - member.setCreateTime(date); - member.setModifyTime(date); this.save(member); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java index 62b978b52e..d4c2af83bd 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/RoleServiceImpl.java @@ -44,7 +44,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Optional; @@ -75,9 +74,6 @@ public Role getByName(String roleName) { @Override public void createRole(Role role) { - Date date = new Date(); - role.setCreateTime(date); - role.setModifyTime(date); this.save(role); String[] menuIds = role.getMenuId().split(StringPool.COMMA); @@ -103,7 +99,6 @@ public void removeById(Long roleId) { @Override public void updateRole(Role role) { - role.setModifyTime(new Date()); baseMapper.updateById(role); LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().eq(RoleMenu::getRoleId, role.getRoleId()); diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java index 70e6b9ea1c..c47fd0ffc7 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamServiceImpl.java @@ -42,7 +42,6 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import java.util.Date; import java.util.List; import java.util.Optional; @@ -90,9 +89,6 @@ public void createTeam(Team team) { "Team name [%s] exists already. Create team failed. Please rename and try again.", team.getTeamName())); team.setId(null); - Date date = new Date(); - team.setCreateTime(date); - team.setModifyTime(date); this.save(team); } @@ -133,7 +129,6 @@ public void updateTeam(Team team) { oldTeam.getTeamName().equals(team.getTeamName()), "Team name can't be changed. Update team failed."); oldTeam.setDescription(team.getDescription()); - oldTeam.setModifyTime(new Date()); updateById(oldTeam); } diff --git a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java index 1ad14f5d4b..c7ff596e58 100644 --- a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java +++ b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/UserServiceImpl.java @@ -112,9 +112,6 @@ public void updateLoginTime(String username) { @Override public void createUser(User user) { - Date date = new Date(); - user.setCreateTime(date); - user.setModifyTime(date); if (StringUtils.isNoneBlank(user.getPassword())) { String salt = ShaHashUtils.getRandomSalt(); String password = ShaHashUtils.encrypt(salt, user.getPassword()); @@ -129,7 +126,6 @@ public RestResponse updateUser(User user) { User existsUser = getById(user.getUserId()); user.setLoginType(null); user.setPassword(null); - user.setModifyTime(new Date()); if (needTransferResource(existsUser, user)) { return RestResponse.success(Collections.singletonMap("needTransferResource", true)); }