feat(xlsx): 添加Excel导出工具类并重构导出功能

- 新增KitXlsxExportDataTransferRowHandler接口用于数据转换
- 新增KitXlsxExportUtil工具类提供统一的Excel导出功能
- 添加多个ExportRowVo类用于导出数据映射
- 重构部门、字典、岗位、菜单等模块的导出功能使用新工具类
- 添加SystemYesOrNoChConst和SystemZhConst常量接口
- 标记KitFileUtil.downloadExcel方法为废弃
- 优化文件名验证逻辑和字符串类型判断
This commit is contained in:
2025-12-30 18:01:24 +08:00
parent 88fbe36145
commit b15182afde
58 changed files with 709 additions and 554 deletions
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.odboy.util;
import static cn.odboy.constant.SystemConst.SYMBOL_ADD;
@@ -44,6 +43,7 @@ import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.util.IOUtils;
@@ -80,7 +80,6 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
* 定义KB的计算常量
*/
private static final int KB = 1024;
/**
* 格式化小数
*/
@@ -185,6 +184,7 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
/**
* 导出excel
*/
@Deprecated
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
File file = new File(tempPath);
@@ -193,7 +193,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
List<Map<String, Object>> sanitizedList = list.parallelStream().map(map -> {
Map<String, Object> sanitizedMap = new LinkedHashMap<>();
map.forEach((key, value) -> {
if (value instanceof String strValue) {
if (value instanceof String) {
String strValue = (String) value;
// 检查并处理以特殊字符开头的值
if (strValue.startsWith(SYMBOL_EQUAL) || strValue.startsWith(SYMBOL_ADD) ||
strValue.startsWith(SYMBOL_SUBTRACT) || strValue.startsWith(SYMBOL_AT)) {
@@ -206,7 +207,7 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
}
});
return sanitizedMap;
}).toList();
}).collect(Collectors.toList());
// 一次性写出内容, 使用默认样式,强制输出标题
writer.write(sanitizedList, true);
SXSSFSheet sheet = (SXSSFSheet) writer.getSheet();
@@ -363,10 +364,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
public static String verifyFilename(String fileName) {
// 过滤掉特殊字符
fileName = fileName.replaceAll("[\\\\/:*?\"<>|~\\s]", "");
// 去掉文件名开头和结尾的空格和点
fileName = fileName.trim().replaceAll("^[. ]+|[. ]+$", "");
// 不允许文件名超过255(在Mac和Linux中)或260(在Windows中)个字符
int maxFileNameLength = 255;
if (System.getProperty(SystemConst.PROPERTY_OS_NAME).startsWith(SystemConst.OS_NAME_WINDOWS)) {
@@ -375,20 +374,15 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
if (fileName.length() > maxFileNameLength) {
fileName = fileName.substring(0, maxFileNameLength);
}
// 过滤掉控制字符
fileName = fileName.replaceAll("[\\p{Cntrl}]", "");
// 过滤掉 ".." 路径
fileName = fileName.replaceAll("\\.{2,}", "");
// 去掉文件名开头的 ".."
fileName = fileName.replaceAll("^\\.+/", "");
// 保留文件名中最后一个 "." 字符,过滤掉其他 "."
fileName = fileName.replaceAll("^(.*)(\\.[^.]*)$", "$1").replaceAll("\\.", "") +
fileName.replaceAll("^(.*)(\\.[^.]*)$", "$2");
return fileName;
}
@@ -0,0 +1,8 @@
package cn.odboy.util.xlsx;
import java.util.List;
public interface KitXlsxExportDataTransferRowHandler<O, T> {
List<T> doHandler(O o);
}
@@ -0,0 +1,62 @@
package cn.odboy.util.xlsx;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.idev.excel.FastExcel;
import cn.odboy.framework.exception.BadRequestException;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import lombok.experimental.UtilityClass;
/**
* xlsx文件导出工具
*
* @author odboy
* @date 2025-12-29
*/
@UtilityClass
public class KitXlsxExportUtil {
/**
* @param response HttpServletResponse
* @param title 标题
* @param dataObjectList 数据源,一般为从数据库直接查询的数据
* @param targetClazz 目标对象Class
* @param rowHandler 数据对象 -> 目标对象 映射逻辑
* @param <O> 数据源对象类型
* @param <T> 目标对象类型
* @throws IOException
*/
public static <O, T> void exportFile(HttpServletResponse response, String title, List<O> dataObjectList, Class<T> targetClazz, KitXlsxExportDataTransferRowHandler<O, T> rowHandler) throws IOException {
if (response == null) {
throw new BadRequestException("参数 HttpServletResponse(response) 必填");
}
if (CollUtil.isEmpty(dataObjectList)) {
throw new BadRequestException("参数 数据源(dataObjectList) 必填");
}
if (StrUtil.isBlank(title)) {
throw new BadRequestException("参数 标题(title) 必填");
}
String sheetName = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN);
List<T> resultList = new ArrayList<>();
for (O o : dataObjectList) {
List<T> rows = rowHandler.doHandler(o);
resultList.addAll(rows);
}
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode(sheetName + "_" + title, StandardCharsets.UTF_8);
response.setHeader("Content-disposition",
"attachment;filename*=utf-8''" + fileName + ".xlsx");
FastExcel.write(response.getOutputStream(), targetClazz)
.sheet(sheetName)
.doWrite(resultList);
}
}
@@ -0,0 +1,6 @@
package cn.odboy.system.constant;
public interface SystemYesOrNoChConst {
String YES_STR = "是";
String NO_STR = "否";
}
@@ -0,0 +1,9 @@
package cn.odboy.system.constant;
public interface SystemZhConst {
String YES_STR = "是";
String NO_STR = "否";
String ENABLE_STR = "启用";
String DISABLE_STR = "停用";
}
@@ -21,8 +21,8 @@ import cn.odboy.system.dal.model.SystemUserLoginArgs;
import cn.odboy.system.service.SystemAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
@@ -15,18 +15,22 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.constant.SystemZhConst;
import cn.odboy.system.dal.dataobject.SystemDeptTb;
import cn.odboy.system.dal.model.SystemCreateDeptArgs;
import cn.odboy.system.dal.model.SystemDeptExportRowVo;
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
import cn.odboy.system.service.SystemDeptService;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -50,7 +54,14 @@ public class SystemDeptController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('dept:list')")
public void exportDept(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception {
systemDeptService.exportDeptExcel(systemDeptService.queryAllDeptByArgs(args, false), response);
List<SystemDeptTb> systemDeptTbs = systemDeptService.queryAllDeptByArgs(args, false);
KitXlsxExportUtil.exportFile(response, "部门数据", systemDeptTbs, SystemDeptExportRowVo.class, (dataObject) -> {
SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR);
rowVo.setCreateTime(dataObject.getCreateTime());
return CollUtil.newArrayList(rowVo);
});
}
@ApiOperation("查询部门")
@@ -15,19 +15,25 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import cn.odboy.system.dal.model.SystemCreateDictArgs;
import cn.odboy.system.dal.model.SystemDictDetailVo;
import cn.odboy.system.dal.model.SystemDictExportRowVo;
import cn.odboy.system.dal.model.SystemQueryDictArgs;
import cn.odboy.system.service.SystemDictDetailService;
import cn.odboy.system.service.SystemDictService;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -45,12 +51,37 @@ public class SystemDictController {
@Autowired
private SystemDictService systemDictService;
@Autowired
private SystemDictDetailService systemDictDetailService;
@ApiOperation("导出字典数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('dict:list')")
public void exportDict(HttpServletResponse response, SystemQueryDictArgs args) throws IOException {
systemDictService.exportDictExcel(systemDictService.queryDictByArgs(args), response);
List<SystemDictTb> systemDictTbs = systemDictService.queryDictByArgs(args);
KitXlsxExportUtil.exportFile(response, "字典数据", systemDictTbs, SystemDictExportRowVo.class, (dataObject) -> {
List<SystemDictDetailVo> dictDetails = systemDictDetailService.listDictDetailByName(dataObject.getName());
if (CollUtil.isEmpty(dictDetails)) {
SystemDictExportRowVo rowVo = new SystemDictExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setDescription(dataObject.getDescription());
rowVo.setCreateTime(dataObject.getCreateTime());
rowVo.setLabel("");
rowVo.setValue("");
return CollUtil.newArrayList(rowVo);
}
List<SystemDictExportRowVo> rowVos = new ArrayList<>();
for (SystemDictDetailVo dictDetail : dictDetails) {
SystemDictExportRowVo rowVo = new SystemDictExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setDescription(dataObject.getDescription());
rowVo.setCreateTime(dataObject.getCreateTime());
rowVo.setLabel(dictDetail.getLabel());
rowVo.setValue(dictDetail.getValue());
rowVos.add(rowVo);
}
return rowVos;
});
}
@ApiOperation("查询字典")
@@ -15,18 +15,22 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemJobTb;
import cn.odboy.system.dal.model.SystemCreateJobArgs;
import cn.odboy.system.dal.model.SystemJobExportRowVo;
import cn.odboy.system.dal.model.SystemQueryJobArgs;
import cn.odboy.system.service.SystemJobService;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -49,7 +53,14 @@ public class SystemJobController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('job:list')")
public void exportJob(HttpServletResponse response, SystemQueryJobArgs args) throws IOException {
systemJobService.exportJobExcel(systemJobService.queryJobByArgs(args), response);
List<SystemJobTb> systemJobTbs = systemJobService.queryJobByArgs(args);
KitXlsxExportUtil.exportFile(response, "岗位数据", systemJobTbs, SystemJobExportRowVo.class, (dataObject) -> {
SystemJobExportRowVo rowVo = new SystemJobExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用");
rowVo.setCreateTime(dataObject.getCreateTime());
return CollUtil.newArrayList(rowVo);
});
}
@ApiOperation("查询岗位")
@@ -15,16 +15,21 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemLocalStorageTb;
import cn.odboy.system.dal.model.SystemLocalStorageExportRowVo;
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
import cn.odboy.system.service.SystemLocalStorageService;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -58,7 +63,9 @@ public class SystemLocalStorageController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('storage:list')")
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs args) throws IOException {
localStorageService.exportLocalStorageExcel(localStorageService.queryLocalStorageByArgs(args), response);
List<SystemLocalStorageTb> systemLocalStorageTbs = localStorageService.queryLocalStorageByArgs(args);
KitXlsxExportUtil.exportFile(response, "文件上传记录数据", systemLocalStorageTbs, SystemLocalStorageExportRowVo.class,
(dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemLocalStorageExportRowVo.class)));
}
@ApiOperation("上传文件")
@@ -15,19 +15,23 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.system.constant.SystemYesOrNoChConst;
import cn.odboy.system.dal.dataobject.SystemMenuTb;
import cn.odboy.system.dal.model.SystemMenuExportRowVo;
import cn.odboy.system.dal.model.SystemMenuVo;
import cn.odboy.system.dal.model.SystemQueryMenuArgs;
import cn.odboy.system.service.SystemMenuService;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -51,7 +55,18 @@ public class SystemMenuController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('menu:list')")
public void exportMenu(HttpServletResponse response, SystemQueryMenuArgs args) throws Exception {
systemMenuService.exportMenuExcel(systemMenuService.queryAllMenu(args, false), response);
List<SystemMenuTb> systemMenuTbs = systemMenuService.queryAllMenu(args, false);
KitXlsxExportUtil.exportFile(response, "菜单数据", systemMenuTbs, SystemMenuExportRowVo.class, (dataObject -> {
SystemMenuExportRowVo rowVo = new SystemMenuExportRowVo();
rowVo.setTitle(dataObject.getTitle());
rowVo.setType(dataObject.getType() == null ? "目录" : dataObject.getType() == 1 ? "菜单" : "按钮");
rowVo.setPermission(dataObject.getPermission());
rowVo.setIFrame(dataObject.getIFrame() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR);
rowVo.setHidden(dataObject.getHidden() ? SystemYesOrNoChConst.NO_STR : SystemYesOrNoChConst.YES_STR);
rowVo.setCache(dataObject.getCache() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR);
rowVo.setCreateTime(dataObject.getCreateTime());
return CollUtil.newArrayList(rowVo);
}));
}
@PostMapping(value = "/buildMenus")
@@ -15,18 +15,22 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.model.SystemUserOnlineExportRowVo;
import cn.odboy.system.dal.model.SystemUserOnlineVo;
import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -59,7 +63,8 @@ public class SystemOnlineController {
@PreAuthorize("@el.check()")
public void exportOnlineUser(HttpServletResponse response, String username) throws IOException {
List<SystemUserOnlineVo> userOnlineVos = systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username);
systemUserOnlineInfoDAO.downloadUserOnlineModelExcel(userOnlineVos, response);
KitXlsxExportUtil.exportFile(response, "在线用户数据", userOnlineVos, SystemUserOnlineExportRowVo.class,
(dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemUserOnlineExportRowVo.class)));
}
@ApiOperation("踢出用户")
@@ -15,17 +15,22 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemOssStorageTb;
import cn.odboy.system.dal.model.SystemOssStorageExportRowVo;
import cn.odboy.system.dal.model.SystemOssStorageVo;
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
import cn.odboy.system.service.SystemOssStorageService;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
@@ -61,7 +66,9 @@ public class SystemOssStorageController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('storage:list')")
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs args) throws IOException {
systemOssStorageService.exportOssStorageExcel(systemOssStorageService.queryOssStorage(args), response);
List<SystemOssStorageVo> systemOssStorageVos = systemOssStorageService.queryOssStorage(args);
KitXlsxExportUtil.exportFile(response, "OSS文件上传记录数据", systemOssStorageVos, SystemOssStorageExportRowVo.class,
(dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemOssStorageExportRowVo.class)));
}
@ApiOperation("上传文件")
@@ -15,19 +15,24 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemQuartzJobTb;
import cn.odboy.system.dal.dataobject.SystemQuartzLogTb;
import cn.odboy.system.dal.model.SystemQuartzJobExportRowVo;
import cn.odboy.system.dal.model.SystemQuartzLogExportRowVo;
import cn.odboy.system.dal.model.SystemQueryQuartzJobArgs;
import cn.odboy.system.dal.model.SystemUpdateQuartzJobArgs;
import cn.odboy.system.service.SystemQuartzJobService;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
@@ -63,14 +68,41 @@ public class SystemQuartzJobController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('quartzJob:list')")
public void exportQuartzJob(HttpServletResponse response, SystemQueryQuartzJobArgs args) throws IOException {
systemQuartzJobService.exportQuartzJobExcel(systemQuartzJobService.queryQuartzJobByArgs(args), response);
List<SystemQuartzJobTb> systemQuartzJobTbs = systemQuartzJobService.queryQuartzJobByArgs(args);
KitXlsxExportUtil.exportFile(response, "定时任务数据", systemQuartzJobTbs, SystemQuartzJobExportRowVo.class,
(dataObject) -> {
SystemQuartzJobExportRowVo rowVo = new SystemQuartzJobExportRowVo();
rowVo.setJobName(dataObject.getJobName());
rowVo.setBeanName(dataObject.getBeanName());
rowVo.setMethodName(dataObject.getMethodName());
rowVo.setParams(dataObject.getParams());
rowVo.setCronExpression(dataObject.getCronExpression());
rowVo.setIsPause(dataObject.getIsPause() ? "暂停中" : "运行中");
rowVo.setDescription(dataObject.getDescription());
rowVo.setCreateTime(dataObject.getCreateTime());
return CollUtil.newArrayList(rowVo);
});
}
@ApiOperation("导出日志数据")
@GetMapping(value = "/logs/download")
@PreAuthorize("@el.check('quartzJob:list')")
public void exportQuartzJobLog(HttpServletResponse response, SystemQueryQuartzJobArgs args) throws IOException {
systemQuartzJobService.exportQuartzLogExcel(systemQuartzJobService.queryQuartzLogByArgs(args), response);
List<SystemQuartzLogTb> systemQuartzLogTbs = systemQuartzJobService.queryQuartzLogByArgs(args);
KitXlsxExportUtil.exportFile(response, "定时任务日志数据", systemQuartzLogTbs, SystemQuartzLogExportRowVo.class,
(dataObject) -> {
SystemQuartzLogExportRowVo rowVo = new SystemQuartzLogExportRowVo();
rowVo.setJobName(dataObject.getJobName());
rowVo.setBeanName(dataObject.getBeanName());
rowVo.setMethodName(dataObject.getMethodName());
rowVo.setParams(dataObject.getParams());
rowVo.setCronExpression(dataObject.getCronExpression());
rowVo.setExceptionDetail(dataObject.getExceptionDetail());
rowVo.setTime(dataObject.getTime());
rowVo.setStatus(dataObject.getIsSuccess() ? "成功" : "失败");
rowVo.setCreateTime(dataObject.getCreateTime());
return CollUtil.newArrayList(rowVo);
});
}
@ApiOperation("查询任务执行日志")
@@ -15,21 +15,24 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Dict;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemRoleTb;
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
import cn.odboy.system.dal.model.SystemRoleExportRowVo;
import cn.odboy.system.dal.model.SystemRoleVo;
import cn.odboy.system.service.SystemRoleService;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -59,7 +62,15 @@ public class SystemRoleController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('role:list')")
public void exportRole(HttpServletResponse response, SystemQueryRoleArgs args) throws IOException {
systemRoleService.exportRoleExcel(systemRoleService.queryRoleByArgs(args), response);
List<SystemRoleVo> systemRoleVos = systemRoleService.queryRoleByArgs(args);
KitXlsxExportUtil.exportFile(response, "角色数据", systemRoleVos, SystemRoleExportRowVo.class, (dataObject) -> {
SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setLevel(dataObject.getLevel());
rowVo.setDescription(dataObject.getDescription());
rowVo.setCreateTime(dataObject.getCreateTime());
return CollUtil.newArrayList(rowVo);
});
}
@ApiOperation("返回全部的角色")
@@ -15,22 +15,29 @@
*/
package cn.odboy.system.controller;
import cn.hutool.core.collection.CollUtil;
import cn.odboy.base.KitPageArgs;
import cn.odboy.base.KitPageResult;
import cn.odboy.base.KitSelectOptionVo;
import cn.odboy.system.constant.SystemZhConst;
import cn.odboy.system.dal.dataobject.SystemJobTb;
import cn.odboy.system.dal.dataobject.SystemRoleTb;
import cn.odboy.system.dal.dataobject.SystemUserTb;
import cn.odboy.system.dal.model.SystemQueryUserArgs;
import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs;
import cn.odboy.system.dal.model.SystemUserExportRowVo;
import cn.odboy.system.dal.model.SystemUserVo;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
import cn.odboy.system.service.SystemUserService;
import cn.odboy.util.xlsx.KitXlsxExportUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -57,7 +64,20 @@ public class SystemUserController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('user:list')")
public void exportUserExcel(HttpServletResponse response, SystemQueryUserArgs args) throws IOException {
systemUserService.exportUserExcel(systemUserService.queryUserByArgs(args), response);
List<SystemUserVo> systemUserVos = systemUserService.queryUserVoByArgs(args);
KitXlsxExportUtil.exportFile(response, "用户数据", systemUserVos, SystemUserExportRowVo.class, (dataObject) -> {
SystemUserExportRowVo rowVo = new SystemUserExportRowVo();
rowVo.setUsername(dataObject.getUsername());
rowVo.setRoles(dataObject.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.joining(",")));
rowVo.setDept(dataObject.getDept().getName());
rowVo.setJobs(dataObject.getJobs().stream().map(SystemJobTb::getName).collect(Collectors.joining(",")));
rowVo.setEmail(dataObject.getEmail());
rowVo.setStatus(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR);
rowVo.setMobile(dataObject.getPhone());
rowVo.setUpdatePwdTime(dataObject.getPwdResetTime());
rowVo.setCreateTime(dataObject.getCreateTime());
return CollUtil.newArrayList(rowVo);
});
}
@ApiOperation("查询用户")
@@ -17,9 +17,9 @@ package cn.odboy.system.dal.model;
import cn.odboy.base.KitObject;
import cn.odboy.system.dal.dataobject.SystemDeptTb;
import java.util.Set;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.util.Set;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -0,0 +1,19 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemDeptExportRowVo extends KitObject {
@ExcelProperty("部门名称")
private String name;
@ExcelProperty("部门状态")
private String enabled;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,22 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemDictExportRowVo extends KitObject {
@ExcelProperty("字典名称")
private String name;
@ExcelProperty("字典描述")
private String description;
@ExcelProperty("字典标签")
private String label;
@ExcelProperty("字典值")
private String value;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,19 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemJobExportRowVo extends KitObject {
@ExcelProperty("岗位名称")
private String name;
@ExcelProperty("岗位状态")
private String enabled;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,25 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemLocalStorageExportRowVo extends KitObject {
@ExcelProperty(value = "文件名")
private String realName;
@ExcelProperty(value = "备注名")
private String name;
@ExcelProperty(value = "文件类型")
private String type;
@ExcelProperty(value = "文件大小")
private String size;
@ExcelProperty(value = "创建者")
private String createBy;
@ExcelProperty(value = "创建日期")
private Date createTime;
}
@@ -0,0 +1,27 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemMenuExportRowVo extends KitObject {
@ExcelProperty("菜单标题")
private String title;
@ExcelProperty("菜单类型")
private String type;
@ExcelProperty("权限标识")
private String permission;
@ExcelProperty("外链菜单")
private String iFrame;
@ExcelProperty("菜单可见")
private String hidden;
@ExcelProperty("是否缓存")
private String cache;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,29 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemOssStorageExportRowVo extends KitObject {
@ExcelProperty("服务类型")
private String serviceType;
@ExcelProperty("服务地址")
private String endpoint;
@ExcelProperty("存储桶名称")
private String bucketName;
@ExcelProperty("文件名称")
private String fileName;
@ExcelProperty("文件大小")
private String fileSizeDesc;
@ExcelProperty("文件类型")
private String fileMime;
@ExcelProperty("创建人")
private String createBy;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,29 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemQuartzJobExportRowVo extends KitObject {
@ExcelProperty("任务名称")
private String jobName;
@ExcelProperty("Bean名称")
private String beanName;
@ExcelProperty("执行方法")
private String methodName;
@ExcelProperty("参数")
private String params;
@ExcelProperty("表达式")
private String cronExpression;
@ExcelProperty("状态")
private String isPause;
@ExcelProperty("描述")
private String description;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,30 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemQuartzLogExportRowVo extends KitObject {
@ExcelProperty("任务名称")
private String jobName;
@ExcelProperty("Bean名称")
private String beanName;
@ExcelProperty("执行方法")
private String methodName;
@ExcelProperty("参数")
private String params;
@ExcelProperty("表达式")
private String cronExpression;
@ExcelProperty("异常详情")
private String exceptionDetail;
@ExcelProperty("耗时/毫秒")
private Long time;
@ExcelProperty("状态")
private String status;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,20 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemRoleExportRowVo extends KitObject {
@ExcelProperty("角色名称")
private String name;
@ExcelProperty("角色级别")
private Integer level;
@ExcelProperty("描述")
private String description;
@ExcelProperty("角色名称")
private Date createTime;
}
@@ -0,0 +1,31 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemUserExportRowVo extends KitObject {
@ExcelProperty("用户名")
private String username;
@ExcelProperty("角色")
private String roles;
@ExcelProperty("部门")
private String dept;
@ExcelProperty("岗位")
private String jobs;
@ExcelProperty("邮箱")
private String email;
@ExcelProperty("状态")
private String status;
@ExcelProperty("手机号码")
private String mobile;
@ExcelProperty("修改密码的时间")
private Date updatePwdTime;
@ExcelProperty("创建日期")
private Date createTime;
}
@@ -0,0 +1,24 @@
package cn.odboy.system.dal.model;
import cn.idev.excel.annotation.ExcelProperty;
import cn.odboy.base.KitObject;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SystemUserOnlineExportRowVo extends KitObject {
@ExcelProperty("用户名")
private String userName;
@ExcelProperty("部门")
private String dept;
@ExcelProperty("登录IP")
private String ip;
@ExcelProperty("登录地点")
private String address;
@ExcelProperty("浏览器")
private String browser;
@ExcelProperty("登录日期")
private String loginTime;
}
@@ -18,10 +18,10 @@ import cn.odboy.system.framework.permission.core.handler.TokenProvider;
import cn.odboy.system.framework.permission.core.handler.UserDetailsHandler;
import cn.odboy.util.KitRsaEncryptUtil;
import com.wf.captcha.base.Captcha;
import jakarta.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -31,16 +31,12 @@ import cn.odboy.system.dal.model.SystemQueryDeptArgs;
import cn.odboy.system.dal.mysql.SystemDeptMapper;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
import cn.odboy.util.KitClassUtil;
import cn.odboy.util.KitFileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -109,25 +105,6 @@ public class SystemDeptService {
}
}
/**
* 导出数据
*
* @param deptList 待导出的数据
* @param response /
* @throws IOException /
*/
public void exportDeptExcel(List<SystemDeptTb> deptList, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemDeptTb dept : deptList) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("部门名称", dept.getName());
map.put("部门状态", dept.getEnabled() ? "启用" : "停用");
map.put("创建日期", dept.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 更新父节点中子节点数目
*
@@ -16,25 +16,16 @@
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
import cn.odboy.system.dal.dataobject.SystemDictTb;
import cn.odboy.system.dal.model.SystemCreateDictArgs;
import cn.odboy.system.dal.model.SystemDictDetailVo;
import cn.odboy.system.dal.model.SystemQueryDictArgs;
import cn.odboy.system.dal.mysql.SystemDictMapper;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -84,40 +75,6 @@ public class SystemDictService {
systemDictDetailService.deleteDictDetailByDictIds(ids);
}
/**
* 导出数据
*
* @param dicts 待导出的数据
* @param response /
* @throws IOException /
*/
public void exportDictExcel(List<SystemDictTb> dicts, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemDictTb dict : dicts) {
List<SystemDictDetailVo> dictDetails = systemDictDetailService.listDictDetailByName(dict.getName());
if (CollectionUtil.isNotEmpty(dictDetails)) {
for (SystemDictDetailTb dictDetail : dictDetails) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("字典名称", dict.getName());
map.put("字典描述", dict.getDescription());
map.put("字典标签", dictDetail.getLabel());
map.put("字典值", dictDetail.getValue());
map.put("创建日期", dictDetail.getCreateTime());
list.add(map);
}
} else {
Map<String, Object> map = new LinkedHashMap<>();
map.put("字典名称", dict.getName());
map.put("字典描述", dict.getDescription());
map.put("字典标签", null);
map.put("字典值", null);
map.put("创建日期", dict.getCreateTime());
list.add(map);
}
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 分页查询
*
@@ -24,16 +24,10 @@ import cn.odboy.system.dal.dataobject.SystemJobTb;
import cn.odboy.system.dal.model.SystemCreateJobArgs;
import cn.odboy.system.dal.model.SystemQueryJobArgs;
import cn.odboy.system.dal.mysql.SystemJobMapper;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -89,24 +83,6 @@ public class SystemJobService {
systemJobMapper.deleteByIds(ids);
}
/**
* 导出数据
*
* @param jobs 待导出的数据
* @param response /
*/
public void exportJobExcel(List<SystemJobTb> jobs, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemJobTb job : jobs) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("岗位名称", job.getName());
map.put("岗位状态", job.getEnabled() ? "启用" : "停用");
map.put("创建日期", job.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 分页查询
*
@@ -33,14 +33,9 @@ import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -124,29 +119,6 @@ public class SystemLocalStorageService {
}
}
/**
* 导出数据
*
* @param localStorages 待导出的数据
* @param response /
* @throws IOException /
*/
public void exportLocalStorageExcel(List<SystemLocalStorageTb> localStorages, HttpServletResponse response)
throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemLocalStorageTb localStorage : localStorages) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("文件名", localStorage.getRealName());
map.put("备注名", localStorage.getName());
map.put("文件类型", localStorage.getType());
map.put("文件大小", localStorage.getSize());
map.put("创建者", localStorage.getCreateBy());
map.put("创建日期", localStorage.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 分页查询
*
@@ -33,19 +33,14 @@ import cn.odboy.system.dal.mysql.SystemMenuMapper;
import cn.odboy.system.dal.mysql.SystemRoleMenuMapper;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
import cn.odboy.util.KitClassUtil;
import cn.odboy.util.KitFileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -56,15 +51,12 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class SystemMenuService {
private static final String YES_STR = "是";
private static final String NO_STR = "否";
@Autowired
private SystemMenuMapper systemMenuMapper;
@Autowired
private SystemRoleMenuMapper systemRoleMenuMapper;
@Autowired
private SystemRoleService systemRoleService;
@Autowired
private SystemRoleMenuService systemRoleMenuService;
@Autowired
private SystemUserRoleService systemUserRoleService;
@@ -185,29 +177,6 @@ public class SystemMenuService {
}
}
/**
* 导出
*
* @param menus 待导出的数据
* @param response /
* @throws IOException /
*/
public void exportMenuExcel(List<SystemMenuTb> menus, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemMenuTb menu : menus) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("菜单标题", menu.getTitle());
map.put("菜单类型", menu.getType() == null ? "目录" : menu.getType() == 1 ? "菜单" : "按钮");
map.put("权限标识", menu.getPermission());
map.put("外链菜单", menu.getIFrame() ? YES_STR : NO_STR);
map.put("菜单可见", menu.getHidden() ? NO_STR : YES_STR);
map.put("是否缓存", menu.getCache() ? YES_STR : NO_STR);
map.put("创建日期", menu.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
@Transactional(rollbackFor = Exception.class)
public void updateMenuSubCnt(Long menuId) {
if (menuId != null) {
@@ -21,9 +21,9 @@ import cn.odboy.system.dal.model.SystemOssStorageVo;
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
/**
@@ -30,17 +30,11 @@ import cn.odboy.system.dal.model.SystemUpdateQuartzJobArgs;
import cn.odboy.system.dal.mysql.SystemQuartzJobMapper;
import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
import cn.odboy.system.framework.quartz.QuartzManage;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.quartz.CronExpression;
import org.springframework.beans.factory.annotation.Autowired;
@@ -192,57 +186,6 @@ public class SystemQuartzJobService {
}
}
/**
* 导出定时任务
*
* @param quartzJobs 待导出的数据
* @param response /
* @throws IOException /
*/
public void exportQuartzJobExcel(List<SystemQuartzJobTb> quartzJobs, HttpServletResponse response)
throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemQuartzJobTb quartzJob : quartzJobs) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("任务名称", quartzJob.getJobName());
map.put("Bean名称", quartzJob.getBeanName());
map.put("执行方法", quartzJob.getMethodName());
map.put("参数", quartzJob.getParams());
map.put("表达式", quartzJob.getCronExpression());
map.put("状态", quartzJob.getIsPause() ? "暂停中" : "运行中");
map.put("描述", quartzJob.getDescription());
map.put("创建日期", quartzJob.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 导出定时任务日志
*
* @param queryAllLog 待导出的数据
* @param response /
* @throws IOException /
*/
public void exportQuartzLogExcel(List<SystemQuartzLogTb> queryAllLog, HttpServletResponse response)
throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemQuartzLogTb quartzLog : queryAllLog) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("任务名称", quartzLog.getJobName());
map.put("Bean名称", quartzLog.getBeanName());
map.put("执行方法", quartzLog.getMethodName());
map.put("参数", quartzLog.getParams());
map.put("表达式", quartzLog.getCronExpression());
map.put("异常详情", quartzLog.getExceptionDetail());
map.put("耗时/毫秒", quartzLog.getTime());
map.put("状态", quartzLog.getIsSuccess() ? "成功" : "失败");
map.put("创建日期", quartzLog.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 分页查询
*
@@ -31,18 +31,12 @@ import cn.odboy.system.dal.model.SystemRoleCodeVo;
import cn.odboy.system.dal.model.SystemRoleVo;
import cn.odboy.system.dal.mysql.SystemRoleMapper;
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
@@ -151,25 +145,6 @@ public class SystemRoleService {
systemRoleMenuService.batchDeleteRoleMenu(ids);
}
/**
* 导出数据
*
* @param roles 待导出的数据
* @param response /
*/
public void exportRoleExcel(List<SystemRoleVo> roles, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemRoleVo role : roles) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("角色名称", role.getName());
map.put("角色级别", role.getLevel());
map.put("描述", role.getDescription());
map.put("创建日期", role.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 查询全部角色
*/
@@ -50,13 +50,9 @@ import cn.odboy.util.KitRsaEncryptUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -335,32 +331,6 @@ public class SystemUserService {
systemUserInfoDAO.deleteUserLoginInfoByUserName(username);
}
/**
* 导出数据
*
* @param users 待导出的数据
* @param response /
* @throws IOException /
*/
public void exportUserExcel(List<SystemUserVo> users, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemUserVo user : users) {
List<String> roles = user.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.toList());
Map<String, Object> map = new LinkedHashMap<>();
map.put("用户名", user.getUsername());
map.put("角色", roles);
map.put("部门", user.getDept().getName());
map.put("岗位", user.getJobs().stream().map(SystemJobTb::getName).collect(Collectors.toList()));
map.put("邮箱", user.getEmail());
map.put("状态", user.getEnabled() ? "启用" : "禁用");
map.put("手机号码", user.getPhone());
map.put("修改密码的时间", user.getPwdResetTime());
map.put("创建日期", user.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
/**
* 查询全部
*
@@ -384,7 +354,7 @@ public class SystemUserService {
* @param args 条件
* @return /
*/
public List<SystemUserVo> queryUserByArgs(SystemQueryUserArgs args) {
public List<SystemUserVo> queryUserVoByArgs(SystemQueryUserArgs args) {
// 查询用户基本信息
LambdaQueryWrapper<SystemUserTb> wrapper = buildUserQueryWrapper(args);
List<SystemUserTb> users = systemUserMapper.selectList(wrapper);
@@ -36,13 +36,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -50,14 +50,14 @@ import org.springframework.web.multipart.MultipartFile;
/**
* <p>
* OSS存储 服务实现类
* OSS存储 Minio服务实现类
* </p>
*
* @author codegen
* @since 2025-07-15
*/
@Service
public class SystemOssStorageServiceImpl extends ServiceImpl<SystemOssStorageMapper, SystemOssStorageTb>
public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageMapper, SystemOssStorageTb>
implements SystemOssStorageService {
@Autowired