From c7e2f3344d4428583893b7b30348fa2d176ae6bc Mon Sep 17 00:00:00 2001 From: zhc077 <565291854> Date: Mon, 22 May 2023 15:42:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=205.22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/controller/JeecgController.java | 43 +++++++++++-------- .../controller/CmsArticleController.java | 7 +-- .../admin/controller/CmsColumnController.java | 18 ++++---- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java index 2b9728a..3834ef8 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.beanutils.PropertyUtils; import org.apache.shiro.SecurityUtils; +import org.hibernate.procedure.spi.ParameterRegistrationImplementor; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.vo.LoginUser; @@ -37,11 +38,15 @@ import java.util.stream.Collectors; */ @Slf4j public class JeecgController> { + + public static final Boolean HAS_QUERY = Boolean.TRUE.booleanValue(); + @Autowired S service; @Value("${jeecg.path.upload}") private String upLoadPath; + /** * 导出excel * @@ -53,10 +58,9 @@ public class JeecgController> { LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - String getRealname="佚名"; - if(sysUser!=null) - { - getRealname=sysUser.getRealname(); + String getRealname = "佚名"; + if (sysUser != null) { + getRealname = sysUser.getRealname(); } // Step.2 获取导出数据 @@ -76,34 +80,35 @@ public class JeecgController> { mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下 mv.addObject(NormalExcelConstants.CLASS, clazz); //update-begin--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置-------------------- - ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + getRealname, title); + ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + getRealname, title); exportParams.setImageBasePath(upLoadPath); //update-end--Author:liusq Date:20210126 for:图片导出报错,ImageBasePath未设置---------------------- - mv.addObject(NormalExcelConstants.PARAMS,exportParams); + mv.addObject(NormalExcelConstants.PARAMS, exportParams); mv.addObject(NormalExcelConstants.DATA_LIST, exportList); return mv; } + /** * 根据每页sheet数量导出多sheet * * @param request - * @param object 实体类 - * @param clazz 实体类class - * @param title 标题 + * @param object 实体类 + * @param clazz 实体类class + * @param title 标题 * @param exportFields 导出字段自定义 - * @param pageNum 每个sheet的数据条数 + * @param pageNum 每个sheet的数据条数 * @param request */ - protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class clazz, String title,String exportFields,Integer pageNum) { + protected ModelAndView exportXlsSheet(HttpServletRequest request, T object, Class clazz, String title, String exportFields, Integer pageNum) { // Step.1 组装查询条件 QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(object, request.getParameterMap()); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); // Step.2 计算分页sheet数据 double total = service.count(); - int count = (int)Math.ceil(total/pageNum); + int count = (int) Math.ceil(total / pageNum); // Step.3 多sheet处理 List> listMap = new ArrayList>(); - for (int i = 1; i <=count ; i++) { + for (int i = 1; i <= count; i++) { Page page = new Page(i, pageNum); IPage pageList = service.page(page, queryWrapper); List records = pageList.getRecords(); @@ -117,11 +122,11 @@ public class JeecgController> { exportList = records; } Map map = new HashMap(); - ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title+i,upLoadPath); + ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title + i, upLoadPath); exportParams.setType(ExcelType.XSSF); //map.put("title",exportParams);//表格Title - map.put(NormalExcelConstants.PARAMS,exportParams);//表格Title - map.put(NormalExcelConstants.CLASS,clazz);//表格对应实体 + map.put(NormalExcelConstants.PARAMS, exportParams);//表格Title + map.put(NormalExcelConstants.CLASS, clazz);//表格对应实体 map.put(NormalExcelConstants.DATA_LIST, exportList);//数据集合 listMap.add(map); } @@ -138,9 +143,9 @@ public class JeecgController> { * * @param request */ - protected ModelAndView exportXls(HttpServletRequest request, T object, Class clazz, String title,String exportFields) { - ModelAndView mv = this.exportXls(request,object,clazz,title); - mv.addObject(NormalExcelConstants.EXPORT_FIELDS,exportFields); + protected ModelAndView exportXls(HttpServletRequest request, T object, Class clazz, String title, String exportFields) { + ModelAndView mv = this.exportXls(request, object, clazz, title); + mv.addObject(NormalExcelConstants.EXPORT_FIELDS, exportFields); return mv; } diff --git a/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsArticleController.java b/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsArticleController.java index 9ecc960..eb06a43 100644 --- a/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsArticleController.java +++ b/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsArticleController.java @@ -55,7 +55,7 @@ public class CmsArticleController extends JeecgController queryPageList(CmsArticle cmsArticle, @@ -74,7 +74,6 @@ public class CmsArticleController extends JeecgController add(@RequestBody CmsArticle cmsArticle) { @@ -106,7 +105,6 @@ public class CmsArticleController extends JeecgController edit(@RequestBody CmsArticle cmsArticle) { @@ -125,7 +123,6 @@ public class CmsArticleController extends JeecgController delete(@RequestParam(name = "id", required = true) String id) { @@ -139,7 +136,6 @@ public class CmsArticleController extends JeecgController deleteBatch(@RequestParam(name = "ids", required = true) String ids) { @@ -153,7 +149,6 @@ public class CmsArticleController extends JeecgController queryById(@RequestParam(name = "id", required = true) String id) { diff --git a/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsColumnController.java b/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsColumnController.java index c871553..9336aba 100644 --- a/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsColumnController.java +++ b/jeecg-boot/jeecg-boot-module-cms/src/main/java/org/jeecg/modules/cms/admin/controller/CmsColumnController.java @@ -46,6 +46,8 @@ public class CmsColumnController extends JeecgController getColumnTree(HttpServletRequest req) { @@ -76,7 +78,6 @@ public class CmsColumnController extends JeecgController queryPageList(CmsColumn cmsColumn, @@ -84,7 +85,7 @@ public class CmsColumnController extends JeecgController queryWrapper = QueryGenerator.initQueryWrapper(cmsColumn, req.getParameterMap()); List list = cmsColumnService.queryTreeListNoPage(queryWrapper); IPage pageList = new Page<>(1, 10, list.size()); @@ -105,7 +106,6 @@ public class CmsColumnController extends JeecgController page = new Page(pageNo, pageSize); IPage pageList = cmsColumnService.page(page, queryWrapper); List records = pageList.getRecords(); -// records.sort(Comparator.comparing(CmsColumn::getSort)); Collections.sort(records, Comparator.comparingInt(CmsColumn::getSort)); return Result.OK(pageList); @@ -119,7 +119,6 @@ public class CmsColumnController extends JeecgController queryPageList(CmsColumn cmsColumn, HttpServletRequest req) { @@ -138,7 +137,6 @@ public class CmsColumnController extends JeecgController add(@RequestBody CmsColumn cmsColumn) { @@ -178,7 +175,6 @@ public class CmsColumnController extends JeecgController edit(@RequestBody CmsColumn cmsColumn) { @@ -196,9 +192,13 @@ public class CmsColumnController extends JeecgController delete(@RequestParam(name = "id", required = true) String id) { CmsColumn cmsColumn = cmsColumnService.getById(id); - if (StringUtils.equals("99", cmsColumn.getId())) throw new JeecgBootException("文章总栏目不可删除"); + if (StringUtils.equals(ADMIN_COLUMN_KEY, cmsColumn.getId())) { + throw new JeecgBootException("文章总栏目不可删除"); + } int count = cmsColumnService.count(new LambdaQueryWrapper().eq(CmsColumn::getPid, cmsColumn.getId())); - if (count > 0) throw new JeecgBootException("存在子栏目暂不可删除"); + if (count > 0) { + throw new JeecgBootException("存在子栏目暂不可删除"); + } cmsColumnService.deleteCmsColumn(id); return Result.OK("删除成功!"); }