diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java index 14f57fda..5bd40bae 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java @@ -1,11 +1,13 @@ package com.ruoyi.web.controller.monitor; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; @@ -40,12 +42,12 @@ public class SysLogininforController extends BaseController @Log(title = "登录日志", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") - @GetMapping("/export") - public AjaxResult export(SysLogininfor logininfor) + @PostMapping("/export") + public void export(HttpServletResponse response, SysLogininfor logininfor) { List list = logininforService.selectLogininforList(logininfor); ExcelUtil util = new ExcelUtil(SysLogininfor.class); - return util.exportExcel(list, "登录日志"); + util.exportExcel(response, list, "登录日志"); } @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java index 75bf1268..4ce126a5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java @@ -1,11 +1,13 @@ package com.ruoyi.web.controller.monitor; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; @@ -40,12 +42,12 @@ public class SysOperlogController extends BaseController @Log(title = "操作日志", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('monitor:operlog:export')") - @GetMapping("/export") - public AjaxResult export(SysOperLog operLog) + @PostMapping("/export") + public void export(HttpServletResponse response, SysOperLog operLog) { List list = operLogService.selectOperLogList(operLog); ExcelUtil util = new ExcelUtil(SysOperLog.class); - return util.exportExcel(list, "操作日志"); + util.exportExcel(response, list, "操作日志"); } @Log(title = "操作日志", businessType = BusinessType.DELETE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java index dc2532fb..04f71629 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java @@ -1,6 +1,7 @@ package com.ruoyi.web.controller.system; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -13,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; -import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -49,12 +49,12 @@ public class SysConfigController extends BaseController @Log(title = "参数管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:config:export')") - @GetMapping("/export") - public AjaxResult export(SysConfig config) + @PostMapping("/export") + public void export(HttpServletResponse response, SysConfig config) { List list = configService.selectConfigList(config); ExcelUtil util = new ExcelUtil(SysConfig.class); - return util.exportExcel(list, "参数数据"); + util.exportExcel(response, list, "参数数据"); } /** @@ -82,7 +82,6 @@ public class SysConfigController extends BaseController @PreAuthorize("@ss.hasPermi('system:config:add')") @Log(title = "参数管理", businessType = BusinessType.INSERT) @PostMapping - @RepeatSubmit public AjaxResult add(@Validated @RequestBody SysConfig config) { if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index b9e3dc3b..eea89fd0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -2,6 +2,7 @@ package com.ruoyi.web.controller.system; import java.util.ArrayList; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -50,12 +51,12 @@ public class SysDictDataController extends BaseController @Log(title = "字典数据", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:dict:export')") - @GetMapping("/export") - public AjaxResult export(SysDictData dictData) + @PostMapping("/export") + public void export(HttpServletResponse response, SysDictData dictData) { List list = dictDataService.selectDictDataList(dictData); ExcelUtil util = new ExcelUtil(SysDictData.class); - return util.exportExcel(list, "字典数据"); + util.exportExcel(response, list, "字典数据"); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java index acad00e2..0dd3474c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java @@ -1,6 +1,7 @@ package com.ruoyi.web.controller.system; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -45,12 +46,12 @@ public class SysDictTypeController extends BaseController @Log(title = "字典类型", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:dict:export')") - @GetMapping("/export") - public AjaxResult export(SysDictType dictType) + @PostMapping("/export") + public void export(HttpServletResponse response, SysDictType dictType) { List list = dictTypeService.selectDictTypeList(dictType); ExcelUtil util = new ExcelUtil(SysDictType.class); - return util.exportExcel(list, "字典类型"); + util.exportExcel(response, list, "字典类型"); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java index 30a87616..1a2b408e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -1,6 +1,7 @@ package com.ruoyi.web.controller.system; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -48,12 +49,12 @@ public class SysPostController extends BaseController @Log(title = "岗位管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:post:export')") - @GetMapping("/export") - public AjaxResult export(SysPost post) + @PostMapping("/export") + public void export(HttpServletResponse response, SysPost post) { List list = postService.selectPostList(post); ExcelUtil util = new ExcelUtil(SysPost.class); - return util.exportExcel(list, "岗位数据"); + util.exportExcel(response, list, "岗位数据"); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java index d7374908..d70fa815 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java @@ -1,6 +1,7 @@ package com.ruoyi.web.controller.system; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -61,12 +62,12 @@ public class SysRoleController extends BaseController @Log(title = "角色管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:role:export')") - @GetMapping("/export") - public AjaxResult export(SysRole role) + @PostMapping("/export") + public void export(HttpServletResponse response, SysRole role) { List list = roleService.selectRoleList(role); ExcelUtil util = new ExcelUtil(SysRole.class); - return util.exportExcel(list, "角色数据"); + util.exportExcel(response, list, "角色数据"); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 6cfbfb8d..9aacc3be 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -2,6 +2,7 @@ package com.ruoyi.web.controller.system; import java.util.List; import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -62,12 +63,12 @@ public class SysUserController extends BaseController @Log(title = "用户管理", businessType = BusinessType.EXPORT) @PreAuthorize("@ss.hasPermi('system:user:export')") - @GetMapping("/export") - public AjaxResult export(SysUser user) + @PostMapping("/export") + public void export(HttpServletResponse response, SysUser user) { List list = userService.selectUserList(user); ExcelUtil util = new ExcelUtil(SysUser.class); - return util.exportExcel(list, "用户数据"); + util.exportExcel(response, list, "用户数据"); } @Log(title = "用户管理", businessType = BusinessType.IMPORT) @@ -82,11 +83,11 @@ public class SysUserController extends BaseController return AjaxResult.success(message); } - @GetMapping("/importTemplate") - public AjaxResult importTemplate() + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) { ExcelUtil util = new ExcelUtil(SysUser.class); - return util.importTemplateExcel("用户数据"); + util.importTemplateExcel(response, "用户数据"); } /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 4169360a..93a19e87 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -431,7 +431,7 @@ public class ExcelUtil * @return 结果 * @throws IOException */ - public void exportExcel(HttpServletResponse response, List list, String sheetName)throws IOException + public void exportExcel(HttpServletResponse response, List list, String sheetName) { exportExcel(response, list, sheetName, StringUtils.EMPTY); } @@ -446,12 +446,12 @@ public class ExcelUtil * @return 结果 * @throws IOException */ - public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) throws IOException + public void exportExcel(HttpServletResponse response, List list, String sheetName, String title) { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); this.init(list, sheetName, title, Type.EXPORT); - exportExcel(response.getOutputStream()); + exportExcel(response); } /** @@ -484,7 +484,7 @@ public class ExcelUtil * @param sheetName 工作表的名称 * @return 结果 */ - public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException + public void importTemplateExcel(HttpServletResponse response, String sheetName) { importTemplateExcel(response, sheetName, StringUtils.EMPTY); } @@ -496,12 +496,12 @@ public class ExcelUtil * @param title 标题 * @return 结果 */ - public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) throws IOException + public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setCharacterEncoding("utf-8"); this.init(null, sheetName, title, Type.IMPORT); - exportExcel(response.getOutputStream()); + exportExcel(response); } /** @@ -509,12 +509,12 @@ public class ExcelUtil * * @return 结果 */ - public void exportExcel(OutputStream out) + public void exportExcel(HttpServletResponse response) { try { writeSheet(); - wb.write(out); + wb.write(response.getOutputStream()); } catch (Exception e) { @@ -523,7 +523,6 @@ public class ExcelUtil finally { IOUtils.closeQuietly(wb); - IOUtils.closeQuietly(out); } } diff --git a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm index 56ff5e66..ab19cf51 100644 --- a/ruoyi-generator/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -1,6 +1,7 @@ package ${packageName}.controller; import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -61,12 +62,12 @@ public class ${ClassName}Controller extends BaseController */ @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") @Log(title = "${functionName}", businessType = BusinessType.EXPORT) - @GetMapping("/export") - public AjaxResult export(${ClassName} ${className}) + @PostMapping("/export") + public void export(HttpServletResponse response, ${ClassName} ${className}) { List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); - return util.exportExcel(list, "${functionName}数据"); + util.exportExcel(response, list, "${functionName}数据"); } /** diff --git a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index 867225ab..729a9daf 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -108,7 +108,6 @@ plain icon="el-icon-download" size="mini" - :loading="exportLoading" @click="handleExport" v-hasPermi="['${moduleName}:${businessName}:export']" >导出 @@ -313,7 +312,7 @@