From 142863d5ca5ed9c5bc8ecc81924607d6dbf47800 Mon Sep 17 00:00:00 2001 From: shanwb Date: Wed, 16 Aug 2023 18:36:53 +0800 Subject: [PATCH 1/3] Delete jcommon/test/src/main/java/com/xiaomi/youpin/test/codefilter/c directory delete --- .../com/xiaomi/youpin/test/codefilter/c/test-1.4-SNAPSHOT.jar | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 jcommon/test/src/main/java/com/xiaomi/youpin/test/codefilter/c/test-1.4-SNAPSHOT.jar diff --git a/jcommon/test/src/main/java/com/xiaomi/youpin/test/codefilter/c/test-1.4-SNAPSHOT.jar b/jcommon/test/src/main/java/com/xiaomi/youpin/test/codefilter/c/test-1.4-SNAPSHOT.jar deleted file mode 100644 index 5f0bb22b4..000000000 --- a/jcommon/test/src/main/java/com/xiaomi/youpin/test/codefilter/c/test-1.4-SNAPSHOT.jar +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f9df4eae49d52c33425d54fd6351ee7d7928fa91f37c87189408f44411348ffc -size 41064 From 325d530ea5bc131e5d793654684a1d19371c5e6e Mon Sep 17 00:00:00 2001 From: shanwb Date: Thu, 17 Aug 2023 09:23:47 +0800 Subject: [PATCH 2/3] add common result --- jcommon/infra-common/pom.xml | 20 ++++++ .../main/java/run/mone/common/ErrorCode.java | 31 ++++++++ .../src/main/java/run/mone/common/Result.java | 71 +++++++++++++++++++ jcommon/pom.xml | 1 + 4 files changed, 123 insertions(+) create mode 100644 jcommon/infra-common/pom.xml create mode 100644 jcommon/infra-common/src/main/java/run/mone/common/ErrorCode.java create mode 100644 jcommon/infra-common/src/main/java/run/mone/common/Result.java diff --git a/jcommon/infra-common/pom.xml b/jcommon/infra-common/pom.xml new file mode 100644 index 000000000..056aaea38 --- /dev/null +++ b/jcommon/infra-common/pom.xml @@ -0,0 +1,20 @@ + + + + jcommon + run.mone + 1.4-SNAPSHOT + + 4.0.0 + + infra-common + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/jcommon/infra-common/src/main/java/run/mone/common/ErrorCode.java b/jcommon/infra-common/src/main/java/run/mone/common/ErrorCode.java new file mode 100644 index 000000000..80693a212 --- /dev/null +++ b/jcommon/infra-common/src/main/java/run/mone/common/ErrorCode.java @@ -0,0 +1,31 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.common; + +/** + * @author shanwb + * @date 2023-08-16 + */ +public class ErrorCode { + public static final int SUCCESS = 0; + + public static final int PARAM_ERROR = 400; + public static final int INTERNAL_ERROR = 500; + + public ErrorCode() { + } +} diff --git a/jcommon/infra-common/src/main/java/run/mone/common/Result.java b/jcommon/infra-common/src/main/java/run/mone/common/Result.java new file mode 100644 index 000000000..aedec4f9d --- /dev/null +++ b/jcommon/infra-common/src/main/java/run/mone/common/Result.java @@ -0,0 +1,71 @@ +/* + * Copyright 2020 Xiaomi + * + * Licensed 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 run.mone.common; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Map; + +/** + * @author shanwb + * @date 2023-08-16 + */ +@Data +public class Result implements Serializable { + private int code; + private String message; + private T data; + private String traceId; + private Map attributes; + + public Result(int code, String message, T data) { + this.code = code; + this.message = message; + this.data = data; + } + + public Result(int code, String message, T data, String traceId) { + this.code = code; + this.message = message; + this.data = data; + this.traceId = traceId; + } + + public static Result success(T data) { + return new Result(ErrorCode.SUCCESS, "success", data); + } + + public static Result fail(int code, String message) { + return new Result(code, message, null); + } + + public static Result fromException(Throwable e) { + return fail(ErrorCode.INTERNAL_ERROR, e.getMessage()); + } + + @Override + public String toString() { + return "Result{" + + "code=" + code + + ", message='" + message + '\'' + + ", data=" + data + + ", traceId='" + traceId + '\'' + + ", attributes=" + attributes + + '}'; + } +} diff --git a/jcommon/pom.xml b/jcommon/pom.xml index 337323d66..624e2dd70 100644 --- a/jcommon/pom.xml +++ b/jcommon/pom.xml @@ -96,6 +96,7 @@ openai excel match + infra-common From ee927fa1c1e667159bf4a5d66b2863248530b5dc Mon Sep 17 00:00:00 2001 From: shanwb Date: Thu, 17 Aug 2023 09:25:43 +0800 Subject: [PATCH 3/3] update --- jcommon/infra-common/pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/jcommon/infra-common/pom.xml b/jcommon/infra-common/pom.xml index 056aaea38..1f60d6bda 100644 --- a/jcommon/infra-common/pom.xml +++ b/jcommon/infra-common/pom.xml @@ -12,8 +12,6 @@ infra-common - 17 - 17 UTF-8