Skip to content

Commit

Permalink
fix create time and modify time not in effect (#3885)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuangchong authored Jul 18, 2024
1 parent 006dd94 commit e7d33b6
Show file tree
Hide file tree
Showing 26 changed files with 156 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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> baseEntity(MetaObject metaObject) {
return Optional.ofNullable(metaObject)
.map(MetaObject::getOriginalObject)
.filter(BaseEntity.class::isInstance)
.map(BaseEntity.class::cast);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -48,8 +49,4 @@ public class ExternalLink implements Serializable {

@TableField(exist = false)
private String renderedLinkUrl;

private Date createTime;

private Date modifyTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,7 +46,4 @@ public class FlinkGateWay {
@NotBlank(message = "{required}")
private String address;

private Date createTime;

private Date modifyTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Loading

0 comments on commit e7d33b6

Please sign in to comment.