Browse Source

查看详情

huianan 2 years ago
parent
commit
979ac3a886

+ 18 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/post/PostBulletinController.java

@@ -1,6 +1,7 @@
 package com.ruoyi.web.controller.post;
 
 import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.page.TableDataInfo;
@@ -44,7 +45,7 @@ public class PostBulletinController extends BaseController
      * 导出通知公告;
      */
     @PreAuthorize("@ss.hasPermi('system:bulletin:export')")
-    @Log(title = "通知公告;", businessType = BusinessType.EXPORT)
+    @Log(title = "导出通知公告;", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, PostBulletin postBulletin)
     {
@@ -67,10 +68,13 @@ public class PostBulletinController extends BaseController
      * 新增通知公告;
      */
     @PreAuthorize("@ss.hasPermi('system:bulletin:add')")
-    @Log(title = "通知公告; ", businessType = BusinessType.INSERT)
+    @Log(title = "新增通知公告; ", businessType = BusinessType.INSERT)
     @PostMapping("/add")
     public AjaxResult add(@RequestBody PostBulletin postBulletin)
     {
+//        if(UserConstants.NOT_UNIQUE.equals(postBulletinService.newsTitleAndNewsContentIsNull(postBulletin))){
+//            return AjaxResult.error("新增失败"+postBulletin.getNoticeTitle()+"消息标题及内容已经存在");
+//        }
         return toAjax(postBulletinService.insertPostBulletin(postBulletin));
     }
 
@@ -78,7 +82,7 @@ public class PostBulletinController extends BaseController
      * 修改通知公告;
      */
     @PreAuthorize("@ss.hasPermi('system:bulletin:edit')")
-    @Log(title = "通知公告; ", businessType = BusinessType.UPDATE)
+    @Log(title = "修改通知公告; ", businessType = BusinessType.UPDATE)
     @PutMapping("/edit")
     public AjaxResult edit(@RequestBody PostBulletin postBulletin)
     {
@@ -89,10 +93,20 @@ public class PostBulletinController extends BaseController
      * 删除通知公告;
      */
     @PreAuthorize("@ss.hasPermi('system:bulletin:remove')")
-    @Log(title = "通知公告; ", businessType = BusinessType.DELETE)
+    @Log(title = "删除通知公告; ", businessType = BusinessType.DELETE)
     @DeleteMapping("/{noticeIds}")
     public AjaxResult remove(@PathVariable Integer[] noticeIds)
     {
         return toAjax(postBulletinService.deletePostBulletinByNoticeIds(noticeIds));
     }
+
+    /**
+     * 查看详情
+     */
+    @PreAuthorize("@ss.hasPermi('system:bulletin:query')")
+    @GetMapping(value = "/details/{noticeId}")
+    public AjaxResult ViewDetails(@PathVariable("noticeId") Integer noticeId)
+    {
+        return success(postBulletinService.selectViewDetail(noticeId));
+    }
 }

+ 102 - 0
ruoyi-post/src/main/java/com/ruoyi/post/common/Ognl.java

@@ -0,0 +1,102 @@
+package com.ruoyi.post.common;
+
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @Author HuiANan
+ * @Date 2023/1/29 19:00
+ * @Exegesis:
+ */
+public class Ognl {
+    public Ognl() {
+    }
+
+    public static boolean isEmpty(Object o) throws IllegalArgumentException {
+        if (o == null) {
+            return true;
+        } else {
+            if (o instanceof String) {
+                if (((String) o).length() == 0) {
+                    return true;
+                }
+            } else if (o instanceof Collection) {
+                if (((Collection) o).isEmpty()) {
+                    return true;
+                }
+            } else if (o.getClass().isArray()) {
+                if (Array.getLength(o) == 0) {
+                    return true;
+                }
+            } else {
+                if (!(o instanceof Map)) {
+                    return false;
+                }
+
+                if (((Map) o).isEmpty()) {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+    }
+
+    public static boolean isNotEmpty(Object o) {
+        return !isEmpty(o);
+    }
+
+    public static boolean isNotBlank(Object o) {
+        return !isBlank(o);
+    }
+
+    public static boolean isNumber(Object o) {
+        if (o == null) {
+            return false;
+        } else if (o instanceof Number) {
+            return true;
+        } else if (o instanceof String) {
+            String str = (String) o;
+            if (str.length() == 0) {
+                return false;
+            } else if (str.trim().length() == 0) {
+                return false;
+            } else {
+                try {
+                    Double.parseDouble(str);
+                    return true;
+                } catch (NumberFormatException var3) {
+                    return false;
+                }
+            }
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isBlank(Object o) {
+        if (o == null) {
+            return true;
+        } else if (o instanceof String) {
+            String str = (String) o;
+            return isBlank(str);
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isBlank(String str) {
+        if (str != null && str.length() != 0) {
+            for (int i = 0; i < str.length(); ++i) {
+                if (!Character.isWhitespace(str.charAt(i))) {
+                    return false;
+                }
+            }
+
+            return true;
+        } else {
+            return true;
+        }
+    }
+}

+ 7 - 1
ruoyi-post/src/main/java/com/ruoyi/post/mapper/PostBulletinMapper.java

@@ -59,6 +59,12 @@ public interface PostBulletinMapper {
     public int deletePostBulletinByNoticeIds(Integer[] noticeIds);
 
     /**
-     *
+     * 判断内容以及标题是否存在
+     */
+    public String checkTitleAndContentIsExit(String title,String Content);
+
+    /**
+     * 查看详情
      */
+    public PostBulletin selectViewDetails(Integer noticeId);
 }

+ 4 - 6
ruoyi-post/src/main/java/com/ruoyi/post/service/IPostBulletinService.java

@@ -53,14 +53,12 @@ public interface IPostBulletinService
     public int deletePostBulletinByNoticeId(Integer noticeId);
 
     /**
-     * 判断消息标题是否重复
+     * 公告标题及内容为空判断
      */
-    public void newsTitleIfRepeat(PostNews postNews);
+    public String newsTitleAndNewsContentIsNull(PostBulletin postBulletin);
 
     /**
-     * 消息标题以及消息内容为空判断
+     * 查看详情
      */
-    public void newsTitleAndNewsContentIsNull(PostNews postNews);
-
-
+    public PostBulletin selectViewDetail(Integer noticeId);
 }

+ 28 - 25
ruoyi-post/src/main/java/com/ruoyi/post/service/impl/PostBulletinServiceImpl.java

@@ -1,23 +1,26 @@
 package com.ruoyi.post.service.impl;
 
+import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.post.domain.PostBulletin;
 import com.ruoyi.post.domain.PostNews;
 import com.ruoyi.post.mapper.PostBulletinMapper;
+import com.ruoyi.post.mapper.PostNewsMapper;
 import com.ruoyi.post.service.IPostBulletinService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
 
+
 /**
  * @Author HuiANan
  * @Date 2023/1/13 17:19
  * @Exegesis:
  */
 @Service
-public class PostBulletinServiceImpl implements IPostBulletinService
-{
+public class PostBulletinServiceImpl implements IPostBulletinService {
     @Resource
     private PostBulletinMapper postBulletinMapper;
 
@@ -28,8 +31,7 @@ public class PostBulletinServiceImpl implements IPostBulletinService
      * @return 通知公告管理;
      */
     @Override
-    public PostBulletin selectPostBulletinByNoticeId(Integer noticeId)
-    {
+    public PostBulletin selectPostBulletinByNoticeId(Integer noticeId) {
         return postBulletinMapper.selectPostBulletinByNoticeId(noticeId);
     }
 
@@ -40,20 +42,18 @@ public class PostBulletinServiceImpl implements IPostBulletinService
      * @return 通知公告管理;
      */
     @Override
-    public List<PostBulletin> selectPostBulletinList(PostBulletin postBulletin)
-    {
+    public List<PostBulletin> selectPostBulletinList(PostBulletin postBulletin) {
         return postBulletinMapper.selectPostBulletinList(postBulletin);
     }
 
     /**
-     * 新增通知公告管理; InnoDB free: 8192 kB
+     * 新增通知公告管理;
      *
      * @param postBulletin 通知公告管理;
      * @return 结果
      */
     @Override
-    public int insertPostBulletin(PostBulletin postBulletin)
-    {
+    public int insertPostBulletin(PostBulletin postBulletin) {
         postBulletin.setCreateTime(DateUtils.getNowDate());
         return postBulletinMapper.insertPostBulletin(postBulletin);
     }
@@ -65,8 +65,7 @@ public class PostBulletinServiceImpl implements IPostBulletinService
      * @return 结果
      */
     @Override
-    public int updatePostBulletin(PostBulletin postBulletin)
-    {
+    public int updatePostBulletin(PostBulletin postBulletin) {
         postBulletin.setUpdateTime(DateUtils.getNowDate());
         return postBulletinMapper.updatePostBulletin(postBulletin);
     }
@@ -78,8 +77,7 @@ public class PostBulletinServiceImpl implements IPostBulletinService
      * @return 结果
      */
     @Override
-    public int deletePostBulletinByNoticeIds(Integer[] noticeIds)
-    {
+    public int deletePostBulletinByNoticeIds(Integer[] noticeIds) {
         return postBulletinMapper.deletePostBulletinByNoticeIds(noticeIds);
     }
 
@@ -90,25 +88,30 @@ public class PostBulletinServiceImpl implements IPostBulletinService
      * @return 结果
      */
     @Override
-    public int deletePostBulletinByNoticeId(Integer noticeId)
-    {
+    public int deletePostBulletinByNoticeId(Integer noticeId) {
         return postBulletinMapper.deletePostBulletinByNoticeId(noticeId);
     }
 
     /**
-     * 判断消息标题是否重复
-     * @param postNews
+     * 公告及公告内容为空的判断
+     *
+     * @param postBulletin
      */
     @Override
-    public void newsTitleIfRepeat(PostNews postNews) {
+    public String newsTitleAndNewsContentIsNull(PostBulletin postBulletin) {
+        //查询内容以及标题是否存在
+        String PostNewsId = StringUtils.isNull(postBulletin.getNoticeId()) ? "标题以及内容不存在" : postBulletin.getNoticeId().toString();
+        String title = postBulletinMapper.checkTitleAndContentIsExit(postBulletin.getNoticeTitle(), postBulletin.getNoticeContent());
+        if (StringUtils.isNotNull(title) && postBulletin.getNoticeId().toString() != PostNewsId) {
+            return UserConstants.NOT_UNIQUE;
+        }
+        return UserConstants.UNIQUE;
+    }
 
-     }
-    /**
-     * 消息标题以及消息内容为空判断
-     * @param postNews
-     */
     @Override
-    public void newsTitleAndNewsContentIsNull(PostNews postNews) {
-
+    public PostBulletin selectViewDetail(Integer noticeId) {
+        return postBulletinMapper.selectViewDetails(noticeId);
     }
+
+
 }

+ 19 - 9
ruoyi-post/src/main/resources/mapper/PostBulletinMapper.xml

@@ -17,7 +17,6 @@
         <result property="updateTime" column="update_time"/>
         <result property="remark" column="remark"/>
     </resultMap>
-
     <sql id="selectPostBulletinVo">
         select notice_id,
                notice_title,
@@ -32,30 +31,28 @@
                remark
         from post_bulletin
     </sql>
-
+    <!--列表查询-->
     <select id="selectPostBulletinList" parameterType="PostBulletin" resultMap="PostBulletinResult">
         <include refid="selectPostBulletinVo"/>
         <where>
---标题查询
             <if test="noticeTitle != null and noticeTitle != ''">
                 AND notice_title like concat('%', #{noticeTitle}, '%')
             </if>
---内容查询
             <if test="noticeContent != null and noticeTitle != ''">
                 AND notice_content like concat('%', #{noticeContent}, '%')
             </if>
--- 时间查询
             <if test="createTime != null and noticeTitle != ''">
                 AND create_time like concat('%', #{createTime}, '%')
             </if>
         </where>
     </select>
-
+    <!--ID查询-->
     <select id="selectPostBulletinByNoticeId" parameterType="Integer" resultMap="PostBulletinResult">
         <include refid="selectPostBulletinVo"/>
         where notice_id = #{noticeId}
     </select>
 
+    <!--插入-->
     <insert id="insertPostBulletin" parameterType="PostBulletin" useGeneratedKeys="true" keyProperty="noticeId">
         insert into post_bulletin
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -83,7 +80,7 @@
             <if test="remark != null">#{remark},</if>
         </trim>
     </insert>
-
+    <!--更新-->
     <update id="updatePostBulletin" parameterType="PostBulletin">
         update post_bulletin
         <trim prefix="SET" suffixOverrides=",">
@@ -100,17 +97,30 @@
         </trim>
         where notice_id = #{noticeId}
     </update>
-
+    <!--删除-->
     <delete id="deletePostBulletinByNoticeId" parameterType="Integer">
         delete
         from post_bulletin
         where notice_id = #{noticeId}
     </delete>
-
+    <!--批量删除-->
     <delete id="deletePostBulletinByNoticeIds" parameterType="String">
         delete from post_bulletin where notice_id in
         <foreach item="noticeId" collection="array" open="(" separator="," close=")">
             #{noticeId}
         </foreach>
     </delete>
+
+    <!-- 判断内容以及标题是否为空-->
+    <select id="checkTitleAndContentIsExit" resultType="PostBulletin" resultMap="PostBulletinResult">
+        <include refid="selectPostBulletinVo"></include>
+        <where>
+<!--            <if test="@Ognl@isNotEmpty(noticeTitle)">and notice_title like concat('%', #{noticeTitle}, '%')</if>-->
+            <if test="noticeTitle!= null and noticeTitle!=''">and notice_title like concat('%', #{noticeTitle}, '%')</if>
+            <if test="noticeContent!= null and noticeContent!=''">and notice_content like concat('%', #{noticeContent}, '%')</if>
+        </where>
+    </select>
+    <select id="selectViewDetails" parameterType="Integer" resultMap="PostBulletinResult">
+        select notice_title,create_time,notice_content from post_bulletin where notice_id = #{noticeId}
+    </select>
 </mapper>