You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/09/16 12:56:06 UTC

[incubator-linkis] branch dev-1.3.1 updated: linkis-jobhistory - refactor some method in JobHistoryMapper.xml

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new 42582917f linkis-jobhistory - refactor some method in JobHistoryMapper.xml
42582917f is described below

commit 42582917fc1e89b3fece9159f03a4eeb47a9773c
Author: Alexyang <xu...@qq.com>
AuthorDate: Fri Sep 16 20:55:59 2022 +0800

    linkis-jobhistory - refactor some method in JobHistoryMapper.xml
    
    linkis-jobhistory - refactor some method in JobHistoryMapper.xml
---
 .../jobhistory/dao/impl/JobHistoryMapper.xml       |  8 ++++----
 .../jobhistory/restful/api/QueryRestfulApi.java    | 22 ++++++++++++++++++++++
 .../apache/linkis/jobhistory/util/QueryUtils.scala |  2 +-
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml
index 9dc88cd2e..7c0ea434f 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/dao/impl/JobHistoryMapper.xml
@@ -114,7 +114,7 @@
             <if test="startDate != null">and created_time >= #{startDate} AND created_time <![CDATA[<=]]> #{endDate}</if>
             <if test="status != null">and <foreach collection="status" item="element" close=")" separator="," open="status in (">#{element}</foreach></if>
             <if test="userCreatorKey != null and userCreatorValue != null">
-                and  LOCATE('"${userCreatorKey}":"${userCreatorValue}', labels) > 0
+                and  LOCATE(CONCAT('"', #{userCreatorKey}, '":"', #{userCreatorValue}), labels) > 0
             </if>
             <if test="startId != null">and id >= #{startId}</if>
         </where>
@@ -130,7 +130,7 @@
             <if test="startDate != null">and created_time >= #{startDate} AND created_time <![CDATA[<=]]> #{endDate}</if>
             <if test="status != null">and <foreach collection="status" item="element" close=")" separator="," open="status in (">#{element}</foreach></if>
             <if test="userCreatorKey != null and creator != null">
-                and labels like '%"${userCreatorKey}":"%-${creator}%'
+                and labels like CONCAT('%"', #{userCreatorKey}, '":"%-', #{creator}, '%')
             </if>
             <if test="startId != null">and id >= #{startId}</if>
         </where>
@@ -194,7 +194,7 @@
             <if test="startDate != null">and created_time >= #{startDate} AND created_time <![CDATA[<=]]> #{endDate}</if>
             <if test="status != null">and <foreach collection="status" item="element" close=")" separator="," open="status in (">#{element}</foreach></if>
             <if test="userCreatorKey != null and userCreatorValue != null">
-                and  LOCATE('"${userCreatorKey}":"${userCreatorValue}', labels) > 0
+                and  LOCATE(CONCAT('"', #{userCreatorKey}, '":"', #{userCreatorValue}), labels) > 0
             </if>
         </where>
     </select>
@@ -208,7 +208,7 @@
             <if test="startDate != null">and created_time >= #{startDate} AND created_time <![CDATA[<=]]> #{endDate}</if>
             <if test="status != null">and <foreach collection="status" item="element" close=")" separator="," open="status in (">#{element}</foreach></if>
             <if test="userCreatorKey != null and creator != null">
-                and labels like '%"${userCreatorKey}":"%-${creator}%'
+                and labels like CONCAT('%"', #{userCreatorKey}, '":"%-', #{creator}, '%')
             </if>
         </where>
     </select>
diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java
index e98811721..791bd6418 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/java/org/apache/linkis/jobhistory/restful/api/QueryRestfulApi.java
@@ -271,6 +271,17 @@ public class QueryRestfulApi {
         }
         if (StringUtils.isEmpty(creator)) {
             creator = null;
+        } else {
+            if (!QueryUtils.checkNameValid(creator)) {
+                return Message.error("Invalid creator : " + creator);
+            }
+        }
+        if (StringUtils.isEmpty(engineType)) {
+            engineType = null;
+        } else {
+            if (!QueryUtils.checkNameValid(engineType)) {
+                return Message.error("Invalid engienType: " + engineType);
+            }
         }
         Date sDate = new Date(startDate);
         Date eDate = new Date(endDate);
@@ -345,6 +356,17 @@ public class QueryRestfulApi {
         }
         if (StringUtils.isEmpty(creator)) {
             creator = null;
+        } else {
+            if (!QueryUtils.checkNameValid(creator)) {
+                return Message.error("Invalid creator : " + creator);
+            }
+        }
+        if (StringUtils.isEmpty(engineType)) {
+            engineType = null;
+        } else {
+            if (!QueryUtils.checkNameValid(engineType)) {
+                return Message.error("Invalid engienType: " + engineType);
+            }
         }
         Date sDate = new Date(startDate);
         Date eDate = new Date(endDate);
diff --git a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala
index 5a10a1d39..340b681bb 100644
--- a/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala
+++ b/linkis-public-enhancements/linkis-jobhistory/src/main/scala/org/apache/linkis/jobhistory/util/QueryUtils.scala
@@ -49,7 +49,7 @@ object QueryUtils extends Logging {
   private val CHARSET = "utf-8"
   private val CODE_SPLIT = ";"
   private val LENGTH_SPLIT = "#"
-  private val NAME_REGEX = "^[a-zA-Z\\d_\\.]+$"
+  private val NAME_REGEX = "^[a-zA-Z\\-\\d_\\.]+$"
   private val nameRegexPattern = Pattern.compile(NAME_REGEX)
 
   private val dateFormatLocal = new ThreadLocal[SimpleDateFormat]() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org