Commit 7c35a79c authored by ZhengJie's avatar ZhengJie
Browse files

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

详情 https://www.ydyno.com/archives/1225.html
parent d35ffc9d
/*
* 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; package me.zhengjie.utils;
import javax.crypto.Cipher; import javax.crypto.Cipher;
...@@ -14,7 +29,7 @@ import java.nio.charset.StandardCharsets; ...@@ -14,7 +29,7 @@ import java.nio.charset.StandardCharsets;
*/ */
public class EncryptUtils { public class EncryptUtils {
private static String strParam = "Passw0rd"; private static final String strParam = "Passw0rd";
private static Cipher cipher; private static Cipher cipher;
......
/*
* 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; package me.zhengjie.utils;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
......
/*
* 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; package me.zhengjie.utils;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
......
/*
* 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; package me.zhengjie.utils;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
......
/*
* 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; package me.zhengjie.utils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
......
/*
* 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; package me.zhengjie.utils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
......
/*
* 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; package me.zhengjie.utils;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
......
/*
* 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; package me.zhengjie.utils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
/*
* 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; package me.zhengjie.utils;
import cn.hutool.core.io.resource.ClassPathResource; import cn.hutool.core.io.resource.ClassPathResource;
...@@ -195,4 +210,26 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { ...@@ -195,4 +210,26 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
} }
return weekDays[w]; 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();
}
} }
/*
* 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; package me.zhengjie.utils;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
......
/*
* 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; package me.zhengjie.utils;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
......
/*
* 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; package me.zhengjie.utils;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
......
/*
* 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; package me.zhengjie.domain;
import lombok.Data; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
import me.zhengjie.utils.GenUtil; import me.zhengjie.utils.GenUtil;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable;
/** /**
* 列的数据信息 * 列的数据信息
* @author Zheng Jie * @author Zheng Jie
* @date 2019-01-02 * @date 2019-01-02
*/ */
@Data @Getter
@Setter
@Entity @Entity
@NoArgsConstructor @NoArgsConstructor
@Table(name = "column_config") @Table(name = "code_column_config")
public class ColumnInfo { public class ColumnInfo implements Serializable {
@Id @Id
@Column(name = "column_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id; private Long id;
@ApiModelProperty(value = "表名")
private String tableName; private String tableName;
/** 数据库字段名称 */ @ApiModelProperty(value = "数据库字段名称")
private String columnName; private String columnName;
/** 数据库字段类型 */ @ApiModelProperty(value = "数据库字段类型")
private String columnType; private String columnType;
/** 数据库字段键类型 */ @ApiModelProperty(value = "数据库字段键类型")
private String keyType; private String keyType;
/** 字段额外的参数 */ @ApiModelProperty(value = "字段额外的参数")
private String extra; private String extra;
/** 数据库字段描述 */ @ApiModelProperty(value = "数据库字段描述")
private String remark; private String remark;
/** 必填 */ @ApiModelProperty(value = "是否必填")
private Boolean notNull; private Boolean notNull;
/** 是否在列表显示 */ @ApiModelProperty(value = "是否在列表显示")
private Boolean listShow; private Boolean listShow;
/** 是否表单显示 */ @ApiModelProperty(value = "是否表单显示")
private Boolean formShow; private Boolean formShow;
/** 表单类型 */ @ApiModelProperty(value = "表单类型")
private String formType; private String formType;
/** 查询 1:模糊 2:精确 */ @ApiModelProperty(value = "查询 1:模糊 2:精确")
private String queryType; private String queryType;
/** 字典名称 */ @ApiModelProperty(value = "字典名称")
private String dictName; private String dictName;
/** 日期注解 */ @ApiModelProperty(value = "日期注解")
private String dateAnnotation; private String dateAnnotation;
public ColumnInfo(String tableName, String columnName, Boolean notNull, String columnType, String remark, String keyType, String extra) { public ColumnInfo(String tableName, String columnName, Boolean notNull, String columnType, String remark, String keyType, String extra) {
......
/*
* 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; package me.zhengjie.domain;
import lombok.Data; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*; import javax.persistence.*;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/** /**
* 代码生成配置 * 代码生成配置
* @author Zheng Jie * @author Zheng Jie
* @date 2019-01-03 * @date 2019-01-03
*/ */
@Data @Getter
@Setter
@Entity @Entity
@NoArgsConstructor @NoArgsConstructor
@Table(name = "gen_config") @Table(name = "code_gen_config")
public class GenConfig { public class GenConfig implements Serializable {
public GenConfig(String tableName) { public GenConfig(String tableName) {
this.cover = false;
this.moduleName = "eladmin-system";
this.tableName = tableName; this.tableName = tableName;
} }
@Id @Id
@Column(name = "config_id")
@ApiModelProperty(value = "ID", hidden = true)
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id; private Long id;
@NotBlank @NotBlank
@ApiModelProperty(value = "表名")
private String tableName; private String tableName;
/** 接口名称 **/ @ApiModelProperty(value = "接口名称")
private String apiAlias; private String apiAlias;
/** 包路径 */
@NotBlank @NotBlank
@ApiModelProperty(value = "包路径")
private String pack; private String pack;
/** 模块名 */
@Column(name = "module_name")
@NotBlank @NotBlank
@ApiModelProperty(value = "模块名")
private String moduleName; private String moduleName;
/** 前端文件路径 */
@NotBlank @NotBlank
@ApiModelProperty(value = "前端文件路径")
private String path; private String path;
/** 前端文件路径 */ @ApiModelProperty(value = "前端文件路径")
@Column(name = "api_path")
private String apiPath; private String apiPath;
/** 作者 */ @ApiModelProperty(value = "作者")
private String author; private String author;
/** 表前缀 */ @ApiModelProperty(value = "表前缀")
private String prefix; private String prefix;
/** 是否覆盖 */ @ApiModelProperty(value = "是否覆盖")
private Boolean cover; private Boolean cover = false;
} }
/*
* 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; package me.zhengjie.domain.vo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
......
/*
* 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; package me.zhengjie.repository;
import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.ColumnInfo;
......
/*
* 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; package me.zhengjie.repository;
import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.GenConfig;
......
/*
* 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; package me.zhengjie.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.GenConfig;
import me.zhengjie.service.GenConfigService; import me.zhengjie.service.GenConfigService;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -14,16 +30,13 @@ import org.springframework.web.bind.annotation.*; ...@@ -14,16 +30,13 @@ import org.springframework.web.bind.annotation.*;
* @date 2019-01-14 * @date 2019-01-14
*/ */
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/api/genConfig") @RequestMapping("/api/genConfig")
@Api(tags = "系统:代码生成器配置管理") @Api(tags = "系统:代码生成器配置管理")
public class GenConfigController { public class GenConfigController {
private final GenConfigService genConfigService; private final GenConfigService genConfigService;
public GenConfigController(GenConfigService genConfigService) {
this.genConfigService = genConfigService;
}
@ApiOperation("查询") @ApiOperation("查询")
@GetMapping(value = "/{tableName}") @GetMapping(value = "/{tableName}")
public ResponseEntity<Object> get(@PathVariable String tableName){ public ResponseEntity<Object> get(@PathVariable String tableName){
......
/*
* 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; package me.zhengjie.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.ColumnInfo;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.service.GenConfigService; import me.zhengjie.service.GenConfigService;
...@@ -20,22 +36,17 @@ import java.util.List; ...@@ -20,22 +36,17 @@ import java.util.List;
* @date 2019-01-02 * @date 2019-01-02
*/ */
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/api/generator") @RequestMapping("/api/generator")
@Api(tags = "系统:代码生成管理") @Api(tags = "系统:代码生成管理")
public class GeneratorController { public class GeneratorController {
private final GeneratorService generatorService; private final GeneratorService generatorService;
private final GenConfigService genConfigService; private final GenConfigService genConfigService;
@Value("${generator.enabled}") @Value("${generator.enabled}")
private Boolean generatorEnabled; private Boolean generatorEnabled;
public GeneratorController(GeneratorService generatorService, GenConfigService genConfigService) {
this.generatorService = generatorService;
this.genConfigService = genConfigService;
}
@ApiOperation("查询数据库数据") @ApiOperation("查询数据库数据")
@GetMapping(value = "/tables/all") @GetMapping(value = "/tables/all")
public ResponseEntity<Object> getTables(){ public ResponseEntity<Object> getTables(){
......
/*
* 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; package me.zhengjie.service;
import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.GenConfig;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment