Skip to content

Commit 2f0e566

Browse files
committed
Merge branch 'master' into deploy
2 parents 3d66f10 + 7b6f5af commit 2f0e566

34 files changed

Lines changed: 89 additions & 61 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
**开发文档:** [https://el-admin.vip](https://el-admin.vip)
1515

16-
**备用文档:** [https://doc.el-admin.xin](https://doc.el-admin.xin)
17-
1816
**体验地址:** [https://el-admin.xin](https://el-admin.xin)
1917

2018
**账号密码:** `admin / 123456`
@@ -45,7 +43,7 @@
4543
- 部门管理:可配置系统组织架构,树形表格展示
4644
- 岗位管理:配置各个部门的职位
4745
- 字典管理:可维护常用一些固定的数据,如:状态,性别等
48-
- 系统日志:记录用户操作日志与异常日志,方便开发人员定位拍错
46+
- 系统日志:记录用户操作日志与异常日志,方便开发人员定位排错
4947
- SQL监控:采用druid 监控数据库访问性能,默认用户名admin,密码123456
5048
- 定时任务:整合Quartz做定时任务,加入任务日志,任务运行情况一目了然
5149
- 代码生成:高灵活度生成前后端代码,减少大量重复的工作任务
@@ -111,6 +109,8 @@
111109

112110
- 感谢 [JetBrains](https://www.jetbrains.com/) 提供的非商业开源软件开发授权
113111

112+
- 感谢 [七牛云](https://www.qiniu.com/) 提供云存储支持
113+
114114
- 感谢 [PanJiaChen](https://github.com/PanJiaChen/vue-element-admin) 大佬提供的前端模板
115115

116116
- 感谢 [Moxun](https://github.com/moxun1639) 大佬提供的前端 Curd 通用组件
@@ -125,4 +125,4 @@
125125
项目的发展离不开你的支持,请作者喝杯咖啡吧☕ [Donate](https://el-admin.vip/donation/)
126126

127127
#### 反馈交流
128-
- QQ交流群:891137268
128+
- QQ交流群:一群:<strike>891137268</strike> 已满、二群:947578238

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
import cn.hutool.poi.excel.BigExcelWriter;
2121
import cn.hutool.poi.excel.ExcelUtil;
2222
import me.zhengjie.exception.BadRequestException;
23+
import org.apache.poi.ss.usermodel.CellType;
2324
import org.apache.poi.util.IOUtils;
25+
import org.apache.poi.xssf.streaming.SXSSFCell;
26+
import org.apache.poi.xssf.streaming.SXSSFRow;
27+
import org.apache.poi.xssf.streaming.SXSSFSheet;
2428
import org.slf4j.Logger;
2529
import org.slf4j.LoggerFactory;
2630
import org.springframework.web.multipart.MultipartFile;
@@ -208,6 +212,13 @@ public static void downloadExcel(List<Map<String, Object>> list, HttpServletResp
208212
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
209213
// 一次性写出内容,使用默认样式,强制输出标题
210214
writer.write(list, true);
215+
SXSSFSheet sheet = (SXSSFSheet)writer.getSheet();
216+
//上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
217+
sheet.trackAllColumnsForAutoSizing();
218+
//列宽自适应
219+
writer.autoSizeColumnAll();
220+
//列宽自适应支持中文单元格
221+
sizeChineseColumn(sheet, writer);
211222
//response为HttpServletResponse对象
212223
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
213224
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
@@ -220,6 +231,33 @@ public static void downloadExcel(List<Map<String, Object>> list, HttpServletResp
220231
IoUtil.close(out);
221232
}
222233

234+
/**
235+
* 自适应宽度(中文支持)
236+
*/
237+
private static void sizeChineseColumn(SXSSFSheet sheet, BigExcelWriter writer) {
238+
for (int columnNum = 0; columnNum < writer.getColumnCount(); columnNum++) {
239+
int columnWidth = sheet.getColumnWidth(columnNum) / 256;
240+
for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
241+
SXSSFRow currentRow;
242+
if (sheet.getRow(rowNum) == null) {
243+
currentRow = sheet.createRow(rowNum);
244+
} else {
245+
currentRow = sheet.getRow(rowNum);
246+
}
247+
if (currentRow.getCell(columnNum) != null) {
248+
SXSSFCell currentCell = currentRow.getCell(columnNum);
249+
if (currentCell.getCellTypeEnum() == CellType.STRING) {
250+
int length = currentCell.getStringCellValue().getBytes().length;
251+
if (columnWidth < length) {
252+
columnWidth = length;
253+
}
254+
}
255+
}
256+
}
257+
sheet.setColumnWidth(columnNum, columnWidth * 256);
258+
}
259+
}
260+
223261
public static String getFileType(String type) {
224262
String documents = "txt doc pdf ppt pps xlsx xls docx";
225263
String music = "mp3 wav wma mpa ram ra aac aif m4a";

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.springframework.data.redis.connection.RedisConnectionFactory;
2525
import org.springframework.data.redis.core.*;
2626
import org.springframework.stereotype.Component;
27-
import org.springframework.util.CollectionUtils;
2827

2928
import java.util.*;
3029
import java.util.concurrent.TimeUnit;

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,8 @@ public class SecurityUtils {
4141
* @return UserDetails
4242
*/
4343
public static UserDetails getCurrentUser() {
44-
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
45-
if (authentication == null) {
46-
throw new BadRequestException(HttpStatus.UNAUTHORIZED, "当前登录状态过期");
47-
}
48-
if (authentication.getPrincipal() instanceof UserDetails) {
49-
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
50-
UserDetailsService userDetailsService = SpringContextHolder.getBean(UserDetailsService.class);
51-
return userDetailsService.loadUserByUsername(userDetails.getUsername());
52-
}
53-
throw new BadRequestException(HttpStatus.UNAUTHORIZED, "找不到当前登录的信息");
44+
UserDetailsService userDetailsService = SpringContextHolder.getBean(UserDetailsService.class);
45+
return userDetailsService.loadUserByUsername(getCurrentUsername());
5446
}
5547

5648
/**
@@ -63,8 +55,11 @@ public static String getCurrentUsername() {
6355
if (authentication == null) {
6456
throw new BadRequestException(HttpStatus.UNAUTHORIZED, "当前登录状态过期");
6557
}
66-
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
67-
return userDetails.getUsername();
58+
if (authentication.getPrincipal() instanceof UserDetails) {
59+
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
60+
return userDetails.getUsername();
61+
}
62+
throw new BadRequestException(HttpStatus.UNAUTHORIZED, "找不到当前登录的信息");
6863
}
6964

7065
/**

eladmin-common/src/test/java/me/zhengjie/utils/DateUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class DateUtilsTest {
1010
public void test1() {
1111
long l = System.currentTimeMillis() / 1000;
1212
LocalDateTime localDateTime = DateUtil.fromTimeStamp(l);
13-
System.out.printf(DateUtil.localDateTimeFormatyMdHms(localDateTime));
13+
System.out.print(DateUtil.localDateTimeFormatyMdHms(localDateTime));
1414
}
1515

1616
@Test

eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public interface GeneratorService {
4949
* @param columnInfos /
5050
* @param columnInfoList /
5151
*/
52-
@Async
5352
void sync(List<ColumnInfo> columnInfos, List<ColumnInfo> columnInfoList);
5453

5554
/**

eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import cn.hutool.core.lang.Dict;
1919
import cn.hutool.core.util.ObjectUtil;
20-
import cn.hutool.json.JSONObject;
2120
import cn.hutool.json.JSONUtil;
2221
import lombok.RequiredArgsConstructor;
2322
import me.zhengjie.domain.Log;

eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import me.zhengjie.modules.mnt.domain.ServerDeploy;
1919
import org.springframework.data.jpa.repository.JpaRepository;
2020
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
21-
import org.springframework.data.jpa.repository.Modifying;
22-
import org.springframework.data.jpa.repository.Query;
2321

2422
/**
2523
* @author zhanghouying

eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package me.zhengjie.modules.mnt.util;
1717

18-
import cn.hutool.crypto.SecureUtil;
1918
import com.alibaba.druid.pool.DruidDataSource;
2019
import com.alibaba.druid.util.StringUtils;
2120
import com.google.common.collect.Lists;

eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ZipUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ public static void upZipFile(File zipFile, String folderPath) throws ZipExceptio
131131
for (Enumeration<?> entries = zf.entries(); entries.hasMoreElements(); ) {
132132
ZipEntry entry = ((ZipEntry) entries.nextElement());
133133
InputStream in = zf.getInputStream(entry);
134-
String str = folderPath;
135-
File desFile = new File(str, java.net.URLEncoder.encode(entry.getName(), "UTF-8"));
134+
File desFile = new File(folderPath, java.net.URLEncoder.encode(entry.getName(), "UTF-8"));
136135

137136
if (!desFile.exists()) {
138137
File fileParentDir = desFile.getParentFile();

0 commit comments

Comments
 (0)