[新增功能](el-admin v2.5): v2.5 beta

详情 https://www.ydyno.com/archives/1225.html
pull/361/head^2
ZhengJie 2020-05-05 20:58:02 +08:00
parent d35ffc9d8c
commit 7c35a79c95
297 changed files with 5096 additions and 2853 deletions

View File

@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright 2019 Zheng Jie
Copyright 2019-2020 Zheng Jie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.annotation;
import java.lang.annotation.ElementType;

View File

@ -1,7 +1,21 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.annotation;
import me.zhengjie.aspect.LimitType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.annotation;
import java.lang.annotation.ElementType;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.aspect;
import com.google.common.collect.ImmutableList;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.aspect;
/**

View File

@ -13,18 +13,11 @@ import java.sql.Timestamp;
@Setter
public class BaseDTO implements Serializable {
private Boolean isDelete;
private String createBy;
private String updatedBy;
private Timestamp createTime;
private Timestamp updateTime;
@Override
public String toString() {
return "BaseDTO{" +
"isDelete=" + isDelete +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}

View File

@ -1,5 +1,21 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.base;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -8,7 +24,6 @@ import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
@ -17,6 +32,7 @@ import java.lang.reflect.Field;
import java.sql.Timestamp;
/**
* is_del
* @author Zheng Jie
* @Date 2019102420:46:32
*/
@ -26,38 +42,30 @@ import java.sql.Timestamp;
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity implements Serializable {
/** 删除标识 **/
@Column(name = "is_delete", columnDefinition = "bit default 0")
private Boolean isDelete = false;
/**
*
*/
@CreatedBy
@Column(name = "create_by", updatable = false)
private String createdBy;
@ApiModelProperty(value = "创建人", hidden = true)
private String createBy;
/**
*
*/
@CreationTimestamp
@Column(name = "create_time", updatable = false)
private Timestamp createTime;
/**
*
*/
@LastModifiedBy
@Column(name = "update_by")
@ApiModelProperty(value = "更新人", hidden = true)
private String updatedBy;
/**
*
*/
@CreationTimestamp
@Column(name = "create_time", updatable = false)
@ApiModelProperty(value = "创建时间", hidden = true)
private Timestamp createTime;
@UpdateTimestamp
@Column(name = "update_time")
@ApiModelProperty(value = "更新时间", hidden = true)
private Timestamp updateTime;
/* 分组校验 */
public @interface Create {}
/* 分组校验 */
public @interface Update {}
@Override

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.base;
import java.util.List;

View File

@ -1,9 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;
import java.util.Optional;
/**

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import me.zhengjie.utils.SecurityUtils;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import lombok.Data;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import cn.hutool.core.lang.Assert;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import com.fasterxml.classmate.TypeResolver;
@ -27,11 +42,10 @@ import static com.google.common.collect.Lists.newArrayList;
import static springfox.documentation.schema.AlternateTypeRules.newRule;
/**
* api /swagger-ui.html
* api /doc.html
* @author Zheng Jie
* @date 2018-11-23
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@ -68,8 +82,9 @@ public class SwaggerConfig {
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("eladmin 接口文档")
.version("2.3")
.description("一个简单且易上手的 Spring boot 后台管理框架")
.title("EL-ADMIN 接口文档")
.version("2.4")
.build();
}

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.exception;
import lombok.Getter;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.exception;
import org.springframework.util.StringUtils;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.exception;
import org.springframework.util.StringUtils;

View File

@ -1,8 +1,22 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.exception.handler;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.exception.handler;
import lombok.extern.slf4j.Slf4j;
@ -7,7 +22,6 @@ import me.zhengjie.exception.EntityNotFoundException;
import me.zhengjie.utils.ThrowableUtil;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
/**
@ -7,10 +22,6 @@ package me.zhengjie.utils;
*/
public class ElAdminConstant {
public static final String RESET_PASS = "重置密码";
public static final String RESET_MAIL = "重置邮箱";
/**
* IP
*/

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import javax.crypto.Cipher;
@ -14,7 +29,7 @@ import java.nio.charset.StandardCharsets;
*/
public class EncryptUtils {
private static String strParam = "Passw0rd";
private static final String strParam = "Passw0rd";
private static Cipher cipher;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import cn.hutool.core.codec.Base64;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import org.springframework.data.domain.Page;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import cn.hutool.core.collection.CollUtil;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import org.springframework.beans.factory.annotation.Value;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import org.springframework.web.context.request.RequestContextHolder;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import cn.hutool.json.JSONObject;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import lombok.extern.slf4j.Slf4j;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import cn.hutool.core.io.resource.ClassPathResource;
@ -195,4 +210,26 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
}
return weekDays[w];
}
/**
* IP
* @return /
*/
public static String getLocalIp(){
InetAddress addr;
try {
addr = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
return "unknown";
}
byte[] ipAddr = addr.getAddress();
StringBuilder ipAddrStr = new StringBuilder();
for (int i = 0; i < ipAddr.length; i++) {
if (i > 0) {
ipAddrStr.append(".");
}
ipAddrStr.append(ipAddr[i] & 0xFF);
}
return ipAddrStr.toString();
}
}

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import me.zhengjie.exception.BadRequestException;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import cn.hutool.json.JSONArray;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import cn.hutool.core.util.ObjectUtil;

View File

@ -1,62 +1,83 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import me.zhengjie.utils.GenUtil;
import javax.persistence.*;
import java.io.Serializable;
/**
*
* @author Zheng Jie
* @date 2019-01-02
*/
@Data
@Getter
@Setter
@Entity
@NoArgsConstructor
@Table(name = "column_config")
public class ColumnInfo {
@Table(name = "code_column_config")
public class ColumnInfo implements Serializable {
@Id
@Column(name = "column_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@ApiModelProperty(value = "表名")
private String tableName;
/** 数据库字段名称 */
@ApiModelProperty(value = "数据库字段名称")
private String columnName;
/** 数据库字段类型 */
@ApiModelProperty(value = "数据库字段类型")
private String columnType;
/** 数据库字段键类型 */
@ApiModelProperty(value = "数据库字段键类型")
private String keyType;
/** 字段额外的参数 */
@ApiModelProperty(value = "字段额外的参数")
private String extra;
/** 数据库字段描述 */
@ApiModelProperty(value = "数据库字段描述")
private String remark;
/** 必填 */
@ApiModelProperty(value = "是否必填")
private Boolean notNull;
/** 是否在列表显示 */
@ApiModelProperty(value = "是否在列表显示")
private Boolean listShow;
/** 是否表单显示 */
@ApiModelProperty(value = "是否表单显示")
private Boolean formShow;
/** 表单类型 */
@ApiModelProperty(value = "表单类型")
private String formType;
/** 查询 1:模糊 2精确 */
@ApiModelProperty(value = "查询 1:模糊 2精确")
private String queryType;
/** 字典名称 */
@ApiModelProperty(value = "字典名称")
private String dictName;
/** 日期注解 */
@ApiModelProperty(value = "日期注解")
private String dateAnnotation;
public ColumnInfo(String tableName, String columnName, Boolean notNull, String columnType, String remark, String keyType, String extra) {

View File

@ -1,61 +1,78 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
*
* @author Zheng Jie
* @date 2019-01-03
*/
@Data
@Getter
@Setter
@Entity
@NoArgsConstructor
@Table(name = "gen_config")
public class GenConfig {
@Table(name = "code_gen_config")
public class GenConfig implements Serializable {
public GenConfig(String tableName) {
this.cover = false;
this.moduleName = "eladmin-system";
this.tableName = tableName;
}
@Id
@Column(name = "config_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@NotBlank
@ApiModelProperty(value = "表名")
private String tableName;
/** 接口名称 **/
@ApiModelProperty(value = "接口名称")
private String apiAlias;
/** 包路径 */
@NotBlank
@ApiModelProperty(value = "包路径")
private String pack;
/** 模块名 */
@Column(name = "module_name")
@NotBlank
@ApiModelProperty(value = "模块名")
private String moduleName;
/** 前端文件路径 */
@NotBlank
@ApiModelProperty(value = "前端文件路径")
private String path;
/** 前端文件路径 */
@Column(name = "api_path")
@ApiModelProperty(value = "前端文件路径")
private String apiPath;
/** 作者 */
@ApiModelProperty(value = "作者")
private String author;
/** 表前缀 */
@ApiModelProperty(value = "表前缀")
private String prefix;
/** 是否覆盖 */
private Boolean cover;
@ApiModelProperty(value = "是否覆盖")
private Boolean cover = false;
}

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.domain.vo;
import lombok.AllArgsConstructor;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.repository;
import me.zhengjie.domain.ColumnInfo;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.repository;
import me.zhengjie.domain.GenConfig;

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.GenConfig;
import me.zhengjie.service.GenConfigService;
import org.springframework.http.HttpStatus;
@ -14,16 +30,13 @@ import org.springframework.web.bind.annotation.*;
* @date 2019-01-14
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/genConfig")
@Api(tags = "系统:代码生成器配置管理")
public class GenConfigController {
private final GenConfigService genConfigService;
public GenConfigController(GenConfigService genConfigService) {
this.genConfigService = genConfigService;
}
@ApiOperation("查询")
@GetMapping(value = "/{tableName}")
public ResponseEntity<Object> get(@PathVariable String tableName){

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.service.GenConfigService;
@ -20,22 +36,17 @@ import java.util.List;
* @date 2019-01-02
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/generator")
@Api(tags = "系统:代码生成管理")
public class GeneratorController {
private final GeneratorService generatorService;
private final GenConfigService genConfigService;
@Value("${generator.enabled}")
private Boolean generatorEnabled;
public GeneratorController(GeneratorService generatorService, GenConfigService genConfigService) {
this.generatorService = generatorService;
this.genConfigService = genConfigService;
}
@ApiOperation("查询数据库数据")
@GetMapping(value = "/tables/all")
public ResponseEntity<Object> getTables(){

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service;
import me.zhengjie.domain.GenConfig;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service;
import me.zhengjie.domain.GenConfig;
@ -32,7 +47,7 @@ public interface GeneratorService {
/**
*
* @param columnInfos /
* @param columnInfoList
* @param columnInfoList /
*/
@Async
void sync(List<ColumnInfo> columnInfos, List<ColumnInfo> columnInfoList);

View File

@ -1,12 +1,25 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.impl;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.GenConfig;
import me.zhengjie.repository.GenConfigRepository;
import me.zhengjie.service.GenConfigService;
import me.zhengjie.utils.StringUtils;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.io.File;
@ -15,17 +28,12 @@ import java.io.File;
* @date 2019-01-14
*/
@Service
@CacheConfig(cacheNames = "genConfig")
@RequiredArgsConstructor
public class GenConfigServiceImpl implements GenConfigService {
private final GenConfigRepository genConfigRepository;
public GenConfigServiceImpl(GenConfigRepository genConfigRepository) {
this.genConfigRepository = genConfigRepository;
}
@Override
@Cacheable(key = "#p0")
public GenConfig find(String tableName) {
GenConfig genConfig = genConfigRepository.findByTableName(tableName);
if(genConfig == null){
@ -35,7 +43,6 @@ public class GenConfigServiceImpl implements GenConfigService {
}
@Override
@CachePut(key = "#p0")
public GenConfig update(String tableName, GenConfig genConfig) {
// 如果 api 路径为空,则自动生成路径
if(StringUtils.isBlank(genConfig.getApiPath())){

View File

@ -1,8 +1,24 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ZipUtil;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.GenConfig;
import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.domain.vo.TableInfo;
@ -33,7 +49,7 @@ import java.util.stream.Collectors;
* @date 2019-01-02
*/
@Service
@SuppressWarnings({"unchecked","all"})
@RequiredArgsConstructor
public class GeneratorServiceImpl implements GeneratorService {
@PersistenceContext
@ -41,10 +57,6 @@ public class GeneratorServiceImpl implements GeneratorService {
private final ColumnInfoRepository columnInfoRepository;
public GeneratorServiceImpl(ColumnInfoRepository columnInfoRepository) {
this.columnInfoRepository = columnInfoRepository;
}
@Override
public Object getTables() {
// 使用预编译防止sql注入
@ -117,7 +129,7 @@ public class GeneratorServiceImpl implements GeneratorService {
// 第一种情况,数据库类字段改变或者新增字段
for (ColumnInfo columnInfo : columnInfoList) {
// 根据字段名称查找
List<ColumnInfo> columns = new ArrayList<ColumnInfo>(columnInfos.stream().filter(c-> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()));
List<ColumnInfo> columns = columnInfos.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList());
// 如果能找到,就修改部分可能被字段
if(CollectionUtil.isNotEmpty(columns)){
ColumnInfo column = columns.get(0);
@ -136,7 +148,7 @@ public class GeneratorServiceImpl implements GeneratorService {
// 第二种情况,数据库字段删除了
for (ColumnInfo columnInfo : columnInfos) {
// 根据字段名称查找
List<ColumnInfo> columns = new ArrayList<ColumnInfo>(columnInfoList.stream().filter(c-> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()));
List<ColumnInfo> columns = columnInfoList.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList());
// 如果找不到,就代表字段被删除了,则需要删除该字段
if(CollectionUtil.isEmpty(columns)){
columnInfoRepository.delete(columnInfo);

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import org.apache.commons.configuration.*;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.utils;
import cn.hutool.core.util.StrUtil;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.aop.log;
import java.lang.annotation.ElementType;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.aspect;
import lombok.extern.slf4j.Slf4j;
@ -14,7 +29,6 @@ import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.domain;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.io.Serializable;
@ -12,12 +28,14 @@ import java.sql.Timestamp;
* @date 2018-11-24
*/
@Entity
@Data
@Table(name = "log")
@Getter
@Setter
@Table(name = "sys_log")
@NoArgsConstructor
public class Log implements Serializable {
@Id
@Column(name = "log_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ -31,19 +49,15 @@ public class Log implements Serializable {
private String method;
/** 参数 */
@Column(columnDefinition = "text")
private String params;
/** 日志类型 */
@Column(name = "log_type")
private String logType;
/** 请求ip */
@Column(name = "request_ip")
private String requestIp;
/** 地址 */
@Column(name = "address")
private String address;
/** 浏览器 */
@ -53,12 +67,10 @@ public class Log implements Serializable {
private Long time;
/** 异常详细 */
@Column(name = "exception_detail", columnDefinition = "text")
private byte[] exceptionDetail;
/** 创建日期 */
@CreationTimestamp
@Column(name = "create_time")
private Timestamp createTime;
public Log(String logType, Long time) {

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.repository;
import me.zhengjie.domain.Log;
@ -7,8 +22,6 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import javax.transaction.Transactional;
/**
* @author Zheng Jie
* @date 2018-11-24
@ -16,20 +29,11 @@ import javax.transaction.Transactional;
@Repository
public interface LogRepository extends JpaRepository<Log,Long>, JpaSpecificationExecutor<Log> {
/**
* IP
* @param date1 startTime
* @param date2 entTime
* @return IP
*/
@Query(value = "select count(*) FROM (select request_ip FROM log where create_time between ?1 and ?2 GROUP BY request_ip) as s",nativeQuery = true)
Long findIp(String date1, String date2);
/**
*
* @param logType
*/
@Query(nativeQuery = true,value = "delete from log where log_type = ?1")
@Modifying
@Query(value = "delete from sys_log where log_type = ?1", nativeQuery = true)
void deleteByLogType(String logType);
}

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log;
import me.zhengjie.service.LogService;
import me.zhengjie.service.dto.LogQueryCriteria;
@ -19,16 +35,13 @@ import java.io.IOException;
* @date 2018-11-24
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/logs")
@Api(tags = "监控:日志管理")
@Api(tags = "系统:日志管理")
public class LogController {
private final LogService logService;
public LogController(LogService logService) {
this.logService = logService;
}
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service;
import me.zhengjie.domain.Log;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.dto;
import lombok.Data;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.dto;
import lombok.Data;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.dto;
import lombok.Data;

View File

@ -1,8 +1,24 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.impl;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.Log;
import me.zhengjie.repository.LogRepository;
import me.zhengjie.service.LogService;
@ -17,7 +33,6 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Method;
@ -31,21 +46,14 @@ import java.util.Map;
* @date 2018-11-24
*/
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class LogServiceImpl implements LogService {
private final LogRepository logRepository;
private final LogErrorMapper logErrorMapper;
private final LogSmallMapper logSmallMapper;
public LogServiceImpl(LogRepository logRepository, LogErrorMapper logErrorMapper, LogSmallMapper logSmallMapper) {
this.logRepository = logRepository;
this.logErrorMapper = logErrorMapper;
this.logSmallMapper = logSmallMapper;
}
@Override
public Object queryAll(LogQueryCriteria criteria, Pageable pageable){
Page<Log> page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)),pageable);

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.mapper;
import me.zhengjie.base.BaseMapper;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.service.mapper;
import me.zhengjie.base.BaseMapper;

View File

@ -1,33 +0,0 @@
<h1 style="text-align: center">el-admin 客户端监控模块</h1>
<div style="text-align: center">
[![AUR](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/elunez/eladmin/blob/master/LICENSE)
[![star](https://gitee.com/elunez/eladmin/badge/star.svg?theme=white)](https://gitee.com/elunez/eladmin)
[![GitHub stars](https://img.shields.io/github/stars/elunez/eladmin.svg?style=social&label=Stars)](https://github.com/elunez/eladmin)
[![GitHub forks](https://img.shields.io/github/forks/elunez/eladmin.svg?style=social&label=Fork)](https://github.com/elunez/eladmin)
</div>
#### 项目简介
希望通过简单的配置即可实现对服务器CPU、内存、磁盘以及交换区占用情况的监控
**开发文档** [https://docs.auauz.net/](https://docs.auauz.net)
**体验地址** [https://auauz.net/](https://auauz.net/)
**账号密码** ```admin/123456```(默认密码都是123456)
#### 项目源码
| | 后端源码 | 前端源码 |
|--- |--- | --- |
| github | https://github.com/elunez/eladmin | https://github.com/elunez/eladmin-qd |
| 码云 | https://gitee.com/elunez/eladmin | https://gitee.com/elunez/eladmin-qt |
#### 使用说明
- 将打包好的eladmin-monitor-2.2.jar 放到服务器上,执行 nohup java -jar eladmin-monitor-2.2.jar & 即可
#### 项目捐赠
项目的发展离不开你的支持,请作者喝杯咖啡吧 ☕! [Donate](https://docs.auauz.net/#/jz)
#### 反馈交流
- QQ交流群891137268

View File

@ -1,81 +0,0 @@
<?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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eladmin-monitor</artifactId>
<version>2.4</version>
<name>客户端监控模块</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- oshi监控需要指定jna版本, 问题详见 https://github.com/oshi/oshi/issues/1040 -->
<jna.version>5.5.0</jna.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.oshi/oshi-core -->
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>4.4.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 跳过单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
<excludes>
</excludes>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>

View File

@ -1,20 +0,0 @@
package me.zhengjie;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
/**
*
* @author: Zhang houying
* @date: 2019/11/3
*/
@EnableAsync
@SpringBootApplication
public class MonitorRun {
public static void main(String[] args) {
SpringApplication.run(MonitorRun.class, args);
}
}

View File

@ -1,65 +0,0 @@
package me.zhengjie.res;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.VirtualMemory;
import oshi.software.os.OSFileStore;
import oshi.software.os.OperatingSystem;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* @author Zhang houying
* @date 2019-11-03
*/
@RestController
@RequestMapping("/api/serverMonitor")
public class ServerMonitorController {
private static final double GB = 1024 * 1024 * 1024.00;
@GetMapping
public ResponseEntity<Object> getServerInfo() {
Map<String, Object> resultMap = new HashMap<>(8);
try {
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
CentralProcessor processor = hal.getProcessor();
long[] prevTicks = processor.getSystemCpuLoadTicks();
TimeUnit.SECONDS.sleep(1);
resultMap.put("cpuRate", processor.getSystemCpuLoadBetweenTicks(prevTicks));
resultMap.put("cpuCore", processor.getLogicalProcessorCount());
GlobalMemory memory = hal.getMemory();
resultMap.put("memTotal", memory.getTotal() / GB);
resultMap.put("memUsed", (memory.getTotal() - memory.getAvailable()) / GB);
double diskTotal = 0;
double diskUsable = 0;
OperatingSystem os = si.getOperatingSystem();
OSFileStore[] fsArray = os.getFileSystem().getFileStores();
for (OSFileStore fs : fsArray) {
long usable = fs.getUsableSpace();
long total = fs.getTotalSpace();
diskTotal += total / GB;
diskUsable += usable / GB;
}
resultMap.put("diskTotal", diskTotal);
resultMap.put("diskUsed", diskTotal - diskUsable);
VirtualMemory vm = memory.getVirtualMemory();
resultMap.put("swapTotal", vm.getSwapTotal() / GB);
resultMap.put("swapUsed", vm.getSwapUsed() / GB);
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<>(resultMap, HttpStatus.OK);
}
}

View File

@ -1,8 +0,0 @@
_ _ _
| | | | (_)
___| |______ __ _ __| |_ __ ___ _ _ __
/ _ | |______/ _` |/ _` | '_ ` _ \| | '_ \
| __| | | (_| | (_| | | | | | | | | | |
\___|_| \__,_|\__,_|_| |_| |_|_|_| |_|
:: Spring Boot :: (v2.1.0.RELEASE)

View File

@ -1,2 +0,0 @@
server:
port: 8777

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>elAdmin Monitor</contextName>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)</pattern>
<charset>utf-8</charset>
</encoder>
</appender>
<!--普通日志输出到控制台-->
<root level="info">
<appender-ref ref="console" />
</root>
</configuration>

View File

@ -1,364 +0,0 @@
/**
* MIT License
* <p>
* Copyright (c) 2010 - 2020 The OSHI Project Contributors: https://github.com/oshi/oshi/graphs/contributors
* <p>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p>
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* <p>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package me.zhengjie;
import static org.junit.Assert.assertFalse;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.PlatformEnum;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.CentralProcessor.TickType;
import oshi.hardware.ComputerSystem;
import oshi.hardware.Display;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HWDiskStore;
import oshi.hardware.HWPartition;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.NetworkIF;
import oshi.hardware.PhysicalMemory;
import oshi.hardware.PowerSource;
import oshi.hardware.Sensors;
import oshi.hardware.SoundCard;
import oshi.hardware.UsbDevice;
import oshi.hardware.VirtualMemory;
import oshi.software.os.FileSystem;
import oshi.software.os.NetworkParams;
import oshi.software.os.OSFileStore;
import oshi.software.os.OSProcess;
import oshi.software.os.OSService;
import oshi.software.os.OperatingSystem;
import oshi.software.os.OperatingSystem.ProcessSort;
import oshi.util.FormatUtil;
import oshi.util.Util;
/**
* A demonstration of access to many of OSHI's capabilities
*/
public class SystemInfoTest {
private static final Logger logger = LoggerFactory.getLogger(SystemInfoTest.class);
static List<String> oshi = new ArrayList<>();
/**
* Test that this platform is implemented..
*/
@Test
public void testPlatformEnum() {
assertFalse(PlatformEnum.UNKNOWN.equals(SystemInfo.getCurrentPlatformEnum()));
// Exercise the main method
main(null);
}
/**
* The main method, demonstrating use of classes.
*
* @param args the arguments (unused)
*/
public static void main(String[] args) {
logger.info("Initializing System...");
SystemInfo si = new SystemInfo();
HardwareAbstractionLayer hal = si.getHardware();
OperatingSystem os = si.getOperatingSystem();
printOperatingSystem(os);
logger.info("Checking computer system...");
printComputerSystem(hal.getComputerSystem());
logger.info("Checking Processor...");
printProcessor(hal.getProcessor());
logger.info("Checking Memory...");
printMemory(hal.getMemory());
logger.info("Checking CPU...");
printCpu(hal.getProcessor());
logger.info("Checking Processes...");
printProcesses(os, hal.getMemory());
logger.info("Checking Services...");
printServices(os);
logger.info("Checking Sensors...");
printSensors(hal.getSensors());
logger.info("Checking Power sources...");
printPowerSources(hal.getPowerSources());
logger.info("Checking Disks...");
printDisks(hal.getDiskStores());
logger.info("Checking File System...");
printFileSystem(os.getFileSystem());
logger.info("Checking Network interfaces...");
printNetworkInterfaces(hal.getNetworkIFs());
logger.info("Checking Network parameters...");
printNetworkParameters(os.getNetworkParams());
// hardware: displays
logger.info("Checking Displays...");
printDisplays(hal.getDisplays());
// hardware: USB devices
logger.info("Checking USB Devices...");
printUsbDevices(hal.getUsbDevices(true));
logger.info("Checking Sound Cards...");
printSoundCards(hal.getSoundCards());
StringBuilder output = new StringBuilder();
for (int i = 0; i < oshi.size(); i++) {
output.append(oshi.get(i));
if (oshi.get(i) != null && !oshi.get(i).endsWith("\n")) {
output.append('\n');
}
}
logger.info("Printing Operating System and Hardware Info:{}{}", '\n', output);
}
private static void printOperatingSystem(final OperatingSystem os) {
oshi.add(String.valueOf(os));
oshi.add("Booted: " + Instant.ofEpochSecond(os.getSystemBootTime()));
oshi.add("Uptime: " + FormatUtil.formatElapsedSecs(os.getSystemUptime()));
oshi.add("Running with" + (os.isElevated() ? "" : "out") + " elevated permissions.");
}
private static void printComputerSystem(final ComputerSystem computerSystem) {
oshi.add("system: " + computerSystem.toString());
oshi.add(" firmware: " + computerSystem.getFirmware().toString());
oshi.add(" baseboard: " + computerSystem.getBaseboard().toString());
}
private static void printProcessor(CentralProcessor processor) {
oshi.add(processor.toString());
}
private static void printMemory(GlobalMemory memory) {
oshi.add("Memory: \n " + memory.toString());
VirtualMemory vm = memory.getVirtualMemory();
oshi.add("Swap: \n " + vm.toString());
PhysicalMemory[] pmArray = memory.getPhysicalMemory();
if (pmArray.length > 0) {
oshi.add("Physical Memory: ");
for (PhysicalMemory pm : pmArray) {
oshi.add(" " + pm.toString());
}
}
}
private static void printCpu(CentralProcessor processor) {
oshi.add("Context Switches/Interrupts: " + processor.getContextSwitches() + " / " + processor.getInterrupts());
long[] prevTicks = processor.getSystemCpuLoadTicks();
long[][] prevProcTicks = processor.getProcessorCpuLoadTicks();
oshi.add("CPU, IOWait, and IRQ ticks @ 0 sec:" + Arrays.toString(prevTicks));
// Wait a second...
Util.sleep(1000);
long[] ticks = processor.getSystemCpuLoadTicks();
oshi.add("CPU, IOWait, and IRQ ticks @ 1 sec:" + Arrays.toString(ticks));
long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()];
long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()];
long sys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()];
long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()];
long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()];
long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()];
long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()];
long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()];
long totalCpu = user + nice + sys + idle + iowait + irq + softirq + steal;
oshi.add(String.format(
"User: %.1f%% Nice: %.1f%% System: %.1f%% Idle: %.1f%% IOwait: %.1f%% IRQ: %.1f%% SoftIRQ: %.1f%% Steal: %.1f%%",
100d * user / totalCpu, 100d * nice / totalCpu, 100d * sys / totalCpu, 100d * idle / totalCpu,
100d * iowait / totalCpu, 100d * irq / totalCpu, 100d * softirq / totalCpu, 100d * steal / totalCpu));
oshi.add(String.format("CPU load: %.1f%%", processor.getSystemCpuLoadBetweenTicks(prevTicks) * 100));
double[] loadAverage = processor.getSystemLoadAverage(3);
oshi.add("CPU load averages:" + (loadAverage[0] < 0 ? " N/A" : String.format(" %.2f", loadAverage[0]))
+ (loadAverage[1] < 0 ? " N/A" : String.format(" %.2f", loadAverage[1]))
+ (loadAverage[2] < 0 ? " N/A" : String.format(" %.2f", loadAverage[2])));
// per core CPU
StringBuilder procCpu = new StringBuilder("CPU load per processor:");
double[] load = processor.getProcessorCpuLoadBetweenTicks(prevProcTicks);
for (double avg : load) {
procCpu.append(String.format(" %.1f%%", avg * 100));
}
oshi.add(procCpu.toString());
long freq = processor.getProcessorIdentifier().getVendorFreq();
if (freq > 0) {
oshi.add("Vendor Frequency: " + FormatUtil.formatHertz(freq));
}
freq = processor.getMaxFreq();
if (freq > 0) {
oshi.add("Max Frequency: " + FormatUtil.formatHertz(freq));
}
long[] freqs = processor.getCurrentFreq();
if (freqs[0] > 0) {
StringBuilder sb = new StringBuilder("Current Frequencies: ");
for (int i = 0; i < freqs.length; i++) {
if (i > 0) {
sb.append(", ");
}
sb.append(FormatUtil.formatHertz(freqs[i]));
}
oshi.add(sb.toString());
}
}
private static void printProcesses(OperatingSystem os, GlobalMemory memory) {
oshi.add("My PID: " + os.getProcessId() + " with affinity "
+ Long.toBinaryString(os.getProcessAffinityMask(os.getProcessId())));
oshi.add("Processes: " + os.getProcessCount() + ", Threads: " + os.getThreadCount());
// Sort by highest CPU
List<OSProcess> procs = Arrays.asList(os.getProcesses(5, ProcessSort.CPU));
oshi.add(" PID %CPU %MEM VSZ RSS Name");
for (int i = 0; i < procs.size() && i < 5; i++) {
OSProcess p = procs.get(i);
oshi.add(String.format(" %5d %5.1f %4.1f %9s %9s %s", p.getProcessID(),
100d * (p.getKernelTime() + p.getUserTime()) / p.getUpTime(),
100d * p.getResidentSetSize() / memory.getTotal(), FormatUtil.formatBytes(p.getVirtualSize()),
FormatUtil.formatBytes(p.getResidentSetSize()), p.getName()));
}
}
private static void printServices(OperatingSystem os) {
oshi.add("Services: ");
oshi.add(" PID State Name");
// DO 5 each of running and stopped
int i = 0;
for (OSService s : os.getServices()) {
if (s.getState().equals(OSService.State.RUNNING) && i++ < 5) {
oshi.add(String.format(" %5d %7s %s", s.getProcessID(), s.getState(), s.getName()));
}
}
i = 0;
for (OSService s : os.getServices()) {
if (s.getState().equals(OSService.State.STOPPED) && i++ < 5) {
oshi.add(String.format(" %5d %7s %s", s.getProcessID(), s.getState(), s.getName()));
}
}
}
private static void printSensors(Sensors sensors) {
oshi.add("Sensors: " + sensors.toString());
}
private static void printPowerSources(PowerSource[] powerSources) {
StringBuilder sb = new StringBuilder("Power Sources: ");
if (powerSources.length == 0) {
sb.append("Unknown");
}
for (PowerSource powerSource : powerSources) {
sb.append("\n ").append(powerSource.toString());
}
oshi.add(sb.toString());
}
private static void printDisks(HWDiskStore[] diskStores) {
oshi.add("Disks:");
for (HWDiskStore disk : diskStores) {
oshi.add(" " + disk.toString());
HWPartition[] partitions = disk.getPartitions();
for (HWPartition part : partitions) {
oshi.add(" |-- " + part.toString());
}
}
}
private static void printFileSystem(FileSystem fileSystem) {
oshi.add("File System:");
oshi.add(String.format(" File Descriptors: %d/%d", fileSystem.getOpenFileDescriptors(),
fileSystem.getMaxFileDescriptors()));
OSFileStore[] fsArray = fileSystem.getFileStores();
for (OSFileStore fs : fsArray) {
long usable = fs.getUsableSpace();
long total = fs.getTotalSpace();
oshi.add(String.format(
" %s (%s) [%s] %s of %s free (%.1f%%), %s of %s files free (%.1f%%) is %s "
+ (fs.getLogicalVolume() != null && fs.getLogicalVolume().length() > 0 ? "[%s]" : "%s")
+ " and is mounted at %s",
fs.getName(), fs.getDescription().isEmpty() ? "file system" : fs.getDescription(), fs.getType(),
FormatUtil.formatBytes(usable), FormatUtil.formatBytes(fs.getTotalSpace()), 100d * usable / total,
FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""),
100d * fs.getFreeInodes() / fs.getTotalInodes(), fs.getVolume(), fs.getLogicalVolume(),
fs.getMount()));
}
}
private static void printNetworkInterfaces(NetworkIF[] networkIFs) {
StringBuilder sb = new StringBuilder("Network Interfaces:");
if (networkIFs.length == 0) {
sb.append(" Unknown");
}
for (NetworkIF net : networkIFs) {
sb.append("\n ").append(net.toString());
}
oshi.add(sb.toString());
}
private static void printNetworkParameters(NetworkParams networkParams) {
oshi.add("Network parameters:\n " + networkParams.toString());
}
private static void printDisplays(Display[] displays) {
oshi.add("Displays:");
int i = 0;
for (Display display : displays) {
oshi.add(" Display " + i + ":");
oshi.add(String.valueOf(display));
i++;
}
}
private static void printUsbDevices(UsbDevice[] usbDevices) {
oshi.add("USB Devices:");
for (UsbDevice usbDevice : usbDevices) {
oshi.add(String.valueOf(usbDevice));
}
}
private static void printSoundCards(SoundCard[] cards) {
oshi.add("Sound Cards:");
for (SoundCard card : cards) {
oshi.add(" " + String.valueOf(card));
}
}
}

View File

@ -14,6 +14,8 @@
<properties>
<jjwt.version>0.10.6</jjwt.version>
<!-- oshi监控需要指定jna版本, 问题详见 https://github.com/oshi/oshi/issues/1040 -->
<jna.version>5.5.0</jna.version>
</properties>
<dependencies>
@ -77,6 +79,12 @@
<version>0.1.55</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>4.7.1</version>
</dependency>
</dependencies>
<build>

View File

@ -1,5 +1,21 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie;
import io.swagger.annotations.Api;
import me.zhengjie.annotation.AnonymousAccess;
import me.zhengjie.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication;
@ -20,9 +36,10 @@ import org.springframework.web.bind.annotation.RestController;
*/
@EnableAsync
@RestController
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@Api(hidden = true)
@SpringBootApplication
@EnableTransactionManagement
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
public class AppRun {
public static void main(String[] args) {

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import org.springframework.context.annotation.Bean;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import me.zhengjie.modules.system.domain.Dept;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config;
import org.springframework.context.annotation.Bean;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config.thread;
import lombok.extern.slf4j.Slf4j;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config.thread;
import lombok.Data;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config.thread;
import org.springframework.stereotype.Component;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.config.thread;
import me.zhengjie.utils.SpringContextHolder;

View File

@ -1,75 +1,66 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_app")
public class App implements Serializable {
public class App extends BaseEntity implements Serializable {
/**
*
*/
@Id
@Column(name = "app_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
*
*/
@Column(name = "name")
@ApiModelProperty(value = "名称")
private String name;
/**
*
*/
@Column(name = "port")
@ApiModelProperty(value = "端口")
private int port;
/**
*
*/
@Column(name = "upload_path")
@ApiModelProperty(value = "上传路径")
private String uploadPath;
/**
*
*/
@Column(name = "deploy_path")
@ApiModelProperty(value = "部署路径")
private String deployPath;
/**
*
*/
@Column(name = "backup_path")
@ApiModelProperty(value = "备份路径")
private String backupPath;
/**
*
*/
@Column(name = "start_script")
@ApiModelProperty(value = "启动脚本")
private String startScript;
/**
*
*/
@Column(name = "deploy_script")
@ApiModelProperty(value = "部署脚本")
private String deployScript;
@CreationTimestamp
private Timestamp createTime;
public void copy(App source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -1,57 +1,56 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_database")
public class Database implements Serializable {
public class Database extends BaseEntity implements Serializable {
/**
* id
*/
@Id
@Column(name = "id")
@Column(name = "db_id")
@ApiModelProperty(value = "ID", hidden = true)
private String id;
/**
*
*/
@Column(name = "name",nullable = false)
@ApiModelProperty(value = "数据库名称")
private String name;
/**
*
*/
@Column(name = "jdbc_url",nullable = false)
@ApiModelProperty(value = "数据库连接地址")
private String jdbcUrl;
/**
*
*/
@Column(name = "pwd",nullable = false)
@ApiModelProperty(value = "数据库密码")
private String pwd;
/**
*
*/
@Column(name = "user_name",nullable = false)
@ApiModelProperty(value = "用户名")
private String userName;
@CreationTimestamp
private Timestamp createTime;
public void copy(Database source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -1,13 +1,28 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;
/**
@ -15,33 +30,28 @@ import java.util.Set;
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_deploy")
public class Deploy implements Serializable {
public class Deploy extends BaseEntity implements Serializable {
/**
*
*/
@Id
@Column(name = "deploy_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
*
*/
@ManyToOne
@JoinColumn(name = "app_id")
private App app;
/**
*
*/
@ManyToMany
@JoinTable(name = "mnt_deploy_server", joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "id")})
@ApiModelProperty(name = "服务器", hidden = true)
@JoinTable(name = "mnt_deploy_server",
joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "deploy_id")},
inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "server_id")})
private Set<ServerDeploy> deploys;
@CreationTimestamp
private Timestamp createTime;
@ManyToOne
@JoinColumn(name = "app_id")
@ApiModelProperty(value = "应用编号")
private App app;
public void copy(Deploy source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));

View File

@ -1,10 +1,26 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
@ -14,46 +30,30 @@ import java.sql.Timestamp;
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_deploy_history")
public class DeployHistory implements Serializable {
/**
*
*/
@Id
@Column(name = "id")
@Column(name = "history_id")
@ApiModelProperty(value = "ID", hidden = true)
private String id;
/**
*
*/
@Column(name = "app_name",nullable = false)
@ApiModelProperty(value = "应用名称")
private String appName;
/**
* IP
*/
@Column(name = "ip",nullable = false)
@ApiModelProperty(value = "IP")
private String ip;
/**
*
*/
@Column(name = "deploy_date")
@CreationTimestamp
@ApiModelProperty(value = "部署时间")
private Timestamp deployDate;
/**
*
*/
@Column(name = "deploy_user",nullable = false)
@ApiModelProperty(value = "部署者")
private String deployUser;
/**
*
*/
@Column(name = "deploy_id",nullable = false)
@ApiModelProperty(value = "部署ID")
private Long deployId;
public void copy(DeployHistory source){

View File

@ -1,40 +1,60 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.domain;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseEntity;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Entity
@Data
@Getter
@Setter
@Table(name="mnt_server")
public class ServerDeploy implements Serializable {
public class ServerDeploy extends BaseEntity implements Serializable {
@Id
@Column(name = "server_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(value = "服务器名称")
private String name;
@ApiModelProperty(value = "IP")
private String ip;
@ApiModelProperty(value = "端口")
private Integer port;
@ApiModelProperty(value = "账号")
private String account;
@ApiModelProperty(value = "密码")
private String password;
@CreationTimestamp
private Timestamp createTime;
public void copy(ServerDeploy source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.repository;
import me.zhengjie.modules.mnt.domain.App;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.repository;
import me.zhengjie.modules.mnt.domain.Database;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.repository;
import me.zhengjie.modules.mnt.domain.DeployHistory;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.repository;
import me.zhengjie.modules.mnt.domain.Deploy;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.repository;
import me.zhengjie.modules.mnt.domain.ServerDeploy;

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.mnt.domain.App;
import me.zhengjie.modules.mnt.service.AppService;
@ -20,17 +36,14 @@ import java.util.Set;
* @author zhanghouying
* @date 2019-08-24
*/
@Api(tags = "应用管理")
@RestController
@Api(tags = "运维:应用管理")
@RequiredArgsConstructor
@RequestMapping("/api/app")
public class AppController {
private final AppService appService;
public AppController(AppService appService){
this.appService = appService;
}
@Log("导出应用数据")
@ApiOperation("导出应用数据")
@GetMapping(value = "/download")

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.mnt.domain.Database;
@ -27,19 +43,15 @@ import java.util.Set;
* @author zhanghouying
* @date 2019-08-24
*/
@Api(tags = "数据库管理")
@Api(tags = "运维:数据库管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/database")
public class DatabaseController {
private String fileSavePath = System.getProperty("java.io.tmpdir");
private final String fileSavePath = System.getProperty("java.io.tmpdir");
private final DatabaseService databaseService;
public DatabaseController(DatabaseService databaseService) {
this.databaseService = databaseService;
}
@Log("导出数据库数据")
@ApiOperation("导出数据库数据")
@GetMapping(value = "/download")

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.mnt.domain.Deploy;
import me.zhengjie.modules.mnt.domain.DeployHistory;
@ -28,18 +44,15 @@ import java.util.Set;
* @author zhanghouying
* @date 2019-08-24
*/
@Api(tags = "部署管理")
@RestController
@Api(tags = "运维:部署管理")
@RequiredArgsConstructor
@RequestMapping("/api/deploy")
public class DeployController {
private String fileSavePath = System.getProperty("java.io.tmpdir");
private final String fileSavePath = System.getProperty("java.io.tmpdir");
private final DeployService deployService;
public DeployController(DeployService deployService) {
this.deployService = deployService;
}
@Log("导出部署数据")
@ApiOperation("导出部署数据")

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.mnt.service.DeployHistoryService;
import me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria;
@ -18,17 +34,14 @@ import java.util.Set;
* @author zhanghouying
* @date 2019-08-24
*/
@Api(tags = "部署历史管理")
@RestController
@RequiredArgsConstructor
@Api(tags = "运维:部署历史管理")
@RequestMapping("/api/deployHistory")
public class DeployHistoryController {
private final DeployHistoryService deployhistoryService;
public DeployHistoryController(DeployHistoryService deployhistoryService) {
this.deployhistoryService = deployhistoryService;
}
@Log("导出部署历史数据")
@ApiOperation("导出部署历史数据")
@GetMapping(value = "/download")

View File

@ -1,7 +1,23 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.mnt.domain.ServerDeploy;
import me.zhengjie.modules.mnt.service.ServerDeployService;
@ -20,17 +36,14 @@ import java.util.Set;
* @author zhanghouying
* @date 2019-08-24
*/
@Api(tags = "服务器管理")
@RestController
@Api(tags = "运维:服务器管理")
@RequiredArgsConstructor
@RequestMapping("/api/serverDeploy")
public class ServerDeployController {
private final ServerDeployService serverDeployService;
public ServerDeployController(ServerDeployService serverDeployService) {
this.serverDeployService = serverDeployService;
}
@Log("导出服务器数据")
@ApiOperation("导出服务器数据")
@GetMapping(value = "/download")

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service;
import me.zhengjie.modules.mnt.domain.App;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service;
import me.zhengjie.modules.mnt.domain.Database;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service;
import me.zhengjie.modules.mnt.domain.DeployHistory;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service;
import me.zhengjie.modules.mnt.domain.Deploy;

View File

@ -1,3 +1,18 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service;
import me.zhengjie.modules.mnt.domain.ServerDeploy;

View File

@ -1,17 +1,32 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service.dto;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseDTO;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Data
public class AppDto implements Serializable {
@Getter
@Setter
public class AppDto extends BaseDTO implements Serializable {
/**
*
@ -53,6 +68,4 @@ public class AppDto implements Serializable {
*/
private String deployScript;
private Timestamp createTime;
}

View File

@ -1,8 +1,22 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;

View File

@ -1,16 +1,32 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service.dto;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseDTO;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24
*/
@Data
public class DatabaseDto implements Serializable {
@Getter
@Setter
public class DatabaseDto extends BaseDTO implements Serializable {
/**
* id
@ -36,6 +52,4 @@ public class DatabaseDto implements Serializable {
*
*/
private String userName;
private Timestamp createTime;
}

View File

@ -1,8 +1,22 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service.dto;
import lombok.Data;
import me.zhengjie.annotation.Query;
import java.sql.Timestamp;
import java.util.List;

View File

@ -1,9 +1,25 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service.dto;
import cn.hutool.core.collection.CollectionUtil;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import me.zhengjie.base.BaseDTO;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;
import java.util.stream.Collectors;
@ -12,8 +28,9 @@ import java.util.stream.Collectors;
* @author zhanghouying
* @date 2019-08-24
*/
@Data
public class DeployDto implements Serializable {
@Getter
@Setter
public class DeployDto extends BaseDTO implements Serializable {
/**
*
@ -34,8 +51,6 @@ public class DeployDto implements Serializable {
*/
private String status;
private Timestamp createTime;
public String getServers() {
if(CollectionUtil.isNotEmpty(deploys)){
return deploys.stream().map(ServerDeployDto::getName).collect(Collectors.joining(","));

View File

@ -1,10 +1,24 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* 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 me.zhengjie.modules.mnt.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author zhanghouying
* @date 2019-08-24

Some files were not shown because too many files have changed in this diff Show More