Browse Source

搜索接口

zyf12 2 years ago
parent
commit
06069d90c0

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

@@ -1,7 +1,11 @@
 package com.ruoyi.system.mapper;
 
+import java.util.Date;
 import java.util.List;
 import com.ruoyi.system.domain.PostNotice;
+import org.apache.ibatis.annotations.Param;
+
+
 
 /**
  * 公告Mapper接口
@@ -66,4 +70,5 @@ public interface PostNoticeMapper
      */
     public int deletePostNoticeByNoticeIds(Long[] noticeIds);
 
+    public List<PostNotice> selectPostNoticeListByTitleOrNoticeTime(@Param("noticeTitle")String noticeTitle, @Param("noticeTimeLeft")Date noticeTimeLeft, @Param("noticeTimeRight")Date noticeTimeRight);
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IPostNoticeService.java

@@ -1,8 +1,10 @@
 package com.ruoyi.system.service;
 
+import java.util.Date;
 import java.util.List;
 import com.ruoyi.system.domain.PostNotice;
 
+
 /**
  * 公告Service接口
  *
@@ -66,4 +68,7 @@ public interface IPostNoticeService
      * @return
      */
     public String selectDetailByNoticeId(Long noticeId);
+
+
+    public List<PostNotice> selectPostNoticeListByTitleOrNoticeTime(String noticeTitle, Date noticeTimeLeft,Date noticeTimeRight);
 }

+ 17 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PostNoticeServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.service.impl;
 
+import java.util.Date;
 import java.util.List;
 import com.ruoyi.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -8,6 +9,8 @@ import com.ruoyi.system.mapper.PostNoticeMapper;
 import com.ruoyi.system.domain.PostNotice;
 import com.ruoyi.system.service.IPostNoticeService;
 
+import javax.xml.crypto.Data;
+
 /**
  * 公告Service业务层处理
  *
@@ -50,6 +53,19 @@ public class PostNoticeServiceImpl implements IPostNoticeService
         return postNoticeMapper.selectDetailByNoticeId(noticeId);
     }
 
+
+    /**
+     * 搜素
+     * @param noticeTitle
+     * @param noticeTimeLeft
+     * @param noticeTimeRight
+     * @return
+     */
+    @Override
+    public List<PostNotice> selectPostNoticeListByTitleOrNoticeTime(String noticeTitle, Date noticeTimeLeft, Date noticeTimeRight) {
+        return postNoticeMapper.selectPostNoticeListByTitleOrNoticeTime(noticeTitle,noticeTimeLeft,noticeTimeRight);
+    }
+
     /**
      * 新增公告
      *
@@ -82,6 +98,7 @@ public class PostNoticeServiceImpl implements IPostNoticeService
      * @param noticeIds 需要删除的公告主键
      * @return 结果
      */
+
     @Override
     public int deletePostNoticeByNoticeIds(Long[] noticeIds)
     {

+ 11 - 1
ruoyi-system/src/main/resources/mapper/system/PostNoticeMapper.xml

@@ -23,11 +23,19 @@
         <include refid="selectPostNoticeVo"/>
         <where>
             <if test="noticeTitle != null  and noticeTitle != ''"> and notice_title = #{noticeTitle}</if>
-            <if test="noticeTime != null "> and notice_time = #{noticeTime}</if>
+            <if test="noticeTime != null "> and notice_time like "%str%"</if>
             <if test="detailDetail != null  and detailDetail != ''"> and detail_detail = #{detailDetail}</if>
         </where>
     </select>
 
+    <select id="selectPostNoticeListByTitleOrNoticeTime" resultType="PostNotice" resultMap="PostNoticeResult">
+        <include refid="selectPostNoticeVo"/>
+        <where>
+            <if test="noticeTitle != null  and noticeTitle != ''"> and notice_title = #{title}</if>
+            <if test="noticeTime != null "> and notice_time between #{noticeTimeLeft} AND #{noticeTimeRight}</if>
+        </where>
+    </select>
+
     <select id="selectPostNoticeByNoticeId" parameterType="Long" resultMap="PostNoticeResult">
         <include refid="selectPostNoticeVo"/>
         where notice_id = #{noticeId}
@@ -37,6 +45,8 @@
         where notice_id = #{noticeId}
     </select>
 
+
+
     <insert id="insertPostNotice" parameterType="PostNotice" useGeneratedKeys="true" keyProperty="noticeId">
         insert into post_notice
         <trim prefix="(" suffix=")" suffixOverrides=",">