From d76ba21b7edf0d400fbe22acf11435ecdea42c48 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期五, 14 一月 2022 11:27:11 +0800 Subject: [PATCH] 定时任务屏蔽违规的字符 --- src/main/java/com/ruoyi/framework/web/controller/BaseController.java | 94 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/ruoyi/framework/web/controller/BaseController.java b/src/main/java/com/ruoyi/framework/web/controller/BaseController.java index cb9b7d0..2294052 100644 --- a/src/main/java/com/ruoyi/framework/web/controller/BaseController.java +++ b/src/main/java/com/ruoyi/framework/web/controller/BaseController.java @@ -11,8 +11,11 @@ import com.github.pagehelper.PageInfo; import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.PageUtils; +import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.sql.SqlUtil; +import com.ruoyi.framework.security.LoginUser; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.page.PageDomain; import com.ruoyi.framework.web.page.TableDataInfo; @@ -25,7 +28,7 @@ */ public class BaseController { - protected final Logger logger = LoggerFactory.getLogger(BaseController.class); + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); /** * 灏嗗墠鍙颁紶閫掕繃鏉ョ殑鏃ユ湡鏍煎紡鐨勫瓧绗︿覆锛岃嚜鍔ㄨ浆鍖栦负Date绫诲瀷 @@ -49,13 +52,19 @@ */ protected void startPage() { + PageUtils.startPage(); + } + + /** + * 璁剧疆璇锋眰鎺掑簭鏁版嵁 + */ + protected void startOrderBy() + { PageDomain pageDomain = TableSupport.buildPageRequest(); - Integer pageNum = pageDomain.getPageNum(); - Integer pageSize = pageDomain.getPageSize(); - if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) + if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) { String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); - PageHelper.startPage(pageNum, pageSize, orderBy); + PageHelper.orderBy(orderBy); } } @@ -74,6 +83,38 @@ } /** + * 杩斿洖鎴愬姛 + */ + public AjaxResult success() + { + return AjaxResult.success(); + } + + /** + * 杩斿洖澶辫触娑堟伅 + */ + public AjaxResult error() + { + return AjaxResult.error(); + } + + /** + * 杩斿洖鎴愬姛娑堟伅 + */ + public AjaxResult success(String message) + { + return AjaxResult.success(message); + } + + /** + * 杩斿洖澶辫触娑堟伅 + */ + public AjaxResult error(String message) + { + return AjaxResult.error(message); + } + + /** * 鍝嶅簲杩斿洖缁撴灉 * * @param rows 褰卞搷琛屾暟 @@ -83,4 +124,47 @@ { return rows > 0 ? AjaxResult.success() : AjaxResult.error(); } + + /** + * 鍝嶅簲杩斿洖缁撴灉 + * + * @param result 缁撴灉 + * @return 鎿嶄綔缁撴灉 + */ + protected AjaxResult toAjax(boolean result) + { + return result ? success() : error(); + } + + /** + * 鑾峰彇鐢ㄦ埛缂撳瓨淇℃伅 + */ + public LoginUser getLoginUser() + { + return SecurityUtils.getLoginUser(); + } + + /** + * 鑾峰彇鐧诲綍鐢ㄦ埛id + */ + public Long getUserId() + { + return getLoginUser().getUserId(); + } + + /** + * 鑾峰彇鐧诲綍閮ㄩ棬id + */ + public Long getDeptId() + { + return getLoginUser().getDeptId(); + } + + /** + * 鑾峰彇鐧诲綍鐢ㄦ埛鍚� + */ + public String getUsername() + { + return getLoginUser().getUsername(); + } } -- Gitblit v1.9.3