Browse Source

搜索接口

zyf12 2 years ago
parent
commit
6e56ce0c09

+ 40 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PostNoticeController.java

@@ -3,9 +3,11 @@ package com.ruoyi.web.controller.system;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+import java.util.Date;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -51,6 +53,44 @@ public class PostNoticeController extends BaseController
         List<PostNotice> list = postNoticeService.selectPostNoticeList(postNotice);
         return getDataTable(list);
     }
+    /*@ApiOperation("搜索公告")
+    @PreAuthorize("@ss.hasPermi('system:notice:queryNotice')")
+    @GetMapping("/queryNotice")
+    public AjaxResult queryByTitleOrTime(String noticeTitle, Date noticeTimeLeft,Date noticeTimeRight){
+        if(noticeTitle!=null){
+            if(noticeTimeLeft!=null&&noticeTimeRight!=null) {
+                List<PostNotice> list = postNoticeService.selectPostNoticeListByTitleOrNoticeTime(noticeTitle, noticeTimeLeft,noticeTimeRight);
+                return success(list);
+            }
+            return error("请输入完整时间范围");
+        }
+        return error("未找到相应数据");
+    }*/
+
+    @ApiOperation("搜索公告列表")
+    @PreAuthorize("@ss.hasPermi('system:notice:queryNotice')")
+    @GetMapping("/queryNotice")
+    public TableDataInfo list(PostNotice postNotice, String title, Date noticeTimeLeft, Date noticeTimeRight)
+    {
+        startPage();
+        List<PostNotice> list=null;
+        if(title!=null){
+            //标题不为空则判断时间
+            if(noticeTimeLeft!=null&&noticeTimeRight!=null&&noticeTimeLeft.before(noticeTimeRight)) {
+                //时间不为空
+                list = postNoticeService.selectPostNoticeListByTitleOrNoticeTime(title, noticeTimeLeft,noticeTimeRight);
+            }
+        }else{
+            //标题为空
+            if(noticeTimeLeft!=null&&noticeTimeRight!=null&&noticeTimeLeft.before(noticeTimeRight)) {
+                //时间不为空
+                //list = postNoticeService.selectPostNoticeListOnlyByTitleOrNoticeTime(noticeTimeLeft,noticeTimeRight);
+            }else {
+                list = postNoticeService.selectPostNoticeList(postNotice);
+            }
+        }
+        return getDataTable(list);
+    }
 
     /**
      * 导出公告列表