feat: 数据库内容显示
This commit is contained in:
parent
650cbc12b4
commit
3d4d256c9a
|
@ -23,6 +23,16 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
|
@ -64,6 +74,26 @@
|
|||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.6.14</version>
|
||||
</dependency>
|
||||
<!-- fastjson2 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package cn.bunny.config;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;
|
||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 去除前端传递的空格
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class ControllerStringParamTrimConfig {
|
||||
|
||||
/**
|
||||
* 创建 String trim 编辑器
|
||||
* 构造方法中 boolean 参数含义为如果是空白字符串,是否转换为null
|
||||
* 即如果为true,那么 " " 会被转换为 null,否者为 ""
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
StringTrimmerEditor propertyEditor = new StringTrimmerEditor(false);
|
||||
// 为 String 类对象注册编辑器
|
||||
binder.registerCustomEditor(String.class, propertyEditor);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
|
||||
return jacksonObjectMapperBuilder -> {
|
||||
// 为 String 类型自定义反序列化操作
|
||||
jacksonObjectMapperBuilder
|
||||
.deserializerByType(String.class, new StdScalarDeserializer<String>(String.class) {
|
||||
@Override
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext ctx) throws IOException {
|
||||
// // 去除全部空格
|
||||
// return StringUtils.trimAllWhitespace(jsonParser.getValueAsString());
|
||||
|
||||
// 仅去除前后空格
|
||||
return jsonParser.getValueAsString().trim();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package cn.bunny.config;
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springdoc.core.models.GroupedOpenApi;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class Knife4jConfig {
|
||||
@Bean
|
||||
public OpenAPI openAPI() {
|
||||
// 作者等信息
|
||||
Contact contact = new Contact().name("Bunny" ).email("1319900154@qq.com" ).url("http://localhost:9999" );
|
||||
// 使用协议
|
||||
License license = new License().name("MIT" ).url("https://mit-license.org" );
|
||||
// 相关信息
|
||||
Info info = new Info().title("Bunny-Admin" )
|
||||
.contact(contact).license(license)
|
||||
.description("Bunny代码生成器" )
|
||||
.summary("Bunny的代码生成器" )
|
||||
.termsOfService("http://localhost:9999" )
|
||||
.version("v1.0.0" );
|
||||
|
||||
return new OpenAPI().info(info).externalDocs(new ExternalDocumentation());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi all() {
|
||||
return GroupedOpenApi.builder().group("全部请求接口" ).pathsToMatch("/api/**" ).build();
|
||||
}
|
||||
}
|
|
@ -1,22 +1,51 @@
|
|||
package cn.bunny.controller;
|
||||
|
||||
import cn.bunny.service.IndexService;
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.vo.TableInfoVo;
|
||||
import cn.bunny.service.TableService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
public class IndexController {
|
||||
|
||||
private final IndexService indexService;
|
||||
private final TableService tableService;
|
||||
|
||||
public IndexController(IndexService indexService) {
|
||||
this.indexService = indexService;
|
||||
public IndexController(TableService tableService) {
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public String index() {
|
||||
@GetMapping("/" )
|
||||
public String index(Model model) {
|
||||
List<TableInfoVo> list = tableService.getAllTableMetaData();
|
||||
model.addAttribute("list" , list);
|
||||
|
||||
return "index";
|
||||
}
|
||||
|
||||
@GetMapping("/preview/{tableName}" )
|
||||
public String preview(Model model, @PathVariable String tableName) {
|
||||
TableInfoVo tableMetaData = tableService.getTableMetaData(tableName);
|
||||
List<ColumnMetaData> columnInfo = tableService.getColumnInfo(tableName);
|
||||
|
||||
model.addAttribute("tableMetaData" , tableMetaData);
|
||||
model.addAttribute("columnInfo" , columnInfo);
|
||||
|
||||
return "preview";
|
||||
}
|
||||
|
||||
@GetMapping("/generator/{tableName}" )
|
||||
public String generator(Model model, @PathVariable String tableName) {
|
||||
TableInfoVo tableMetaData = tableService.getTableMetaData(tableName);
|
||||
List<ColumnMetaData> columnInfo = tableService.getColumnInfo(tableName);
|
||||
|
||||
model.addAttribute("tableMetaData" , tableMetaData);
|
||||
model.addAttribute("columnInfo" , columnInfo);
|
||||
|
||||
return "generator";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package cn.bunny.controller;
|
||||
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.vo.TableInfoVo;
|
||||
import cn.bunny.service.TableService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "表控制器" , description = "代码生成器接口" )
|
||||
@RestController
|
||||
@RequestMapping("/api" )
|
||||
public class TableController {
|
||||
|
||||
private final TableService tableService;
|
||||
|
||||
public TableController(TableService tableService) {
|
||||
this.tableService = tableService;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有表" , description = "获取所有表" )
|
||||
@GetMapping("getAllTableMetaData" )
|
||||
public List<TableInfoVo> getAllTableMetaData() {
|
||||
return tableService.getAllTableMetaData();
|
||||
}
|
||||
|
||||
@Operation(summary = "获取表属性" , description = "获取表属性" )
|
||||
@GetMapping("getTableMetaData" )
|
||||
public TableInfoVo getTableMetaData(String tableName) {
|
||||
return tableService.getTableMetaData(tableName);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取列属性" , description = "获取列属性" )
|
||||
@GetMapping("getColumnInfo" )
|
||||
public List<ColumnMetaData> getColumnInfo(String tableName) {
|
||||
return tableService.getColumnInfo(tableName);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.entity;
|
||||
package cn.bunny.dao.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.entity;
|
||||
package cn.bunny.dao.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
@ -22,9 +22,6 @@ public class TableMetaData {
|
|||
/* 表类型(通常是"TABLE") */
|
||||
private String tableType;
|
||||
|
||||
/* 表的注释/描述 */
|
||||
private String remarks;
|
||||
|
||||
/* 类型的目录(可能为null) */
|
||||
private String typeCat;
|
||||
|
||||
|
@ -46,7 +43,7 @@ public class TableMetaData {
|
|||
/* 类名 */
|
||||
private String className;
|
||||
|
||||
/* 注释内哦让那个 */
|
||||
/* 注释内容 */
|
||||
private String comment;
|
||||
|
||||
/* 列名称 */
|
|
@ -0,0 +1,34 @@
|
|||
package cn.bunny.dao.result;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 封装分页查询结果
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "PageResult 对象" , title = "分页返回结果" , description = "分页返回结果" )
|
||||
public class PageResult<T> implements Serializable {
|
||||
|
||||
@Schema(name = "pageNo" , title = "当前页" )
|
||||
private Long pageNo;
|
||||
|
||||
@Schema(name = "pageSize" , title = "每页记录数" )
|
||||
private Long pageSize;
|
||||
|
||||
@Schema(name = "total" , title = "总记录数" )
|
||||
private Long total;
|
||||
|
||||
@Schema(name = "list" , title = "当前页数据集合" )
|
||||
private List<T> list;
|
||||
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package cn.bunny.dao.result;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Result<T> {
|
||||
// 状态码
|
||||
private Integer code;
|
||||
// 返回消息
|
||||
private String message;
|
||||
// 返回数据
|
||||
private T data;
|
||||
|
||||
/**
|
||||
* * 自定义返回体
|
||||
*
|
||||
* @param data 返回体
|
||||
* @return Result<T>
|
||||
*/
|
||||
protected static <T> Result<T> build(T data) {
|
||||
Result<T> result = new Result<>();
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 自定义返回体,使用ResultCodeEnum构建
|
||||
*
|
||||
* @param body 返回体
|
||||
* @param codeEnum 返回状态码
|
||||
* @return Result<T>
|
||||
*/
|
||||
public static <T> Result<T> build(T body, ResultCodeEnum codeEnum) {
|
||||
Result<T> result = build(body);
|
||||
result.setCode(codeEnum.getCode());
|
||||
result.setMessage(codeEnum.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 自定义返回体
|
||||
*
|
||||
* @param body 返回体
|
||||
* @param code 返回状态码
|
||||
* @param message 返回消息
|
||||
* @return Result<T>
|
||||
*/
|
||||
public static <T> Result<T> build(T body, Integer code, String message) {
|
||||
Result<T> result = build(body);
|
||||
result.setCode(code);
|
||||
result.setMessage(message);
|
||||
result.setData(null);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作成功
|
||||
*
|
||||
* @return Result<T>
|
||||
*/
|
||||
public static <T> Result<T> success() {
|
||||
return success(null, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作成功
|
||||
*
|
||||
* @param data baseCategory1List
|
||||
*/
|
||||
public static <T> Result<T> success(T data) {
|
||||
return build(data, ResultCodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作成功-状态码
|
||||
*
|
||||
* @param codeEnum 状态码
|
||||
*/
|
||||
public static <T> Result<T> success(ResultCodeEnum codeEnum) {
|
||||
return success(null, codeEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作成功-自定义返回数据和状态码
|
||||
*
|
||||
* @param data 返回体
|
||||
* @param codeEnum 状态码
|
||||
*/
|
||||
public static <T> Result<T> success(T data, ResultCodeEnum codeEnum) {
|
||||
return build(data, codeEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败-自定义返回数据和状态码
|
||||
*
|
||||
* @param data 返回体
|
||||
* @param message 错误信息
|
||||
*/
|
||||
public static <T> Result<T> success(T data, String message) {
|
||||
return build(data, 200, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败-自定义返回数据和状态码
|
||||
*
|
||||
* @param data 返回体
|
||||
* @param code 状态码
|
||||
* @param message 错误信息
|
||||
*/
|
||||
public static <T> Result<T> success(T data, Integer code, String message) {
|
||||
return build(data, code, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败
|
||||
*/
|
||||
public static <T> Result<T> error() {
|
||||
return Result.build(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败-自定义返回数据
|
||||
*
|
||||
* @param data 返回体
|
||||
*/
|
||||
public static <T> Result<T> error(T data) {
|
||||
return build(data, ResultCodeEnum.FAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败-状态码
|
||||
*
|
||||
* @param codeEnum 状态码
|
||||
*/
|
||||
public static <T> Result<T> error(ResultCodeEnum codeEnum) {
|
||||
return build(null, codeEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败-自定义返回数据和状态码
|
||||
*
|
||||
* @param data 返回体
|
||||
* @param codeEnum 状态码
|
||||
*/
|
||||
public static <T> Result<T> error(T data, ResultCodeEnum codeEnum) {
|
||||
return build(data, codeEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败-自定义返回数据和状态码
|
||||
*
|
||||
* @param data 返回体
|
||||
* @param code 状态码
|
||||
* @param message 错误信息
|
||||
*/
|
||||
public static <T> Result<T> error(T data, Integer code, String message) {
|
||||
return build(data, code, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* * 操作失败-自定义返回数据和状态码
|
||||
*
|
||||
* @param data 返回体
|
||||
* @param message 错误信息
|
||||
*/
|
||||
public static <T> Result<T> error(T data, String message) {
|
||||
return build(null, 500, message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package cn.bunny.dao.result;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 统一返回结果状态信息类
|
||||
*/
|
||||
@Getter
|
||||
public enum ResultCodeEnum {
|
||||
// 成功操作 200
|
||||
SUCCESS(200, "操作成功" ),
|
||||
ADD_SUCCESS(200, "添加成功" ),
|
||||
UPDATE_SUCCESS(200, "修改成功" ),
|
||||
DELETE_SUCCESS(200, "删除成功" ),
|
||||
SORT_SUCCESS(200, "排序成功" ),
|
||||
SUCCESS_UPLOAD(200, "上传成功" ),
|
||||
SUCCESS_LOGOUT(200, "退出成功" ),
|
||||
LOGOUT_SUCCESS(200, "退出成功" ),
|
||||
EMAIL_CODE_REFRESH(200, "邮箱验证码已刷新" ),
|
||||
EMAIL_CODE_SEND_SUCCESS(200, "邮箱验证码已发送" ),
|
||||
|
||||
// 验证错误 201
|
||||
USERNAME_OR_PASSWORD_NOT_EMPTY(201, "用户名或密码不能为空" ),
|
||||
EMAIL_CODE_NOT_EMPTY(201, "邮箱验证码不能为空" ),
|
||||
SEND_EMAIL_CODE_NOT_EMPTY(201, "请先发送邮箱验证码" ),
|
||||
EMAIL_CODE_NOT_MATCHING(201, "邮箱验证码不匹配" ),
|
||||
LOGIN_ERROR(500, "账号或密码错误" ),
|
||||
LOGIN_ERROR_USERNAME_PASSWORD_NOT_EMPTY(201, "登录信息不能为空" ),
|
||||
GET_BUCKET_EXCEPTION(201, "获取文件信息失败" ),
|
||||
SEND_MAIL_CODE_ERROR(201, "邮件发送失败" ),
|
||||
EMAIL_CODE_EMPTY(201, "邮箱验证码过期或不存在" ),
|
||||
EMAIL_EXIST(201, "邮箱已存在" ),
|
||||
REQUEST_IS_EMPTY(201, "请求数据为空" ),
|
||||
DATA_TOO_LARGE(201, "请求数据为空" ),
|
||||
UPDATE_NEW_PASSWORD_SAME_AS_OLD_PASSWORD(201, "新密码与密码相同" ),
|
||||
|
||||
// 数据相关 206
|
||||
ILLEGAL_REQUEST(206, "非法请求" ),
|
||||
REPEAT_SUBMIT(206, "重复提交" ),
|
||||
DATA_ERROR(206, "数据异常" ),
|
||||
EMAIL_USER_TEMPLATE_IS_EMPTY(206, "邮件模板为空" ),
|
||||
EMAIL_TEMPLATE_IS_EMPTY(206, "邮件模板为空" ),
|
||||
EMAIL_USER_IS_EMPTY(206, "关联邮件用户配置为空" ),
|
||||
DATA_EXIST(206, "数据已存在" ),
|
||||
DATA_NOT_EXIST(206, "数据不存在" ),
|
||||
ALREADY_USER_EXCEPTION(206, "用户已存在" ),
|
||||
USER_IS_EMPTY(206, "用户不存在" ),
|
||||
FILE_NOT_EXIST(206, "文件不存在" ),
|
||||
NEW_PASSWORD_SAME_OLD_PASSWORD(206, "新密码不能和旧密码相同" ),
|
||||
MISSING_TEMPLATE_FILES(206, "缺少模板文件" ),
|
||||
|
||||
// 身份过期 208
|
||||
LOGIN_AUTH(208, "请先登陆" ),
|
||||
AUTHENTICATION_EXPIRED(208, "身份验证过期" ),
|
||||
SESSION_EXPIRATION(208, "会话过期" ),
|
||||
|
||||
// 209
|
||||
THE_SAME_USER_HAS_LOGGED_IN(209, "相同用户已登录" ),
|
||||
|
||||
// 提示错误
|
||||
UPDATE_ERROR(216, "修改失败" ),
|
||||
URL_ENCODE_ERROR(216, "URL编码失败" ),
|
||||
ILLEGAL_CALLBACK_REQUEST_ERROR(217, "非法回调请求" ),
|
||||
FETCH_USERINFO_ERROR(219, "获取用户信息失败" ),
|
||||
ILLEGAL_DATA_REQUEST(219, "非法数据请求" ),
|
||||
CLASS_NOT_FOUND(219, "类名不存在" ),
|
||||
ADMIN_ROLE_CAN_NOT_DELETED(219, "无法删除admin角色" ),
|
||||
ROUTER_RANK_NEED_LARGER_THAN_THE_PARENT(219, "设置路由等级需要大于或等于父级的路由等级" ),
|
||||
|
||||
// 无权访问 403
|
||||
FAIL_NO_ACCESS_DENIED(403, "无权访问" ),
|
||||
FAIL_NO_ACCESS_DENIED_USER_OFFLINE(403, "用户强制下线" ),
|
||||
TOKEN_PARSING_FAILED(403, "token解析失败" ),
|
||||
FAIL_NO_ACCESS_DENIED_USER_LOCKED(403, "该账户已封禁" ),
|
||||
|
||||
// 系统错误 500
|
||||
UNKNOWN_EXCEPTION(500, "服务异常" ),
|
||||
SERVICE_ERROR(500, "服务异常" ),
|
||||
UPLOAD_ERROR(500, "上传失败" ),
|
||||
FAIL(500, "失败" ),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
|
||||
ResultCodeEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package cn.bunny.dao.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TableInfoVo {
|
||||
|
||||
/* 表目录 */
|
||||
private String tableCat;
|
||||
|
||||
/* 表模式(可能为null) */
|
||||
private String tableSchem;
|
||||
|
||||
/* 表类型(通常是"TABLE") */
|
||||
private String tableType;
|
||||
|
||||
/* 类型的目录(可能为null) */
|
||||
private String typeCat;
|
||||
|
||||
/* 类型的模式(可能为null) */
|
||||
private String typeSchem;
|
||||
|
||||
/* 类型名称(可能为null) */
|
||||
private String typeName;
|
||||
|
||||
/* 自引用列名(可能为null) */
|
||||
private String selfReferencingColName;
|
||||
|
||||
/* 引用生成(可能为null) */
|
||||
private String refGeneration;
|
||||
|
||||
/* 表名 */
|
||||
private String tableName;
|
||||
|
||||
/* 类名 */
|
||||
private String className;
|
||||
|
||||
/* 注释内容 */
|
||||
private String comment;
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package cn.bunny.exception;
|
||||
|
||||
import cn.bunny.dao.result.ResultCodeEnum;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
@Slf4j
|
||||
public class AuthCustomerException extends RuntimeException {
|
||||
// 状态码
|
||||
Integer code;
|
||||
|
||||
// 描述信息
|
||||
String message = "服务异常";
|
||||
|
||||
// 返回结果状态
|
||||
ResultCodeEnum resultCodeEnum;
|
||||
|
||||
|
||||
public AuthCustomerException(Integer code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public AuthCustomerException(String message) {
|
||||
super(message);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public AuthCustomerException(ResultCodeEnum codeEnum) {
|
||||
super(codeEnum.getMessage());
|
||||
this.code = codeEnum.getCode();
|
||||
this.message = codeEnum.getMessage();
|
||||
this.resultCodeEnum = codeEnum;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package cn.bunny.exception;
|
||||
|
||||
|
||||
import cn.bunny.dao.result.Result;
|
||||
import cn.bunny.dao.result.ResultCodeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.nio.file.AccessDeniedException;
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 全局异常拦截器
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
// 自定义异常信息
|
||||
@ExceptionHandler(AuthCustomerException.class)
|
||||
@ResponseBody
|
||||
public Result<Object> exceptionHandler(AuthCustomerException exception) {
|
||||
Integer code = exception.getCode() != null ? exception.getCode() : 500;
|
||||
return Result.error(null, code, exception.getMessage());
|
||||
}
|
||||
|
||||
// 运行时异常信息
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
@ResponseBody
|
||||
public Result<Object> exceptionHandler(RuntimeException exception) {
|
||||
String message = exception.getMessage();
|
||||
message = StringUtils.hasText(message) ? message : "服务器异常";
|
||||
exception.printStackTrace();
|
||||
|
||||
// 解析异常
|
||||
String jsonParseError = "JSON parse error (.*)";
|
||||
Matcher jsonParseErrorMatcher = Pattern.compile(jsonParseError).matcher(message);
|
||||
if (jsonParseErrorMatcher.find()) {
|
||||
return Result.error(null, 500, "JSON解析异常 " + jsonParseErrorMatcher.group(1));
|
||||
}
|
||||
|
||||
// 数据过大
|
||||
String dataTooLongError = "Data too long for column (.*?) at row 1";
|
||||
Matcher dataTooLongErrorMatcher = Pattern.compile(dataTooLongError).matcher(message);
|
||||
if (dataTooLongErrorMatcher.find()) {
|
||||
return Result.error(null, 500, dataTooLongErrorMatcher.group(1) + " 字段数据过大" );
|
||||
}
|
||||
|
||||
// 主键冲突
|
||||
String primaryKeyError = "Duplicate entry '(.*?)' for key .*";
|
||||
Matcher primaryKeyErrorMatcher = Pattern.compile(primaryKeyError).matcher(message);
|
||||
if (primaryKeyErrorMatcher.find()) {
|
||||
return Result.error(null, 500, "[" + primaryKeyErrorMatcher.group(1) + "]已存在" );
|
||||
}
|
||||
|
||||
// corn表达式错误
|
||||
String cronExpression = "CronExpression '(.*?)' is invalid";
|
||||
Matcher cronExpressionMatcher = Pattern.compile(cronExpression).matcher(message);
|
||||
if (cronExpressionMatcher.find()) {
|
||||
return Result.error(null, 500, "表达式 " + cronExpressionMatcher.group(1) + " 不合法" );
|
||||
}
|
||||
|
||||
log.error("GlobalExceptionHandler===>运行时异常信息:{}" , message);
|
||||
return Result.error(null, 500, message);
|
||||
}
|
||||
|
||||
// 表单验证字段
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public Result<String> handleValidationExceptions(MethodArgumentNotValidException ex) {
|
||||
String errorMessage = ex.getBindingResult().getFieldErrors().stream()
|
||||
.map(DefaultMessageSourceResolvable::getDefaultMessage)
|
||||
.collect(Collectors.joining(", " ));
|
||||
return Result.error(null, 201, errorMessage);
|
||||
}
|
||||
|
||||
// 特定异常处理
|
||||
@ExceptionHandler(ArithmeticException.class)
|
||||
@ResponseBody
|
||||
public Result<Object> error(ArithmeticException exception) {
|
||||
log.error("GlobalExceptionHandler===>特定异常信息:{}" , exception.getMessage());
|
||||
|
||||
return Result.error(null, 500, exception.getMessage());
|
||||
}
|
||||
|
||||
// spring security异常
|
||||
@ExceptionHandler(AccessDeniedException.class)
|
||||
@ResponseBody
|
||||
public Result<String> error(AccessDeniedException exception) throws AccessDeniedException {
|
||||
log.error("GlobalExceptionHandler===>spring security异常:{}" , exception.getMessage());
|
||||
|
||||
return Result.error(ResultCodeEnum.SERVICE_ERROR);
|
||||
}
|
||||
|
||||
// 处理SQL异常
|
||||
@ExceptionHandler(SQLIntegrityConstraintViolationException.class)
|
||||
@ResponseBody
|
||||
public Result<String> exceptionHandler(SQLIntegrityConstraintViolationException exception) {
|
||||
log.error("GlobalExceptionHandler===>处理SQL异常:{}" , exception.getMessage());
|
||||
|
||||
String message = exception.getMessage();
|
||||
if (message.contains("Duplicate entry" )) {
|
||||
// 错误信息
|
||||
return Result.error(ResultCodeEnum.USER_IS_EMPTY);
|
||||
} else {
|
||||
return Result.error(ResultCodeEnum.UNKNOWN_EXCEPTION);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package cn.bunny.service;
|
||||
|
||||
public interface IndexService {
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package cn.bunny.service;
|
||||
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.vo.TableInfoVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TableService {
|
||||
|
||||
/**
|
||||
* 获取表属性
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 表属性
|
||||
*/
|
||||
TableInfoVo getTableMetaData(String tableName);
|
||||
|
||||
/**
|
||||
* 获取所有表
|
||||
*
|
||||
* @return 所有表信息
|
||||
*/
|
||||
List<TableInfoVo> getAllTableMetaData();
|
||||
|
||||
/**
|
||||
* 获取列属性
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 当前表所有的列内容
|
||||
*/
|
||||
List<ColumnMetaData> getColumnInfo(String tableName);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package cn.bunny.service.impl;
|
||||
|
||||
import cn.bunny.service.IndexService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class IndexServiceImpl implements IndexService {
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package cn.bunny.service.impl;
|
||||
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.entity.TableMetaData;
|
||||
import cn.bunny.dao.vo.TableInfoVo;
|
||||
import cn.bunny.service.TableService;
|
||||
import cn.bunny.utils.DbInfoUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
||||
public class TableServiceImpl implements TableService {
|
||||
|
||||
private final DbInfoUtil dbInfoUtil;
|
||||
|
||||
public TableServiceImpl(DbInfoUtil dbInfoUtil) {
|
||||
this.dbInfoUtil = dbInfoUtil;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表属性
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 表属性
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public TableInfoVo getTableMetaData(String tableName) {
|
||||
TableInfoVo tableInfoVo = new TableInfoVo();
|
||||
|
||||
TableMetaData tableMetaData = dbInfoUtil.tableInfo(tableName);
|
||||
BeanUtils.copyProperties(tableMetaData, tableInfoVo);
|
||||
|
||||
return tableInfoVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有表
|
||||
*
|
||||
* @return 所有表信息
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public List<TableInfoVo> getAllTableMetaData() {
|
||||
List<TableMetaData> allTableInfo = dbInfoUtil.getAllTableInfo();
|
||||
|
||||
return allTableInfo.stream().map(tableMetaData -> {
|
||||
TableInfoVo tableInfoVo = new TableInfoVo();
|
||||
BeanUtils.copyProperties(tableMetaData, tableInfoVo);
|
||||
|
||||
return tableInfoVo;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列属性
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 当前表所有的列内容
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public List<ColumnMetaData> getColumnInfo(String tableName) {
|
||||
return dbInfoUtil.columnInfo(tableName);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package cn.bunny.utils;
|
||||
|
||||
import cn.bunny.config.DatabaseMetadataHolder;
|
||||
import cn.bunny.entity.ColumnMetaData;
|
||||
import cn.bunny.entity.TableMetaData;
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.entity.TableMetaData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -10,13 +10,49 @@ import java.sql.DatabaseMetaData;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class DbInfoUtil {
|
||||
@Autowired
|
||||
private DatabaseMetadataHolder metadataHolder;
|
||||
|
||||
/**
|
||||
* 获取表的所有主键列名
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return 主键列名的集合
|
||||
*/
|
||||
public Set<String> getPrimaryKeyColumns(String tableName) throws SQLException {
|
||||
Set<String> primaryKeys = new HashSet<>();
|
||||
DatabaseMetaData metaData = metadataHolder.getMetaData();
|
||||
|
||||
try (ResultSet pkResultSet = metaData.getPrimaryKeys(null, null, tableName)) {
|
||||
while (pkResultSet.next()) {
|
||||
primaryKeys.add(pkResultSet.getString("COLUMN_NAME" ).toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
return primaryKeys;
|
||||
}
|
||||
|
||||
public List<TableMetaData> getAllTableInfo() throws SQLException {
|
||||
DatabaseMetaData metaData = metadataHolder.getMetaData();
|
||||
ResultSet tables = metaData.getTables(null, null, "%" , new String[]{"TABLE"});
|
||||
|
||||
List<TableMetaData> list = new ArrayList<>();
|
||||
|
||||
while (tables.next()) {
|
||||
String tableName = tables.getString("TABLE_NAME" );
|
||||
TableMetaData tableMetaData = tableInfo(tableName);
|
||||
list.add(tableMetaData);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表注释信息
|
||||
*
|
||||
|
@ -43,7 +79,7 @@ public class DbInfoUtil {
|
|||
|
||||
tableMetaData = TableMetaData.builder()
|
||||
.tableName(tableName)
|
||||
.remarks(remarks)
|
||||
.comment(remarks)
|
||||
.tableCat(tableCat)
|
||||
.tableSchem(tableSchem)
|
||||
.tableType(tableType)
|
||||
|
@ -69,19 +105,26 @@ public class DbInfoUtil {
|
|||
DatabaseMetaData metaData = metadataHolder.getMetaData();
|
||||
List<ColumnMetaData> columns = new ArrayList<>();
|
||||
|
||||
Set<String> primaryKeyColumns = getPrimaryKeyColumns(tableName);
|
||||
|
||||
try (ResultSet columnsRs = metaData.getColumns(null, null, tableName, null)) {
|
||||
while (columnsRs.next()) {
|
||||
ColumnMetaData column = new ColumnMetaData();
|
||||
column.setColumnName(columnsRs.getString("COLUMN_NAME" ));
|
||||
String columnName = columnsRs.getString("COLUMN_NAME" );
|
||||
|
||||
column.setColumnName(columnName);
|
||||
column.setFieldName(ConvertUtil.convertToFieldName(column.getColumnName()));
|
||||
column.setJdbcType(columnsRs.getString("TYPE_NAME" ));
|
||||
column.setJavaType(ConvertUtil.convertToJavaType(column.getJdbcType()));
|
||||
column.setComment(columnsRs.getString("REMARKS" ));
|
||||
column.setIsPrimaryKey(primaryKeyColumns.contains(columnName));
|
||||
|
||||
columns.add(column);
|
||||
}
|
||||
}
|
||||
|
||||
columns.get(0).setIsPrimaryKey(true);
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<contextName>logback</contextName>
|
||||
|
||||
<!-- 格式化 年-月-日 输出 -->
|
||||
<timestamp key="datetime" datePattern="yyyy-MM-dd"/>
|
||||
|
||||
<!--编码-->
|
||||
<property name="ENCODING" value="UTF-8"/>
|
||||
|
||||
<!-- 控制台日志 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- 临界值过滤器 -->
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>%cyan([%thread %d{yyyy-MM-dd HH:mm:ss}]) %yellow(%-5level) %green(%logger{100}).%boldRed(%method)-%boldMagenta(%line)-%blue(%msg%n)
|
||||
</pattern>
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 文件日志 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>logs/${datetime}/financial-server.log</file>
|
||||
<append>true</append>
|
||||
<encoder>
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss} [%-5level] %thread %file:%line %logger %msg%n</pattern>
|
||||
<charset>${ENCODING}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 让SpringBoot内部日志ERROR级别 减少日志输出 -->
|
||||
<logger name="org.springframework" level="ERROR" additivity="false">
|
||||
<appender-ref ref="STOUT"/>
|
||||
</logger>
|
||||
|
||||
<!-- 让mybatis整合包日志ERROR 减少日志输出 -->
|
||||
<logger name="org.mybatis" level="ERROR" additivity="false">
|
||||
<appender-ref ref="STOUT"/>
|
||||
</logger>
|
||||
|
||||
<!-- 让ibatis 日志ERROR 减少日志输出 -->
|
||||
<logger name="org.apache.ibatis" level="ERROR" additivity="false">
|
||||
<appender-ref ref="STOUT"/>
|
||||
</logger>
|
||||
|
||||
<!-- 让 tomcat包打印日志 日志ERROR 减少日志输出 -->
|
||||
<logger name="org.apache" level="ERROR" additivity="false">
|
||||
<appender-ref ref="STOUT"/>
|
||||
</logger>
|
||||
|
||||
<!-- 我们自己开发的程序为DEBUG -->
|
||||
<logger name="cn.bunny" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="STOUT"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.baomidou" level="ERROR" additivity="false">
|
||||
<appender-ref ref="STOUT"/>
|
||||
</logger>
|
||||
|
||||
<!-- 根日志记录器:INFO级别 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>400 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 400 - Bad Request</h1>
|
||||
<dl>
|
||||
<dt>错误说明:因为错误的语法导致服务器无法理解请求信息。</dt>
|
||||
<dt>原因1:客户端发起的请求不符合服务器对请求的某些限制,或者请求本身存在一定的错误。</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>链接中有特殊字符或者链接长度过长导致,请对应修改.</dd>
|
||||
<dt>原因2:request header 或者 cookie 过大所引起</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>crtl+shift+delete 快捷键清除cookie.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>403 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>403 - Forbidden 禁止访问: 访问被拒绝</h1>
|
||||
<dl>
|
||||
<dt>错误说明:禁止访问,服务器拒绝访问</dt>
|
||||
<dt>原因1:未找到默认的索引文件</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>IIS中【启用默认内容文档】选项中将默认打开文档修改为程序首页文件格式,如:index.html或者index.php</dd>
|
||||
<dt>原因2:文件夹安全权限导致</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>程序文件-右击-属性-安全-Users-修改为读取和执行权限</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,78 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>404 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 50px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>404 - Page Not Found 未找到</h1>
|
||||
<dl>
|
||||
<dt>错误说明:请求的页面不存在</dt>
|
||||
<dt>原因1:访问的文档权限不够</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>修改文件权限为755,windos系统修改目录权限为可写可读。</dd>
|
||||
<dt>原因2:防火墙的原因</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>先关闭让防火墙通过WWW服务。</dd>
|
||||
<dt>原因3:站点根目录无默认访问文件</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>在根目录中创建index.html或者创建index.php。</dd>
|
||||
<dt>原因4:站点配置目录不正确</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>将网站应用程序复制到站点目录中,或者修改站点配置目录指定到应用程序目录中。</dd>
|
||||
<dt>原因5:站点使用了伪静态</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>将伪静态规则删除,或者重新编写正确的伪静态规则,或关闭伪静态配置。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-cmn-Hans">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>500 - 服务器错误</title>
|
||||
<meta content="width=device-width, maximum-scale=1, initial-scale=1" name="viewport"/>
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #333;
|
||||
margin: auto;
|
||||
padding: 1em;
|
||||
display: table;
|
||||
user-select: none;
|
||||
box-sizing: border-box;
|
||||
font: lighter 20px "微软雅黑";
|
||||
}
|
||||
|
||||
a {
|
||||
color: #3498db;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
font-size: 3.5em;
|
||||
}
|
||||
|
||||
main {
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.btn {
|
||||
color: #fff;
|
||||
padding: .75em 1em;
|
||||
background: #3498db;
|
||||
border-radius: 1.5em;
|
||||
display: inline-block;
|
||||
transition: opacity .3s, transform .3s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
opacity: .7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>:'(</h1>
|
||||
<p>服务器开小差啦!管理员正在修理中...</p>
|
||||
<p>还请阁下静候站点恢复~</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>501 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 501 - Not Implemented</h1>
|
||||
<dl>
|
||||
<dt>错误说明:服务器没有相应的执行动作来完成当前请求。</dt>
|
||||
<dt>原因1:Web 服务器不支持实现此请求所需的功能</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>可以用来HttpWebRequest指定一个UserAgent来试试的,有时候你可以换电脑来测试一下的。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,80 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>502 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 50px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 502 - Bad Gateway 没有响应</h1>
|
||||
<dl>
|
||||
<dt>错误说明:坏的网关,http向后端节点请求,没有响应</dt>
|
||||
<dt>原因1:DNS 缓冲</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>在dos窗口运行 ipconfig /flushdns,该命令会刷新DNS缓冲。</dd>
|
||||
<dt>原因2:浏览器代理</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>关掉代理。</dd>
|
||||
<dt>原因3:dns 被劫持了,即使使用国外的dns,也会被劫持</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>
|
||||
去掉VPN服务器的DNS。切换另外的dns。在windows系统中,可以在本地网络连接的属性中,去掉默认的dns,选用国外的dns,比如google的或opendns。
|
||||
</dd>
|
||||
<dt>原因4:php执行超时</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>修改/usr/local/php/etc/php.ini 将max_execution_time 改为300。</dd>
|
||||
<dt>原因5:nginx等待时间超时</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>适当增加nginx.conf配置文件中FastCGI的timeout时间。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>503 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 503 - Service Unavailable 服务不可用</h1>
|
||||
<dl>
|
||||
<dt>错误说明:服务当前不可用</dt>
|
||||
<dt>原因1:服务不可用状态</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>服务器或许就是正在维护或者暂停了,你可以联系一下服务器空间商。</dd>
|
||||
<dt>原因2:程序占用资源太多</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>通过设置应用程序池把账户改为NetworkService即可解决。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,81 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>504 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 50px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 504 - Gateway Timeout 网关超时</h1>
|
||||
<dl>
|
||||
<dt>错误说明:网关超时,服务器响应时间,达到超出设定的范围</dt>
|
||||
<dt>原因1:后端电脑之间 IP 通讯缓慢而产生</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>如果您的 Web 服务器由某一网站托管, 只有负责那个网站设置的人员才能解决这个问题。</dd>
|
||||
<dt>原因2:由于nginx默认的fastcgi进程响应的缓冲区太小造成的错误</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>一般默认的fastcgi进程响应的缓冲区是8K,这时可以设置大一点,在nginx.conf里,加入:fastcgi_buffers 8
|
||||
128k这表示设置fastcgi缓冲区为8块128k大小的空间。当然如果在进行某一项即时的操作, 可能需要nginx的超时参数调大点,
|
||||
例如设置成60秒:send_timeout 60;经过这两个参数的调整,一般不会再提示“504 Gateway Time-out”错误,问题基本解决。
|
||||
</dd>
|
||||
<dt>原因3:PHP环境的配置问题</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>更改php-fpm的几处配置: 把max_children由之前的10改为现在的30,这样就可以保证有充足的php-cgi进程可以被使用;
|
||||
把request_terminate_timeout由之前的0s改为60s,这样php-cgi进程 处理脚本的超时时间就是60秒,可以防止进程都被挂起,提高利用效率。
|
||||
接着再更改nginx的几个配置项,减少FastCGI的请求次数,尽量维持buffers不变: fastcgi_buffers由 4 64k 改为 2
|
||||
256k; fastcgi_buffer_size 由 64k 改为 128K; fastcgi_busy_buffers_size 由 128K 改为 256K;
|
||||
fastcgi_temp_file_write_size 由 128K 改为 256K。 重新加载php-fpm和nginx的配置,再次测试,如果没有出现“504
|
||||
Gateway Time-out”错误,问题解决。
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>505 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 505 - HTTP Version Not Supported</h1>
|
||||
<dl>
|
||||
<dt>错误说明:HTTP 版本不受支持。</dt>
|
||||
<dt>原因1:您的 Web 服务器不支持,或拒绝支持客户端(如您的浏览器)在发送给服务器的 HTTP 请求数据流中指定的 HTTP
|
||||
协议版本
|
||||
</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>升级您的 Web 服务器软件。</dd>
|
||||
<dt>原因2:http请求格式的错误</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>对照一下自己的代码,从打印的信息中终于找到问题所在。可能在请求后面多加了一个空格。http协议真是很严格了。
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>506 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 506 - Variant Also Negotiates</h1>
|
||||
<dl>
|
||||
<dt>错误说明:</dt>
|
||||
<dt>原因1:服务器存在内部配置错误</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>被请求的协商变元资源被配置为在透明内容协商中使用自己,因此在一个协商处理中不是一个合适的重点。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>507 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 507 - Insufficient Storage</h1>
|
||||
<dl>
|
||||
<dt>错误说明:</dt>
|
||||
<dt>原因1:服务器无法存储完成请求所必须的内容</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>这个状况被认为是临时的。WebDAV (RFC 4918)。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>509 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 509 - Bandwidth Limit Exceeded</h1>
|
||||
<dl>
|
||||
<dt>错误说明:</dt>
|
||||
<dt>原因1:网站流量已经超出您所购买的方案限制即服务器达到带宽限制</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>1.升级方案 2.等到下个月后流量重新计算,网站即可正常浏览。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>510 错误 - phpstudy</title>
|
||||
<meta content="" name="keywords">
|
||||
<meta content="" name="description">
|
||||
<meta content="webkit" name="renderer">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<meta content="black" name="apple-mobile-web-app-status-bar-style">
|
||||
<meta content="yes" name="apple-mobile-web-app-capable">
|
||||
<meta content="telephone=no" name="format-detection">
|
||||
<meta CONTENT="no-cache" HTTP-EQUIV="pragma">
|
||||
<meta CONTENT="no-store, must-revalidate" HTTP-EQUIV="Cache-Control">
|
||||
<meta CONTENT="Wed, 26 Feb 1997 08:21:57 GMT" HTTP-EQUIV="expires">
|
||||
<meta CONTENT="0" HTTP-EQUIV="expires">
|
||||
<style>
|
||||
body {
|
||||
font: 16px arial, 'Microsoft Yahei', 'Hiragino Sans GB', sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
color: #3a87ad;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 45%;
|
||||
margin: 0 auto;
|
||||
|
||||
}
|
||||
|
||||
.content > div {
|
||||
margin-top: 200px;
|
||||
padding: 20px;
|
||||
background: #d9edf7;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.content dl {
|
||||
color: #2d6a88;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.content div div {
|
||||
padding-bottom: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<div>
|
||||
<h1>HTTP 510 - Not Extended</h1>
|
||||
<dl>
|
||||
<dt>错误说明:</dt>
|
||||
<dt>原因1:获取资源所需要的策略并没有被满足</dt>
|
||||
<dd>解决办法:</dd>
|
||||
<dd>需要请求有额外的扩展内容,服务器才能处理请求。</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" th:href="@{/css/semantic-ui.css}">
|
||||
<script th:src="@{/js/semantic.min.js}"></script>
|
||||
<script th:src="@{/js/jquery.min.js}"></script>
|
||||
<title>代码生成页面</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="ui container" style="margin-top: 20px;">
|
||||
<div class="ui cards">
|
||||
<div class="card" style="width: 100%;">
|
||||
<div class="content">
|
||||
<div class="header" th:text="'表名:'+${tableMetaData.tableName}"></div>
|
||||
<div class="meta" th:text="'表注释:'+${tableMetaData.comment}">Friend</div>
|
||||
<div class="description"
|
||||
th:text="'数据库名:'+${tableMetaData.tableCat}+';类型:'+${tableMetaData.tableType}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui secondary menu">
|
||||
<a class="item" th:href="@{'/preview/'+${tableMetaData.tableName}}">
|
||||
预览
|
||||
</a>
|
||||
<a class="item active" th:href="@{'/generator/'+${tableMetaData.tableName}}">
|
||||
生成页面
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -2,19 +2,38 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
||||
<link rel="stylesheet" th:href="@{/css/semantic-ui.css}">
|
||||
<script th:src="@{/js/semantic.min.js}"></script>
|
||||
<script th:src="@{/js/jquery.min.js}"></script>
|
||||
<title>主页</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>666</h1>
|
||||
<button class="bg-red-500">555</button>
|
||||
<div class="ui container" style="margin-top: 20px;">
|
||||
<h1 style="text-align: center">代码生成</h1>
|
||||
|
||||
<form action="">
|
||||
<label>
|
||||
111:
|
||||
<input class="border-2 border-solid" type="text">
|
||||
</label>
|
||||
<table class="ui celled padded table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>数据库名称</th>
|
||||
<th>表类型</th>
|
||||
<th class="single line"> 表名</th>
|
||||
<th>注释内容</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
</form>
|
||||
<tbody>
|
||||
<tr th:each="item : ${list}">
|
||||
<td class="ui center aligned" th:text="${item.tableCat}"></td>
|
||||
<td class="ui center aligned" th:text="${item.tableType}"></td>
|
||||
<td class="ui center aligned">
|
||||
<a class="ui blue label" th:href="@{'/preview/'+${item.tableName}}" th:text="${item.tableName}"></a>
|
||||
</td>
|
||||
<td class="single line center aligned ">
|
||||
<a class="ui grey label" th:href="@{'/preview/'+${item.tableName}}" th:text="${item.comment}"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" th:href="@{/css/semantic-ui.css}">
|
||||
<script th:src="@{/js/semantic.min.js}"></script>
|
||||
<script th:src="@{/js/jquery.min.js}"></script>
|
||||
<title>代码生成页面</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="ui container" style="margin-top: 20px;">
|
||||
<div class="ui cards">
|
||||
<div class="card" style="width: 100%;">
|
||||
<div class="content">
|
||||
<div class="header" th:text="'表名:'+${tableMetaData.tableName}"></div>
|
||||
<div class="meta" th:text="'表注释:'+${tableMetaData.comment}">Friend</div>
|
||||
<div class="description"
|
||||
th:text="'数据库名:'+${tableMetaData.tableCat}+';类型:'+${tableMetaData.tableType}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui secondary menu">
|
||||
<a class="item active" th:href="@{'/preview/'+${tableMetaData.tableName}}">
|
||||
预览
|
||||
</a>
|
||||
<a class="item" th:href="@{'/generator/'+${tableMetaData.tableName}}">
|
||||
生成页面
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<table class="ui celled padded table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>列名称</th>
|
||||
<th>字段名称</th>
|
||||
<th class="single line"> 数据库字段类型</th>
|
||||
<th>Java类型</th>
|
||||
<th>是否为主键</th>
|
||||
<th>字段注释</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr th:each="item : ${columnInfo}">
|
||||
<td class="ui center aligned" th:text="${item.columnName}"></td>
|
||||
<td class="ui center aligned" th:text="${item.fieldName}"></td>
|
||||
<td class="ui center aligned">
|
||||
<a class="ui blue label" th:text="${item.jdbcType}"></a>
|
||||
</td>
|
||||
<td class="single line center aligned ">
|
||||
<a class="ui grey label" th:text="${item.javaType}"></a>
|
||||
</td>
|
||||
<td class="ui center aligned" th:text="${item.isPrimaryKey?'是':'否'}"></td>
|
||||
<td class="ui center aligned" th:text="${item.comment}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -2,8 +2,8 @@ package cn.bunny;
|
|||
|
||||
|
||||
import cn.bunny.config.DatabaseMetadataHolder;
|
||||
import cn.bunny.entity.ColumnMetaData;
|
||||
import cn.bunny.entity.TableMetaData;
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.entity.TableMetaData;
|
||||
import cn.bunny.utils.ConvertUtil;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -29,15 +29,10 @@ public class JDBCTest {
|
|||
metaData = metadataHolder.getMetaData();
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取表注释信息
|
||||
*/
|
||||
@Test
|
||||
void testComment() throws SQLException {
|
||||
String tableName = "sys_i18n";
|
||||
|
||||
TableMetaData tableMetaData;
|
||||
|
||||
ResultSet tables = metaData.getTables(null, null, tableName, new String[]{"TABLE"});
|
||||
|
||||
// 获取表的注释信息
|
||||
|
@ -54,7 +49,7 @@ public class JDBCTest {
|
|||
|
||||
tableMetaData = TableMetaData.builder()
|
||||
.tableName(tableName)
|
||||
.remarks(remarks)
|
||||
.comment(remarks)
|
||||
.tableCat(tableCat)
|
||||
.tableSchem(tableSchem)
|
||||
.tableType(tableType)
|
||||
|
@ -69,6 +64,40 @@ public class JDBCTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAllTableComment() throws SQLException {
|
||||
ResultSet tables = metaData.getTables(null, null, "%" , new String[]{"TABLE"});
|
||||
List<TableMetaData> list = new ArrayList<>();
|
||||
|
||||
while (tables.next()) {
|
||||
String tableName = tables.getString("TABLE_NAME" );
|
||||
String remarks = tables.getString("REMARKS" );
|
||||
String tableCat = tables.getString("TABLE_CAT" );
|
||||
String tableSchem = tables.getString("TABLE_SCHEM" );
|
||||
String tableType = tables.getString("TABLE_TYPE" );
|
||||
String typeCat = tables.getString("TYPE_CAT" );
|
||||
String typeSchem = tables.getString("TYPE_SCHEM" );
|
||||
String typeName = tables.getString("TYPE_NAME" );
|
||||
String selfReferencingColName = tables.getString("SELF_REFERENCING_COL_NAME" );
|
||||
String refGeneration = tables.getString("REF_GENERATION" );
|
||||
|
||||
TableMetaData tableMetaData = TableMetaData.builder()
|
||||
.tableName(tableName).comment(remarks)
|
||||
.tableCat(tableCat)
|
||||
.tableSchem(tableSchem)
|
||||
.tableType(tableType)
|
||||
.typeCat(typeCat)
|
||||
.typeSchem(typeSchem)
|
||||
.typeName(typeName)
|
||||
.selfReferencingColName(selfReferencingColName)
|
||||
.refGeneration(refGeneration)
|
||||
.build();
|
||||
list.add(tableMetaData);
|
||||
}
|
||||
|
||||
System.out.println(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testColumnInfo() throws SQLException {
|
||||
List<ColumnMetaData> columns = new ArrayList<>();
|
||||
|
@ -86,5 +115,7 @@ public class JDBCTest {
|
|||
System.out.println(column);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(columns);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cn.bunny.utils;
|
||||
|
||||
import cn.bunny.entity.ColumnMetaData;
|
||||
import cn.bunny.entity.TableMetaData;
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.entity.TableMetaData;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
class DbInfoUtilTest {
|
||||
|
||||
String tableName = "sys_i18n";
|
||||
|
||||
|
||||
@Autowired
|
||||
private DbInfoUtil dbInfoUtil;
|
||||
|
||||
|
|
Loading…
Reference in New Issue