Browse Source

搜索公告完善

sjx 2 years ago
parent
commit
a3522e90db

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

@@ -38,9 +38,6 @@ public class PostNoticeController extends BaseController
     @Autowired
     private IPostNoticeService postNoticeService;
 
-    @Autowired
-    private HttpServletRequest request;
-
     /**
      * 查询公告列表
      */

+ 0 - 2
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PostNoticeMapper.java

@@ -71,8 +71,6 @@ public interface PostNoticeMapper
 
     public List<PostNotice> selectPostNoticeListByTitleOrNoticeTime(@Param("noticeTitle")String noticeTitle, @Param("noticeTimeLeft")Date noticeTimeLeft, @Param("noticeTimeRight")Date noticeTimeRight);
 
-    public List<PostNotice> selectPostNoticeListOnlyByTitleOrNoticeTime( @Param("noticeTimeLeft")Date noticeTimeLeft, @Param("noticeTimeRight")Date noticeTimeRight);
 
-    List<PostNotice> selectPostNoticeListByTitle(@Param("noticeTitle")String title);
 
 }

+ 11 - 5
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostNoticeServiceImpl.java

@@ -86,16 +86,22 @@ public class PostNoticeServiceImpl implements IPostNoticeService
                 }
             }else {
                 //时间为空
-                return postNoticeMapper.selectPostNoticeListByTitle(title);
+                return postNoticeMapper.selectPostNoticeListByTitleOrNoticeTime(title, noticeTimeLeft, noticeTimeRight);
+
             }
         } else {
             //标题为空
-            if (noticeTimeLeft != null && noticeTimeRight != null && noticeTimeLeft.before(noticeTimeRight)) {
-                //时间不为空
-                return postNoticeMapper.selectPostNoticeListOnlyByTitleOrNoticeTime(noticeTimeLeft, noticeTimeRight);
+            if (noticeTimeLeft != null && noticeTimeRight != null) {
+                //时间不为空 ,且左时间在右时间之前
+                if( noticeTimeLeft.before(noticeTimeRight)) {
+                    return postNoticeMapper.selectPostNoticeListByTitleOrNoticeTime(title, noticeTimeLeft, noticeTimeRight);
+                }else {
+                    return null;
+                }
             }
         }
-        return null;
+        PostNotice postNotice = new PostNotice();
+        return postNoticeMapper.selectPostNoticeList(postNotice);
     }
 
 

+ 0 - 14
ruoyi-system/src/main/resources/mapper/system/PostNoticeMapper.xml

@@ -35,20 +35,6 @@
         </where>
     </select>
 
-    <select id="selectPostNoticeListOnlyByTitleOrNoticeTime" resultType="PostNotice" resultMap="PostNoticeResult">
-        <include refid="selectPostNoticeVo"/>
-        <where>
-            <if test="noticeTimeLeft != null and noticeTimeRight != null "> and notice_time between #{noticeTimeLeft} AND #{noticeTimeRight}</if>
-        </where>
-    </select>
-
-    <select id="selectPostNoticeListByTitle" resultType="PostNotice" resultMap="PostNoticeResult">
-        <include refid="selectPostNoticeVo"/>
-        <where>
-            <if test="noticeTitle != null  and noticeTitle != ''"> and notice_title LIKE '%${noticeTitle}%' </if>
-        </where>
-    </select>
-
 
     <select id="selectPostNoticeByNoticeId" parameterType="Long" resultMap="PostNoticeResult">
         <include refid="selectPostNoticeVo"/>