Administrator пре 1 година
родитељ
комит
4cbcb9054c

+ 31 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/notice/XiaoyuanInfoController.java

@@ -4,6 +4,7 @@ import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.domain.notice.InfoPinglun;
 import com.ruoyi.system.domain.notice.XiaoyuanInfo;
 import com.ruoyi.system.service.notice.IXiaoyuanInfoService;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -86,7 +87,7 @@ public class XiaoyuanInfoController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:xiaoYuanInfo:edit')")
     @Log(title = "校园安全信息", businessType = BusinessType.UPDATE)
-    @PutMapping
+    @PostMapping("/put")
     public AjaxResult edit(@RequestBody XiaoyuanInfo xiaoyuanInfo)
     {
         return toAjax(xiaoyuanInfoService.updateXiaoyuanInfo(xiaoyuanInfo));
@@ -102,4 +103,33 @@ public class XiaoyuanInfoController extends BaseController
     {
         return toAjax(xiaoyuanInfoService.deleteXiaoyuanInfoByInfoIds(infoIds));
     }
+
+
+    /**
+     * 新增校园安全信息评论
+     */
+    @PostMapping("/pingLun")
+    public AjaxResult pingLun(@RequestBody InfoPinglun infoPinglun)
+    {
+        return toAjax(xiaoyuanInfoService.insertInfoPingLun(infoPinglun));
+    }
+
+    /**
+     * 新增校园安全信息点赞接口/取消点赞
+     */
+    @PostMapping("/dianZan")
+    public AjaxResult dianZan(@RequestBody XiaoyuanInfo xiaoyuanInfo)
+    {
+        return xiaoyuanInfoService.dianZan(xiaoyuanInfo);
+    }
+
+    /**
+     * 新增校园安全信息转发接口
+     */
+    @PostMapping("/zhuanFa")
+    public AjaxResult zhuanFa(@RequestBody XiaoyuanInfo xiaoyuanInfo)
+    {
+        return xiaoyuanInfoService.zhuanFa(xiaoyuanInfo);
+    }
+
 }

+ 0 - 105
ruoyi-admin/src/main/java/com/ruoyi/web/controller/notice/XiaoyuanInfoDianzanController.java

@@ -1,105 +0,0 @@
-package com.ruoyi.web.controller.notice;
-
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.system.domain.notice.XiaoyuanInfoDianzan;
-import com.ruoyi.system.service.notice.IXiaoyuanInfoDianzanService;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.annotation.Log;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.common.core.page.TableDataInfo;
-
-/**
- * 校园安全信息点赞Controller
- * 
- * @author boman
- * @date 2023-08-01
- */
-@RestController
-@RequestMapping("/system/dianzan")
-public class XiaoyuanInfoDianzanController extends BaseController
-{
-    @Autowired
-    private IXiaoyuanInfoDianzanService xiaoyuanInfoDianzanService;
-
-    /**
-     * 查询校园安全信息点赞列表
-     */
-    @PreAuthorize("@ss.hasPermi('system:dianzan:list')")
-    @GetMapping("/list")
-    public TableDataInfo list(XiaoyuanInfoDianzan xiaoyuanInfoDianzan)
-    {
-        startPage();
-        List<XiaoyuanInfoDianzan> list = xiaoyuanInfoDianzanService.selectXiaoyuanInfoDianzanList(xiaoyuanInfoDianzan);
-        return getDataTable(list);
-    }
-
-    /**
-     * 导出校园安全信息点赞列表
-     */
-    @PreAuthorize("@ss.hasPermi('system:dianzan:export')")
-    @Log(title = "校园安全信息点赞", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, XiaoyuanInfoDianzan xiaoyuanInfoDianzan)
-    {
-        List<XiaoyuanInfoDianzan> list = xiaoyuanInfoDianzanService.selectXiaoyuanInfoDianzanList(xiaoyuanInfoDianzan);
-        ExcelUtil<XiaoyuanInfoDianzan> util = new ExcelUtil<XiaoyuanInfoDianzan>(XiaoyuanInfoDianzan.class);
-        util.exportExcel(response, list, "校园安全信息点赞数据");
-    }
-
-    /**
-     * 获取校园安全信息点赞详细信息
-     */
-    @PreAuthorize("@ss.hasPermi('system:dianzan:query')")
-    @GetMapping(value = "/{infoDianzanId}")
-    public AjaxResult getInfo(@PathVariable("infoDianzanId") Long infoDianzanId)
-    {
-        return success(xiaoyuanInfoDianzanService.selectXiaoyuanInfoDianzanByInfoDianzanId(infoDianzanId));
-    }
-
-    /**
-     * 新增校园安全信息点赞
-     */
-    @PreAuthorize("@ss.hasPermi('system:dianzan:add')")
-    @Log(title = "校园安全信息点赞", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@RequestBody XiaoyuanInfoDianzan xiaoyuanInfoDianzan)
-    {
-        return toAjax(xiaoyuanInfoDianzanService.insertXiaoyuanInfoDianzan(xiaoyuanInfoDianzan));
-    }
-
-    /**
-     * 修改校园安全信息点赞
-     */
-    @PreAuthorize("@ss.hasPermi('system:dianzan:edit')")
-    @Log(title = "校园安全信息点赞", businessType = BusinessType.UPDATE)
-    @PutMapping
-    public AjaxResult edit(@RequestBody XiaoyuanInfoDianzan xiaoyuanInfoDianzan)
-    {
-        return toAjax(xiaoyuanInfoDianzanService.updateXiaoyuanInfoDianzan(xiaoyuanInfoDianzan));
-    }
-
-    /**
-     * 删除校园安全信息点赞
-     */
-    @PreAuthorize("@ss.hasPermi('system:dianzan:remove')")
-    @Log(title = "校园安全信息点赞", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{infoDianzanIds}")
-    public AjaxResult remove(@PathVariable Long[] infoDianzanIds)
-    {
-        return toAjax(xiaoyuanInfoDianzanService.deleteXiaoyuanInfoDianzanByInfoDianzanIds(infoDianzanIds));
-    }
-}

+ 12 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java

@@ -69,4 +69,16 @@ public class CacheConstants
      * 对应考试id的查看人数
      */
     public static final String SCORE_PEOPLE_CHAKAN_COUNT = "score_people_chakan_count:";
+    /**
+     * 校园安全点赞key
+     */
+    public static final String XIAOYUAN_INFO_DIANZAN = "xiaoyuan_info_dianzan:";
+    /**
+     * 谁点赞的id
+     */
+    public static final String XIAOYUAN_INFO_DIANZAN_USER = "xiaoyuan_info_dianzan_user:";
+    /**
+     * 校园安全转发key
+     */
+    public static final String XIAOYUAN_INFO_ZHUANFA = "xiaoyuan_info_zhuanfa:";
 }

+ 11 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/notice/XiaoyuanInfo.java

@@ -72,6 +72,10 @@ public class XiaoyuanInfo extends BaseEntity
     /** 转发人数 */
     @Excel(name = "转发人数")
     private String infoZhuanFa;
+    /**
+     * 是否点赞,只作为查询使用
+     */
+    private String isDianZan;
 
     /** 信息评论表id */
     @Excel(name = "信息评论表id")
@@ -81,6 +85,13 @@ public class XiaoyuanInfo extends BaseEntity
     private List<InfoPinglun> infoPingLunList;
 
 
+    public String getIsDianZan() {
+        return isDianZan;
+    }
+
+    public void setIsDianZan(String isDianZan) {
+        this.isDianZan = isDianZan;
+    }
 
     public void setInfoId(Long infoId)
     {

+ 0 - 84
ruoyi-system/src/main/java/com/ruoyi/system/domain/notice/XiaoyuanInfoDianzan.java

@@ -1,84 +0,0 @@
-package com.ruoyi.system.domain.notice;
-
-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;
-
-/**
- * 校园安全信息点赞对象 xiaoyuan_info_dianzan
- * 
- * @author boman
- * @date 2023-08-01
- */
-public class XiaoyuanInfoDianzan extends BaseEntity
-{
-    private static final long serialVersionUID = 1L;
-
-    /** 校园安全信息点赞id */
-    private Long infoDianzanId;
-
-    /** 校园安全信息id */
-    @Excel(name = "校园安全信息id")
-    private Long infoId;
-
-    /** 点赞人id */
-    @Excel(name = "点赞人id")
-    private Long dianzanUserId;
-
-    /** 是否点赞 N:否 Y:是 */
-    @Excel(name = "是否点赞 N:否 Y:是")
-    private String dianzanType;
-
-    public void setInfoDianzanId(Long infoDianzanId) 
-    {
-        this.infoDianzanId = infoDianzanId;
-    }
-
-    public Long getInfoDianzanId() 
-    {
-        return infoDianzanId;
-    }
-    public void setInfoId(Long infoId) 
-    {
-        this.infoId = infoId;
-    }
-
-    public Long getInfoId() 
-    {
-        return infoId;
-    }
-    public void setDianzanUserId(Long dianzanUserId) 
-    {
-        this.dianzanUserId = dianzanUserId;
-    }
-
-    public Long getDianzanUserId() 
-    {
-        return dianzanUserId;
-    }
-    public void setDianzanType(String dianzanType) 
-    {
-        this.dianzanType = dianzanType;
-    }
-
-    public String getDianzanType() 
-    {
-        return dianzanType;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("infoDianzanId", getInfoDianzanId())
-            .append("infoId", getInfoId())
-            .append("dianzanUserId", getDianzanUserId())
-            .append("dianzanType", getDianzanType())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
-    }
-}

+ 0 - 62
ruoyi-system/src/main/java/com/ruoyi/system/mapper/notice/XiaoyuanInfoDianzanMapper.java

@@ -1,62 +0,0 @@
-package com.ruoyi.system.mapper.notice;
-
-import com.ruoyi.system.domain.notice.XiaoyuanInfoDianzan;
-
-import java.util.List;
-
-/**
- * 校园安全信息点赞Mapper接口
- * 
- * @author boman
- * @date 2023-08-01
- */
-public interface XiaoyuanInfoDianzanMapper 
-{
-    /**
-     * 查询校园安全信息点赞
-     * 
-     * @param infoDianzanId 校园安全信息点赞主键
-     * @return 校园安全信息点赞
-     */
-    public XiaoyuanInfoDianzan selectXiaoyuanInfoDianzanByInfoDianzanId(Long infoDianzanId);
-
-    /**
-     * 查询校园安全信息点赞列表
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 校园安全信息点赞集合
-     */
-    public List<XiaoyuanInfoDianzan> selectXiaoyuanInfoDianzanList(XiaoyuanInfoDianzan xiaoyuanInfoDianzan);
-
-    /**
-     * 新增校园安全信息点赞
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 结果
-     */
-    public int insertXiaoyuanInfoDianzan(XiaoyuanInfoDianzan xiaoyuanInfoDianzan);
-
-    /**
-     * 修改校园安全信息点赞
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 结果
-     */
-    public int updateXiaoyuanInfoDianzan(XiaoyuanInfoDianzan xiaoyuanInfoDianzan);
-
-    /**
-     * 删除校园安全信息点赞
-     * 
-     * @param infoDianzanId 校园安全信息点赞主键
-     * @return 结果
-     */
-    public int deleteXiaoyuanInfoDianzanByInfoDianzanId(Long infoDianzanId);
-
-    /**
-     * 批量删除校园安全信息点赞
-     * 
-     * @param infoDianzanIds 需要删除的数据主键集合
-     * @return 结果
-     */
-    public int deleteXiaoyuanInfoDianzanByInfoDianzanIds(Long[] infoDianzanIds);
-}

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

@@ -45,6 +45,13 @@ public interface XiaoyuanInfoMapper
      */
     public int updateXiaoyuanInfo(XiaoyuanInfo xiaoyuanInfo);
 
+    /**
+     * 增加已读数量
+     * @param xiaoyuanInfo
+     * @return
+     */
+    public int updateXiaoyuanInfoYiDu(XiaoyuanInfo xiaoyuanInfo);
+
     /**
      * 删除校园安全信息
      * 

+ 2 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/Task.java

@@ -13,6 +13,8 @@ import org.springframework.stereotype.Component;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.ruoyi.common.constant.CacheConstants.XIAOYUAN_INFO_DIANZAN_USER;
+
 @Component
 public class Task {
 
@@ -63,7 +65,6 @@ public class Task {
             }
         }
     }
-
     /***
      * 生成班级下课初始信息
      * */

+ 0 - 96
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/notice/XiaoyuanInfoDianzanServiceImpl.java

@@ -1,96 +0,0 @@
-package com.ruoyi.system.service.impl.notice;
-
-import java.util.List;
-import com.ruoyi.common.utils.DateUtils;
-import com.ruoyi.system.domain.notice.XiaoyuanInfoDianzan;
-import com.ruoyi.system.mapper.notice.XiaoyuanInfoDianzanMapper;
-import com.ruoyi.system.service.notice.IXiaoyuanInfoDianzanService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-/**
- * 校园安全信息点赞Service业务层处理
- * 
- * @author boman
- * @date 2023-08-01
- */
-@Service
-public class XiaoyuanInfoDianzanServiceImpl implements IXiaoyuanInfoDianzanService
-{
-    @Autowired
-    private XiaoyuanInfoDianzanMapper xiaoyuanInfoDianzanMapper;
-
-    /**
-     * 查询校园安全信息点赞
-     * 
-     * @param infoDianzanId 校园安全信息点赞主键
-     * @return 校园安全信息点赞
-     */
-    @Override
-    public XiaoyuanInfoDianzan selectXiaoyuanInfoDianzanByInfoDianzanId(Long infoDianzanId)
-    {
-        return xiaoyuanInfoDianzanMapper.selectXiaoyuanInfoDianzanByInfoDianzanId(infoDianzanId);
-    }
-
-    /**
-     * 查询校园安全信息点赞列表
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 校园安全信息点赞
-     */
-    @Override
-    public List<XiaoyuanInfoDianzan> selectXiaoyuanInfoDianzanList(XiaoyuanInfoDianzan xiaoyuanInfoDianzan)
-    {
-        return xiaoyuanInfoDianzanMapper.selectXiaoyuanInfoDianzanList(xiaoyuanInfoDianzan);
-    }
-
-    /**
-     * 新增校园安全信息点赞
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 结果
-     */
-    @Override
-    public int insertXiaoyuanInfoDianzan(XiaoyuanInfoDianzan xiaoyuanInfoDianzan)
-    {
-        xiaoyuanInfoDianzan.setCreateTime(DateUtils.getNowDate());
-        return xiaoyuanInfoDianzanMapper.insertXiaoyuanInfoDianzan(xiaoyuanInfoDianzan);
-    }
-
-    /**
-     * 修改校园安全信息点赞
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 结果
-     */
-    @Override
-    public int updateXiaoyuanInfoDianzan(XiaoyuanInfoDianzan xiaoyuanInfoDianzan)
-    {
-        xiaoyuanInfoDianzan.setUpdateTime(DateUtils.getNowDate());
-        return xiaoyuanInfoDianzanMapper.updateXiaoyuanInfoDianzan(xiaoyuanInfoDianzan);
-    }
-
-    /**
-     * 批量删除校园安全信息点赞
-     * 
-     * @param infoDianzanIds 需要删除的校园安全信息点赞主键
-     * @return 结果
-     */
-    @Override
-    public int deleteXiaoyuanInfoDianzanByInfoDianzanIds(Long[] infoDianzanIds)
-    {
-        return xiaoyuanInfoDianzanMapper.deleteXiaoyuanInfoDianzanByInfoDianzanIds(infoDianzanIds);
-    }
-
-    /**
-     * 删除校园安全信息点赞信息
-     * 
-     * @param infoDianzanId 校园安全信息点赞主键
-     * @return 结果
-     */
-    @Override
-    public int deleteXiaoyuanInfoDianzanByInfoDianzanId(Long infoDianzanId)
-    {
-        return xiaoyuanInfoDianzanMapper.deleteXiaoyuanInfoDianzanByInfoDianzanId(infoDianzanId);
-    }
-}

+ 128 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/notice/XiaoyuanInfoServiceImpl.java

@@ -1,26 +1,34 @@
 package com.ruoyi.system.service.impl.notice;
 
+import java.util.Comparator;
 import java.util.List;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.FormalParentsStudent;
 import com.ruoyi.common.core.domain.entity.FormalTeacherClass;
 import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.domain.notice.InfoPinglun;
 import com.ruoyi.system.domain.notice.XiaoyuanInfo;
 import com.ruoyi.system.mapper.FormalParentsStudentMapper;
 import com.ruoyi.system.mapper.FormalTeacherClassMapper;
+import com.ruoyi.system.mapper.XiaoyuanNoticeMapper;
 import com.ruoyi.system.mapper.notice.XiaoyuanInfoMapper;
 import com.ruoyi.system.service.notice.IXiaoyuanInfoService;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import java.util.ArrayList;
 import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import com.ruoyi.common.utils.StringUtils;
 import org.springframework.transaction.annotation.Transactional;
 
+import static com.ruoyi.common.constant.CacheConstants.*;
 import static com.ruoyi.common.utils.PageUtils.startPage;
 
 /**
@@ -40,6 +48,9 @@ public class XiaoyuanInfoServiceImpl implements IXiaoyuanInfoService
     @Autowired
     private FormalParentsStudentMapper formalParentsStudentMapper;
 
+    @Autowired
+    private RedisCache redisCache;
+
     /**
      * 查询校园安全信息
      * 
@@ -49,7 +60,53 @@ public class XiaoyuanInfoServiceImpl implements IXiaoyuanInfoService
     @Override
     public XiaoyuanInfo selectXiaoyuanInfoByInfoId(Long infoId)
     {
-        return xiaoyuanInfoMapper.selectXiaoyuanInfoByInfoId(infoId);
+        //已读数量+1
+        XiaoyuanInfo xiaoyuanInfo = xiaoyuanInfoMapper.selectXiaoyuanInfoByInfoId(infoId);
+        String infoYiDu = xiaoyuanInfo.getInfoYiDu();
+        int result = Integer.parseInt(infoYiDu) + 1;
+        xiaoyuanInfo.setInfoYiDu(String.valueOf(result));
+
+        //组装评论
+        List<InfoPinglun> infoPingLunList = xiaoyuanInfo.getInfoPingLunList();
+        if (infoPingLunList != null && infoPingLunList.size() > 0){
+            //根据评论类型进行分组评论类型 1:评论 2:回复
+            Map<String, List<InfoPinglun>> collect = infoPingLunList.stream().sorted(Comparator.comparing(InfoPinglun::getPingLunTime, Comparator.reverseOrder())).collect(Collectors.groupingBy(InfoPinglun::getInfoPingLunType));
+            if (collect != null && collect.size() > 0){
+                //所有评论类型的数据
+                List<InfoPinglun> infoPingLunListFather = collect.get("1");
+                //给他们找自己的回复类型的数据
+                if (infoPingLunListFather != null && infoPingLunListFather.size() > 0){
+                    for (InfoPinglun infoPinglun : infoPingLunListFather) {
+                        List<InfoPinglun> infoPinglunList = collect.get("2");
+                        //回复不是空
+                        if(infoPinglunList != null && infoPinglunList.size() > 0){
+                            Map<Long, List<InfoPinglun>> infoPingLunListParen = infoPinglunList.stream().collect(Collectors.groupingBy(InfoPinglun::getInfoPingLunParent));
+                            List<InfoPinglun> infoPinglunListCh = infoPingLunListParen.get(infoPinglun.getInfoPingLunId());
+                            if (infoPinglunListCh != null && infoPinglunListCh.size() > 0){
+                                infoPinglun.setInfoPingLunList(infoPinglunListCh.stream().sorted(Comparator.comparing(InfoPinglun::getPingLunTime, Comparator.reverseOrder())).collect(Collectors.toList()));
+                            }
+                        }
+                    }
+                }
+                xiaoyuanInfo.setInfoPingLunList(infoPingLunListFather);
+            }
+        }
+        //获取点赞/分享/这个人是否点赞信息
+        Object dianZan = redisCache.getCacheObject(XIAOYUAN_INFO_DIANZAN + xiaoyuanInfo.getInfoId());
+        if (ObjectUtils.isNotEmpty(dianZan)){
+            xiaoyuanInfo.setIsDianZan((String)dianZan);
+        }
+        Object zhuanFa = redisCache.getCacheObject(XIAOYUAN_INFO_ZHUANFA+ xiaoyuanInfo.getInfoId());
+        if (ObjectUtils.isNotEmpty(zhuanFa)){
+            xiaoyuanInfo.setInfoZhuanFa((String)zhuanFa);
+        }
+        Object dianZanUser = redisCache.getCacheObject(XIAOYUAN_INFO_DIANZAN_USER + xiaoyuanInfo.getInfoId());
+        xiaoyuanInfo.setIsDianZan("N");
+        if (ObjectUtils.isNotEmpty(dianZanUser)){
+            xiaoyuanInfo.setIsDianZan("Y");
+        }
+        xiaoyuanInfoMapper.updateXiaoyuanInfoYiDu(xiaoyuanInfo);
+        return xiaoyuanInfo;
     }
 
     /**
@@ -123,6 +180,18 @@ public class XiaoyuanInfoServiceImpl implements IXiaoyuanInfoService
         return rows;
     }
 
+    /**
+     * 新增校园安全信息评论
+     * @param infoPinglun
+     * @return
+     */
+    @Override
+    public int insertInfoPingLun(InfoPinglun infoPinglun) {
+        List<InfoPinglun> infoPingLunList = new ArrayList<>();
+        infoPingLunList.add(infoPinglun);
+        return xiaoyuanInfoMapper.batchInfoPingLun(infoPingLunList);
+    }
+
     /**
      * 修改校园安全信息
      * 
@@ -139,6 +208,64 @@ public class XiaoyuanInfoServiceImpl implements IXiaoyuanInfoService
         return xiaoyuanInfoMapper.updateXiaoyuanInfo(xiaoyuanInfo);
     }
 
+    /**
+     * 点赞接口/取消点赞
+     * @param xiaoyuanInfo
+     * @return
+     */
+    @Override
+    public AjaxResult dianZan(XiaoyuanInfo xiaoyuanInfo) {
+        //从redis中获取点赞数量
+        // key =xiaoyuan_info_dianzan:时间:xiaoyuan_info表中的info_id
+        //value = 点赞数量
+        //谁点赞了,key = xiaoyuan_info_dianzan_user:xiaoyuan_info表中的info_id
+        //value = user_id
+
+        Object cacheObject = redisCache.getCacheObject(XIAOYUAN_INFO_DIANZAN_USER + xiaoyuanInfo.getInfoId());
+        //获取点赞数量
+        Object dianZanNum = redisCache.getCacheObject(XIAOYUAN_INFO_DIANZAN + xiaoyuanInfo.getInfoId());
+        if (ObjectUtils.isEmpty(cacheObject)){
+            //如果是空,则给这个人点赞
+            redisCache.setCacheObject(XIAOYUAN_INFO_DIANZAN_USER + xiaoyuanInfo.getInfoId(),SecurityUtils.getUserId());
+            if (ObjectUtils.isEmpty(dianZanNum)){
+                redisCache.setCacheObject(XIAOYUAN_INFO_DIANZAN + xiaoyuanInfo.getInfoId(),1);
+            }else {
+                redisCache.setCacheObject(XIAOYUAN_INFO_DIANZAN + xiaoyuanInfo.getInfoId(),(int)dianZanNum + 1);
+            }
+        }else {
+            //删除这个key
+            redisCache.deleteObject(XIAOYUAN_INFO_DIANZAN_USER + xiaoyuanInfo.getInfoId());
+            int i = (int) dianZanNum - 1;
+            if (i < 0){
+                i= 0;
+            }
+            redisCache.setCacheObject(XIAOYUAN_INFO_DIANZAN + xiaoyuanInfo.getInfoId(),i);
+        }
+        return AjaxResult.success();
+    }
+
+
+    /**
+     * 转发接口
+     * @param xiaoyuanInfo
+     * @return
+     */
+    @Override
+    public AjaxResult zhuanFa(XiaoyuanInfo xiaoyuanInfo) {
+        //从redis中获取转发数量
+        // key =xiaoyuan_info_zhuanfa:xiaoyuan_info表中的info_id
+        //value = 转发数量
+        Object number = redisCache.getCacheObject(XIAOYUAN_INFO_ZHUANFA + xiaoyuanInfo.getInfoId());
+        if (ObjectUtils.isEmpty(number)){
+            //如果是空,则给这个信息创建一个转发数量
+            redisCache.setCacheObject(XIAOYUAN_INFO_ZHUANFA + xiaoyuanInfo.getInfoId(),1);
+        }else {
+            //转发数量+1
+            redisCache.setCacheObject(XIAOYUAN_INFO_ZHUANFA + xiaoyuanInfo.getInfoId(),(int)number + 1);
+        }
+        return AjaxResult.success();
+    }
+
     /**
      * 批量删除校园安全信息
      * 

+ 0 - 62
ruoyi-system/src/main/java/com/ruoyi/system/service/notice/IXiaoyuanInfoDianzanService.java

@@ -1,62 +0,0 @@
-package com.ruoyi.system.service.notice;
-
-import com.ruoyi.system.domain.notice.XiaoyuanInfoDianzan;
-
-import java.util.List;
-
-/**
- * 校园安全信息点赞Service接口
- * 
- * @author boman
- * @date 2023-08-01
- */
-public interface IXiaoyuanInfoDianzanService 
-{
-    /**
-     * 查询校园安全信息点赞
-     * 
-     * @param infoDianzanId 校园安全信息点赞主键
-     * @return 校园安全信息点赞
-     */
-    public XiaoyuanInfoDianzan selectXiaoyuanInfoDianzanByInfoDianzanId(Long infoDianzanId);
-
-    /**
-     * 查询校园安全信息点赞列表
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 校园安全信息点赞集合
-     */
-    public List<XiaoyuanInfoDianzan> selectXiaoyuanInfoDianzanList(XiaoyuanInfoDianzan xiaoyuanInfoDianzan);
-
-    /**
-     * 新增校园安全信息点赞
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 结果
-     */
-    public int insertXiaoyuanInfoDianzan(XiaoyuanInfoDianzan xiaoyuanInfoDianzan);
-
-    /**
-     * 修改校园安全信息点赞
-     * 
-     * @param xiaoyuanInfoDianzan 校园安全信息点赞
-     * @return 结果
-     */
-    public int updateXiaoyuanInfoDianzan(XiaoyuanInfoDianzan xiaoyuanInfoDianzan);
-
-    /**
-     * 批量删除校园安全信息点赞
-     * 
-     * @param infoDianzanIds 需要删除的校园安全信息点赞主键集合
-     * @return 结果
-     */
-    public int deleteXiaoyuanInfoDianzanByInfoDianzanIds(Long[] infoDianzanIds);
-
-    /**
-     * 删除校园安全信息点赞信息
-     * 
-     * @param infoDianzanId 校园安全信息点赞主键
-     * @return 结果
-     */
-    public int deleteXiaoyuanInfoDianzanByInfoDianzanId(Long infoDianzanId);
-}

+ 23 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/notice/IXiaoyuanInfoService.java

@@ -1,5 +1,7 @@
 package com.ruoyi.system.service.notice;
 
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.notice.InfoPinglun;
 import com.ruoyi.system.domain.notice.XiaoyuanInfo;
 
 import java.util.List;
@@ -36,6 +38,13 @@ public interface IXiaoyuanInfoService
      */
     public int insertXiaoyuanInfo(XiaoyuanInfo xiaoyuanInfo);
 
+    /**
+     * 新增校园安全信息评论
+     * @param infoPinglun
+     * @return
+     */
+    public int insertInfoPingLun(InfoPinglun infoPinglun);
+
     /**
      * 修改校园安全信息
      * 
@@ -44,6 +53,20 @@ public interface IXiaoyuanInfoService
      */
     public int updateXiaoyuanInfo(XiaoyuanInfo xiaoyuanInfo);
 
+    /**
+     * 点赞接口
+     * @param xiaoyuanInfo
+     * @return
+     */
+    public AjaxResult dianZan(XiaoyuanInfo xiaoyuanInfo);
+
+    /**
+     * 转发接口
+     * @param xiaoyuanInfo
+     * @return
+     */
+    public AjaxResult zhuanFa(XiaoyuanInfo xiaoyuanInfo);
+
     /**
      * 批量删除校园安全信息
      * 

+ 0 - 86
ruoyi-system/src/main/resources/mapper/notice/XiaoyuanInfoDianzanMapper.xml

@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.ruoyi.system.mapper.notice.XiaoyuanInfoDianzanMapper">
-    
-    <resultMap type="XiaoyuanInfoDianzan" id="XiaoyuanInfoDianzanResult">
-        <result property="infoDianzanId"    column="info_dianzan_id"    />
-        <result property="infoId"    column="info_id"    />
-        <result property="dianzanUserId"    column="dianzan_user_id"    />
-        <result property="dianzanType"    column="dianzan_type"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="remark"    column="remark"    />
-    </resultMap>
-
-    <sql id="selectXiaoyuanInfoDianzanVo">
-        select info_dianzan_id, info_id, dianzan_user_id, dianzan_type, create_by, create_time, update_by, update_time, remark from xiaoyuan_info_dianzan
-    </sql>
-
-    <select id="selectXiaoyuanInfoDianzanList" parameterType="XiaoyuanInfoDianzan" resultMap="XiaoyuanInfoDianzanResult">
-        <include refid="selectXiaoyuanInfoDianzanVo"/>
-        <where>  
-            <if test="infoId != null "> and info_id = #{infoId}</if>
-            <if test="dianzanUserId != null "> and dianzan_user_id = #{dianzanUserId}</if>
-            <if test="dianzanType != null  and dianzanType != ''"> and dianzan_type = #{dianzanType}</if>
-        </where>
-    </select>
-    
-    <select id="selectXiaoyuanInfoDianzanByInfoDianzanId" parameterType="Long" resultMap="XiaoyuanInfoDianzanResult">
-        <include refid="selectXiaoyuanInfoDianzanVo"/>
-        where info_dianzan_id = #{infoDianzanId}
-    </select>
-        
-    <insert id="insertXiaoyuanInfoDianzan" parameterType="XiaoyuanInfoDianzan" useGeneratedKeys="true" keyProperty="infoDianzanId">
-        insert into xiaoyuan_info_dianzan
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="infoId != null">info_id,</if>
-            <if test="dianzanUserId != null">dianzan_user_id,</if>
-            <if test="dianzanType != null">dianzan_type,</if>
-            <if test="createBy != null">create_by,</if>
-            <if test="createTime != null">create_time,</if>
-            <if test="updateBy != null">update_by,</if>
-            <if test="updateTime != null">update_time,</if>
-            <if test="remark != null">remark,</if>
-         </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="infoId != null">#{infoId},</if>
-            <if test="dianzanUserId != null">#{dianzanUserId},</if>
-            <if test="dianzanType != null">#{dianzanType},</if>
-            <if test="createBy != null">#{createBy},</if>
-            <if test="createTime != null">#{createTime},</if>
-            <if test="updateBy != null">#{updateBy},</if>
-            <if test="updateTime != null">#{updateTime},</if>
-            <if test="remark != null">#{remark},</if>
-         </trim>
-    </insert>
-
-    <update id="updateXiaoyuanInfoDianzan" parameterType="XiaoyuanInfoDianzan">
-        update xiaoyuan_info_dianzan
-        <trim prefix="SET" suffixOverrides=",">
-            <if test="infoId != null">info_id = #{infoId},</if>
-            <if test="dianzanUserId != null">dianzan_user_id = #{dianzanUserId},</if>
-            <if test="dianzanType != null">dianzan_type = #{dianzanType},</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>
-            <if test="updateTime != null">update_time = #{updateTime},</if>
-            <if test="remark != null">remark = #{remark},</if>
-        </trim>
-        where info_dianzan_id = #{infoDianzanId}
-    </update>
-
-    <delete id="deleteXiaoyuanInfoDianzanByInfoDianzanId" parameterType="Long">
-        delete from xiaoyuan_info_dianzan where info_dianzan_id = #{infoDianzanId}
-    </delete>
-
-    <delete id="deleteXiaoyuanInfoDianzanByInfoDianzanIds" parameterType="String">
-        delete from xiaoyuan_info_dianzan where info_dianzan_id in 
-        <foreach item="infoDianzanId" collection="array" open="(" separator="," close=")">
-            #{infoDianzanId}
-        </foreach>
-    </delete>
-</mapper>

+ 10 - 1
ruoyi-system/src/main/resources/mapper/notice/XiaoyuanInfoMapper.xml

@@ -141,7 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="faBuTime != null">fabu_time = #{faBuTime},</if>
             <if test="infoYiDu != null and infoYiDu != ''">info_yidu = #{infoYiDu},</if>
             <if test="infoDianZanId != null">info_dianzan_id = #{infoDianZanId},</if>
-            <if test="infoDianZan != null and infoDianZan != ''">info_dianzan_id = #{infoDianZanId},</if>
+            <if test="infoDianZan != null and infoDianZan != ''">info_dianzan = #{infoDianZan},</if>
             <if test="infoZhuanFa != null and infoZhuanFa != ''">info_zhuanfa = #{infoZhuanFa},</if>
             <if test="infoPingLunId != null">info_pinglun_id = #{infoPingLunId},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
@@ -153,6 +153,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where info_id = #{infoId}
     </update>
 
+    <update id="updateXiaoyuanInfoYiDu" parameterType="XiaoyuanInfo">
+        update xiaoyuan_info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="infoYiDu != null and infoYiDu != ''">info_yidu = #{infoYiDu},</if>
+            <if test="infoDianZan != null and infoDianZan != ''">info_dianzan = #{infoDianZan},</if>
+            <if test="infoZhuanFa != null and infoZhuanFa != ''">info_zhuanfa = #{infoZhuanFa},</if>
+        </trim>
+        where info_id = #{infoId}
+    </update>
     <delete id="deleteXiaoyuanInfoByInfoId" parameterType="Long">
         delete from xiaoyuan_info where info_id = #{infoId}
     </delete>