refactor(system): 重构系统模块中的导出功能实现

This commit is contained in:
2025-12-31 12:42:08 +08:00
parent 6e778ff337
commit 46ba8b966e
54 changed files with 832 additions and 553 deletions
@@ -15,17 +15,13 @@
*/
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 java.util.List;
@@ -54,14 +50,7 @@ public class SystemDeptController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('dept:list')")
public void exportDept(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception {
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);
});
systemDeptService.exportDeptXlsx(response, args);
}
@ApiOperation("查询部门")
@@ -15,22 +15,17 @@
*/
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 java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
@@ -58,30 +53,7 @@ public class SystemDictController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('dict:list')")
public void exportDict(HttpServletResponse response, SystemQueryDictArgs args) throws IOException {
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;
});
systemDictService.exportDictXlsx(response, args);
}
@ApiOperation("查询字典")
@@ -15,20 +15,16 @@
*/
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 java.io.IOException;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
@@ -53,14 +49,7 @@ public class SystemJobController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('job:list')")
public void exportJob(HttpServletResponse response, SystemQueryJobArgs args) throws IOException {
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);
});
systemJobService.exportJobXlsx(response, args);
}
@ApiOperation("查询岗位")
@@ -15,20 +15,15 @@
*/
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 java.io.IOException;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
@@ -63,9 +58,7 @@ public class SystemLocalStorageController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('storage:list')")
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs args) throws IOException {
List<SystemLocalStorageTb> systemLocalStorageTbs = localStorageService.queryLocalStorageByArgs(args);
KitXlsxExportUtil.exportFile(response, "文件上传记录数据", systemLocalStorageTbs, SystemLocalStorageExportRowVo.class,
(dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemLocalStorageExportRowVo.class)));
localStorageService.exportLocalStorageXlsx(response, args);
}
@ApiOperation("上传文件")
@@ -15,18 +15,14 @@
*/
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 java.util.List;
@@ -55,18 +51,7 @@ public class SystemMenuController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('menu:list')")
public void exportMenu(HttpServletResponse response, SystemQueryMenuArgs args) throws Exception {
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);
}));
systemMenuService.exportMenuXlsx(response, args);
}
@PostMapping(value = "/buildMenus")
@@ -15,20 +15,14 @@
*/
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 java.io.IOException;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
@@ -61,10 +55,8 @@ public class SystemOnlineController {
@ApiOperation("导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check()")
public void exportOnlineUser(HttpServletResponse response, String username) throws IOException {
List<SystemUserOnlineVo> userOnlineVos = systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username);
KitXlsxExportUtil.exportFile(response, "在线用户数据", userOnlineVos, SystemUserOnlineExportRowVo.class,
(dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemUserOnlineExportRowVo.class)));
public void exportOnlineUser(HttpServletResponse response, String username) {
systemUserOnlineInfoDAO.exportOnlineUserXlsx(response, username);
}
@ApiOperation("踢出用户")
@@ -15,21 +15,16 @@
*/
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 java.io.IOException;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -66,9 +61,7 @@ public class SystemOssStorageController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('storage:list')")
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs args) throws IOException {
List<SystemOssStorageVo> systemOssStorageVos = systemOssStorageService.queryOssStorage(args);
KitXlsxExportUtil.exportFile(response, "OSS文件上传记录数据", systemOssStorageVos, SystemOssStorageExportRowVo.class,
(dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemOssStorageExportRowVo.class)));
systemOssStorageService.exportOssStorageXlsx(response, args);
}
@ApiOperation("上传文件")
@@ -15,22 +15,16 @@
*/
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 java.io.IOException;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
@@ -67,42 +61,15 @@ public class SystemQuartzJobController {
@ApiOperation("导出任务数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('quartzJob:list')")
public void exportQuartzJob(HttpServletResponse response, SystemQueryQuartzJobArgs args) throws IOException {
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);
});
public void exportQuartzJob(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
systemQuartzJobService.exportQuartzJobXlsx(response, args);
}
@ApiOperation("导出日志数据")
@GetMapping(value = "/logs/download")
@PreAuthorize("@el.check('quartzJob:list')")
public void exportQuartzJobLog(HttpServletResponse response, SystemQueryQuartzJobArgs args) throws IOException {
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);
});
public void exportQuartzJobLog(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
systemQuartzJobService.exportQuartzLogXlsx(response, args);
}
@ApiOperation("查询任务执行日志")
@@ -15,17 +15,14 @@
*/
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;
@@ -62,15 +59,7 @@ public class SystemRoleController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('role:list')")
public void exportRole(HttpServletResponse response, SystemQueryRoleArgs args) throws IOException {
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);
});
systemRoleService.exportRoleXlsx(response, args);
}
@ApiOperation("返回全部的角色")
@@ -15,28 +15,20 @@
*/
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 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;
@@ -63,21 +55,8 @@ public class SystemUserController {
@ApiOperation("导出用户数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('user:list')")
public void exportUserExcel(HttpServletResponse response, SystemQueryUserArgs args) throws IOException {
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);
});
public void exportUserExcel(HttpServletResponse response, SystemQueryUserArgs args) {
systemUserService.exportUserXlsx(response, args);
}
@ApiOperation("查询用户")
@@ -9,6 +9,7 @@ import lombok.Setter;
@Getter
@Setter
public class SystemDictExportRowVo extends KitObject {
@ExcelProperty("字典名称")
private String name;
@ExcelProperty("字典描述")
@@ -9,6 +9,7 @@ import lombok.Setter;
@Getter
@Setter
public class SystemQuartzLogExportRowVo extends KitObject {
@ExcelProperty("任务名称")
private String jobName;
@ExcelProperty("Bean名称")
@@ -9,6 +9,7 @@ import lombok.Setter;
@Getter
@Setter
public class SystemRoleExportRowVo extends KitObject {
@ExcelProperty("角色名称")
private String name;
@ExcelProperty("角色级别")
@@ -16,9 +16,9 @@
package cn.odboy.system.dal.model;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -1,5 +1,6 @@
package cn.odboy.system.dal.redis;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
import cn.odboy.framework.properties.AppProperties;
@@ -12,9 +13,8 @@ import cn.odboy.util.KitDesEncryptUtil;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitIPUtil;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@@ -24,6 +24,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -166,4 +168,12 @@ public class SystemUserOnlineInfoDAO {
this.logoutByToken(token);
}
}
public void exportOnlineUserXlsx(HttpServletResponse response, String username) {
List<SystemUserOnlineVo> userOnlineVos = this.queryUserOnlineModelListByUsername(username);
// KitXlsxExportUtil.exportFile(response, "在线用户数据", userOnlineVos, SystemUserOnlineExportRowVo.class,
// (dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemUserOnlineExportRowVo.class)));
List<SystemUserOnlineVo> rowVos = BeanUtil.copyToList(userOnlineVos, SystemUserOnlineVo.class);
KitExcelExporter.exportSimple(response, "在线用户数据", SystemUserOnlineVo.class, rowVos);
}
}
@@ -23,14 +23,17 @@ import cn.hutool.core.util.StrUtil;
import cn.odboy.base.KitPageResult;
import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.system.constant.SystemDataScopeEnum;
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.SystemProductLineTreeVo;
import cn.odboy.system.dal.model.SystemProductLineVo;
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.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import java.lang.reflect.Field;
import java.util.ArrayList;
@@ -43,6 +46,7 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -464,4 +468,24 @@ public class SystemDeptService {
wrapper.eq(SystemDeptTb::getPid, pid);
return systemDeptMapper.selectList(wrapper);
}
public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception {
List<SystemDeptTb> systemDeptTbs = this.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);
// });
List<SystemDeptExportRowVo> rowVos = new ArrayList<>();
for (SystemDeptTb dataObject : systemDeptTbs) {
SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR);
rowVo.setCreateTime(dataObject.getCreateTime());
rowVos.add(rowVo);
}
KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos);
}
}
@@ -16,17 +16,23 @@
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
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.dal.mysql.SystemDictMapper;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -101,4 +107,55 @@ public class SystemDictService {
injectQueryParams(args, wrapper);
return systemDictMapper.selectList(wrapper);
}
public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) {
List<SystemDictTb> systemDictTbs = this.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;
// });
List<SystemDictExportRowVo> rowVos = new ArrayList<>();
for (SystemDictTb dataObject : systemDictTbs) {
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("");
rowVos.add(rowVo);
continue;
}
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);
}
}
KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos);
}
}
@@ -22,13 +22,17 @@ import cn.odboy.base.KitPageResult;
import cn.odboy.framework.exception.BadRequestException;
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.dal.mysql.SystemJobMapper;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -133,4 +137,24 @@ public class SystemJobService {
}
wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId);
}
public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) {
List<SystemJobTb> systemJobTbs = this.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);
// });
List<SystemJobExportRowVo> rowVos = new ArrayList<>();
for (SystemJobTb dataObject : systemJobTbs) {
SystemJobExportRowVo rowVo = new SystemJobExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用");
rowVo.setCreateTime(dataObject.getCreateTime());
rowVos.add(rowVo);
}
KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos);
}
}
@@ -15,6 +15,7 @@
*/
package cn.odboy.system.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
@@ -27,15 +28,18 @@ import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.framework.properties.AppProperties;
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
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.dal.mysql.SystemLocalStorageMapper;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.File;
import java.util.Date;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -164,4 +168,12 @@ public class SystemLocalStorageService {
}
return KitSpringBeanHolder.getBean(SystemLocalStorageService.class).uploadFile(null, file);
}
public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) {
List<SystemLocalStorageTb> systemLocalStorageTbs = this.queryLocalStorageByArgs(args);
// KitXlsxExportUtil.exportFile(response, "文件上传记录数据", systemLocalStorageTbs, SystemLocalStorageExportRowVo.class,
// (dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemLocalStorageExportRowVo.class)));
List<SystemLocalStorageExportRowVo> rowVos = BeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class);
KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos);
}
}
@@ -21,10 +21,12 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.odboy.framework.context.KitSpringBeanHolder;
import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.system.constant.SystemYesOrNoChConst;
import cn.odboy.system.constant.TransferProtocolConst;
import cn.odboy.system.dal.dataobject.SystemMenuTb;
import cn.odboy.system.dal.dataobject.SystemRoleMenuTb;
import cn.odboy.system.dal.dataobject.SystemRoleTb;
import cn.odboy.system.dal.model.SystemMenuExportRowVo;
import cn.odboy.system.dal.model.SystemMenuMetaVo;
import cn.odboy.system.dal.model.SystemMenuVo;
import cn.odboy.system.dal.model.SystemQueryMenuArgs;
@@ -33,6 +35,7 @@ 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.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import java.lang.reflect.Field;
@@ -44,6 +47,7 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -464,4 +468,32 @@ public class SystemMenuService {
}
return systemMenuTbs;
}
public void exportMenuXlsx(HttpServletResponse response, SystemQueryMenuArgs args) throws Exception {
List<SystemMenuTb> systemMenuTbs = this.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);
// }));
List<SystemMenuExportRowVo> rowVos = new ArrayList<>();
for (SystemMenuTb dataObject : systemMenuTbs) {
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());
rowVos.add(rowVo);
}
KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos);
}
}
@@ -21,7 +21,6 @@ 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 java.io.IOException;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
@@ -40,9 +39,9 @@ public interface SystemOssStorageService extends IService<SystemOssStorageTb> {
List<SystemOssStorageVo> queryOssStorage(SystemQueryStorageArgs args);
void exportOssStorageExcel(List<SystemOssStorageVo> list, HttpServletResponse response) throws IOException;
String uploadFile(MultipartFile file);
void deleteFileByIds(Long[] ids);
void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args);
}
@@ -25,17 +25,22 @@ import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.framework.redis.KitRedisHelper;
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.dal.mysql.SystemQuartzJobMapper;
import cn.odboy.system.dal.mysql.SystemQuartzLogMapper;
import cn.odboy.system.framework.quartz.QuartzManage;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import jakarta.servlet.http.HttpServletResponse;
import org.quartz.CronExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -274,4 +279,68 @@ public class SystemQuartzJobService {
wrapper.eq(SystemQuartzJobTb::getIsPause, 0);
return systemQuartzJobMapper.selectList(wrapper);
}
public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
List<SystemQuartzJobTb> systemQuartzJobTbs = this.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);
// });
List<SystemQuartzJobExportRowVo> rowVos = new ArrayList<>();
for (SystemQuartzJobTb dataObject : systemQuartzJobTbs) {
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());
rowVos.add(rowVo);
}
KitExcelExporter.exportSimple(response, "定时任务数据", SystemQuartzJobExportRowVo.class, rowVos);
}
public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) {
List<SystemQuartzLogTb> systemQuartzLogTbs = this.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);
// });
List<SystemQuartzLogExportRowVo> rowVos = new ArrayList<>();
for (SystemQuartzLogTb dataObject : systemQuartzLogTbs) {
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());
rowVos.add(rowVo);
}
KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos);
}
}
@@ -28,17 +28,21 @@ import cn.odboy.system.dal.dataobject.SystemUserTb;
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
import cn.odboy.system.dal.model.SystemRoleCodeVo;
import cn.odboy.system.dal.model.SystemRoleExportRowVo;
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.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -271,4 +275,26 @@ public class SystemRoleService {
}
return min;
}
public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) {
List<SystemRoleVo> systemRoleVos = this.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);
// });
List<SystemRoleExportRowVo> rowVos = new ArrayList<>();
for (SystemRoleVo dataObject : systemRoleVos) {
SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo();
rowVo.setName(dataObject.getName());
rowVo.setLevel(dataObject.getLevel());
rowVo.setDescription(dataObject.getDescription());
rowVo.setCreateTime(dataObject.getCreateTime());
rowVos.add(rowVo);
}
KitExcelExporter.exportSimple(response, "部门数据", SystemRoleExportRowVo.class, rowVos);
}
}
@@ -26,6 +26,7 @@ import cn.odboy.framework.exception.BadRequestException;
import cn.odboy.framework.properties.AppProperties;
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
import cn.odboy.system.constant.SystemCaptchaBizEnum;
import cn.odboy.system.constant.SystemZhConst;
import cn.odboy.system.dal.dataobject.SystemDeptTb;
import cn.odboy.system.dal.dataobject.SystemJobTb;
import cn.odboy.system.dal.dataobject.SystemRoleTb;
@@ -34,6 +35,7 @@ import cn.odboy.system.dal.dataobject.SystemUserRoleTb;
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.dal.mysql.SystemDeptMapper;
import cn.odboy.system.dal.mysql.SystemJobMapper;
@@ -47,10 +49,12 @@ import cn.odboy.system.framework.permission.core.KitSecurityHelper;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.KitRsaEncryptUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -59,6 +63,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@@ -348,18 +353,23 @@ public class SystemUserService {
return KitPageUtil.toPage(userVos, userPage.getTotal());
}
/**
* 查询全部不分页
*
* @param args 条件
* @return /
*/
public List<SystemUserVo> queryUserVoByArgs(SystemQueryUserArgs args) {
// 查询用户基本信息
// /**
// * 查询全部不分页
// *
// * @param args 条件
// * @return /
// */
// public List<SystemUserVo> queryUserVoByArgs(SystemQueryUserArgs args) {
// // 查询用户基本信息
// LambdaQueryWrapper<SystemUserTb> wrapper = buildUserQueryWrapper(args);
// List<SystemUserTb> users = systemUserMapper.selectList(wrapper);
// // 转换为SystemUserVo并关联查询
// return users.stream().map(this::convertToUserVo).collect(Collectors.toList());
// }
public long countUserByArgs(SystemQueryUserArgs args) {
LambdaQueryWrapper<SystemUserTb> wrapper = buildUserQueryWrapper(args);
List<SystemUserTb> users = systemUserMapper.selectList(wrapper);
// 转换为SystemUserVo并关联查询
return users.stream().map(this::convertToUserVo).collect(Collectors.toList());
return systemUserMapper.selectCount(wrapper);
}
/**
@@ -544,4 +554,55 @@ public class SystemUserService {
}
return KitPageUtil.emptyData();
}
public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) {
// 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);
// });
// List<SystemUserExportRowVo> rowVos = new ArrayList<>();
// for (SystemUserVo dataObject : systemUserVos) {
// 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());
// rowVos.add(rowVo);
// }
// KitExcelExporter.exportSimple(response, "用户数据", SystemUserExportRowVo.class, rowVos);
long totalCount = this.countUserByArgs(args);
KitExcelExporter.exportByPage(response, "用户数据", SystemUserExportRowVo.class, totalCount, (long pageNum, long pageSize) -> {
KitPageResult<SystemUserVo> pageResult = this.searchUserByArgs(args, new Page<>(pageNum, pageSize));
List<SystemUserExportRowVo> rowVos = new ArrayList<>();
for (SystemUserVo dataObject : pageResult.getContent()) {
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());
rowVos.add(rowVo);
}
return rowVos;
});
}
}
@@ -24,6 +24,7 @@ import cn.odboy.framework.properties.AppProperties;
import cn.odboy.framework.properties.model.StorageOSSModel;
import cn.odboy.framework.server.core.KitFileLocalUploadHelper;
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.dal.mysql.SystemOssStorageMapper;
@@ -32,16 +33,13 @@ import cn.odboy.system.service.SystemOssStorageService;
import cn.odboy.util.KitDateUtil;
import cn.odboy.util.KitFileUtil;
import cn.odboy.util.KitPageUtil;
import cn.odboy.util.xlsx.KitExcelExporter;
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 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;
@@ -106,25 +104,6 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
return searchOssStorage(args, page).getContent();
}
@Override
public void exportOssStorageExcel(List<SystemOssStorageVo> ossStorages, HttpServletResponse response)
throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (SystemOssStorageVo ossStorage : ossStorages) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("服务类型", ossStorage.getServiceType());
map.put("服务地址", ossStorage.getEndpoint());
map.put("存储桶名称", ossStorage.getBucketName());
map.put("文件名称", ossStorage.getFileName());
map.put("文件大小", ossStorage.getFileSizeDesc());
map.put("文件类型", ossStorage.getFileMime());
map.put("创建人", ossStorage.getCreateBy());
map.put("创建日期", ossStorage.getCreateTime());
list.add(map);
}
KitFileUtil.downloadExcel(list, response);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String uploadFile(MultipartFile file) {
@@ -174,6 +153,15 @@ public class SystemMinioStorageServiceImpl extends ServiceImpl<SystemOssStorageM
}
}
@Override
public void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) {
List<SystemOssStorageVo> systemOssStorageVos = this.queryOssStorage(args);
// KitXlsxExportUtil.exportFile(response, "OSS文件上传记录数据", systemOssStorageVos, SystemOssStorageExportRowVo.class,
// (dataObject) -> CollUtil.newArrayList(BeanUtil.copyProperties(dataObject, SystemOssStorageExportRowVo.class)));
List<SystemOssStorageExportRowVo> rowVos = BeanUtil.copyToList(systemOssStorageVos, SystemOssStorageExportRowVo.class);
KitExcelExporter.exportSimple(response, "OSS文件上传记录数据", SystemOssStorageExportRowVo.class, rowVos);
}
private SystemOssStorageTb getOssStorageByMd5(String md5) {
return lambdaQuery().eq(SystemOssStorageTb::getFileMd5, md5).one();
}