From dc9c6c612cde7b938c6851383b9da99abab025a4 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 21 五月 2026 15:02:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New_pro' into dev_New_pro
---
src/main/java/com/ruoyi/framework/web/controller/BaseController.java | 124 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 116 insertions(+), 8 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 9662df6..3edde93 100644
--- a/src/main/java/com/ruoyi/framework/web/controller/BaseController.java
+++ b/src/main/java/com/ruoyi/framework/web/controller/BaseController.java
@@ -11,9 +11,12 @@
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.web.domain.AjaxResult;
+import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.framework.web.domain.R;
import com.ruoyi.framework.web.page.PageDomain;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.page.TableSupport;
@@ -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();
}
/**
@@ -74,13 +91,104 @@
}
/**
+ * 杩斿洖鎴愬姛
+ */
+ public R<?> success()
+ {
+ return R.ok();
+ }
+
+ /**
+ * 杩斿洖鎴愬姛娑堟伅
+ */
+ public R<?> success(String message)
+ {
+ return R.ok(null, message);
+ }
+
+ /**
+ * 杩斿洖鎴愬姛娑堟伅
+ */
+ public R<?> success(Object data)
+ {
+ return R.ok(data);
+ }
+
+ /**
+ * 杩斿洖澶辫触娑堟伅
+ */
+ public R<?> error()
+ {
+ return R.fail();
+ }
+
+ /**
+ * 杩斿洖澶辫触娑堟伅
+ */
+ public R<?> error(String message)
+ {
+ return R.fail(message);
+ }
+
+ /**
+ * 杩斿洖璀﹀憡娑堟伅
+ */
+ public R<?> warn(String message)
+ {
+ return R.fail(HttpStatus.WARN, message);
+ }
+
+ /**
* 鍝嶅簲杩斿洖缁撴灉
- *
+ *
* @param rows 褰卞搷琛屾暟
* @return 鎿嶄綔缁撴灉
*/
- protected AjaxResult toAjax(int rows)
+ protected R<?> toAjax(int rows)
{
- return rows > 0 ? AjaxResult.success() : AjaxResult.error();
+ return rows > 0 ? R.ok() : R.fail();
+ }
+
+ /**
+ * 鍝嶅簲杩斿洖缁撴灉
+ *
+ * @param result 缁撴灉
+ * @return 鎿嶄綔缁撴灉
+ */
+ protected R<?> 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().getDeptIds();
+ }
+
+ /**
+ * 鑾峰彇鐧诲綍鐢ㄦ埛鍚�
+ */
+ public String getUsername()
+ {
+ return getLoginUser().getUsername();
}
}
--
Gitblit v1.9.3