Administrator 1 жил өмнө
parent
commit
3bfaf623b3

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -70,6 +70,6 @@ xss:
   # 过滤开关
   enabled: true
   # 排除链接(多个用逗号分隔)
-  excludes: /system/notice,/zxNotice/notice/*
+  excludes: /system/notice,/zxNotice/*
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*,/zxNotice/*

+ 13 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/notice/ZxNotice.java

@@ -3,6 +3,7 @@ package com.ruoyi.system.domain.notice;
 import java.util.List;
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.system.domain.ZxFj;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
@@ -62,6 +63,18 @@ public class ZxNotice extends BaseEntity
 
     /** 用户与政协通知公告关联信息 */
     private List<ZxUserNotice> zxUserNoticeList;
+    /**
+     * 附件
+     */
+    private List<ZxFj> zxFjListFj;
+
+    public List<ZxFj> getZxFjListFj() {
+        return zxFjListFj;
+    }
+
+    public void setZxFjListFj(List<ZxFj> zxFjListFj) {
+        this.zxFjListFj = zxFjListFj;
+    }
 
     public String getType() {
         return type;

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/ZxFjMapper.java

@@ -62,4 +62,11 @@ public interface ZxFjMapper
     public int deleteZxFjByIds(Long[] ids);
 
     void deleteZxFjBySourceId(Long sourceId);
+
+    /**
+     * 批量插入
+     * @param zxFjList
+     * @return
+     */
+    int batchZxFj(List<ZxFj> zxFjList);
 }

+ 38 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZxNoticeServiceImpl.java

@@ -3,8 +3,10 @@ package com.ruoyi.system.service.impl;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.system.domain.ZxFj;
 import com.ruoyi.system.domain.notice.ZxNotice;
 import com.ruoyi.system.domain.notice.ZxUserNotice;
+import com.ruoyi.system.mapper.ZxFjMapper;
 import com.ruoyi.system.service.IZxNoticeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -14,6 +16,8 @@ import com.ruoyi.system.mapper.ZxNoticeMapper;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.ruoyi.common.constant.CommonConstants.THR;
+
 /**
  * 政协通知公告Service业务层处理
  * 
@@ -26,6 +30,9 @@ public class ZxNoticeServiceImpl implements IZxNoticeService
     @Autowired
     private ZxNoticeMapper zxNoticeMapper;
 
+    @Autowired
+    private ZxFjMapper zxFjMapper;
+
     /**
      * 查询政协通知公告
      * 
@@ -64,12 +71,13 @@ public class ZxNoticeServiceImpl implements IZxNoticeService
      * @param zxNotice 政协通知公告
      * @return 结果
      */
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public int insertZxNotice(ZxNotice zxNotice)
     {
         zxNotice.setCreateTime(DateUtils.getNowDate());
         int rows = zxNoticeMapper.insertZxNotice(zxNotice);
+        insertZxFj(zxNotice);
         insertZxUserNotice(zxNotice);
         return rows;
     }
@@ -80,13 +88,15 @@ public class ZxNoticeServiceImpl implements IZxNoticeService
      * @param zxNotice 政协通知公告
      * @return 结果
      */
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public int updateZxNotice(ZxNotice zxNotice)
     {
         zxNotice.setUpdateTime(DateUtils.getNowDate());
         zxNoticeMapper.deleteZxUserNoticeByZxNoticeId(zxNotice.getZxNoticeId());
+        zxFjMapper.deleteZxFjBySourceId(zxNotice.getZxNoticeId());
         insertZxUserNotice(zxNotice);
+        insertZxFj(zxNotice);
         return zxNoticeMapper.updateZxNotice(zxNotice);
     }
 
@@ -141,4 +151,30 @@ public class ZxNoticeServiceImpl implements IZxNoticeService
             }
         }
     }
+
+    /**
+     * 新增通知公告附件关联信息
+     *
+     * @param zxNotice 政协通知公告对象
+     */
+    public void insertZxFj(ZxNotice zxNotice)
+    {
+        List<ZxFj> zxFjListFj = zxNotice.getZxFjListFj();
+        Long zxNoticeId = zxNotice.getZxNoticeId();
+        if (StringUtils.isNotNull(zxFjListFj))
+        {
+            List<ZxFj> list = new ArrayList<ZxFj>();
+            for (ZxFj zxFj : zxFjListFj)
+            {
+                zxFj.setType(THR);
+                zxFj.setMainId(zxNoticeId);
+                zxFj.setSourceId(zxNoticeId);
+                list.add(zxFj);
+            }
+            if (list.size() > 0)
+            {
+                zxFjMapper.batchZxFj(list);
+            }
+        }
+    }
 }

+ 6 - 0
ruoyi-system/src/main/resources/mapper/system/ZxFjMapper.xml

@@ -57,6 +57,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">#{remark},</if>
          </trim>
     </insert>
+    <insert id="batchZxFj">
+        INSERT INTO `zheng_xie`.`zx_fj`(`main_id`, `source_id`, `name`, `url`, `type`, `stytle`, `remark`) VALUES
+        <foreach item="item" index="index" collection="list" separator=",">
+            ( #{item.mainId}, #{item.sourceId}, #{item.name},#{item.url},#{item.type},#{item.stytle},#{item.remark})
+        </foreach>
+    </insert>
 
     <update id="updateZxFj" parameterType="ZxFj">
         update zx_fj