From a680a84d91fb6501951d0265e9b347695568c546 Mon Sep 17 00:00:00 2001
From: 抓蛙师 <770492966@qq.com>
Date: 星期二, 20 九月 2022 16:41:40 +0800
Subject: [PATCH] !236 前端适配多字段排序功能案例OSS页面(重新排序需点击重置按钮,否则按照点击顺序依次排序,重复点击的字段排序位置不发生改变) * 完善前端适配多字段排序功能案例OSS页面(完善排序图标显示效果和重置效果,支持正序,倒序,取消排序) * 前端适配多字段排序功能案例OSS页面(重新排序需点击重置按钮,否则按照点击顺序依次排序,重复点击的字段排序位置不发生改变)
---
ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java | 253 +++++++++++++------------------------------------
1 files changed, 69 insertions(+), 184 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
index 3c26de5..1e0a5d5 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
@@ -1,184 +1,69 @@
-package com.ruoyi.common.core.controller;
-
-import java.beans.PropertyEditorSupport;
-import java.util.Date;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.InitBinder;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import com.ruoyi.common.constant.HttpStatus;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.core.page.PageDomain;
-import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.common.core.page.TableSupport;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.sql.SqlUtil;
-
-/**
- * web灞傞�氱敤鏁版嵁澶勭悊
- *
- * @author ruoyi
- */
-public class BaseController
-{
- protected final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- /**
- * 灏嗗墠鍙颁紶閫掕繃鏉ョ殑鏃ユ湡鏍煎紡鐨勫瓧绗︿覆锛岃嚜鍔ㄨ浆鍖栦负Date绫诲瀷
- */
- @InitBinder
- public void initBinder(WebDataBinder binder)
- {
- // Date 绫诲瀷杞崲
- binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
- {
- @Override
- public void setAsText(String text)
- {
- setValue(DateUtils.parseDate(text));
- }
- });
- }
-
- /**
- * 璁剧疆璇锋眰鍒嗛〉鏁版嵁
- */
- protected void startPage()
- {
- PageDomain pageDomain = TableSupport.buildPageRequest();
- Integer pageNum = pageDomain.getPageNum();
- Integer pageSize = pageDomain.getPageSize();
- if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
- {
- String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
- PageHelper.startPage(pageNum, pageSize, orderBy);
- }
- }
-
- /**
- * 璁剧疆璇锋眰鎺掑簭鏁版嵁
- */
- protected void startOrderBy()
- {
- PageDomain pageDomain = TableSupport.buildPageRequest();
- if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
- {
- String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
- PageHelper.orderBy(orderBy);
- }
- }
-
- /**
- * 鍝嶅簲璇锋眰鍒嗛〉鏁版嵁
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- protected TableDataInfo getDataTable(List<?> list)
- {
- TableDataInfo rspData = new TableDataInfo();
- rspData.setCode(HttpStatus.SUCCESS);
- rspData.setMsg("鏌ヨ鎴愬姛");
- rspData.setRows(list);
- rspData.setTotal(new PageInfo(list).getTotal());
- return rspData;
- }
-
- /**
- * 杩斿洖鎴愬姛
- */
- 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 褰卞搷琛屾暟
- * @return 鎿嶄綔缁撴灉
- */
- protected AjaxResult toAjax(int rows)
- {
- return rows > 0 ? AjaxResult.success() : AjaxResult.error();
- }
-
- /**
- * 鍝嶅簲杩斿洖缁撴灉
- *
- * @param result 缁撴灉
- * @return 鎿嶄綔缁撴灉
- */
- protected AjaxResult toAjax(boolean result)
- {
- return result ? success() : error();
- }
-
- /**
- * 椤甸潰璺宠浆
- */
- public String redirect(String url)
- {
- return StringUtils.format("redirect:{}", url);
- }
-
- /**
- * 鑾峰彇鐢ㄦ埛缂撳瓨淇℃伅
- */
- 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();
- }
-}
+package com.ruoyi.common.core.controller;
+
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.helper.LoginHelper;
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * web灞傞�氱敤鏁版嵁澶勭悊
+ *
+ * @author Lion Li
+ */
+public class BaseController {
+
+ /**
+ * 鍝嶅簲杩斿洖缁撴灉
+ *
+ * @param rows 褰卞搷琛屾暟
+ * @return 鎿嶄綔缁撴灉
+ */
+ protected R<Void> toAjax(int rows) {
+ return rows > 0 ? R.ok() : R.fail();
+ }
+
+ /**
+ * 鍝嶅簲杩斿洖缁撴灉
+ *
+ * @param result 缁撴灉
+ * @return 鎿嶄綔缁撴灉
+ */
+ protected R<Void> toAjax(boolean result) {
+ return result ? R.ok() : R.fail();
+ }
+
+ /**
+ * 椤甸潰璺宠浆
+ */
+ public String redirect(String url) {
+ return StringUtils.format("redirect:{}", url);
+ }
+
+ /**
+ * 鑾峰彇鐢ㄦ埛缂撳瓨淇℃伅
+ */
+ public LoginUser getLoginUser() {
+ return LoginHelper.getLoginUser();
+ }
+
+ /**
+ * 鑾峰彇鐧诲綍鐢ㄦ埛id
+ */
+ public Long getUserId() {
+ return LoginHelper.getUserId();
+ }
+
+ /**
+ * 鑾峰彇鐧诲綍閮ㄩ棬id
+ */
+ public Long getDeptId() {
+ return LoginHelper.getDeptId();
+ }
+
+ /**
+ * 鑾峰彇鐧诲綍鐢ㄦ埛鍚�
+ */
+ public String getUsername() {
+ return LoginHelper.getUsername();
+ }
+}
--
Gitblit v1.9.3