新增mybatisplus代码生成器
This commit is contained in:
1 parent
4ae8d364b9
commit
60a95160fe
198 files changed
+12403
-95
No files matched your search
@@ -222,6 +222,7 @@
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-common</module>
|
||||
<module>ruoyi-api</module>
|
||||
<module>ruoyi-plus-api</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
+4
-3
@@ -37,6 +37,7 @@
|
||||
<hutool.version>4.1.1</hutool.version>
|
||||
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
|
||||
<version>3.5.0</version>
|
||||
<mybatis-plus-boot-starter.version>3.2.0</mybatis-plus-boot-starter.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -122,12 +123,12 @@
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>${mybatis-plus-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generate</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>${mybatis-plus-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.api;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 响应码
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
public enum ApiCode {
|
||||
|
||||
SUCCESS(200, "操作成功"),
|
||||
|
||||
UNAUTHORIZED(401, "非法访问"),
|
||||
|
||||
NOT_PERMISSION(403, "没有权限"),
|
||||
|
||||
NOT_FOUND(404, "你请求的路径不存在"),
|
||||
|
||||
FAIL(500, "操作失败"),
|
||||
|
||||
SYSTEM_EXCEPTION(5000,"系统异常!"),
|
||||
|
||||
PARAMETER_EXCEPTION(5001,"请求参数校验异常"),
|
||||
|
||||
PARAMETER_PARSE_EXCEPTION(5002,"请求参数解析异常"),
|
||||
|
||||
HTTP_MEDIA_TYPE_EXCEPTION(5003,"HTTP Media 类型异常"),
|
||||
|
||||
SYSTEM_LOGIN_EXCEPTION(5005,"系统登录异常")
|
||||
|
||||
;
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
ApiCode(final int code, final String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static ApiCode getApiCode(int code) {
|
||||
ApiCode[] ecs = ApiCode.values();
|
||||
for (ApiCode ec : ecs) {
|
||||
if (ec.getCode() == code) {
|
||||
return ec;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.api;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ApiResultEST API 公共控制器
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class ApiController {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求成功
|
||||
* </p>
|
||||
*
|
||||
* @param data 数据内容
|
||||
* @param <T> 对象泛型
|
||||
* @return
|
||||
*/
|
||||
protected <T> ApiResult<T> ok(T data) {
|
||||
return ApiResult.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求失败
|
||||
* </p>
|
||||
*
|
||||
* @param msg 提示内容
|
||||
* @return
|
||||
*/
|
||||
protected ApiResult<Object> fail(String msg) {
|
||||
return ApiResult.fail(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求失败
|
||||
* </p>
|
||||
*
|
||||
* @param apiCode 请求错误码
|
||||
* @return
|
||||
*/
|
||||
protected ApiResult<Object> fail(ApiCode apiCode) {
|
||||
return ApiResult.fail(apiCode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.api;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 返回结果
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class ApiResult<T> implements Serializable {
|
||||
|
||||
private int code;
|
||||
|
||||
private T data;
|
||||
|
||||
private String msg;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date time;
|
||||
|
||||
public ApiResult() {
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult result(boolean flag){
|
||||
if (flag){
|
||||
return ok();
|
||||
}
|
||||
return fail("");
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode){
|
||||
return result(apiCode,null);
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode,Object data){
|
||||
return result(apiCode,null,data);
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode,String msg,Object data){
|
||||
String message = apiCode.getMsg();
|
||||
if (StringUtils.isNotBlank(msg)){
|
||||
message = msg;
|
||||
}
|
||||
return ApiResult.builder()
|
||||
.code(apiCode.getCode())
|
||||
.msg(message)
|
||||
.data(data)
|
||||
.time(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static ApiResult ok(){
|
||||
return ok(null);
|
||||
}
|
||||
|
||||
public static ApiResult ok(Object data){
|
||||
return result(ApiCode.SUCCESS,data);
|
||||
}
|
||||
|
||||
public static ApiResult ok(String key,Object value){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(key,value);
|
||||
return ok(map);
|
||||
}
|
||||
|
||||
public static ApiResult fail(ApiCode apiCode){
|
||||
return result(apiCode,null);
|
||||
}
|
||||
|
||||
public static ApiResult fail(String msg){
|
||||
return result(ApiCode.FAIL,msg,null);
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult fail(ApiCode apiCode,Object data){
|
||||
if (ApiCode.SUCCESS == apiCode){
|
||||
throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode());
|
||||
}
|
||||
return result(apiCode,data);
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult fail(String key,Object value){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(key,value);
|
||||
return result(ApiCode.FAIL,map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.api;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.api.IErrorCode;
|
||||
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 业务断言<br>
|
||||
* 参考:org.junit.Assert
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
public class Assert {
|
||||
|
||||
protected Assert() {
|
||||
// to do noting
|
||||
}
|
||||
|
||||
/**
|
||||
* 大于O
|
||||
*/
|
||||
public static void gtZero(Integer num, IErrorCode errorCode) {
|
||||
if (num == null || num <= 0) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大于等于O
|
||||
*/
|
||||
public static void geZero(Integer num, IErrorCode errorCode) {
|
||||
if (num == null || num < 0) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* num1大于num2
|
||||
*/
|
||||
public static void gt(Integer num1, Integer num2, IErrorCode errorCode) {
|
||||
if (num1 <= num2) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* num1大于等于num2
|
||||
*/
|
||||
public static void ge(Integer num1, Integer num2, IErrorCode errorCode) {
|
||||
if (num1 < num2) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* obj1 eq obj2
|
||||
*/
|
||||
public static void eq(Object obj1, Object obj2, IErrorCode errorCode) {
|
||||
if (!obj1.equals(obj2)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isTrue(boolean condition, IErrorCode errorCode) {
|
||||
if (!condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isFalse(boolean condition, IErrorCode errorCode) {
|
||||
if (condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isNull(IErrorCode errorCode, Object... conditions) {
|
||||
if (ObjectUtils.isNotNull(conditions)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notNull(IErrorCode errorCode, Object... conditions) {
|
||||
if (ObjectUtils.isNull(conditions)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 失败结果
|
||||
* </p>
|
||||
*
|
||||
* @param errorCode 异常错误码
|
||||
*/
|
||||
public static void fail(IErrorCode errorCode) {
|
||||
throw new ApiException(errorCode);
|
||||
}
|
||||
|
||||
public static void fail(boolean condition, IErrorCode errorCode) {
|
||||
if (condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void fail(String message) {
|
||||
throw new ApiException(message);
|
||||
}
|
||||
|
||||
public static void fail(boolean condition, String message) {
|
||||
if (condition) {
|
||||
Assert.fail(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Object[] array, IErrorCode errorCode) {
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void noNullElements(Object[] array, IErrorCode errorCode) {
|
||||
if (array != null) {
|
||||
for (Object element : array) {
|
||||
if (element == null) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Collection<?> collection, IErrorCode errorCode) {
|
||||
if (CollectionUtils.isNotEmpty(collection)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Map<?, ?> map, IErrorCode errorCode) {
|
||||
if (ObjectUtils.isEmpty(map)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isInstanceOf(Class<?> type, Object obj, IErrorCode errorCode) {
|
||||
Assert.notNull(errorCode, type);
|
||||
if (!type.isInstance(obj)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isAssignable(Class<?> superType, Class<?> subType, IErrorCode errorCode) {
|
||||
Assert.notNull(errorCode, superType);
|
||||
if (subType == null || !superType.isAssignableFrom(subType)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.constant;
|
||||
|
||||
|
||||
public interface CacheKey {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.constant;
|
||||
|
||||
/**
|
||||
* 常量
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface CommonConstant {
|
||||
|
||||
/**
|
||||
* 默认页码为1
|
||||
*/
|
||||
Integer DEFAULT_PAGE_INDEX = 1;
|
||||
|
||||
/**
|
||||
* 默认页大小为10
|
||||
*/
|
||||
Integer DEFAULT_PAGE_SIZE = 10;
|
||||
|
||||
/**
|
||||
* 登录用户
|
||||
*/
|
||||
String LOGIN_SYS_USER = "loginSysUser";
|
||||
|
||||
/**
|
||||
* 登陆token
|
||||
*/
|
||||
String TOKEN = "token";
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
String REFRESH_TOKEN = "refresh_token";
|
||||
|
||||
/**
|
||||
* 初始密码
|
||||
*/
|
||||
String INIT_PWD = "123456";
|
||||
|
||||
/**
|
||||
* 默认头像
|
||||
*/
|
||||
String DEFAULT_HEAD_URL = "";
|
||||
|
||||
/**
|
||||
* 管理员角色名称
|
||||
*/
|
||||
String ADMIN_ROLE_NAME = "管理员";
|
||||
|
||||
String ADMIN_LOGIN = "adminLogin";
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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.ruoyi.app.common.constant;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* redis key 常量
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2019-05-23
|
||||
**/
|
||||
public interface CommonRedisKey {
|
||||
|
||||
/**
|
||||
* 系统登录用户
|
||||
*/
|
||||
String LOGIN_SYS_USER = "login:sys:user:%s";
|
||||
/**
|
||||
* 系统登录token
|
||||
*/
|
||||
String LOGIN_TOKEN = "login:token";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.constant;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 日期格式常量
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface DatePattern {
|
||||
|
||||
/**
|
||||
* 年-月-日
|
||||
*/
|
||||
String yyyy_MM_dd = "yyyy-MM-dd";
|
||||
/**
|
||||
* 年-月-日 时:分
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
|
||||
/**
|
||||
* 年-月-日 时:分:秒
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* 年-月-日 时:分:秒:毫秒
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm_ss_S = "yyyy-MM-dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 时:分
|
||||
*/
|
||||
String HH_mm = "HH:mm";
|
||||
/**
|
||||
* 时:分:秒
|
||||
*/
|
||||
String HH_mm_ss = "HH:mm:ss";
|
||||
/**
|
||||
* 时:分:秒:毫秒
|
||||
*/
|
||||
String HH_mm_ss_S = "HH:mm:ss:S";
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
package com.ruoyi.app.common.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("BaseEntity")
|
||||
public abstract class BaseEntity implements Serializable{
|
||||
}
|
||||
@@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.app.common.service.BaseService;
|
||||
import com.ruoyi.app.common.web.param.OrderQueryParam;
|
||||
import com.ruoyi.app.common.web.param.QueryParam;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -32,7 +34,33 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements BaseService<T> {
|
||||
|
||||
protected Page setPageParam(QueryParam queryParam) {
|
||||
return setPageParam(queryParam,null);
|
||||
}
|
||||
|
||||
protected Page setPageParam(QueryParam queryParam, OrderItem defaultOrder) {
|
||||
Page page = new Page();
|
||||
// 设置当前页码
|
||||
page.setCurrent(queryParam.getCurrent());
|
||||
// 设置页大小
|
||||
page.setSize(queryParam.getSize());
|
||||
/**
|
||||
* 如果是queryParam是OrderQueryParam,并且不为空,则使用前端排序
|
||||
* 否则使用默认排序
|
||||
*/
|
||||
if (queryParam instanceof OrderQueryParam){
|
||||
OrderQueryParam orderQueryParam = (OrderQueryParam) queryParam;
|
||||
List<OrderItem> orderItems = orderQueryParam.getOrders();
|
||||
if (CollectionUtils.isEmpty(orderItems)){
|
||||
page.setOrders(Arrays.asList(defaultOrder));
|
||||
}else{
|
||||
page.setOrders(orderItems);
|
||||
}
|
||||
}else{
|
||||
page.setOrders(Arrays.asList(defaultOrder));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Api文档
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/docs")
|
||||
@ApiIgnore
|
||||
public class ApiDocController extends BaseController {
|
||||
|
||||
/**
|
||||
* swaggerUI
|
||||
*/
|
||||
@GetMapping("")
|
||||
public String swaggerUI(){
|
||||
return "redirect:/swagger-ui.html";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.controller;
|
||||
|
||||
import com.ruoyi.app.common.api.ApiController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class BaseController extends ApiController {
|
||||
|
||||
/**
|
||||
* 获取当前请求
|
||||
*
|
||||
* @return request
|
||||
*/
|
||||
public HttpServletRequest getRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
}
|
||||
/**
|
||||
* 获取当前请求
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.controller;
|
||||
|
||||
import com.ruoyi.app.common.api.ApiResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 项目根路径提示信息
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018/11/12
|
||||
*/
|
||||
@RestController
|
||||
@ApiIgnore
|
||||
@Slf4j
|
||||
public class IndexController {
|
||||
|
||||
@RequestMapping("/index")
|
||||
public ApiResult<String> index(){
|
||||
log.debug("index...");
|
||||
return ApiResult.ok("Welcome to Spring Boot Plus Project...");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("ID参数")
|
||||
public class IdParam implements Serializable {
|
||||
private static final long serialVersionUID = -5353973980674510450L;
|
||||
|
||||
@NotBlank(message="ID不能为空")
|
||||
private String id;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("主键状态VO")
|
||||
public class IdStatusParam implements Serializable {
|
||||
private static final long serialVersionUID = -7581307955242965701L;
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("状态,1:启用 0:禁用")
|
||||
private Integer status;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IdStatusVo{" +
|
||||
"id='" + id + '\'' +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 名称参数
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("名称参数")
|
||||
public class NameParam implements Serializable {
|
||||
private static final long serialVersionUID = -3710501706034574149L;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NameParam{" +
|
||||
"name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.param;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 可排序查询参数对象
|
||||
* @author geekidea
|
||||
* @since 2019-08-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("可排序查询参数对象")
|
||||
public abstract class OrderQueryParam extends QueryParam{
|
||||
private static final long serialVersionUID = 57714391204790143L;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private List<OrderItem> orders;
|
||||
|
||||
public void defaultOrder(OrderItem orderItem){
|
||||
this.defaultOrders(Arrays.asList(orderItem));
|
||||
}
|
||||
|
||||
public void defaultOrders(List<OrderItem> orderItems){
|
||||
if (CollectionUtils.isEmpty(orderItems)){
|
||||
return;
|
||||
}
|
||||
this.orders = orderItems;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.param;
|
||||
|
||||
import com.ruoyi.app.common.constant.CommonConstant;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("查询参数对象")
|
||||
public abstract class QueryParam implements Serializable{
|
||||
private static final long serialVersionUID = -3263921252635611410L;
|
||||
|
||||
@ApiModelProperty(value = "页码,默认为1")
|
||||
private Integer current = CommonConstant.DEFAULT_PAGE_INDEX;
|
||||
@ApiModelProperty(value = "页大小,默认为10")
|
||||
private Integer size = CommonConstant.DEFAULT_PAGE_SIZE;
|
||||
@ApiModelProperty(value = "搜索字符串")
|
||||
private String keyword;
|
||||
|
||||
public void setCurrent(Integer current) {
|
||||
if (current == null || current <= 0){
|
||||
this.current = CommonConstant.DEFAULT_PAGE_INDEX;
|
||||
}else{
|
||||
this.current = current;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
if (size == null || size <= 0){
|
||||
this.size = CommonConstant.DEFAULT_PAGE_SIZE;
|
||||
}else{
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公共ID-NAME-VO对象
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@ApiModel("ID-NAME-VO")
|
||||
public class CommonIdName {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public CommonIdName(String id, String name) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CommonIdName() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommonIdName [id=" + id + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.app.common.web.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("分页")
|
||||
public class Paging<T> implements Serializable {
|
||||
private static final long serialVersionUID = -1683800405530086022L;
|
||||
|
||||
@ApiModelProperty("总行数")
|
||||
@JSONField(name = "total")
|
||||
@JsonProperty("total")
|
||||
private long total = 0;
|
||||
|
||||
@ApiModelProperty("数据列表")
|
||||
@JSONField(name = "records")
|
||||
@JsonProperty("records")
|
||||
private List<T> records = Collections.emptyList();
|
||||
|
||||
public Paging() {
|
||||
}
|
||||
|
||||
public Paging(IPage page) {
|
||||
this.total = page.getTotal();
|
||||
this.records = page.getRecords();
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<T> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(List<T> records) {
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Paging{" +
|
||||
"total=" + total +
|
||||
", records=" + records +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.app.modular.distribution.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.app.common.entity.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="StoreSubstitute对象", description="代发货表")
|
||||
public class StoreSubstitute extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "收货人姓名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "收货手机号")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "城市信息")
|
||||
private String cityInfo;
|
||||
|
||||
@ApiModelProperty(value = "收货详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "产品明细")
|
||||
private String productInfo;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Integer createTime;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.ruoyi.app.modular.distribution.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Repository
|
||||
public interface StoreSubstituteMapper extends BaseMapper<StoreSubstitute> {
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
StoreSubstituteQueryVo getStoreSubstituteById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param storeSubstituteQueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<StoreSubstituteQueryVo> getStoreSubstitutePageList(@Param("page") Page page, @Param("param") StoreSubstituteQueryParam storeSubstituteQueryParam);
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.app.modular.distribution.service;
|
||||
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.common.service.BaseService;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import com.ruoyi.app.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
public interface StoreSubstituteService extends BaseService<StoreSubstitute> {
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
StoreSubstituteQueryVo getStoreSubstituteById(Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param storeSubstituteQueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<StoreSubstituteQueryVo> getStoreSubstitutePageList(StoreSubstituteQueryParam storeSubstituteQueryParam) throws Exception;
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.app.modular.distribution.service.impl;
|
||||
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.modular.distribution.mapper.StoreSubstituteMapper;
|
||||
import com.ruoyi.app.modular.distribution.service.StoreSubstituteService;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import com.ruoyi.app.common.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.app.common.web.vo.Paging;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class StoreSubstituteServiceImpl extends BaseServiceImpl<StoreSubstituteMapper, StoreSubstitute> implements StoreSubstituteService {
|
||||
|
||||
@Autowired
|
||||
private StoreSubstituteMapper storeSubstituteMapper;
|
||||
|
||||
@Override
|
||||
public StoreSubstituteQueryVo getStoreSubstituteById(Serializable id) throws Exception{
|
||||
return storeSubstituteMapper.getStoreSubstituteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<StoreSubstituteQueryVo> getStoreSubstitutePageList(StoreSubstituteQueryParam storeSubstituteQueryParam) throws Exception{
|
||||
Page page = setPageParam(storeSubstituteQueryParam,OrderItem.desc("create_time"));
|
||||
IPage<StoreSubstituteQueryVo> iPage = storeSubstituteMapper.getStoreSubstitutePageList(page,storeSubstituteQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package com.ruoyi.app.modular.distribution.web.controller;
|
||||
|
||||
import com.ruoyi.app.modular.distribution.entity.StoreSubstitute;
|
||||
import com.ruoyi.app.modular.distribution.service.StoreSubstituteService;
|
||||
import com.ruoyi.app.distribution.web.param.StoreSubstituteQueryParam;
|
||||
import com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo;
|
||||
import com.ruoyi.app.common.web.controller.BaseController;
|
||||
import com.ruoyi.app.common.api.ApiResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import com.ruoyi.app.common.web.vo.Paging;
|
||||
import com.ruoyi.app.common.web.param.IdParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-09-30
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/storeSubstitute")
|
||||
@Api("代发货表 API")
|
||||
public class StoreSubstituteController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private StoreSubstituteService storeSubstituteService;
|
||||
|
||||
/**
|
||||
* 添加代发货表
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加StoreSubstitute对象",notes = "添加代发货表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> addStoreSubstitute(@Valid @RequestBody StoreSubstitute storeSubstitute) throws Exception{
|
||||
boolean flag = storeSubstituteService.save(storeSubstitute);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改代发货表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改StoreSubstitute对象",notes = "修改代发货表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> updateStoreSubstitute(@Valid @RequestBody StoreSubstitute storeSubstitute) throws Exception{
|
||||
boolean flag = storeSubstituteService.updateById(storeSubstitute);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除代发货表
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除StoreSubstitute对象",notes = "删除代发货表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> deleteStoreSubstitute(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
boolean flag = storeSubstituteService.removeById(idParam.getId());
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取代发货表
|
||||
*/
|
||||
@PostMapping("/info")
|
||||
@ApiOperation(value = "获取StoreSubstitute对象详情",notes = "查看代发货表",response = StoreSubstituteQueryVo.class)
|
||||
public ApiResult<StoreSubstituteQueryVo> getStoreSubstitute(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
StoreSubstituteQueryVo storeSubstituteQueryVo = storeSubstituteService.getStoreSubstituteById(idParam.getId());
|
||||
return ApiResult.ok(storeSubstituteQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 代发货表分页列表
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
@ApiOperation(value = "获取StoreSubstitute分页列表",notes = "代发货表分页列表",response = StoreSubstituteQueryVo.class)
|
||||
public ApiResult<Paging<StoreSubstituteQueryVo>> getStoreSubstitutePageList(@Valid @RequestBody(required = false) StoreSubstituteQueryParam storeSubstituteQueryParam) throws Exception{
|
||||
Paging<StoreSubstituteQueryVo> paging = storeSubstituteService.getStoreSubstitutePageList(storeSubstituteQueryParam);
|
||||
return ApiResult.ok(paging);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.ruoyi.app.distribution.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import com.ruoyi.app.common.web.param.QueryParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-09-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="StoreSubstituteQueryParam对象", description="代发货表查询参数")
|
||||
public class StoreSubstituteQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.ruoyi.app.distribution.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 代发货表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-09-30
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="StoreSubstituteQueryVo对象", description="代发货表查询参数")
|
||||
public class StoreSubstituteQueryVo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "收货人姓名")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "收货手机号")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "城市信息")
|
||||
private String cityInfo;
|
||||
|
||||
@ApiModelProperty(value = "收货详细地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty(value = "产品明细")
|
||||
private String productInfo;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Integer createTime;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.app.modular.distribution.mapper.StoreSubstituteMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, username, phone, city_info, address, product_info, create_time, updated_at
|
||||
</sql>
|
||||
|
||||
<select id="getStoreSubstituteById" resultType="com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getStoreSubstitutePageList" resultType="com.ruoyi.app.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.app.modular.distribution.mapper.StoreSubstituteMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, username, phone, city_info, address, product_info, create_time, updated_at
|
||||
</sql>
|
||||
|
||||
<select id="getStoreSubstituteById" resultType="com.ruoyi.app.modular.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getStoreSubstitutePageList" resultType="com.ruoyi.app.modular.distribution.web.vo.StoreSubstituteQueryVo">
|
||||
select <include refid="Base_Column_List"/> from store_substitute
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,92 +1,92 @@
|
||||
package com.ruoyi.generator;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DbType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 自动生成
|
||||
*/
|
||||
public class EntityGenerator {
|
||||
|
||||
@Test
|
||||
public void entityGenerator() {
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
gc.setOutputDir("E:\\java\\Supply\\ruoyi-api\\src\\main\\java");//这里写你自己的java目录
|
||||
gc.setFileOverride(true);//是否覆盖
|
||||
gc.setActiveRecord(true);
|
||||
gc.setEnableCache(false);// XML 二级缓存
|
||||
gc.setBaseResultMap(true);// XML ResultMap
|
||||
gc.setBaseColumnList(false);// XML columList
|
||||
gc.setAuthor("hupeng");
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setDbType(DbType.MYSQL);
|
||||
dsc.setTypeConvert(new MySqlTypeConvert() {
|
||||
// 自定义数据库表字段类型转换【可选】
|
||||
@Override
|
||||
public DbColumnType processTypeConvert(String fieldType) {
|
||||
return super.processTypeConvert(fieldType);
|
||||
}
|
||||
});
|
||||
dsc.setDriverName("com.mysql.jdbc.Driver");
|
||||
dsc.setUsername("root");
|
||||
dsc.setPassword("root");
|
||||
dsc.setUrl("jdbc:mysql://127.0.0.1:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
//strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
|
||||
strategy.setInclude(new String[]{"store_order",});
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setParent(null);
|
||||
pc.setEntity("com.ruoyi.app.common.persistence.model");
|
||||
pc.setMapper("com.ruoyi.app.common.persistence.dao");
|
||||
pc.setXml("com.ruoyi.app.common.persistence.dao.mapping");
|
||||
pc.setService("TTT"); //本项目没用,生成之后删掉
|
||||
pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉
|
||||
pc.setController("TTT"); //本项目没用,生成之后删掉
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
|
||||
InjectionConfig cfg = new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
|
||||
this.setMap(map);
|
||||
}
|
||||
};
|
||||
mpg.setCfg(cfg);
|
||||
|
||||
// 执行生成
|
||||
mpg.execute();
|
||||
|
||||
// 打印注入设置
|
||||
System.err.println(mpg.getCfg().getMap().get("abc"));
|
||||
}
|
||||
}
|
||||
//package com.ruoyi.generator;
|
||||
//
|
||||
//
|
||||
//import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
//import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
//import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
//import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.DbType;
|
||||
//import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * 自动生成
|
||||
// */
|
||||
//public class EntityGenerator {
|
||||
//
|
||||
// @Test
|
||||
// public void entityGenerator() {
|
||||
// AutoGenerator mpg = new AutoGenerator();
|
||||
//
|
||||
// // 全局配置
|
||||
// GlobalConfig gc = new GlobalConfig();
|
||||
// gc.setOutputDir("E:\\java\\Supply\\ruoyi-api\\src\\main\\java");//这里写你自己的java目录
|
||||
// gc.setFileOverride(true);//是否覆盖
|
||||
// gc.setActiveRecord(true);
|
||||
// gc.setEnableCache(false);// XML 二级缓存
|
||||
// gc.setBaseResultMap(true);// XML ResultMap
|
||||
// gc.setBaseColumnList(false);// XML columList
|
||||
// gc.setAuthor("hupeng");
|
||||
// mpg.setGlobalConfig(gc);
|
||||
//
|
||||
// // 数据源配置
|
||||
// DataSourceConfig dsc = new DataSourceConfig();
|
||||
// dsc.setDbType(DbType.MYSQL);
|
||||
// dsc.setTypeConvert(new MySqlTypeConvert() {
|
||||
// // 自定义数据库表字段类型转换【可选】
|
||||
// @Override
|
||||
// public DbColumnType processTypeConvert(String fieldType) {
|
||||
// return super.processTypeConvert(fieldType);
|
||||
// }
|
||||
// });
|
||||
// dsc.setDriverName("com.mysql.jdbc.Driver");
|
||||
// dsc.setUsername("root");
|
||||
// dsc.setPassword("root");
|
||||
// dsc.setUrl("jdbc:mysql://127.0.0.1:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8");
|
||||
// mpg.setDataSource(dsc);
|
||||
//
|
||||
// // 策略配置
|
||||
// StrategyConfig strategy = new StrategyConfig();
|
||||
// //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
|
||||
// strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
|
||||
// strategy.setInclude(new String[]{"store_order",});
|
||||
// mpg.setStrategy(strategy);
|
||||
//
|
||||
// // 包配置
|
||||
// PackageConfig pc = new PackageConfig();
|
||||
// pc.setParent(null);
|
||||
// pc.setEntity("com.ruoyi.app.common.persistence.model");
|
||||
// pc.setMapper("com.ruoyi.app.common.persistence.dao");
|
||||
// pc.setXml("com.ruoyi.app.common.persistence.dao.mapping");
|
||||
// pc.setService("TTT"); //本项目没用,生成之后删掉
|
||||
// pc.setServiceImpl("TTT"); //本项目没用,生成之后删掉
|
||||
// pc.setController("TTT"); //本项目没用,生成之后删掉
|
||||
// mpg.setPackageInfo(pc);
|
||||
//
|
||||
// // 注入自定义配置,可以在 VM 中使用 cfg.abc 设置的值
|
||||
// InjectionConfig cfg = new InjectionConfig() {
|
||||
// @Override
|
||||
// public void initMap() {
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("abc", this.getConfig().getGlobalConfig().getAuthor() + "-mp");
|
||||
// this.setMap(map);
|
||||
// }
|
||||
// };
|
||||
// mpg.setCfg(cfg);
|
||||
//
|
||||
// // 执行生成
|
||||
// mpg.execute();
|
||||
//
|
||||
// // 打印注入设置
|
||||
// System.err.println(mpg.getCfg().getMap().get("abc"));
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
package com.ruoyi.plus.test;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class BaseTest {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.test;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* spring-boot-plus代码生成器入口类
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class CodeGenerator {
|
||||
|
||||
private static final String USER_NAME = "root";
|
||||
private static final String PASSWORD = "root";
|
||||
private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";
|
||||
private static final String DRIVER_URL = "jdbc:mysql://127.0.0.1:3306/ruoyi?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8";
|
||||
|
||||
private static final String PARENT_PACKAGE = "com.ruoyi.app";
|
||||
private static final String SUPER_ENTITY = PARENT_PACKAGE + ".common.entity.BaseEntity";
|
||||
private static final String[] SUPER_ENTITY_COMMON_COLUMNS = new String[]{};
|
||||
private static final String SUPER_CONTROLLER = PARENT_PACKAGE + ".common.web.controller.BaseController";
|
||||
private static final String SUPER_SERVICE = PARENT_PACKAGE + ".common.service.BaseService";
|
||||
private static final String SUPER_SERVICE_IMPL = PARENT_PACKAGE + ".common.service.impl.BaseServiceImpl";
|
||||
|
||||
private static final String PROJECT_PACKAGE_PATH = "com/ruoyi/app";
|
||||
|
||||
|
||||
// ############################ 配置部分 start ############################
|
||||
// 模块名称
|
||||
private static final String MODULE_NAME = "distribution";
|
||||
// 作者
|
||||
private static final String AUTHOR = "hupeng";
|
||||
// 生成的表名称
|
||||
private static final String TABLE_NAME = "store_substitute";
|
||||
// 主键数据库列名称
|
||||
private static final String PK_ID_COLUMN_NAME = "id";
|
||||
// 代码生成策略 true:All/false:SIMPLE
|
||||
private static final boolean GENERATOR_STRATEGY = true;
|
||||
// 分页列表查询是否排序 true:有排序参数/false:无
|
||||
private static final boolean PAGE_LIST_ORDER = false;
|
||||
// ############################ 配置部分 end ############################
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
String projectPath = System.getProperty("user.dir");
|
||||
gc.setOutputDir(projectPath + "/ruoyi-api/src/main/java");
|
||||
gc.setAuthor(AUTHOR);
|
||||
gc.setOpen(true); // 是否打开输出目录
|
||||
gc.setSwagger2(true); // 启用swagger注解
|
||||
gc.setIdType(IdType.ID_WORKER); // 主键类型:ID_WORKER
|
||||
gc.setServiceName("%sService"); // 自定义文件命名,注意 %s 会自动填充表实体属性!
|
||||
gc.setFileOverride(true); // 是否覆盖已有文件
|
||||
gc.setDateType(DateType.ONLY_DATE); // 设置日期类型为Date
|
||||
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl(DRIVER_URL);
|
||||
// dsc.setSchemaName("public");
|
||||
dsc.setDriverName(DRIVER_NAME);
|
||||
dsc.setUsername(USER_NAME);
|
||||
dsc.setPassword(PASSWORD);
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName(MODULE_NAME);
|
||||
pc.setParent("com.ruoyi.app.modular");
|
||||
pc.setController("web.controller");
|
||||
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 自定义配置
|
||||
InjectionConfig cfg = new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("customField", "Hello " + this.getConfig().getGlobalConfig().getAuthor());
|
||||
// 查询参数包路径
|
||||
map.put("queryParamPath",PARENT_PACKAGE + StringPool.DOT + pc.getModuleName() + ".web.param." + underlineToPascal(TABLE_NAME) + "QueryParam");
|
||||
// 查询参数共公包路径
|
||||
map.put("queryParamCommonPath",PARENT_PACKAGE + StringPool.DOT + "common.web.param." + "QueryParam");
|
||||
// 查询参数共公包路径
|
||||
map.put("idParamPath",PARENT_PACKAGE + StringPool.DOT + "common.web.param." + "IdParam");
|
||||
// 响应结果包路径
|
||||
map.put("queryVoPath",PARENT_PACKAGE + StringPool.DOT + pc.getModuleName() + ".web.vo." + underlineToPascal(TABLE_NAME) + "QueryVo");
|
||||
// 实体对象名称
|
||||
map.put("entityObjectName",underlineToCamel(TABLE_NAME));
|
||||
// service对象名称
|
||||
map.put("serviceObjectName",underlineToCamel(TABLE_NAME) + "Service");
|
||||
// mapper对象名称
|
||||
map.put("mapperObjectName",underlineToCamel(TABLE_NAME) + "Mapper");
|
||||
// 主键ID列名
|
||||
map.put("pkIdColumnName",PK_ID_COLUMN_NAME);
|
||||
// 主键ID驼峰名称
|
||||
map.put("pkIdCamelName",underlineToCamel(PK_ID_COLUMN_NAME));
|
||||
// 导入分页类
|
||||
map.put("paging",PARENT_PACKAGE + ".common.web.vo.Paging");
|
||||
// 导入排序枚举
|
||||
map.put("orderEnum",PARENT_PACKAGE + ".common.enums.OrderEnum");
|
||||
// 分页列表查询是否排序
|
||||
map.put("pageListOrder",PAGE_LIST_ORDER);
|
||||
// 导入排序查询参数类
|
||||
map.put("orderQueryParamPath",PARENT_PACKAGE + StringPool.DOT + "common.web.param." + "OrderQueryParam");
|
||||
// 代码生成策略
|
||||
map.put("generatorStrategy",GENERATOR_STRATEGY);
|
||||
this.setMap(map);
|
||||
}
|
||||
};
|
||||
List<FileOutConfig> focList = new ArrayList<>();
|
||||
focList.add(new FileOutConfig("/templates/mapper.xml.vm") {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
// 自定义输入文件名称
|
||||
return projectPath + "/ruoyi-api/src/main/resources/mapper/" + pc.getModuleName()
|
||||
+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
|
||||
}
|
||||
});
|
||||
|
||||
// 自定义queryParam模板
|
||||
focList.add(new FileOutConfig("/templates/queryParam.java.vm") {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return projectPath + "/ruoyi-api/src/main/java/"+ PROJECT_PACKAGE_PATH +"/modular/" + pc.getModuleName() + "/web/param/" + tableInfo.getEntityName() + "QueryParam" + StringPool.DOT_JAVA;
|
||||
}
|
||||
});
|
||||
|
||||
// 自定义queryVo模板
|
||||
focList.add(new FileOutConfig("/templates/queryVo.java.vm") {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return projectPath + "/ruoyi-api/src/main/java/"+ PROJECT_PACKAGE_PATH +"/modular/" + pc.getModuleName() + "/web/vo/" + tableInfo.getEntityName() + "QueryVo" + StringPool.DOT_JAVA;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cfg.setFileOutConfigList(focList);
|
||||
mpg.setCfg(cfg);
|
||||
mpg.setTemplate(new TemplateConfig().setXml(null));
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setSuperEntityClass(SUPER_ENTITY);
|
||||
strategy.setEntityLombokModel(true);
|
||||
strategy.setRestControllerStyle(true);
|
||||
strategy.setSuperControllerClass(SUPER_CONTROLLER);
|
||||
strategy.setSuperServiceClass(SUPER_SERVICE);
|
||||
strategy.setSuperServiceImplClass(SUPER_SERVICE_IMPL);
|
||||
strategy.setInclude(TABLE_NAME);
|
||||
strategy.setSuperEntityColumns(SUPER_ENTITY_COMMON_COLUMNS);
|
||||
strategy.setControllerMappingHyphenStyle(true);
|
||||
/**
|
||||
* 注意,根据实际情况,进行设置
|
||||
* 当表名称的前缀和模块名称一样时,会去掉表的前缀
|
||||
* 比如模块名称为user,表明为user_info,则生成的实体名称是Info.java,一定要注意
|
||||
*/
|
||||
//strategy.setTablePrefix(pc.getModuleName() + "_");
|
||||
mpg.setStrategy(strategy);
|
||||
mpg.execute();
|
||||
}
|
||||
|
||||
public static String underlineToCamel(String underline){
|
||||
if (StringUtils.isNotBlank(underline)){
|
||||
return NamingStrategy.underlineToCamel(underline);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String underlineToPascal(String underline){
|
||||
if (StringUtils.isNotBlank(underline)){
|
||||
return NamingStrategy.capitalFirst(NamingStrategy.underlineToCamel(underline));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.plus.test;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2019/8/4
|
||||
*/
|
||||
public class IpTest {
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package ${package.Controller};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
#if(${superControllerClassPackage})
|
||||
import ${superControllerClassPackage};
|
||||
#end
|
||||
import com.ruoyi.app.common.api.ApiResult;
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
#end
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
#if(${restControllerStyle})
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
#else
|
||||
import org.springframework.stereotype.Controller;
|
||||
#end
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import ${cfg.paging};
|
||||
import ${cfg.idParamPath};
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Slf4j
|
||||
#if(${restControllerStyle})
|
||||
@RestController
|
||||
#else
|
||||
@Controller
|
||||
#end
|
||||
@RequestMapping("/${cfg.entityObjectName}")
|
||||
@Api("$!{table.comment} API")
|
||||
#if(${kotlin})
|
||||
class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
|
||||
|
||||
#else
|
||||
#if(${superControllerClass})
|
||||
public class ${table.controllerName} extends ${superControllerClass} {
|
||||
#else
|
||||
public class ${table.controllerName} {
|
||||
#end
|
||||
|
||||
@Autowired
|
||||
private ${table.serviceName} ${cfg.serviceObjectName};
|
||||
|
||||
#if(${cfg.generatorStrategy})
|
||||
/**
|
||||
* 添加$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加${entity}对象",notes = "添加$!{table.comment}",response = ApiResult.class)
|
||||
public ApiResult<Boolean> add${entity}(@Valid @RequestBody ${entity} ${cfg.entityObjectName}) throws Exception{
|
||||
boolean flag = ${cfg.serviceObjectName}.save(${cfg.entityObjectName});
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改${entity}对象",notes = "修改$!{table.comment}",response = ApiResult.class)
|
||||
public ApiResult<Boolean> update${entity}(@Valid @RequestBody ${entity} ${cfg.entityObjectName}) throws Exception{
|
||||
boolean flag = ${cfg.serviceObjectName}.updateById(${cfg.entityObjectName});
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除${entity}对象",notes = "删除$!{table.comment}",response = ApiResult.class)
|
||||
public ApiResult<Boolean> delete${entity}(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
boolean flag = ${cfg.serviceObjectName}.removeById(idParam.getId());
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取$!{table.comment}
|
||||
*/
|
||||
@PostMapping("/info")
|
||||
@ApiOperation(value = "获取${entity}对象详情",notes = "查看$!{table.comment}",response = ${entity}QueryVo.class)
|
||||
public ApiResult<${entity}QueryVo> get${entity}(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
${entity}QueryVo ${cfg.entityObjectName}QueryVo = ${cfg.serviceObjectName}.get${entity}ById(idParam.getId());
|
||||
return ApiResult.ok(${cfg.entityObjectName}QueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* $!{table.comment}分页列表
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
@ApiOperation(value = "获取${entity}分页列表",notes = "$!{table.comment}分页列表",response = ${entity}QueryVo.class)
|
||||
public ApiResult<Paging<${entity}QueryVo>> get${entity}PageList(@Valid @RequestBody(required = false) ${entity}QueryParam ${cfg.entityObjectName}QueryParam) throws Exception{
|
||||
Paging<${entity}QueryVo> paging = ${cfg.entityObjectName}Service.get${entity}PageList(${cfg.entityObjectName}QueryParam);
|
||||
return ApiResult.ok(paging);
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
|
||||
#end
|
||||
@@ -0,0 +1,161 @@
|
||||
package ${package.Entity};
|
||||
|
||||
#foreach($pkg in ${table.importPackages})
|
||||
import ${pkg};
|
||||
#end
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
## import lombok.experimental.Accessors;
|
||||
#end
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment}
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${entityLombokModel})
|
||||
@Data
|
||||
#if(${superEntityClass})
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
#else
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
#end
|
||||
## @Accessors(chain = true)
|
||||
#end
|
||||
#if(${table.convert})
|
||||
@TableName("${table.name}")
|
||||
#end
|
||||
#if(${swagger2})
|
||||
@ApiModel(value="${entity}对象", description="$!{table.comment}")
|
||||
#end
|
||||
#if(${superEntityClass})
|
||||
public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {
|
||||
#elseif(${activeRecord})
|
||||
public class ${entity} extends Model<${entity}> {
|
||||
#else
|
||||
public class ${entity} implements Serializable {
|
||||
#end
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
## ---------- BEGIN 字段循环遍历 ----------
|
||||
#foreach($field in ${table.fields})
|
||||
## 自定义属性,是否是主键
|
||||
#set($custom_is_pk=false)
|
||||
|
||||
#if(${field.keyFlag})
|
||||
#set($keyPropertyName=${field.propertyName})
|
||||
#end
|
||||
#if("$!field.comment" != "")
|
||||
#if(${swagger2})
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
#else
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
#end
|
||||
#end
|
||||
#if(${field.keyFlag})
|
||||
## 主键
|
||||
#if(${field.keyIdentityFlag})
|
||||
@TableId(value = "${field.name}", type = IdType.AUTO)
|
||||
#elseif(!$null.isNull(${idType}) && "$!idType" != "")
|
||||
## 设置主键注解
|
||||
@TableId(value = "${field.name}", type = IdType.${idType})
|
||||
## 是主键类型
|
||||
#set($custom_is_pk=true)
|
||||
#elseif(${field.convert})
|
||||
@TableId("${field.name}")
|
||||
#end
|
||||
## 普通字段
|
||||
#elseif(${field.fill})
|
||||
## ----- 存在字段填充设置 -----
|
||||
#if(${field.convert})
|
||||
@TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
||||
#else
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
#end
|
||||
#elseif(${field.convert})
|
||||
@TableField("${field.name}")
|
||||
#end
|
||||
## 乐观锁注解
|
||||
#if(${versionFieldName}==${field.name})
|
||||
@Version
|
||||
#end
|
||||
## 逻辑删除注解
|
||||
#if(${logicDeleteFieldName}==${field.name})
|
||||
@TableLogic
|
||||
#end
|
||||
#if(${custom_is_pk})
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#else
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#end
|
||||
#end
|
||||
## ---------- END 字段循环遍历 ----------
|
||||
#if(!${entityLombokModel})
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.propertyType.equals("boolean")})
|
||||
#set($getprefix="is")
|
||||
#else
|
||||
#set($getprefix="get")
|
||||
#end
|
||||
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
#if(${entityBuilderModel})
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#else
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#end
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
#if(${entityBuilderModel})
|
||||
return this;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if(${entityColumnConstant})
|
||||
#foreach($field in ${table.fields})
|
||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
||||
|
||||
#end
|
||||
#end
|
||||
#if(${activeRecord})
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
#if(${keyPropertyName})
|
||||
return this.${keyPropertyName};
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
}
|
||||
|
||||
#end
|
||||
#if(!${entityLombokModel})
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
#foreach($field in ${table.fields})
|
||||
#if($!{foreach.index}==0)
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
#else
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
#end
|
||||
#end
|
||||
"}";
|
||||
}
|
||||
#end
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package ${package.Mapper};
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import ${superMapperClassPackage};
|
||||
import ${package.Entity}.${entity};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${kotlin})
|
||||
interface ${table.mapperName} : ${superMapperClass}<${entity}>
|
||||
#else
|
||||
@Repository
|
||||
public interface ${table.mapperName} extends ${superMapperClass}<${entity}> {
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
${entity}QueryVo get${entity}ById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param ${cfg.entityObjectName}QueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<${entity}QueryVo> get${entity}PageList(@Param("page") Page page, @Param("param") ${entity}QueryParam ${cfg.entityObjectName}QueryParam);
|
||||
#end
|
||||
|
||||
}
|
||||
#end
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${package.Mapper}.${table.mapperName}">
|
||||
|
||||
#if(${enableCache})
|
||||
<!-- 开启二级缓存 -->
|
||||
<cache type="org.mybatis.caches.ehcache.LoggingEhcache"/>
|
||||
|
||||
#end
|
||||
#if(${baseResultMap})
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="${package.Entity}.${entity}">
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.keyFlag})##生成主键排在第一位
|
||||
<id column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
#foreach($field in ${table.commonFields})##生成公共字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#foreach($field in ${table.fields})
|
||||
#if(!${field.keyFlag})##生成普通字段
|
||||
<result column="${field.name}" property="${field.propertyName}" />
|
||||
#end
|
||||
#end
|
||||
</resultMap>
|
||||
|
||||
#end
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
#foreach($field in ${table.commonFields})
|
||||
${field.name},
|
||||
#end
|
||||
${table.fieldNames}
|
||||
</sql>
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
<select id="get${entity}ById" resultType="${cfg.queryVoPath}">
|
||||
select <include refid="Base_Column_List"/> from ${table.name} where ${cfg.pkIdColumnName} = #{id}
|
||||
</select>
|
||||
|
||||
<select id="get${entity}PageList" resultType="${cfg.queryVoPath}">
|
||||
select <include refid="Base_Column_List"/> from ${table.name}
|
||||
</select>
|
||||
|
||||
#end
|
||||
</mapper>
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.app.${package.ModuleName}.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
#if(${cfg.pageListOrder})
|
||||
import ${cfg.orderQueryParamPath};
|
||||
#else
|
||||
import ${cfg.queryParamCommonPath};
|
||||
#end
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="${entity}QueryParam对象", description="$!{table.comment}查询参数")
|
||||
#if(${cfg.pageListOrder})
|
||||
public class ${entity}QueryParam extends OrderQueryParam {
|
||||
#else
|
||||
public class ${entity}QueryParam extends QueryParam {
|
||||
#end
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.ruoyi.app.${package.ModuleName}.web.vo;
|
||||
|
||||
#if(${swagger2})
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
#end
|
||||
#if(${entityLombokModel})
|
||||
import lombok.Data;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${date}
|
||||
*/
|
||||
#if(${entityLombokModel})
|
||||
@Data
|
||||
#end
|
||||
#if(${table.convert})
|
||||
@TableName("${table.name}")
|
||||
#end
|
||||
@ApiModel(value="${entity}QueryVo对象", description="$!{table.comment}查询参数")
|
||||
public class ${entity}QueryVo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
## ---------- BEGIN 字段循环遍历 ----------
|
||||
#foreach($field in ${table.fields})
|
||||
|
||||
#if(${field.keyFlag})
|
||||
#set($keyPropertyName=${field.propertyName})
|
||||
#end
|
||||
#if("$!field.comment" != "")
|
||||
#if(${swagger2})
|
||||
@ApiModelProperty(value = "${field.comment}")
|
||||
#else
|
||||
/**
|
||||
* ${field.comment}
|
||||
*/
|
||||
#end
|
||||
#end
|
||||
#if(${field.keyFlag})
|
||||
## 普通字段
|
||||
#elseif(${field.fill})
|
||||
## ----- 存在字段填充设置 -----
|
||||
#if(${field.convert})
|
||||
@TableField(value = "${field.name}", fill = FieldFill.${field.fill})
|
||||
#else
|
||||
@TableField(fill = FieldFill.${field.fill})
|
||||
#end
|
||||
#elseif(${field.convert})
|
||||
@TableField("${field.name}")
|
||||
#end
|
||||
## 乐观锁注解
|
||||
#if(${versionFieldName}==${field.name})
|
||||
@Version
|
||||
#end
|
||||
## 逻辑删除注解
|
||||
#if(${logicDeleteFieldName}==${field.name})
|
||||
@TableLogic
|
||||
#end
|
||||
private ${field.propertyType} ${field.propertyName};
|
||||
#end
|
||||
## ---------- END 字段循环遍历 ----------
|
||||
#if(!${entityLombokModel})
|
||||
#foreach($field in ${table.fields})
|
||||
#if(${field.propertyType.equals("boolean")})
|
||||
#set($getprefix="is")
|
||||
#else
|
||||
#set($getprefix="get")
|
||||
#end
|
||||
|
||||
public ${field.propertyType} ${getprefix}${field.capitalName}() {
|
||||
return ${field.propertyName};
|
||||
}
|
||||
|
||||
#if(${entityBuilderModel})
|
||||
public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#else
|
||||
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
|
||||
#end
|
||||
this.${field.propertyName} = ${field.propertyName};
|
||||
#if(${entityBuilderModel})
|
||||
return this;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
|
||||
#if(${entityColumnConstant})
|
||||
#foreach($field in ${table.fields})
|
||||
public static final String ${field.name.toUpperCase()} = "${field.name}";
|
||||
|
||||
#end
|
||||
#end
|
||||
#if(${activeRecord})
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
#if(${keyPropertyName})
|
||||
return this.${keyPropertyName};
|
||||
#else
|
||||
return null;
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#if(!${entityLombokModel})
|
||||
@Override
|
||||
public String toString() {
|
||||
return "${entity}{" +
|
||||
#foreach($field in ${table.fields})
|
||||
#if($!{foreach.index}==0)
|
||||
"${field.propertyName}=" + ${field.propertyName} +
|
||||
#else
|
||||
", ${field.propertyName}=" + ${field.propertyName} +
|
||||
#end
|
||||
#end
|
||||
"}";
|
||||
}
|
||||
#end
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package ${package.Service};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${superServiceClassPackage};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
import ${cfg.paging};
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
#if(${kotlin})
|
||||
interface ${table.serviceName} : ${superServiceClass}<${entity}>
|
||||
#else
|
||||
public interface ${table.serviceName} extends ${superServiceClass}<${entity}> {
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
${entity}QueryVo get${entity}ById(Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param ${cfg.entityObjectName}QueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<${entity}QueryVo> get${entity}PageList(${entity}QueryParam ${cfg.entityObjectName}QueryParam) throws Exception;
|
||||
#end
|
||||
|
||||
}
|
||||
#end
|
||||
@@ -0,0 +1,57 @@
|
||||
package ${package.ServiceImpl};
|
||||
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
import ${cfg.queryParamPath};
|
||||
import ${cfg.queryVoPath};
|
||||
import ${superServiceImplClassPackage};
|
||||
import ${cfg.paging};
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* $!{table.comment} 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
#if(${kotlin})
|
||||
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {
|
||||
|
||||
}
|
||||
#else
|
||||
public class ${table.serviceImplName} extends BaseServiceImpl<${table.mapperName}, ${entity}> implements ${table.serviceName} {
|
||||
|
||||
@Autowired
|
||||
private ${table.mapperName} ${cfg.mapperObjectName};
|
||||
#if(${cfg.generatorStrategy})
|
||||
|
||||
@Override
|
||||
public ${entity}QueryVo get${entity}ById(Serializable id) throws Exception{
|
||||
return ${cfg.mapperObjectName}.get${entity}ById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<${entity}QueryVo> get${entity}PageList(${entity}QueryParam ${cfg.entityObjectName}QueryParam) throws Exception{
|
||||
Page page = setPageParam(${cfg.entityObjectName}QueryParam,OrderItem.desc("create_time"));
|
||||
IPage<${entity}QueryVo> iPage = ${cfg.mapperObjectName}.get${entity}PageList(page,${cfg.entityObjectName}QueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
#end
|
||||
|
||||
}
|
||||
#end
|
||||
@@ -0,0 +1,447 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>ruoyi</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>4.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>ruoyi-plus-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<utf8>UTF-8</utf8>
|
||||
<project.build.sourceEncoding>${utf8}</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>${utf8}</project.reporting.outputEncoding>
|
||||
<project-parent.version>${parent.version}</project-parent.version>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
|
||||
<mybatis-plus-boot-starter.version>3.2.0</mybatis-plus-boot-starter.version>
|
||||
<fastjson.version>1.2.60</fastjson.version>
|
||||
<swagger2.version>2.6.1</swagger2.version>
|
||||
<commons-lang3.version>3.9</commons-lang3.version>
|
||||
<commons-collections4.version>4.4</commons-collections4.version>
|
||||
<velocity.version>1.7</velocity.version>
|
||||
<mysql.version>5.1.47</mysql.version>
|
||||
<druid.version>1.1.20</druid.version>
|
||||
<commons-io.version>2.6</commons-io.version>
|
||||
<reflections.version>0.9.11</reflections.version>
|
||||
<commons-codec.version>1.13</commons-codec.version>
|
||||
<commons-net.version>3.6</commons-net.version>
|
||||
<jansi.version>1.18</jansi.version>
|
||||
<lombok.version>1.18.8</lombok.version>
|
||||
<commons-pool2.version>2.7.0</commons-pool2.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<spring-boot-admin.version>2.1.6</spring-boot-admin.version>
|
||||
<hutool.version>4.6.4</hutool.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
|
||||
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
|
||||
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- spring-boot start -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- spring-boot end -->
|
||||
|
||||
<!-- mybatis-plus begin -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>${mybatis-plus-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>${mybatis-plus-boot-starter.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>${velocity.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
<!-- mybatis-plus end -->
|
||||
|
||||
<!-- alibaba start -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<!-- alibaba end -->
|
||||
|
||||
<!-- swagger start -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.5.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger2.version}</version>
|
||||
</dependency>
|
||||
<!-- swagger end -->
|
||||
|
||||
<!-- apache commons start -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>${commons-collections4.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons-codec.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-net</groupId>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<version>${commons-net.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>${commons-pool2.version}</version>
|
||||
</dependency>
|
||||
<!-- apache commons end -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>${reflections.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.fusesource.jansi</groupId>
|
||||
<artifactId>jansi</artifactId>
|
||||
<version>${jansi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- spring boot admin start -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
<version>${spring-boot-admin.version}</version>
|
||||
</dependency>
|
||||
<!-- spring boot admin end -->
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>spring-boot-plus</finalName>
|
||||
|
||||
<resources>
|
||||
<!-- 资源文件配置 -->
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>config/**</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
|
||||
<!-- 过滤配置文件到config目录 -->
|
||||
<resource>
|
||||
<directory>src/main/resources/config</directory>
|
||||
<filtering>true</filtering>
|
||||
<targetPath>config</targetPath>
|
||||
<includes>
|
||||
<include>application.yml</include>
|
||||
<include>application-${profileActive}.yml</include>
|
||||
<include>banner.txt</include>
|
||||
<include>logback.xml</include>
|
||||
<include>*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<!-- 由于没有直接继承spring-boot-starter-parent,此处修添加主类和设置repackage -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>io.geekidea.springbootplus.SpringBootPlusApplication</mainClass>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven-resources-plugin.version}</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- 打包时跳过测试 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
<testFailureIgnore>true</testFailureIgnore>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- 打包插件 -->
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<finalName>${project.build.finalName}-server</finalName>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${maven-javadoc-plugin.version}</version>
|
||||
<configuration>
|
||||
<additionalOptions>
|
||||
<additionalOption>-Xdoclint:none</additionalOption>
|
||||
</additionalOptions>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
|
||||
<!--MAVEN打包选择运行环境-->
|
||||
<!-- 1:local(默认) 本地 2:dev:开发环境 3:test 4:uat 用户验收测试 5.prod:生产环境 -->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local</id>
|
||||
<properties>
|
||||
<profileActive>local</profileActive>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<profileActive>dev</profileActive>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>test</id>
|
||||
<properties>
|
||||
<profileActive>test</profileActive>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>uat</id>
|
||||
<properties>
|
||||
<profileActive>uat</profileActive>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<profileActive>prod</profileActive>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<repositories>
|
||||
<!--阿里云仓库-->
|
||||
<repository>
|
||||
<id>aliyun</id>
|
||||
<name>aliyun-maven</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://maven.aliyun.com/repository/spring</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>maven-central</name>
|
||||
<url>http://central.maven.org/maven2/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus;
|
||||
|
||||
import de.codecentric.boot.admin.server.config.EnableAdminServer;
|
||||
import com.ruoyi.plus.util.PrintApplicationInfo;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
|
||||
/**
|
||||
* spring-boot-plus 项目启动入口
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@EnableAsync
|
||||
//@EnableScheduling
|
||||
@EnableTransactionManagement
|
||||
@EnableConfigurationProperties
|
||||
//@EnableAdminServer
|
||||
@MapperScan({"com.ruoyi.plus.**.mapper"})
|
||||
@SpringBootApplication
|
||||
public class SpringBootPlusApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 启动spring-boot-plus
|
||||
ConfigurableApplicationContext context = SpringApplication.run(SpringBootPlusApplication.class, args);
|
||||
// 打印项目信息
|
||||
PrintApplicationInfo.print(context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.aop;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.plus.common.api.ApiCode;
|
||||
import com.ruoyi.plus.common.api.ApiResult;
|
||||
import com.ruoyi.plus.util.AnsiUtil;
|
||||
import com.ruoyi.plus.util.DateUtil;
|
||||
import com.ruoyi.plus.util.IpUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Controller Aop
|
||||
* 获取响应结果信息
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
@Aspect
|
||||
public class LogAop {
|
||||
|
||||
/**
|
||||
* 切点
|
||||
*/
|
||||
private static final String POINTCUT = "execution(public * io.geekidea.springbootplus.*.web.controller..*.*(..))";
|
||||
/**
|
||||
* 默认的请求内容类型,表单提交
|
||||
**/
|
||||
private static final String APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
|
||||
/**
|
||||
* JSON请求内容类型
|
||||
**/
|
||||
private static final String APPLICATION_JSON = "application/json";
|
||||
/**
|
||||
* GET请求
|
||||
**/
|
||||
private static final String GET = "GET";
|
||||
/**
|
||||
* POST请求
|
||||
**/
|
||||
private static final String POST = "POST";
|
||||
|
||||
/**
|
||||
* 请求日志是否格式化输出
|
||||
*/
|
||||
private boolean requestLogFormat;
|
||||
|
||||
/**
|
||||
* 响应日期是否格式化输出
|
||||
*/
|
||||
private boolean responseLogFormat;
|
||||
|
||||
@Around(POINTCUT)
|
||||
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
|
||||
// 获取请求相关信息
|
||||
try {
|
||||
// 获取当前的HttpServletRequest对象
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
|
||||
// 获取请求类名和方法名称
|
||||
Signature signature = joinPoint.getSignature();
|
||||
|
||||
// 获取真实的方法对象
|
||||
MethodSignature methodSignature = (MethodSignature) signature;
|
||||
Method method = methodSignature.getMethod();
|
||||
|
||||
// 请求全路径
|
||||
String url = request.getRequestURI();
|
||||
map.put("path",url);
|
||||
// IP地址
|
||||
String ip = IpUtil.getRequestIp();
|
||||
map.put("ip",ip);
|
||||
|
||||
// 获取请求方式
|
||||
String requestMethod = request.getMethod();
|
||||
map.put("requestMethod",requestMethod);
|
||||
|
||||
// 获取请求内容类型
|
||||
String contentType = request.getContentType();
|
||||
map.put("contentType",contentType);
|
||||
|
||||
// 判断控制器方法参数中是否有RequestBody注解
|
||||
Annotation[][] annotations = method.getParameterAnnotations();
|
||||
boolean isRequestBody = isRequestBody(annotations);
|
||||
map.put("isRequestBody",isRequestBody);
|
||||
// 设置请求参数
|
||||
Object requestParamJson = getRequestParamJsonString(joinPoint, request, requestMethod, contentType, isRequestBody);
|
||||
map.put("param",requestParamJson);
|
||||
map.put("time", DateUtil.getYYYYMMDDHHMMSS(new Date()));
|
||||
|
||||
// 获取请求头token
|
||||
map.put("x-auth-token",request.getHeader("x-auth-token"));
|
||||
|
||||
String requestInfo = null;
|
||||
try {
|
||||
if (requestLogFormat){
|
||||
requestInfo = "\n" + JSON.toJSONString(map,true);
|
||||
}else{
|
||||
requestInfo = JSON.toJSONString(map);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
log.info(AnsiUtil.getAnsi(Ansi.Color.GREEN,"requestInfo:" + requestInfo));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 执行目标方法,获得返回值
|
||||
Object result = joinPoint.proceed();
|
||||
try{
|
||||
if (result != null && result instanceof ApiResult){
|
||||
ApiResult apiResult = (ApiResult) result;
|
||||
int code = apiResult.getCode();
|
||||
String responseResultInfo = "responseResult:";
|
||||
if (responseLogFormat){
|
||||
responseResultInfo += "\n" + JSON.toJSONString(apiResult,true);
|
||||
}else{
|
||||
responseResultInfo += JSON.toJSONString(apiResult);
|
||||
}
|
||||
if (code == ApiCode.SUCCESS.getCode()){
|
||||
log.info(AnsiUtil.getAnsi(Ansi.Color.BLUE,responseResultInfo));
|
||||
}else{
|
||||
log.error(AnsiUtil.getAnsi(Ansi.Color.RED,responseResultInfo));
|
||||
}
|
||||
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("处理响应结果异常",e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取请求参数JSON字符串
|
||||
*
|
||||
* @param joinPoint
|
||||
* @param request
|
||||
* @param requestMethod
|
||||
* @param contentType
|
||||
* @param isRequestBody
|
||||
*/
|
||||
private Object getRequestParamJsonString(ProceedingJoinPoint joinPoint, HttpServletRequest request, String requestMethod, String contentType, boolean isRequestBody) {
|
||||
/**
|
||||
* 判断请求内容类型
|
||||
* 通常有3中请求内容类型
|
||||
* 1.发送get请求时,contentType为null
|
||||
* 2.发送post请求时,contentType为application/x-www-form-urlencoded
|
||||
* 3.发送post json请求,contentType为application/json
|
||||
* 4.发送post json请求并有RequestBody注解,contentType为application/json
|
||||
*/
|
||||
Object paramObject = null;
|
||||
int requestType = 0;
|
||||
if (GET.equals(requestMethod)) {
|
||||
requestType = 1;
|
||||
} else if (POST.equals(requestMethod)) {
|
||||
if (contentType == null) {
|
||||
requestType = 5;
|
||||
} else if (contentType.startsWith(APPLICATION_X_WWW_FORM_URLENCODED)) {
|
||||
requestType = 2;
|
||||
} else if (contentType.startsWith(APPLICATION_JSON)) {
|
||||
if (isRequestBody) {
|
||||
requestType = 4;
|
||||
} else {
|
||||
requestType = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 1,2,3中类型时,获取getParameterMap中所有的值,处理后序列化成JSON字符串
|
||||
if (requestType == 1 || requestType == 2 || requestType == 3 || requestType == 5) {
|
||||
Map<String, String[]> paramsMap = request.getParameterMap();
|
||||
paramObject = getJsonForParamMap(paramsMap);
|
||||
} else if (requestType == 4) { // POST,application/json,RequestBody的类型,简单判断,然后序列化成JSON字符串
|
||||
Object[] args = joinPoint.getArgs();
|
||||
paramObject = argsArrayToJsonString(args);
|
||||
}
|
||||
|
||||
return paramObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断控制器方法参数中是否有RequestBody注解
|
||||
*
|
||||
* @param annotations
|
||||
* @return
|
||||
*/
|
||||
private boolean isRequestBody(Annotation[][] annotations) {
|
||||
boolean isRequestBody = false;
|
||||
for (Annotation[] annotationArray : annotations) {
|
||||
for (Annotation annotation : annotationArray) {
|
||||
if (annotation instanceof RequestBody) {
|
||||
isRequestBody = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isRequestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求参数拼装
|
||||
*
|
||||
* @param args
|
||||
* @return
|
||||
*/
|
||||
private Object argsArrayToJsonString(Object[] args) {
|
||||
if (args == null) {
|
||||
return null;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
return args[0];
|
||||
} else {
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取参数Map的JSON字符串
|
||||
*
|
||||
* @param paramsMap
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getJsonForParamMap(Map<String, String[]> paramsMap) {
|
||||
int paramSize = paramsMap.size();
|
||||
if (paramsMap == null || paramSize == 0) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
for (Map.Entry<String, String[]> kv : paramsMap.entrySet()) {
|
||||
String key = kv.getKey();
|
||||
String[] values = kv.getValue();
|
||||
if (values == null) { // 没有值
|
||||
jsonObject.put(key, null);
|
||||
} else if (values.length == 1) { // 一个值
|
||||
jsonObject.put(key, values[0]);
|
||||
} else { // 多个值
|
||||
jsonObject.put(key, values);
|
||||
}
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.api;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 响应码
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
public enum ApiCode {
|
||||
|
||||
SUCCESS(200, "操作成功"),
|
||||
|
||||
UNAUTHORIZED(401, "非法访问"),
|
||||
|
||||
NOT_PERMISSION(403, "没有权限"),
|
||||
|
||||
NOT_FOUND(404, "你请求的路径不存在"),
|
||||
|
||||
FAIL(500, "操作失败"),
|
||||
|
||||
SYSTEM_EXCEPTION(5000,"系统异常!"),
|
||||
|
||||
PARAMETER_EXCEPTION(5001,"请求参数校验异常"),
|
||||
|
||||
PARAMETER_PARSE_EXCEPTION(5002,"请求参数解析异常"),
|
||||
|
||||
HTTP_MEDIA_TYPE_EXCEPTION(5003,"HTTP Media 类型异常"),
|
||||
|
||||
SYSTEM_LOGIN_EXCEPTION(5005,"系统登录异常")
|
||||
|
||||
;
|
||||
|
||||
private final int code;
|
||||
private final String msg;
|
||||
|
||||
ApiCode(final int code, final String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static ApiCode getApiCode(int code) {
|
||||
ApiCode[] ecs = ApiCode.values();
|
||||
for (ApiCode ec : ecs) {
|
||||
if (ec.getCode() == code) {
|
||||
return ec;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.api;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ApiResultEST API 公共控制器
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class ApiController {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求成功
|
||||
* </p>
|
||||
*
|
||||
* @param data 数据内容
|
||||
* @param <T> 对象泛型
|
||||
* @return
|
||||
*/
|
||||
protected <T> ApiResult<T> ok(T data) {
|
||||
return ApiResult.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求失败
|
||||
* </p>
|
||||
*
|
||||
* @param msg 提示内容
|
||||
* @return
|
||||
*/
|
||||
protected ApiResult<Object> fail(String msg) {
|
||||
return ApiResult.fail(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 请求失败
|
||||
* </p>
|
||||
*
|
||||
* @param apiCode 请求错误码
|
||||
* @return
|
||||
*/
|
||||
protected ApiResult<Object> fail(ApiCode apiCode) {
|
||||
return ApiResult.fail(apiCode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.api;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 返回结果
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class ApiResult<T> implements Serializable {
|
||||
|
||||
private int code;
|
||||
|
||||
private T data;
|
||||
|
||||
private String msg;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date time;
|
||||
|
||||
public ApiResult() {
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult result(boolean flag){
|
||||
if (flag){
|
||||
return ok();
|
||||
}
|
||||
return fail("");
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode){
|
||||
return result(apiCode,null);
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode,Object data){
|
||||
return result(apiCode,null,data);
|
||||
}
|
||||
|
||||
public static ApiResult result(ApiCode apiCode,String msg,Object data){
|
||||
String message = apiCode.getMsg();
|
||||
if (StringUtils.isNotBlank(msg)){
|
||||
message = msg;
|
||||
}
|
||||
return ApiResult.builder()
|
||||
.code(apiCode.getCode())
|
||||
.msg(message)
|
||||
.data(data)
|
||||
.time(new Date())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static ApiResult ok(){
|
||||
return ok(null);
|
||||
}
|
||||
|
||||
public static ApiResult ok(Object data){
|
||||
return result(ApiCode.SUCCESS,data);
|
||||
}
|
||||
|
||||
public static ApiResult ok(String key,Object value){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(key,value);
|
||||
return ok(map);
|
||||
}
|
||||
|
||||
public static ApiResult fail(ApiCode apiCode){
|
||||
return result(apiCode,null);
|
||||
}
|
||||
|
||||
public static ApiResult fail(String msg){
|
||||
return result(ApiCode.FAIL,msg,null);
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult fail(ApiCode apiCode,Object data){
|
||||
if (ApiCode.SUCCESS == apiCode){
|
||||
throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode());
|
||||
}
|
||||
return result(apiCode,data);
|
||||
|
||||
}
|
||||
|
||||
public static ApiResult fail(String key,Object value){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(key,value);
|
||||
return result(ApiCode.FAIL,map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.api;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.api.IErrorCode;
|
||||
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* REST API 业务断言<br>
|
||||
* 参考:org.junit.Assert
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
public class Assert {
|
||||
|
||||
protected Assert() {
|
||||
// to do noting
|
||||
}
|
||||
|
||||
/**
|
||||
* 大于O
|
||||
*/
|
||||
public static void gtZero(Integer num, IErrorCode errorCode) {
|
||||
if (num == null || num <= 0) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 大于等于O
|
||||
*/
|
||||
public static void geZero(Integer num, IErrorCode errorCode) {
|
||||
if (num == null || num < 0) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* num1大于num2
|
||||
*/
|
||||
public static void gt(Integer num1, Integer num2, IErrorCode errorCode) {
|
||||
if (num1 <= num2) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* num1大于等于num2
|
||||
*/
|
||||
public static void ge(Integer num1, Integer num2, IErrorCode errorCode) {
|
||||
if (num1 < num2) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* obj1 eq obj2
|
||||
*/
|
||||
public static void eq(Object obj1, Object obj2, IErrorCode errorCode) {
|
||||
if (!obj1.equals(obj2)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isTrue(boolean condition, IErrorCode errorCode) {
|
||||
if (!condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isFalse(boolean condition, IErrorCode errorCode) {
|
||||
if (condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isNull(IErrorCode errorCode, Object... conditions) {
|
||||
if (ObjectUtils.isNotNull(conditions)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notNull(IErrorCode errorCode, Object... conditions) {
|
||||
if (ObjectUtils.isNull(conditions)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 失败结果
|
||||
* </p>
|
||||
*
|
||||
* @param errorCode 异常错误码
|
||||
*/
|
||||
public static void fail(IErrorCode errorCode) {
|
||||
throw new ApiException(errorCode);
|
||||
}
|
||||
|
||||
public static void fail(boolean condition, IErrorCode errorCode) {
|
||||
if (condition) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void fail(String message) {
|
||||
throw new ApiException(message);
|
||||
}
|
||||
|
||||
public static void fail(boolean condition, String message) {
|
||||
if (condition) {
|
||||
Assert.fail(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Object[] array, IErrorCode errorCode) {
|
||||
if (ObjectUtils.isEmpty(array)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void noNullElements(Object[] array, IErrorCode errorCode) {
|
||||
if (array != null) {
|
||||
for (Object element : array) {
|
||||
if (element == null) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Collection<?> collection, IErrorCode errorCode) {
|
||||
if (CollectionUtils.isNotEmpty(collection)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notEmpty(Map<?, ?> map, IErrorCode errorCode) {
|
||||
if (ObjectUtils.isEmpty(map)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isInstanceOf(Class<?> type, Object obj, IErrorCode errorCode) {
|
||||
Assert.notNull(errorCode, type);
|
||||
if (!type.isInstance(obj)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static void isAssignable(Class<?> superType, Class<?> subType, IErrorCode errorCode) {
|
||||
Assert.notNull(errorCode, superType);
|
||||
if (subType == null || !superType.isAssignableFrom(subType)) {
|
||||
Assert.fail(errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constant;
|
||||
|
||||
|
||||
public interface CacheKey {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constant;
|
||||
|
||||
/**
|
||||
* 常量
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface CommonConstant {
|
||||
|
||||
/**
|
||||
* 默认页码为1
|
||||
*/
|
||||
Integer DEFAULT_PAGE_INDEX = 1;
|
||||
|
||||
/**
|
||||
* 默认页大小为10
|
||||
*/
|
||||
Integer DEFAULT_PAGE_SIZE = 10;
|
||||
|
||||
/**
|
||||
* 登录用户
|
||||
*/
|
||||
String LOGIN_SYS_USER = "loginSysUser";
|
||||
|
||||
/**
|
||||
* 登陆token
|
||||
*/
|
||||
String TOKEN = "token";
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
String REFRESH_TOKEN = "refresh_token";
|
||||
|
||||
/**
|
||||
* 初始密码
|
||||
*/
|
||||
String INIT_PWD = "123456";
|
||||
|
||||
/**
|
||||
* 默认头像
|
||||
*/
|
||||
String DEFAULT_HEAD_URL = "";
|
||||
|
||||
/**
|
||||
* 管理员角色名称
|
||||
*/
|
||||
String ADMIN_ROLE_NAME = "管理员";
|
||||
|
||||
String ADMIN_LOGIN = "adminLogin";
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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.ruoyi.plus.common.constant;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* redis key 常量
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2019-05-23
|
||||
**/
|
||||
public interface CommonRedisKey {
|
||||
|
||||
/**
|
||||
* 系统登录用户
|
||||
*/
|
||||
String LOGIN_SYS_USER = "login:sys:user:%s";
|
||||
/**
|
||||
* 系统登录token
|
||||
*/
|
||||
String LOGIN_TOKEN = "login:token";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constant;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 日期格式常量
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface DatePattern {
|
||||
|
||||
/**
|
||||
* 年-月-日
|
||||
*/
|
||||
String yyyy_MM_dd = "yyyy-MM-dd";
|
||||
/**
|
||||
* 年-月-日 时:分
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
|
||||
/**
|
||||
* 年-月-日 时:分:秒
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* 年-月-日 时:分:秒:毫秒
|
||||
*/
|
||||
String yyyy_MM_dd_HH_mm_ss_S = "yyyy-MM-dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 时:分
|
||||
*/
|
||||
String HH_mm = "HH:mm";
|
||||
/**
|
||||
* 时:分:秒
|
||||
*/
|
||||
String HH_mm_ss = "HH:mm:ss";
|
||||
/**
|
||||
* 时:分:秒:毫秒
|
||||
*/
|
||||
String HH_mm_ss_S = "HH:mm:ss:S";
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constraints;
|
||||
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 自定义系统内的枚举验证注解
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Documented
|
||||
@Constraint(validatedBy = { EmailValidator.class })
|
||||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface Email {
|
||||
String message() default "请输入有效的邮箱";
|
||||
|
||||
Class<?>[] groups() default { };
|
||||
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constraints;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 自定义邮箱验证注解实现类
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class EmailValidator implements ConstraintValidator<Email, String> {
|
||||
private static final String REG_EX = "^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$";
|
||||
private static final Pattern PATTERN = Pattern.compile(REG_EX);
|
||||
|
||||
@Override
|
||||
public void initialize(Email parameters) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
if (value ==null){
|
||||
return true;
|
||||
}
|
||||
return PATTERN.matcher(value).matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constraints;
|
||||
|
||||
import com.ruoyi.plus.common.enums.BaseTypeStateEnum;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 自定义邮箱正则验证注解
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Documented
|
||||
@Constraint(validatedBy = { EnumTypeValidator.class })
|
||||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface EnumType {
|
||||
String message() default "请输入正确的类型值";
|
||||
|
||||
Class<? extends BaseTypeStateEnum> type();
|
||||
|
||||
Class<?>[] groups() default { };
|
||||
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
package com.ruoyi.plus.common.constraints;
|
||||
|
||||
import com.ruoyi.plus.common.enums.BaseTypeStateEnum;
|
||||
import com.ruoyi.plus.common.exception.BusinessException;
|
||||
import com.ruoyi.plus.util.EnumUtil;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* 自定义系统内的枚举验证注解实现类
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class EnumTypeValidator implements ConstraintValidator<EnumType, Integer> {
|
||||
|
||||
private Class<? extends BaseTypeStateEnum> baseTypeStateEnum;
|
||||
|
||||
@Override
|
||||
public void initialize(EnumType parameters) {
|
||||
baseTypeStateEnum = parameters.type();
|
||||
if (baseTypeStateEnum == null){
|
||||
throw new BusinessException("请传入枚举类型类");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
if (value ==null){
|
||||
return true;
|
||||
}
|
||||
return EnumUtil.exists(baseTypeStateEnum,value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constraints;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 自定义身份证号码正则验证注解
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Documented
|
||||
@Constraint(validatedBy = { IdCardValidator.class })
|
||||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface IdCard {
|
||||
String message() default "请输入有效的身份证号码";
|
||||
|
||||
Class<?>[] groups() default { };
|
||||
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constraints;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 自定义身份证号码验证注解实现类
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class IdCardValidator implements ConstraintValidator<IdCard, String> {
|
||||
private static final String REG_EX = "(^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{2}[0-9Xx]$)|(^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}[0-9Xx]$)";
|
||||
private static final Pattern PATTERN = Pattern.compile(REG_EX);
|
||||
|
||||
@Override
|
||||
public void initialize(IdCard parameters) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
if (value ==null){
|
||||
return true;
|
||||
}
|
||||
return PATTERN.matcher(value).matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constraints;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 自定义手机号码正则验证注解
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Documented
|
||||
@Constraint(validatedBy = { PhoneValidator.class })
|
||||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface Phone {
|
||||
String message() default "请输入有效的手机号码";
|
||||
|
||||
Class<?>[] groups() default { };
|
||||
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.constraints;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 自定义手机号码验证注解实现类
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class PhoneValidator implements ConstraintValidator<Phone, String> {
|
||||
|
||||
private static final String REG_EX = "^1[3,4,5,6,7,8,9]\\d{9}$";
|
||||
private static final Pattern PATTERN = Pattern.compile(REG_EX);
|
||||
|
||||
@Override
|
||||
public void initialize(Phone parameters) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
if (value ==null){
|
||||
return true;
|
||||
}
|
||||
return PATTERN.matcher(value).matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("BaseEntity")
|
||||
public abstract class BaseEntity implements Serializable{
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.enums;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface BaseTypeStateEnum {
|
||||
|
||||
Integer getKey();
|
||||
|
||||
String getValue();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.exception;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class BusinessException extends RuntimeException{
|
||||
private Integer code;
|
||||
public BusinessException() {
|
||||
}
|
||||
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BusinessException(Integer code ,String message){
|
||||
this(StringUtils.isBlank(message)?String.valueOf(code):message);
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.exception;
|
||||
|
||||
import com.ruoyi.plus.common.api.ApiCode;
|
||||
import com.ruoyi.plus.common.api.ApiResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
|
||||
/**
|
||||
* 全局Error/404处理
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiIgnore
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class GlobalErrorController implements ErrorController {
|
||||
|
||||
private static final String ERROR_PATH = "/error";
|
||||
|
||||
@RequestMapping(ERROR_PATH)
|
||||
public ApiResult handleError(){
|
||||
log.error("404 NOT FOUND");
|
||||
return ApiResult.fail(ApiCode.NOT_FOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorPath() {
|
||||
log.error("errorPath....");
|
||||
return ERROR_PATH;
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.exception;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.plus.common.api.ApiCode;
|
||||
import com.ruoyi.plus.common.api.ApiResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.HttpMediaTypeException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ControllerAdvice
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
/**
|
||||
* 非法参数验证异常
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public ApiResult handleMethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException ex) {
|
||||
BindingResult bindingResult = ex.getBindingResult();
|
||||
List<String> list = new ArrayList<>();
|
||||
List<FieldError> fieldErrors = bindingResult.getFieldErrors();
|
||||
for (FieldError fieldError : fieldErrors) {
|
||||
list.add(fieldError.getDefaultMessage());
|
||||
}
|
||||
Collections.sort(list);
|
||||
log.error("fieldErrors"+ JSON.toJSONString(list));
|
||||
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION,list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统登录异常处理
|
||||
* @param exception
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = SysLoginException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ApiResult sysLoginExceptionHandler(SysLoginException exception) {
|
||||
log.warn("系统登录异常:" + exception.getMessage());
|
||||
return ApiResult.fail(ApiCode.SYSTEM_LOGIN_EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HTTP解析请求参数异常
|
||||
* @param exception
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = HttpMessageNotReadableException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ApiResult httpMessageNotReadableException(HttpMessageNotReadableException exception) {
|
||||
log.error("httpMessageNotReadableException:",exception);
|
||||
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, ApiCode.PARAMETER_PARSE_EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP
|
||||
* @param exception
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = HttpMediaTypeException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ApiResult httpMediaTypeException(HttpMediaTypeException exception) {
|
||||
log.error("httpMediaTypeException:",exception);
|
||||
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, ApiCode.HTTP_MEDIA_TYPE_EXCEPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认的异常处理
|
||||
* @param exception
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ApiResult exceptionHandler(Exception exception) {
|
||||
log.error("exception:",exception);
|
||||
return ApiResult.fail(ApiCode.SYSTEM_EXCEPTION);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.exception;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 系统登录异常
|
||||
* @author geekidea
|
||||
* @date 2019-08-04
|
||||
*/
|
||||
public class SysLoginException extends RuntimeException{
|
||||
private Integer code;
|
||||
public SysLoginException() {
|
||||
}
|
||||
|
||||
public SysLoginException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SysLoginException(Integer code , String message){
|
||||
this(StringUtils.isBlank(message)?String.valueOf(code):message);
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 公共部分
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common;
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public interface BaseService<T> extends IService<T> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.plus.common.service.BaseService;
|
||||
import com.ruoyi.plus.common.web.param.OrderQueryParam;
|
||||
import com.ruoyi.plus.common.web.param.QueryParam;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements BaseService<T> {
|
||||
|
||||
protected Page setPageParam(QueryParam queryParam) {
|
||||
return setPageParam(queryParam,null);
|
||||
}
|
||||
|
||||
protected Page setPageParam(QueryParam queryParam, OrderItem defaultOrder) {
|
||||
Page page = new Page();
|
||||
// 设置当前页码
|
||||
page.setCurrent(queryParam.getCurrent());
|
||||
// 设置页大小
|
||||
page.setSize(queryParam.getSize());
|
||||
/**
|
||||
* 如果是queryParam是OrderQueryParam,并且不为空,则使用前端排序
|
||||
* 否则使用默认排序
|
||||
*/
|
||||
if (queryParam instanceof OrderQueryParam){
|
||||
OrderQueryParam orderQueryParam = (OrderQueryParam) queryParam;
|
||||
List<OrderItem> orderItems = orderQueryParam.getOrders();
|
||||
if (CollectionUtils.isEmpty(orderItems)){
|
||||
page.setOrders(Arrays.asList(defaultOrder));
|
||||
}else{
|
||||
page.setOrders(orderItems);
|
||||
}
|
||||
}else{
|
||||
page.setOrders(Arrays.asList(defaultOrder));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Api文档
|
||||
* </p>
|
||||
*
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/docs")
|
||||
@ApiIgnore
|
||||
public class ApiDocController extends BaseController {
|
||||
|
||||
/**
|
||||
* swaggerUI
|
||||
*/
|
||||
@GetMapping("")
|
||||
public String swaggerUI(){
|
||||
return "redirect:/swagger-ui.html";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.controller;
|
||||
|
||||
import com.ruoyi.plus.common.api.ApiController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class BaseController extends ApiController {
|
||||
|
||||
/**
|
||||
* 获取当前请求
|
||||
*
|
||||
* @return request
|
||||
*/
|
||||
public HttpServletRequest getRequest() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
}
|
||||
/**
|
||||
* 获取当前请求
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.controller;
|
||||
|
||||
import com.ruoyi.plus.common.api.ApiResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 项目根路径提示信息
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018/11/12
|
||||
*/
|
||||
@RestController
|
||||
@ApiIgnore
|
||||
@Slf4j
|
||||
public class IndexController {
|
||||
|
||||
@RequestMapping("/index")
|
||||
public ApiResult<String> index(){
|
||||
log.debug("index...");
|
||||
return ApiResult.ok("Welcome to Spring Boot Plus Project...");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.filter;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.plus.common.api.ApiResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* 设置允许跨域
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class CrossDomainFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Methods", "*");
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Headers", "*");
|
||||
httpServletResponse.setHeader("Access-Control-Request-Headers","*");
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Headers", "content-type,x-auth-token");
|
||||
httpServletResponse.setHeader("Access-Control-Expose-Headers", "*");
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
String method = request.getMethod();
|
||||
if ("OPTIONS".equals(method)){
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
PrintWriter w = response.getWriter();
|
||||
ApiResult apiResult = new ApiResult();
|
||||
apiResult.setCode(200);
|
||||
apiResult.setMsg("ok...");
|
||||
w.append(JSON.toJSONString(apiResult));
|
||||
return;
|
||||
}
|
||||
|
||||
filterChain.doFilter(servletRequest, httpServletResponse);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.filter;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请求路径过滤器
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class RequestPathFilter implements Filter {
|
||||
|
||||
private static List<String> excludes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
// 控制台日志忽略spring boot admin访问路径
|
||||
excludes.add("/actuator");
|
||||
excludes.add("/instances");
|
||||
excludes.add("/logfile");
|
||||
excludes.add("/sba-settings.js");
|
||||
excludes.add("/assets/img/favicon.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
String path = req.getServletPath();
|
||||
String url = req.getRequestURL().toString();
|
||||
|
||||
boolean isOut = true;
|
||||
for (String p : excludes){
|
||||
if (path.startsWith(p)){
|
||||
isOut = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isOut){
|
||||
log.debug("requestURL:"+url);
|
||||
}
|
||||
chain.doFilter(req,response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.interceptor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 权限拦截器
|
||||
*
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class PermissionInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
log.info(request.getRequestURI());
|
||||
log.info("\n\nPermissionInterceptor...\n\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.interceptor;
|
||||
|
||||
import com.ruoyi.plus.common.constant.CommonConstant;
|
||||
import com.ruoyi.plus.util.LoginUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Token超时拦截器
|
||||
*
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Slf4j
|
||||
public class TokenTimeoutInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
|
||||
// 如果访问的不是控制器,则跳出,继续执行下一个拦截器
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 获取token
|
||||
String token = request.getHeader(CommonConstant.TOKEN);
|
||||
boolean hastoken = false;
|
||||
if (StringUtils.isNotBlank(token)){
|
||||
hastoken = true;
|
||||
}
|
||||
if (hastoken == false){
|
||||
token = request.getParameter(CommonConstant.TOKEN);
|
||||
if (StringUtils.isNotBlank(token)){
|
||||
hastoken = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 排除自动刷新的路径
|
||||
if (hastoken == true){
|
||||
// 如果有token,延长时间
|
||||
redisTemplate.expire(token,LoginUtil.TOKEN_VALID_TIME_MINUTE, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("ID参数")
|
||||
public class IdParam implements Serializable {
|
||||
private static final long serialVersionUID = -5353973980674510450L;
|
||||
|
||||
@NotBlank(message="ID不能为空")
|
||||
private String id;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("主键状态VO")
|
||||
public class IdStatusParam implements Serializable {
|
||||
private static final long serialVersionUID = -7581307955242965701L;
|
||||
|
||||
@ApiModelProperty("主键ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("状态,1:启用 0:禁用")
|
||||
private Integer status;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IdStatusVo{" +
|
||||
"id='" + id + '\'' +
|
||||
", status=" + status +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 名称参数
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("名称参数")
|
||||
public class NameParam implements Serializable {
|
||||
private static final long serialVersionUID = -3710501706034574149L;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NameParam{" +
|
||||
"name='" + name + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.param;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 可排序查询参数对象
|
||||
* @author geekidea
|
||||
* @since 2019-08-04
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("可排序查询参数对象")
|
||||
public abstract class OrderQueryParam extends QueryParam{
|
||||
private static final long serialVersionUID = 57714391204790143L;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private List<OrderItem> orders;
|
||||
|
||||
public void defaultOrder(OrderItem orderItem){
|
||||
this.defaultOrders(Arrays.asList(orderItem));
|
||||
}
|
||||
|
||||
public void defaultOrders(List<OrderItem> orderItems){
|
||||
if (CollectionUtils.isEmpty(orderItems)){
|
||||
return;
|
||||
}
|
||||
this.orders = orderItems;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.param;
|
||||
|
||||
import com.ruoyi.plus.common.constant.CommonConstant;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("查询参数对象")
|
||||
public abstract class QueryParam implements Serializable{
|
||||
private static final long serialVersionUID = -3263921252635611410L;
|
||||
|
||||
@ApiModelProperty(value = "页码,默认为1")
|
||||
private Integer current = CommonConstant.DEFAULT_PAGE_INDEX;
|
||||
@ApiModelProperty(value = "页大小,默认为10")
|
||||
private Integer size = CommonConstant.DEFAULT_PAGE_SIZE;
|
||||
@ApiModelProperty(value = "搜索字符串")
|
||||
private String keyword;
|
||||
|
||||
public void setCurrent(Integer current) {
|
||||
if (current == null || current <= 0){
|
||||
this.current = CommonConstant.DEFAULT_PAGE_INDEX;
|
||||
}else{
|
||||
this.current = current;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
if (size == null || size <= 0){
|
||||
this.size = CommonConstant.DEFAULT_PAGE_SIZE;
|
||||
}else{
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 公共ID-NAME-VO对象
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@ApiModel("ID-NAME-VO")
|
||||
public class CommonIdName {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public CommonIdName(String id, String name) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CommonIdName() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommonIdName [id=" + id + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.common.web.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@ApiModel("分页")
|
||||
public class Paging<T> implements Serializable {
|
||||
private static final long serialVersionUID = -1683800405530086022L;
|
||||
|
||||
@ApiModelProperty("总行数")
|
||||
@JSONField(name = "total")
|
||||
@JsonProperty("total")
|
||||
private long total = 0;
|
||||
|
||||
@ApiModelProperty("数据列表")
|
||||
@JSONField(name = "records")
|
||||
@JsonProperty("records")
|
||||
private List<T> records = Collections.emptyList();
|
||||
|
||||
public Paging() {
|
||||
}
|
||||
|
||||
public Paging(IPage page) {
|
||||
this.total = page.getTotal();
|
||||
this.records = page.getRecords();
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<T> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(List<T> records) {
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Paging{" +
|
||||
"total=" + total +
|
||||
", records=" + records +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config;
|
||||
|
||||
import com.ruoyi.plus.common.web.filter.CrossDomainFilter;
|
||||
import com.ruoyi.plus.common.web.filter.RequestPathFilter;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
public class FilterConfig {
|
||||
|
||||
|
||||
@Bean
|
||||
public Filter crossDomainFilter(){
|
||||
return new CrossDomainFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Filter requestPathFilter(){
|
||||
return new RequestPathFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(1)
|
||||
public FilterRegistrationBean requestPathFilterBean() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setFilter(requestPathFilter());
|
||||
registration.addUrlPatterns("/*");
|
||||
return registration;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Order(2)
|
||||
public FilterRegistrationBean crossDomainFilterBean() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setFilter(crossDomainFilter());
|
||||
registration.addUrlPatterns("/*");
|
||||
return registration;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config;
|
||||
|
||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
|
||||
/**
|
||||
* 文件上传配置
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
public class MultipartConfig {
|
||||
|
||||
/**
|
||||
* 文件上传配置
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public MultipartConfigElement multipartConfigElement() {
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
//单个文件最大
|
||||
//factory.setMaxFileSize("100MB"); //KB,MB
|
||||
factory.setMaxFileSize(DataSize.of(100, DataUnit.MEGABYTES));
|
||||
///设置总上传数据总大小
|
||||
// factory.setMaxRequestSize("100MB");
|
||||
factory.setMaxRequestSize(DataSize.of(100,DataUnit.MEGABYTES));
|
||||
return factory.createMultipartConfig();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* MybatisPlus配置
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @since 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
/**
|
||||
* mybatis-plus分页插件<br>
|
||||
*/
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
return new PaginationInterceptor();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Redis Cache配置
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisCacheConfig extends CachingConfigurerSupport {
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public KeyGenerator keyGenerator() {
|
||||
return (target, method, params) -> {
|
||||
StringBuffer redisKey = new StringBuffer();
|
||||
redisKey.append(target.getClass().getName()).append("-");
|
||||
redisKey.append(method.getName());
|
||||
if (params.length > 0) {
|
||||
redisKey.append("-").append(Arrays.deepToString(params));
|
||||
}
|
||||
return redisKey.toString();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager(RedisConnectionFactory factory) {
|
||||
// 生成一个默认配置,通过config对象即可对缓存进行自定义配置
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
||||
// 设置缓存的默认过期时间,也是使用Duration设置
|
||||
config = config.entryTtl(Duration.ofMinutes(5)); // 过期时间5分钟
|
||||
//.disableCachingNullValues(); // 不缓存空值
|
||||
|
||||
// 设置一个初始化的缓存空间set集合
|
||||
Set<String> cacheNames = new HashSet<>();
|
||||
cacheNames.add("my-redis-cache1");
|
||||
cacheNames.add("my-redis-cache2");
|
||||
|
||||
// 对每个缓存空间应用不同的配置
|
||||
Map<String, RedisCacheConfiguration> configMap = new HashMap<>();
|
||||
configMap.put("my-redis-cache1", config);
|
||||
configMap.put("my-redis-cache2", config.entryTtl(Duration.ofSeconds(120)));
|
||||
|
||||
// 使用自定义的缓存配置初始化一个cacheManager
|
||||
RedisCacheManager cacheManager = RedisCacheManager.builder(factory)
|
||||
.initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置
|
||||
.withInitialCacheConfigurations(configMap)
|
||||
.build();
|
||||
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config;
|
||||
|
||||
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Redis Template 配置
|
||||
* </p>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
|
||||
// 自定义的string序列化器和fastjson序列化器
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
|
||||
// jackson 序列化器
|
||||
// GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
|
||||
|
||||
// fastjson 序列化器
|
||||
GenericFastJsonRedisSerializer jsonRedisSerializer = new GenericFastJsonRedisSerializer();
|
||||
|
||||
// kv 序列化
|
||||
redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||
redisTemplate.setValueSerializer(jsonRedisSerializer);
|
||||
|
||||
// hash 序列化
|
||||
redisTemplate.setHashKeySerializer(stringRedisSerializer);
|
||||
redisTemplate.setHashValueSerializer(jsonRedisSerializer);
|
||||
|
||||
redisTemplate.afterPropertiesSet();
|
||||
|
||||
return redisTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
factory.setReadTimeout(5000);//单位为ms
|
||||
factory.setConnectTimeout(5000);//单位为ms
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.ParameterBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.schema.ModelRef;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.service.Parameter;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Swagger2全局配置
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2Config {
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Value("${swagger.title}")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 基本包
|
||||
*/
|
||||
@Value("${swagger.base.package}")
|
||||
private String basePackage;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Value("${swagger.description}")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
@Value("${swagger.url}")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
@Value("${swagger.contact.name}")
|
||||
private String contactName;
|
||||
|
||||
/**
|
||||
* 作者网址
|
||||
*/
|
||||
@Value("${swagger.contact.url}")
|
||||
private String contactUrl;
|
||||
|
||||
/**
|
||||
* 作者邮箱
|
||||
*/
|
||||
@Value("${swagger.contact.email}")
|
||||
private String contactEmail;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
@Value("${swagger.version}")
|
||||
private String version;
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage(basePackage))
|
||||
.paths(PathSelectors.any())
|
||||
.build()
|
||||
.globalOperationParameters(setHeaderToken());
|
||||
}
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title(title)
|
||||
.description(description)
|
||||
.termsOfServiceUrl(url)
|
||||
.contact(new Contact(contactName,contactUrl,contactEmail))
|
||||
.version(version)
|
||||
.build();
|
||||
}
|
||||
private List<Parameter> setHeaderToken() {
|
||||
List<Parameter> pars = new ArrayList<>();
|
||||
|
||||
// TODO 测试token值,上线关闭
|
||||
String testTokenValue = "";
|
||||
ParameterBuilder tokenPar = new ParameterBuilder();
|
||||
Parameter tokenParameter = tokenPar.name("token").description("token").modelRef(new ModelRef("string")).parameterType("header").required(false).defaultValue(testTokenValue).build();
|
||||
pars.add(tokenParameter);
|
||||
return pars;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.converter;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 转换器配置
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
@Configuration
|
||||
public class ConverterConfig {
|
||||
|
||||
@Bean
|
||||
public Converter<String, Date> stringToDateConverter() {
|
||||
return new StringToDateConverter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Converter<String, Integer> stringToIntegerConverter() {
|
||||
return new StringToIntegerConverter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Converter<String, Double> stringToDoubleConverter() {
|
||||
return new StringToDoubleConverter();
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.converter;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <code>
|
||||
* 日期转换器,将请求参数的日期字符串转换成java.util.Date类型
|
||||
* </code>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class StringToDateConverter implements Converter<String, Date> {
|
||||
|
||||
@Override
|
||||
public Date convert(String source) {
|
||||
return StringToDateUtil.convert(source);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.converter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <code>
|
||||
* <pre>
|
||||
* 日期转换器,将请求参数的日期字符串转换成java.util.Date类型
|
||||
* 日期格式顺序:
|
||||
* 1.yyyy-MM-dd HH:mm:ss:S
|
||||
* 2.yyyy-MM-dd HH:mm:ss
|
||||
* 3.yyyy-MM-dd HH:mm
|
||||
* 4.yyyy-MM-dd HH
|
||||
* 5.yyyy-MM-dd
|
||||
* </pre>
|
||||
* </code>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class StringToDateUtil{
|
||||
/**
|
||||
* 日期格式化数组
|
||||
*/
|
||||
private static DateFormat[] dateFormats = {
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:S"),
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"),
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm"),
|
||||
new SimpleDateFormat("yyyy-MM-dd HH"),
|
||||
new SimpleDateFormat("yyyy-MM-dd"),
|
||||
new SimpleDateFormat("yyyy-MM")
|
||||
};
|
||||
|
||||
/**
|
||||
* <code>
|
||||
* <pre>
|
||||
* 1.如果日期字符串为空,则直接返回空
|
||||
* 2.使用格式化组进行格式化,如果解析成功,则直接返回
|
||||
* 4.否则,抛出非法参数异常
|
||||
* @param source 请求的日期参数
|
||||
* @return 解析后的日期类型:java.util.Date
|
||||
* @exception IllegalArgumentException 非法参数异常
|
||||
* </pre>
|
||||
* </code>
|
||||
*/
|
||||
public static Date convert(String source) {
|
||||
if (StringUtils.isBlank(source)){
|
||||
return null;
|
||||
}
|
||||
source = source.trim();
|
||||
|
||||
try{
|
||||
int timeLength = source.length();
|
||||
Long time = Long.parseLong(source);
|
||||
if (timeLength == 10){
|
||||
time = time * 1000;
|
||||
}
|
||||
Date date = new Date(time);
|
||||
return date;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
Date date = null;
|
||||
boolean flag = false;
|
||||
for (DateFormat dateFormat : dateFormats) {
|
||||
try {
|
||||
date = dateFormat.parse(source);
|
||||
flag = true;
|
||||
break;
|
||||
} catch (ParseException e) {
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
return date;
|
||||
}else{
|
||||
throw new IllegalArgumentException("不能解析日期:" + source);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.converter;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
/**
|
||||
* <code>
|
||||
*
|
||||
* </code>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class StringToDoubleConverter implements Converter<String, Double> {
|
||||
|
||||
@Override
|
||||
public Double convert(String source) {
|
||||
return StringToDoubleUtil.convert(source);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.converter;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* <code>
|
||||
* <pre>
|
||||
* 空字符串("")转换成Double的null
|
||||
*
|
||||
* </pre>
|
||||
* </code>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class StringToDoubleUtil {
|
||||
|
||||
public static Double convert(String source) {
|
||||
if (StringUtils.isBlank(source)){
|
||||
return null;
|
||||
}
|
||||
Double d = Double.parseDouble(source);
|
||||
return d;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.converter;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
|
||||
/**
|
||||
* <code>
|
||||
*
|
||||
* </code>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class StringToIntegerConverter implements Converter<String, Integer> {
|
||||
|
||||
@Override
|
||||
public Integer convert(String source) {
|
||||
return StringToIntegerUtil.convert(source);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.converter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* <code>
|
||||
* <pre>
|
||||
* 空字符串("")转换成Integer的null
|
||||
*
|
||||
* </pre>
|
||||
* </code>
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
public class StringToIntegerUtil {
|
||||
|
||||
public static Integer convert(String source) {
|
||||
if (StringUtils.isBlank(source)){
|
||||
return null;
|
||||
}
|
||||
Integer i = Integer.parseInt(source);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
|
||||
*
|
||||
* 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.ruoyi.plus.config.json.fastjson;
|
||||
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.serializer.ToStringSerializer;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author geekidea
|
||||
* @date 2018-11-08
|
||||
*/
|
||||
//@Configuration
|
||||
public class FastJsonMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
private static final String DEFAULT_CHARSET = "UTF-8";
|
||||
private static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
|
||||
@Override
|
||||
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
|
||||
|
||||
List<MediaType> mediaTypes = new ArrayList<>();
|
||||
mediaTypes.add(MediaType.APPLICATION_JSON);
|
||||
mediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
||||
mediaTypes.add(MediaType.TEXT_HTML);
|
||||
mediaTypes.add(new MediaType("application", "xml"));
|
||||
mediaTypes.add(new MediaType("text", "xml"));
|
||||
mediaTypes.add(new MediaType("application", "*+xml"));
|
||||
mediaTypes.add(MediaType.ALL);
|
||||
fastJsonHttpMessageConverter.setSupportedMediaTypes(mediaTypes);
|
||||
|
||||
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
||||
fastJsonConfig.setCharset(Charset.forName(DEFAULT_CHARSET));
|
||||
fastJsonConfig.setDateFormat(DEFAULT_DATE_FORMAT);
|
||||
SerializerFeature[] serializerFeatures = new SerializerFeature[]{
|
||||
SerializerFeature.PrettyFormat, // 格式化
|
||||
SerializerFeature.WriteMapNullValue, // 输出空值
|
||||
SerializerFeature.WriteNullListAsEmpty, // 空集合输出[]
|
||||
SerializerFeature.WriteDateUseDateFormat // 日期格式化
|
||||
};
|
||||
fastJsonConfig.setSerializerFeatures(serializerFeatures);
|
||||
|
||||
|
||||
SerializeConfig serializeConfig = SerializeConfig.globalInstance;
|
||||
serializeConfig.put(BigInteger.class, ToStringSerializer.instance);
|
||||
serializeConfig.put(Long.class, ToStringSerializer.instance);
|
||||
serializeConfig.put(Long.TYPE, ToStringSerializer.instance);
|
||||
fastJsonConfig.setSerializeConfig(serializeConfig);
|
||||
|
||||
fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
|
||||
|
||||
converters.add(0,fastJsonHttpMessageConverter);
|
||||
|
||||
}
|
||||
}
|
||||
Loaded 100 of 198 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user