ruanwenjun commented on code in PR #2190:
URL: 
https://github.com/apache/incubator-seatunnel/pull/2190#discussion_r925087297


##########
seatunnel-server/seatunnel-server-common/src/main/java/org/apache/seatunnel/server/common/DateUtils.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.seatunnel.server.common;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
+@Slf4j
+public class DateUtils {
+    public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+    public static final String DEFAULT_DATETIME_FORMAT_WITH_TIMEZONE = 
"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ";
+
+    public static String format(Date date) {
+        return format(date2LocalDateTime(date), DEFAULT_DATETIME_FORMAT);
+    }
+
+    public static String format(LocalDateTime localDateTime, String format) {
+        return localDateTime.format(DateTimeFormatter.ofPattern(format));
+    }
+
+    private static LocalDateTime date2LocalDateTime(Date date) {
+        return LocalDateTime.ofInstant(date.toInstant(), 
ZoneId.systemDefault());
+    }
+
+    public static Date parse(String date) {

Review Comment:
   Please add comment on this method, e.g. the input data should formatted as 
`yyyy-MM-dd HH:mm:ss`.



##########
seatunnel-server/seatunnel-server-common/pom.xml:
##########
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>seatunnel-server</artifactId>
+        <groupId>org.apache.seatunnel</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>seatunnel-server-common</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.scala-lang</groupId>
+            <artifactId>scala-library</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>

Review Comment:
   I remember we have added `Lombok` at root/pom, so you don't need to add it 
again.
   ```suggestion
   
   ```



##########
seatunnel-server/pom.xml:
##########
@@ -27,6 +27,17 @@
     <packaging>pom</packaging>
     <modules>
         <module>seatunnel-app</module>
+        <module>seatunnel-spi</module>

Review Comment:
   Can we rename `seatunnel-spi` to `seatunnal-scheduler-spi`? It seems this 
module only defines some interfaces for the scheduler.



##########
seatunnel-server/seatunnel-server-common/src/main/java/org/apache/seatunnel/server/common/SeatunnelErrorEnum.java:
##########
@@ -15,16 +15,29 @@
  * limitations under the License.
  */
 
-package org.apache.seatunnel.app.common;
+package org.apache.seatunnel.server.common;
 
 public enum SeatunnelErrorEnum {
 
     SCRIPT_ALREADY_EXIST(10001, "script already exist", "You already have a 
script with the same name : '%s'"),
     NO_SUCH_SCRIPT(10002, "no such script", "No such script. Maybe deleted by 
others."),
     USER_ALREADY_EXISTS(10003, "user already exist", "The same username [%s] 
is exist."),
     NO_SUCH_USER(10002, "no such user", "No such user. Maybe deleted by 
others."),
+    SCHEDULER_CONFIG_NOT_EXIST(10003, "scheduler config not exist", "This 
script's scheduler config not exist, please check your config."),
+    JSON_TRANSFORM_FAILED(10004, "json transform failed", "Json transform 
failed, it may be a bug."),
+
+    /**
+     * request dolphinscheduler failed
+     */
+    UNEXPECTED_RETURN_CODE(20000, "Unexpected return code", "Unexpected return 
code : [%s], error msg is [%s]"),
+    QUERY_PROJECT_CODE_FAILED(20001, "query project code failed", "Request ds 
for querying project code failed"),
+    NO_MATCHED_PROJECT(20002, "no matched project", "No matched project [%s], 
please check your configuration"),
+    NO_MATCHED_SCRIPT_SAVE_DIR(20003, "no matched script save dir", "No 
matched script save dir [%s], please check your configuration"),
+
+    UNSUPPORTED_OPERATION(99996, "unsupported operation", "This operation [%s] 
is not supported now."),

Review Comment:
   Why the code begins with `99996` :).



##########
seatunnel-server/seatunnel-server-common/src/main/java/org/apache/seatunnel/server/common/DateUtils.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.seatunnel.server.common;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
+@Slf4j
+public class DateUtils {
+    public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+    public static final String DEFAULT_DATETIME_FORMAT_WITH_TIMEZONE = 
"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ";
+
+    public static String format(Date date) {
+        return format(date2LocalDateTime(date), DEFAULT_DATETIME_FORMAT);
+    }
+
+    public static String format(LocalDateTime localDateTime, String format) {
+        return localDateTime.format(DateTimeFormatter.ofPattern(format));
+    }
+
+    private static LocalDateTime date2LocalDateTime(Date date) {
+        return LocalDateTime.ofInstant(date.toInstant(), 
ZoneId.systemDefault());
+    }
+
+    public static Date parse(String date) {
+        LocalDateTime localDateTime = LocalDateTime.parse(date, 
DateTimeFormatter.ofPattern(DEFAULT_DATETIME_FORMAT));
+        return localDateTime2Date(localDateTime);
+    }
+
+    public static Date parse(String date, String format) {
+        LocalDateTime localDateTime = LocalDateTime.parse(date, 
DateTimeFormatter.ofPattern(format));
+        return localDateTime2Date(localDateTime);
+    }
+
+    private static Date localDateTime2Date(LocalDateTime localDateTime) {
+        Instant instant = 
localDateTime.atZone(ZoneId.systemDefault()).toInstant();

Review Comment:
   I think this transform is not needed, the Date doesn't contain zone 
information, so you only need to get the millseconds from `localDateTime`, and 
the millsecond is not related to timezone. 



##########
tools/dependencies/known-dependencies.txt:
##########
@@ -172,6 +172,7 @@ google-http-client-1.26.0.jar
 google-http-client-jackson2-1.26.0.jar
 google-oauth-client-1.26.0.jar
 gson-2.2.4.jar
+gson-2.9.0.jar

Review Comment:
   Can we unify the version of gson?



##########
seatunnel-server/seatunnel-app/src/main/resources/application.yml:
##########
@@ -20,6 +20,6 @@ spring:
     name: seatunnel
   datasource:
     driver-class-name: com.mysql.jdbc.Driver
-    url: 
jdbc:mysql://127.0.0.1:3306/seatunnel?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
+    url: 
jdbc:mysql://124.223.162.92:9918/seatunnel?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
     username: root
-    password: 123456
\ No newline at end of file
+    password: 8989*(*())

Review Comment:
   Please revert thr url and password



##########
seatunnel-server/seatunnel-server-common/pom.xml:
##########
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>seatunnel-server</artifactId>
+        <groupId>org.apache.seatunnel</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>seatunnel-server-common</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>

Review Comment:
   Please remove these properties.
   ```suggestion
       
   ```



##########
seatunnel-server/seatunnel-spi/pom.xml:
##########
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>seatunnel-server</artifactId>
+        <groupId>org.apache.seatunnel</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>seatunnel-spi</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.seatunnel</groupId>
+            <artifactId>seatunnel-server-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>

Review Comment:
   ```suggestion
          
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to