Skip to content

Commit 28ef109

Browse files
committed
[代码完善](v2.5): v2.5 beta 菜单管理、部门管理,列表和弹窗数据懒加载
1、菜单管理表格,弹窗数据懒加载 2、部门管理表格,弹窗数据懒加载 3、角色管理,菜单分配数据懒加载 4、用户管理,左侧部门数据懒加载 5、其他杂项优化,sql脚本更新 2.5 Beta 详情:https://www.ydyno.com/archives/1225.html
1 parent 5c4d0e4 commit 28ef109

37 files changed

Lines changed: 519 additions & 162 deletions

eladmin-common/src/main/java/me/zhengjie/annotation/Query.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ enum Type {
7171
,BETWEEN
7272
// 不为空
7373
,NOT_NULL
74+
// 为空
75+
,IS_NULL
7476
}
7577

7678
/**

eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import lombok.Getter;
44
import lombok.Setter;
5+
import org.apache.commons.lang3.builder.ToStringBuilder;
6+
57
import java.io.Serializable;
8+
import java.lang.reflect.Field;
69
import java.sql.Timestamp;
710

811
/**
@@ -20,4 +23,19 @@ public class BaseDTO implements Serializable {
2023
private Timestamp createTime;
2124

2225
private Timestamp updateTime;
26+
27+
@Override
28+
public String toString() {
29+
ToStringBuilder builder = new ToStringBuilder(this);
30+
Field[] fields = this.getClass().getDeclaredFields();
31+
try {
32+
for (Field f : fields) {
33+
f.setAccessible(true);
34+
builder.append(f.getName(), f.get(this)).append("\n");
35+
}
36+
} catch (Exception e) {
37+
builder.append("toString builder encounter an error");
38+
}
39+
return builder.toString();
40+
}
2341
}

eladmin-common/src/main/java/me/zhengjie/config/FileProperties.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
package me.zhengjie.config;
1717

1818
import lombok.Data;
19+
import me.zhengjie.utils.ElAdminConstant;
1920
import org.springframework.boot.context.properties.ConfigurationProperties;
2021
import org.springframework.context.annotation.Configuration;
2122

23+
/**
24+
* @author Zheng Jie
25+
*/
2226
@Data
2327
@Configuration
2428
@ConfigurationProperties(prefix = "file")
@@ -38,9 +42,9 @@ public class FileProperties {
3842

3943
public ElPath getPath(){
4044
String os = System.getProperty("os.name");
41-
if(os.toLowerCase().startsWith("win")) {
45+
if(os.toLowerCase().startsWith(ElAdminConstant.WIN)) {
4246
return windows;
43-
} else if(os.toLowerCase().startsWith("mac")){
47+
} else if(os.toLowerCase().startsWith(ElAdminConstant.MAC)){
4448
return mac;
4549
}
4650
return linux;

eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@ public class ElAdminConstant {
2525
/**
2626
* 用于IP定位转换
2727
*/
28-
static final String REGION = "内网IP|内网IP";
28+
public static final String REGION = "内网IP|内网IP";
29+
30+
/**
31+
* win 系统
32+
*/
33+
public static final String WIN = "win";
34+
35+
/**
36+
* mac 系统
37+
*/
38+
public static final String MAC = "mac";
2939

3040
/**
3141
* 常用接口

eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
* @author Zheng Jie
2828
* @date 2018-11-23
2929
*/
30+
3031
public class EncryptUtils {
3132

32-
private static final String strParam = "Passw0rd";
33+
private static final String STR_PARAM = "Passw0rd";
3334

3435
private static Cipher cipher;
3536

36-
private static IvParameterSpec iv = new IvParameterSpec(strParam.getBytes(StandardCharsets.UTF_8));
37+
private static final IvParameterSpec IV = new IvParameterSpec(STR_PARAM.getBytes(StandardCharsets.UTF_8));
3738

3839
private static DESKeySpec getDesKeySpec(String source) throws Exception {
3940
if (source == null || source.length() == 0){
@@ -51,7 +52,7 @@ public static String desEncrypt(String source) throws Exception {
5152
DESKeySpec desKeySpec = getDesKeySpec(source);
5253
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
5354
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
54-
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
55+
cipher.init(Cipher.ENCRYPT_MODE, secretKey, IV);
5556
return byte2hex(
5657
cipher.doFinal(source.getBytes(StandardCharsets.UTF_8))).toUpperCase();
5758
}
@@ -64,7 +65,7 @@ public static String desDecrypt(String source) throws Exception {
6465
DESKeySpec desKeySpec = getDesKeySpec(source);
6566
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
6667
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
67-
cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
68+
cipher.init(Cipher.DECRYPT_MODE, secretKey, IV);
6869
byte[] retByte = cipher.doFinal(src);
6970
return new String(retByte);
7071
}

eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuild
5656
List<Field> fields = getAllFields(query.getClass(), new ArrayList<>());
5757
for (Field field : fields) {
5858
boolean accessible = field.isAccessible();
59+
// 设置对象的访问权限,保证对private的属性的访
5960
field.setAccessible(true);
6061
Query q = field.getAnnotation(Query.class);
6162
if (q != null) {
@@ -143,6 +144,9 @@ public static <R, Q> Predicate getPredicate(Root<R> root, Q query, CriteriaBuild
143144
case NOT_NULL:
144145
list.add(cb.isNotNull(getExpression(attributeName,join,root)));
145146
break;
147+
case IS_NULL:
148+
list.add(cb.isNull(getExpression(attributeName,join,root)));
149+
break;
146150
case BETWEEN:
147151
List<Object> between = new ArrayList<>((List<Object>)val);
148152
list.add(cb.between(getExpression(attributeName, join, root).as((Class<? extends Comparable>) between.get(0).getClass()),
@@ -182,7 +186,7 @@ private static boolean isBlank(final CharSequence cs) {
182186
return true;
183187
}
184188

185-
private static List<Field> getAllFields(Class clazz, List<Field> fields) {
189+
public static List<Field> getAllFields(Class clazz, List<Field> fields) {
186190
if (clazz != null) {
187191
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
188192
getAllFields(clazz.getSuperclass(), fields);

eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import me.zhengjie.base.BaseEntity;
2424
import javax.persistence.*;
2525
import java.io.Serializable;
26+
import java.util.Objects;
2627

2728
/**
2829
* @author zhanghouying
@@ -58,4 +59,22 @@ public class ServerDeploy extends BaseEntity implements Serializable {
5859
public void copy(ServerDeploy source){
5960
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
6061
}
62+
63+
@Override
64+
public boolean equals(Object o) {
65+
if (this == o) {
66+
return true;
67+
}
68+
if (o == null || getClass() != o.getClass()) {
69+
return false;
70+
}
71+
ServerDeploy that = (ServerDeploy) o;
72+
return Objects.equals(id, that.id) &&
73+
Objects.equals(name, that.name);
74+
}
75+
76+
@Override
77+
public int hashCode() {
78+
return Objects.hash(id, name);
79+
}
6180
}

eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployDto.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import lombok.Setter;
2121
import me.zhengjie.base.BaseDTO;
2222
import java.io.Serializable;
23+
import java.util.Objects;
2324
import java.util.Set;
2425
import java.util.stream.Collectors;
2526

@@ -57,4 +58,21 @@ public String getServers() {
5758
}
5859
return servers;
5960
}
61+
62+
@Override
63+
public boolean equals(Object o) {
64+
if (this == o) {
65+
return true;
66+
}
67+
if (o == null || getClass() != o.getClass()) {
68+
return false;
69+
}
70+
DeployDto deployDto = (DeployDto) o;
71+
return Objects.equals(id, deployDto.id);
72+
}
73+
74+
@Override
75+
public int hashCode() {
76+
return Objects.hash(id);
77+
}
6078
}

eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDto.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import lombok.Setter;
2020
import me.zhengjie.base.BaseDTO;
2121
import java.io.Serializable;
22+
import java.util.Objects;
2223

2324
/**
2425
* @author zhanghouying
@@ -39,4 +40,22 @@ public class ServerDeployDto extends BaseDTO implements Serializable {
3940
private String account;
4041

4142
private String password;
43+
44+
@Override
45+
public boolean equals(Object o) {
46+
if (this == o) {
47+
return true;
48+
}
49+
if (o == null || getClass() != o.getClass()) {
50+
return false;
51+
}
52+
ServerDeployDto that = (ServerDeployDto) o;
53+
return Objects.equals(id, that.id) &&
54+
Objects.equals(name, that.name);
55+
}
56+
57+
@Override
58+
public int hashCode() {
59+
return Objects.hash(id, name);
60+
}
4261
}

eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public class DeployServiceImpl implements DeployService {
6464
private final DeployMapper deployMapper;
6565
private final ServerDeployService serverDeployService;
6666
private final DeployHistoryService deployHistoryService;
67-
// 循环次数
67+
/**
68+
* 循环次数
69+
*/
6870
private final Integer count = 30;
6971

7072

0 commit comments

Comments
 (0)