From 5c70cf9b9d6d227d71f3c11e4d1708db548144cf Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期一, 26 九月 2022 08:07:12 +0800
Subject: [PATCH] 若依 3.8.4
---
src/main/java/com/ruoyi/framework/web/controller/BaseController.java | 79 ++++++++++++++++++++++++++++++++-------
1 files changed, 64 insertions(+), 15 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 40724ba..5b8fabc 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;
@@ -49,14 +52,28 @@
*/
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);
}
+ }
+
+ /**
+ * 娓呯悊鍒嗛〉鐨勭嚎绋嬪彉閲�
+ */
+ protected void clearPage()
+ {
+ PageUtils.clearPage();
}
/**
@@ -71,17 +88,6 @@
rspData.setRows(list);
rspData.setTotal(new PageInfo(list).getTotal());
return rspData;
- }
-
- /**
- * 鍝嶅簲杩斿洖缁撴灉
- *
- * @param result 缁撴灉
- * @return 鎿嶄綔缁撴灉
- */
- protected AjaxResult toAjax(boolean result)
- {
- return result ? success() : error();
}
/**
@@ -126,4 +132,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