ソースを参照

!131 移除苗标记的web常用对象
Merge pull request !131 from 小锅盖/feature_remove_web

青苗 4 年 前
コミット
2667386d56

+ 0 - 65
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/api/ApiController.java

@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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 com.baomidou.mybatisplus.extension.api;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * REST API 通用控制器
- *
- * @author hubin
- * @since 2018-06-08
- */
-// 使用度较低,如果使用请及时迁移本地 3.5.0 移除
-@Deprecated
-public class ApiController {
-
-    protected final Logger logger = LoggerFactory.getLogger(getClass());
-
-
-    /**
-     * 请求成功
-     *
-     * @param data 数据内容
-     * @param <T>  对象泛型
-     * @return ignore
-     */
-    protected <T> R<T> success(T data) {
-        return R.ok(data);
-    }
-
-    /**
-     * 请求失败
-     *
-     * @param msg 提示内容
-     * @return ignore
-     */
-    protected <T> R<T> failed(String msg) {
-        return R.failed(msg);
-    }
-
-    /**
-     * 请求失败
-     *
-     * @param errorCode 请求错误码
-     * @return ignore
-     */
-    protected <T> R<T> failed(IErrorCode errorCode) {
-        return R.failed(errorCode);
-    }
-
-}

+ 0 - 207
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/api/Assert.java

@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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 com.baomidou.mybatisplus.extension.api;
-
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
-import com.baomidou.mybatisplus.extension.exceptions.ApiException;
-import org.springframework.context.MessageSource;
-import org.springframework.context.i18n.LocaleContextHolder;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * REST API 业务断言
- * <p>参考:org.junit.Assert</p>
- *
- * @author hubin
- * @since 2018-06-05
- */
-// 使用度较低,如果使用请及时迁移本地 3.5.0 移除
-@Deprecated
-public class Assert {
-
-    protected Assert() {
-        // to do noting
-    }
-
-    /**
-     * 大于O
-     */
-    public static void gtZero(Integer num, IErrorCode errorCode) {
-        if (num == null || num <= 0) {
-            fail(errorCode);
-        }
-    }
-
-    /**
-     * 大于等于O
-     */
-    public static void geZero(Integer num, IErrorCode errorCode) {
-        if (num == null || num < 0) {
-            fail(errorCode);
-        }
-    }
-
-    /**
-     * num1大于num2
-     */
-    public static void gt(Integer num1, Integer num2, IErrorCode errorCode) {
-        if (num1 <= num2) {
-            fail(errorCode);
-        }
-    }
-
-    /**
-     * num1大于等于num2
-     */
-    public static void ge(Integer num1, Integer num2, IErrorCode errorCode) {
-        if (num1 < num2) {
-            fail(errorCode);
-        }
-    }
-
-    /**
-     * obj1 eq obj2
-     */
-    public static void eq(Object obj1, Object obj2, IErrorCode errorCode) {
-        if (!obj1.equals(obj2)) {
-            fail(errorCode);
-        }
-    }
-
-    public static void isTrue(boolean condition, IErrorCode errorCode) {
-        if (!condition) {
-            fail(errorCode);
-        }
-    }
-
-    public static void isFalse(boolean condition, IErrorCode errorCode) {
-        if (condition) {
-            fail(errorCode);
-        }
-    }
-
-    public static void isNull(IErrorCode errorCode, Object... conditions) {
-        if (ObjectUtils.isNotNull(conditions)) {
-            fail(errorCode);
-        }
-    }
-
-    public static void notNull(IErrorCode errorCode, Object... conditions) {
-        if (ObjectUtils.isNull(conditions)) {
-            fail(errorCode);
-        }
-    }
-
-    /**
-     * 失败结果
-     *
-     * @param errorCode 异常错误码
-     */
-    public static void fail(IErrorCode errorCode) {
-        throw new ApiException(errorCode);
-    }
-
-    public static void fail(boolean condition, IErrorCode errorCode) {
-        if (condition) {
-            fail(errorCode);
-        }
-    }
-
-    public static void fail(String message) {
-        throw new ApiException(message);
-    }
-
-    public static void fail(boolean condition, String message) {
-        if (condition) {
-            fail(message);
-        }
-    }
-
-
-    /**
-     * 返回多语言异常消息
-     *
-     * @param message       多语言消息 KEY
-     * @param args          多语言提示默认参数数组对象
-     * @param messageSource 多语言资源对象
-     */
-    public static void fail(String message, Object[] args, MessageSource messageSource) {
-        throw new ApiException(messageSource.getMessage(message,
-            args, LocaleContextHolder.getLocale()));
-    }
-
-    public static void fail(boolean condition, String message, Object[] args, MessageSource messageSource) {
-        if (condition) {
-            fail(message, args, messageSource);
-        }
-    }
-
-    public static void fail(String message, MessageSource messageSource) {
-        throw new ApiException(messageSource.getMessage(message,
-            null, LocaleContextHolder.getLocale()));
-    }
-
-    public static void fail(boolean condition, String message, MessageSource messageSource) {
-        if (condition) {
-            fail(message, messageSource);
-        }
-    }
-
-    public static void notEmpty(Object[] array, IErrorCode errorCode) {
-        if (ObjectUtils.isEmpty(array)) {
-            fail(errorCode);
-        }
-    }
-
-    public static void noNullElements(Object[] array, IErrorCode errorCode) {
-        if (array != null) {
-            for (Object element : array) {
-                if (element == null) {
-                    fail(errorCode);
-                }
-            }
-        }
-    }
-
-    public static void notEmpty(Collection<?> collection, IErrorCode errorCode) {
-        if (CollectionUtils.isEmpty(collection)) {
-            fail(errorCode);
-        }
-    }
-
-    public static void notEmpty(Map<?, ?> map, IErrorCode errorCode) {
-        if (ObjectUtils.isEmpty(map)) {
-            fail(errorCode);
-        }
-    }
-
-    public static void isInstanceOf(Class<?> type, Object obj, IErrorCode errorCode) {
-        notNull(errorCode, type);
-        if (!type.isInstance(obj)) {
-            fail(errorCode);
-        }
-    }
-
-    public static void isAssignable(Class<?> superType, Class<?> subType, IErrorCode errorCode) {
-        notNull(errorCode, superType);
-        if (subType == null || !superType.isAssignableFrom(subType)) {
-            fail(errorCode);
-        }
-    }
-}

+ 0 - 37
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/api/IErrorCode.java

@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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 com.baomidou.mybatisplus.extension.api;
-
-/**
- * REST API 错误码接口
- *
- * @author hubin
- * @since 2018-06-05
- */
-// 使用度较低,如果使用请及时迁移本地 3.5.0 移除
-@Deprecated
-public interface IErrorCode {
-
-    /**
-     * 错误编码 -1、失败 0、成功
-     */
-    long getCode();
-
-    /**
-     * 错误描述
-     */
-    String getMsg();
-}

+ 0 - 107
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/api/R.java

@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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 com.baomidou.mybatisplus.extension.api;
-
-import com.baomidou.mybatisplus.extension.enums.ApiErrorCode;
-import com.baomidou.mybatisplus.extension.exceptions.ApiException;
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-import java.util.Optional;
-
-/**
- * REST API 返回结果
- *
- * @author hubin
- * @since 2018-06-05
- */
-// 使用度较低,如果使用请及时迁移本地 3.5.0 移除
-@Deprecated
-@Data
-@Accessors(chain = true)
-public class R<T> implements Serializable {
-
-    /**
-	 * serialVersionUID
-	 */
-	private static final long serialVersionUID = 1L;
-
-	/**
-     * 业务错误码
-     */
-    private long code;
-    /**
-     * 结果集
-     */
-    private T data;
-    /**
-     * 描述
-     */
-    private String msg;
-
-    public R() {
-        // to do nothing
-    }
-
-    public R(IErrorCode errorCode) {
-        errorCode = Optional.ofNullable(errorCode).orElse(ApiErrorCode.FAILED);
-        this.code = errorCode.getCode();
-        this.msg = errorCode.getMsg();
-    }
-
-    public static <T> R<T> ok(T data) {
-        ApiErrorCode aec = ApiErrorCode.SUCCESS;
-        if (data instanceof Boolean && Boolean.FALSE.equals(data)) {
-            aec = ApiErrorCode.FAILED;
-        }
-        return restResult(data, aec);
-    }
-
-    public static <T> R<T> failed(String msg) {
-        return restResult(null, ApiErrorCode.FAILED.getCode(), msg);
-    }
-
-    public static <T> R<T> failed(IErrorCode errorCode) {
-        return restResult(null, errorCode);
-    }
-
-    public static <T> R<T> restResult(T data, IErrorCode errorCode) {
-        return restResult(data, errorCode.getCode(), errorCode.getMsg());
-    }
-
-    private static <T> R<T> restResult(T data, long code, String msg) {
-        R<T> apiResult = new R<>();
-        apiResult.setCode(code);
-        apiResult.setData(data);
-        apiResult.setMsg(msg);
-        return apiResult;
-    }
-
-    public boolean ok() {
-        return ApiErrorCode.SUCCESS.getCode() == code;
-    }
-
-    /**
-     * 服务间调用非业务正常,异常直接释放
-     */
-    public T serviceData() {
-        if (!ok()) {
-            throw new ApiException(this.msg);
-        }
-        return data;
-    }
-}

+ 0 - 22
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/api/package-info.java

@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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.
- */
-/**
- * REST API 相关通用类
- *
- * @author hubin
- * @since 2018-06-05
- */
-package com.baomidou.mybatisplus.extension.api;

+ 0 - 70
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/enums/ApiErrorCode.java

@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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 com.baomidou.mybatisplus.extension.enums;
-
-import com.baomidou.mybatisplus.extension.api.IErrorCode;
-
-/**
- * REST API 错误码
- *
- * @author hubin
- * @since 2017-06-26
- */
-// 使用度较低,如果使用请及时迁移本地 3.5.0 移除
-@Deprecated
-public enum ApiErrorCode implements IErrorCode {
-    /**
-     * 失败
-     */
-    FAILED(-1, "操作失败"),
-    /**
-     * 成功
-     */
-    SUCCESS(0, "执行成功");
-
-    private final long code;
-    private final String msg;
-
-    ApiErrorCode(final long code, final String msg) {
-        this.code = code;
-        this.msg = msg;
-    }
-
-    public static ApiErrorCode fromCode(long code) {
-        ApiErrorCode[] ecs = ApiErrorCode.values();
-        for (ApiErrorCode ec : ecs) {
-            if (ec.getCode() == code) {
-                return ec;
-            }
-        }
-        return SUCCESS;
-    }
-
-    @Override
-    public long getCode() {
-        return code;
-    }
-
-    @Override
-    public String getMsg() {
-        return msg;
-    }
-
-    @Override
-    public String toString() {
-        return String.format(" ErrorCode:{code=%s, msg=%s} ", code, msg);
-    }
-}

+ 0 - 22
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/enums/package-info.java

@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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.
- */
-/**
- * 扩展枚举相关枚举类
- *
- * @author hubin
- * @since 2018-06-08
- */
-package com.baomidou.mybatisplus.extension.enums;

+ 0 - 60
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/exceptions/ApiException.java

@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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 com.baomidou.mybatisplus.extension.exceptions;
-
-import com.baomidou.mybatisplus.extension.api.IErrorCode;
-
-/**
- * REST API 请求异常类
- *
- * @author hubin
- * @since 2017-06-26
- */
-// 使用度较低,如果使用请及时迁移本地 3.5.0 移除
-@Deprecated
-public class ApiException extends RuntimeException {
-
-    /**
-	 * serialVersionUID
-	 */
-	private static final long serialVersionUID = -5885155226898287919L;
-
-	/**
-     * 错误码
-     */
-    private IErrorCode errorCode;
-
-    public ApiException(IErrorCode errorCode) {
-        super(errorCode.getMsg());
-        this.errorCode = errorCode;
-    }
-
-    public ApiException(String message) {
-        super(message);
-    }
-
-    public ApiException(Throwable cause) {
-        super(cause);
-    }
-
-    public ApiException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public IErrorCode getErrorCode() {
-        return errorCode;
-    }
-}

+ 0 - 19
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/exceptions/package-info.java

@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
- *
- * 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 com.baomidou.mybatisplus.extension.exceptions;