Ver Fonte

文件上传下载功能

sjx há 2 anos atrás
pai
commit
c792d7e480

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

@@ -32,7 +32,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
  */
 @Api(tags = "PostNoticeController",description = "公告功能页面")
 @RestController
-@RequestMapping("/system/notices")
+@RequestMapping("/system/notice")
 public class PostNoticeController extends BaseController
 {
     @Autowired

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java

@@ -26,7 +26,7 @@ import com.ruoyi.system.service.ISysNoticeService;
  * @author ruoyi
  */
 @RestController
-@RequestMapping("/system/notice")
+@RequestMapping("/system/notices")
 public class SysNoticeController extends BaseController
 {
     @Autowired

+ 23 - 18
ruoyi-system/src/main/java/com/ruoyi/system/domain/PostNotice.java

@@ -2,11 +2,15 @@ package com.ruoyi.system.domain;
 
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.xss.Xss;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
 /**
  * 公告对象 post_notice
  *
@@ -22,6 +26,9 @@ public class PostNotice extends BaseEntity
 
     /** 公告标题 */
     @Excel(name = "公告标题")
+    @Xss(message = "公告标题不能包含脚本字符")
+    @NotBlank(message = "公告标题不能为空")
+    @Size(min = 0, max = 20, message = "公告标题不能超过20个字符")
     private String noticeTitle;
 
     /** 发布时间 */
@@ -31,7 +38,7 @@ public class PostNotice extends BaseEntity
 
     /** 公告详情id */
     @Excel(name = "公告详情id")
-    private String detailDetail;
+    private String noticeContent;
 
     /** 图片名称 */
     @Excel(name = "图片名称")
@@ -61,13 +68,7 @@ public class PostNotice extends BaseEntity
         this.noticeTime = noticeTime;
     }
 
-    public String getDetailDetail() {
-        return detailDetail;
-    }
 
-    public void setDetailDetail(String detailDetail) {
-        this.detailDetail = detailDetail;
-    }
 
     public String getImage() {
         return image;
@@ -77,18 +78,22 @@ public class PostNotice extends BaseEntity
         this.image = image;
     }
 
+    public String getNoticeContent() {
+        return noticeContent;
+    }
+
+    public void setNoticeContent(String noticeContent) {
+        this.noticeContent = noticeContent;
+    }
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-                .append("noticeId", getNoticeId())
-                .append("noticeTitle", getNoticeTitle())
-                .append("noticeTime", getNoticeTime())
-                .append("detailDetail", getDetailDetail())
-                .append("createBy", getCreateBy())
-                .append("createTime", getCreateTime())
-                .append("updateBy", getUpdateBy())
-                .append("updateTime", getUpdateTime())
-                .append("image",getImage())
-                .toString();
+        return "PostNotice{" +
+                "noticeId=" + noticeId +
+                ", noticeTitle='" + noticeTitle + '\'' +
+                ", noticeTime=" + noticeTime +
+                ", noticeContent='" + noticeContent + '\'' +
+                ", image='" + image + '\'' +
+                '}';
     }
 }

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

@@ -8,7 +8,7 @@
         <result property="noticeId"    column="notice_id"    />
         <result property="noticeTitle"    column="notice_title"    />
         <result property="noticeTime"    column="notice_time"    />
-        <result property="detailDetail"    column="detail_detail"    />
+        <result property="noticeContent"  column="notice_content"  />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
@@ -17,14 +17,14 @@
     </resultMap>
 
     <sql id="selectPostNoticeVo">
-        select notice_id, notice_title, notice_time, detail_detail, create_by, create_time, update_by, update_time ,image from post_notice
+        select notice_id, notice_title, notice_time, cast(notice_content as char) as notice_content, create_by, create_time, update_by, update_time ,image from post_notice
     </sql>
 
     <select id="selectPostNoticeList" parameterType="PostNotice" resultMap="PostNoticeResult">
         <include refid="selectPostNoticeVo"/>
         <where>
             <if test="noticeTitle != null  and noticeTitle != ''"> and notice_title = #{noticeTitle}</if>
-            <if test="detailDetail != null  and detailDetail != ''"> and detail_detail = #{detailDetail}</if>
+            <if test="noticeContent != null and noticeContent != ''">and notice_content = #{noticeContent} </if>
         </where>
     </select>
 
@@ -42,7 +42,7 @@
         where notice_id = #{noticeId}
     </select>
     <select id="selectDetailByNoticeId" resultType="String">
-        select detail_detail from post_notice
+        select notice_content from post_notice
         where notice_id = #{noticeId}
     </select>
 
@@ -53,7 +53,7 @@
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="noticeTitle != null">notice_title,</if>
             <if test="noticeTime != null">notice_time,</if>
-            <if test="detailDetail != null">detail_detail,</if>
+            <if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
@@ -64,7 +64,7 @@
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="noticeTitle != null">#{noticeTitle},</if>
             <if test="noticeTime != null">#{noticeTime},</if>
-            <if test="detailDetail != null">#{detailDetail},</if>
+            <if test="noticeContent != null and noticeContent != '' ">#{notice_content},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
@@ -78,7 +78,7 @@
         <trim prefix="SET" suffixOverrides=",">
             <if test="noticeTitle != null">notice_title = #{noticeTitle},</if>
             <if test="noticeTime != null">notice_time = #{noticeTime},</if>
-            <if test="detailDetail != null">detail_detail = #{detailDetail},</if>
+            <if test="noticeContent != null">notice_content = #{noticeContent}, </if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>