From 93d8526049eedb40ff7750f97be7d9c917a863c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=B6=E4=B8=9C?= <1654135867@qq.com> Date: Fri, 17 Nov 2023 11:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/SysUserController.java | 35 ++++++++++++++++++- .../src/views/system/user/index.vue | 10 ++++-- .../src/views/system/user/user.api.js | 3 ++ .../src/views/system/user/user.api.ts | 3 ++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java index 9d5b4d2f..6aec1c80 100644 --- a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java +++ b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysUserController.java @@ -20,6 +20,7 @@ import org.jeecg.common.aspect.annotation.PermissionData; import org.jeecg.common.config.TenantContext; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.constant.SymbolConstant; +import org.jeecg.config.JeecgBaseConfig; import org.jeecg.config.mybatis.MybatisPlusSaasConfig; import org.jeecg.modules.base.service.BaseCommonService; import org.jeecg.common.system.query.QueryGenerator; @@ -46,6 +47,7 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -100,6 +102,8 @@ public class SysUserController { @Autowired private ISysUserTenantService userTenantService; + @Resource + private JeecgBaseConfig jeecgBaseConfig; /** * 获取租户下用户数据(支持租户隔离) @@ -514,7 +518,15 @@ public class SysUserController { String passwordEncode = PasswordUtil.encrypt(sysUserExcel.getUsername(), sysUserExcel.getPassword(), salt); sysUserExcel.setPassword(passwordEncode); try { - sysUserService.save(sysUserExcel); + if (sysUserExcel.getUsername()=="" || sysUserExcel.getUsername().isEmpty() || sysUserExcel.getUsername()==null) { + }else { + if (sysUserExcel.getJuese().equals("学生")) { + sysUserExcel.setDelFlag(0); + sysUserService.save(sysUserExcel); + } else { + errorMessage.add("第 " + i + 1 + " 行:目前仅允许导入学生身份的用户,其他身份请手动导入"); + } + } successLines++; } catch (Exception e) { errorLines++; @@ -1742,4 +1754,25 @@ public class SysUserController { sysUserService.editTenantUser(sysUser,tenantId,departs,roles); return Result.ok("修改成功"); } + + + @RequestMapping(value = "/exportXlsMb") + public ModelAndView exportXlsMb(HttpServletRequest request, SysUser awardPersion) { + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + // Step.2 获取导出数据 + List exportList = new ArrayList<>(); + + // Step.3 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + //此处设置的filename无效 ,前端会重更新设置一下 + mv.addObject(NormalExcelConstants.FILE_NAME, "学生导入模板"); + mv.addObject(NormalExcelConstants.CLASS, SysUser.class); + //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- + ExportParams exportParams=new ExportParams("学生导入模板", "用户名和学号均为学号" , "学生导入模板"); + exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload()); + //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- + mv.addObject(NormalExcelConstants.PARAMS,exportParams); + mv.addObject(NormalExcelConstants.DATA_LIST, exportList); + return mv; + } } diff --git a/jeecgboot-vue3-master/src/views/system/user/index.vue b/jeecgboot-vue3-master/src/views/system/user/index.vue index f0fa5f67..cc50f2da 100644 --- a/jeecgboot-vue3-master/src/views/system/user/index.vue +++ b/jeecgboot-vue3-master/src/views/system/user/index.vue @@ -8,6 +8,7 @@ 新增专家 导出 导入 + 导出模板 同步流程 回收站 @@ -73,7 +74,7 @@ import { useModal } from '/@/components/Modal'; import { useMessage } from '/@/hooks/web/useMessage'; import { columns, searchFormSchema } from './user.data'; - import { listNoCareTenant, deleteUser, batchDeleteUser, getImportUrl, getExportUrl, frozenBatch, syncUser,queryByUserId } from './user.api'; + import { listNoCareTenant, deleteUser, batchDeleteUser, getImportUrl, getExportUrl, frozenBatch, syncUser,queryByUserId,getExportUrlMb } from './user.api'; import {usePermission} from "/@/hooks/web/usePermission"; import {defHttp} from "../../../utils/http/axios"; @@ -94,7 +95,7 @@ const [registerQuitModal, { openModal: openQuitModal }] = useModal(); // 列表页面公共参数、方法 - const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ + const { prefixCls, tableContext, onExportXls, onImportXls,onExportXlsMb } = useListPage({ designScope: 'user-list', tableProps: { title: '用户列表', @@ -116,6 +117,11 @@ name: '用户列表', url: getExportUrl, }, + exportConfigMb: { + name: "导出模板", + url: getExportUrlMb, + params: null, + }, importConfig: { url: getImportUrl, }, diff --git a/jeecgboot-vue3-master/src/views/system/user/user.api.js b/jeecgboot-vue3-master/src/views/system/user/user.api.js index 8e3ee4f1..42a0236d 100644 --- a/jeecgboot-vue3-master/src/views/system/user/user.api.js +++ b/jeecgboot-vue3-master/src/views/system/user/user.api.js @@ -17,6 +17,7 @@ var Api; Api["deleteBatch"] = "/sys/user/deleteBatch"; Api["importExcel"] = "/sys/user/importExcel"; Api["exportXls"] = "/sys/user/exportXls"; + Api["exportXlsMb"] = "/sys/user/exportXlsMb"; Api["recycleBinList"] = "/sys/user/recycleBin"; Api["putRecycleBin"] = "/sys/user/putRecycleBin"; Api["deleteRecycleBin"] = "/sys/user/deleteRecycleBin"; @@ -45,6 +46,8 @@ export const getExportUrl = Api.exportXls; * 导入api */ export const getImportUrl = Api.importExcel; + +export const getExportUrlMb = Api.exportXlsMb; /** * 根据userid判断是否为专家 * @param params diff --git a/jeecgboot-vue3-master/src/views/system/user/user.api.ts b/jeecgboot-vue3-master/src/views/system/user/user.api.ts index 168942d2..48f56ab5 100644 --- a/jeecgboot-vue3-master/src/views/system/user/user.api.ts +++ b/jeecgboot-vue3-master/src/views/system/user/user.api.ts @@ -34,6 +34,7 @@ enum Api { putCancelQuit = '/sys/user/putCancelQuit', updateUserTenantStatus='/sys/tenant/updateUserTenantStatus', getUserTenantPageList='/sys/tenant/getUserTenantPageList', + exportXlsMb = '/sys/user/exportXlsMb', queryByUserId = '/expert/expert/queryByUserId', } /** @@ -48,6 +49,8 @@ export const queryByUserId = (params) => { * @param params */ export const getExportUrl = Api.exportXls; + +export const getExportUrlMb = Api.exportXlsMb; /** * 导入api */