diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityNoticeController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityNoticeController.java new file mode 100644 index 0000000..db235ac --- /dev/null +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityNoticeController.java @@ -0,0 +1,105 @@ +package com.inspur.web.controller.community; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +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.inspur.common.annotation.Log; +import com.inspur.common.core.controller.BaseController; +import com.inspur.common.core.domain.AjaxResult; +import com.inspur.common.enums.BusinessType; +import com.inspur.community.domain.CommunityNotice; +import com.inspur.community.service.ICommunityNoticeService; +import com.inspur.common.utils.poi.ExcelUtil; +import com.inspur.common.core.page.TableDataInfo; + +/** + * 社区通知Controller + * + * @author inspur + * @date 2024-05-08 + */ +@RestController +@RequestMapping("/community/notice") +public class CommunityNoticeController extends BaseController +{ + @Autowired + private ICommunityNoticeService communityNoticeService; + + /** + * 查询社区通知列表 + */ + @PreAuthorize("@ss.hasPermi('community:notice:list')") + @GetMapping("/list") + public TableDataInfo list(CommunityNotice communityNotice) + { + startPage(); + List list = communityNoticeService.selectCommunityNoticeList(communityNotice); + return getDataTable(list); + } + + /** + * 导出社区通知列表 + */ + @PreAuthorize("@ss.hasPermi('community:notice:export')") + @Log(title = "社区通知", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, CommunityNotice communityNotice) + { + List list = communityNoticeService.selectCommunityNoticeList(communityNotice); + ExcelUtil util = new ExcelUtil(CommunityNotice.class); + util.exportExcel(response, list, "社区通知数据"); + } + + /** + * 获取社区通知详细信息 + */ + @PreAuthorize("@ss.hasPermi('community:notice:query')") + @GetMapping(value = "/{noticeId}") + public AjaxResult getInfo(@PathVariable("noticeId") String noticeId) + { + return success(communityNoticeService.selectCommunityNoticeByNoticeId(noticeId)); + } + + /** + * 新增社区通知 + */ + @PreAuthorize("@ss.hasPermi('community:notice:add')") + @Log(title = "社区通知", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody CommunityNotice communityNotice) + { + return toAjax(communityNoticeService.insertCommunityNotice(communityNotice)); + } + + /** + * 修改社区通知 + */ + @PreAuthorize("@ss.hasPermi('community:notice:edit')") + @Log(title = "社区通知", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody CommunityNotice communityNotice) + { + return toAjax(communityNoticeService.updateCommunityNotice(communityNotice)); + } + + /** + * 删除社区通知 + */ + @PreAuthorize("@ss.hasPermi('community:notice:remove')") + @Log(title = "社区通知", businessType = BusinessType.DELETE) + @DeleteMapping("/{noticeIds}") + public AjaxResult remove(@PathVariable String[] noticeIds) + { + return toAjax(communityNoticeService.deleteCommunityNoticeByNoticeIds(noticeIds)); + } +} + diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostInfoController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostInfoController.java index c4f6f42..2df17ac 100644 --- a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostInfoController.java +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostInfoController.java @@ -1,8 +1,10 @@ package com.inspur.web.controller.community; +import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.inspur.common.utils.SecurityUtils; import com.inspur.community.domain.vo.CommunityPostInfoVO; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -48,6 +50,25 @@ public class CommunityPostInfoController extends BaseController return getDataTable(list); } + /** + * 查询当前登录用户社区帖子信息列表 + */ + @PreAuthorize("@ss.hasPermi('community:info:list')") + @GetMapping("/listLogUser") + public TableDataInfo listLogUser(CommunityPostInfo communityPostInfo) + { + startPage(); + List list = new ArrayList<>(); + if(SecurityUtils.getLoginUser()!=null) { + communityPostInfo.setUserId(SecurityUtils.getLoginUser().getUserId()); + + list = communityPostInfoService.selectCommunityPostInfoList(communityPostInfo); + }else { + list = null; + } + return getDataTable(list); + } + /** * 导出社区帖子信息列表 */ diff --git a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostLikeController.java b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostLikeController.java index 395357a..93524b3 100644 --- a/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostLikeController.java +++ b/inspur-service/inspur-admin/src/main/java/com/inspur/web/controller/community/CommunityPostLikeController.java @@ -1,9 +1,11 @@ package com.inspur.web.controller.community; +import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.inspur.common.utils.SecurityUtils; +import com.inspur.community.domain.vo.CommunityPostLikeVO; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -48,6 +50,23 @@ public class CommunityPostLikeController extends BaseController return getDataTable(list); } + /** + * 查询当前登录用户社区点赞信息列表 + */ + @PreAuthorize("@ss.hasPermi('community:like:list')") + @GetMapping("/listLogUser") + public TableDataInfo listLogUser(CommunityPostLike communityPostLike) + { + startPage(); + List list = new ArrayList<>(); + if(SecurityUtils.getLoginUser() != null){ + list = communityPostLikeService.selectCommunityPostLikeListByUserId(SecurityUtils.getLoginUser().getUserId()); + }else{ + list = null; + } + return getDataTable(list); + } + /** * 导出社区点赞信息列表 */ diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/CommunityNotice.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/CommunityNotice.java new file mode 100644 index 0000000..483ed84 --- /dev/null +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/CommunityNotice.java @@ -0,0 +1,137 @@ +package com.inspur.community.domain; + +import com.inspur.common.annotation.Excel; +import com.inspur.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 社区通知对象 community_notice + * + * @author zhangjunwen + * @date 2024-05-08 + */ +public class CommunityNotice extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private String noticeId; + + /** 帖子id */ + @Excel(name = "帖子id") + private String postId; + + /** + * 回复id + */ + private String replyId; + + /** + * 用户id + */ + private Long userId; + + /** 帖子名称 */ + @Excel(name = "帖子名称") + private String postName; + + /** + * 回复内容 + */ + private String replyContent; + + /** 通知类型:1 点赞,2 回复,3 封禁 */ + @Excel(name = "通知类型:1 点赞,2 回复,3 封禁") + private String noticeType; + + /** 状态:0未读,1 已读 */ + @Excel(name = "状态:0未读,1 已读") + private String status; + + public void setNoticeId(String noticeId) + { + this.noticeId = noticeId; + } + + public String getNoticeId() + { + return noticeId; + } + public void setPostId(String postId) + { + this.postId = postId; + } + + public String getPostId() + { + return postId; + } + + public String getReplyId() { + return replyId; + } + + public void setReplyId(String replyId) { + this.replyId = replyId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public void setPostName(String postName) + { + this.postName = postName; + } + + public String getPostName() + { + return postName; + } + + public String getReplyContent() { + return replyContent; + } + + public void setReplyContent(String replyContent) { + this.replyContent = replyContent; + } + + public void setNoticeType(String noticeType) + { + this.noticeType = noticeType; + } + + public String getNoticeType() + { + return noticeType; + } + public void setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("noticeId", getNoticeId()) + .append("postId", getPostId()) + .append("replyId", getReplyId()) + .append("postName", getPostName()) + .append("noticeType", getNoticeType()) + .append("remark", getRemark()) + .append("status", getStatus()) + .toString(); + } +} + diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/vo/CommunityPostLikeVO.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/vo/CommunityPostLikeVO.java new file mode 100644 index 0000000..31f9d4a --- /dev/null +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/domain/vo/CommunityPostLikeVO.java @@ -0,0 +1,41 @@ +package com.inspur.community.domain.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.inspur.common.annotation.Excel; +import com.inspur.community.domain.CommunityPostInfo; +import com.inspur.community.domain.CommunityPostReply; +import lombok.Data; + +import java.util.Date; + +/** + * @Author zhangjunwen + * @create 2024/5/9 + */ +@Data +public class CommunityPostLikeVO { + + /** 用户id */ + private Long userId; + + /** 点赞帖子id */ + private String likePostId; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + /** 点赞时间 */ + private Date likeTime; + + private String replyContent; + + private String postTitle; + + /** + * 点赞的回复信息 + */ + private CommunityPostReply communityPostReply; + + /** + * 贴子信息 + */ + private CommunityPostInfo communityPostInfo; +} diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityNoticeMapper.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityNoticeMapper.java new file mode 100644 index 0000000..f9c0c3d --- /dev/null +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityNoticeMapper.java @@ -0,0 +1,62 @@ +package com.inspur.community.mapper; + +import java.util.List; +import com.inspur.community.domain.CommunityNotice; + +/** + * 社区通知Mapper接口 + * + * @author zjw + * @date 2024-05-08 + */ +public interface CommunityNoticeMapper +{ + /** + * 查询社区通知 + * + * @param noticeId 社区通知主键 + * @return 社区通知 + */ + public CommunityNotice selectCommunityNoticeByNoticeId(String noticeId); + + /** + * 查询社区通知列表 + * + * @param communityNotice 社区通知 + * @return 社区通知集合 + */ + public List selectCommunityNoticeList(CommunityNotice communityNotice); + + /** + * 新增社区通知 + * + * @param communityNotice 社区通知 + * @return 结果 + */ + public int insertCommunityNotice(CommunityNotice communityNotice); + + /** + * 修改社区通知 + * + * @param communityNotice 社区通知 + * @return 结果 + */ + public int updateCommunityNotice(CommunityNotice communityNotice); + + /** + * 删除社区通知 + * + * @param noticeId 社区通知主键 + * @return 结果 + */ + public int deleteCommunityNoticeByNoticeId(String noticeId); + + /** + * 批量删除社区通知 + * + * @param noticeIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCommunityNoticeByNoticeIds(String[] noticeIds); +} + diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostLikeMapper.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostLikeMapper.java index aad0de4..39e93eb 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostLikeMapper.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/mapper/CommunityPostLikeMapper.java @@ -2,6 +2,7 @@ package com.inspur.community.mapper; import java.util.List; import com.inspur.community.domain.CommunityPostLike; +import com.inspur.community.domain.vo.CommunityPostLikeVO; import org.apache.ibatis.annotations.Param; /** @@ -28,6 +29,11 @@ public interface CommunityPostLikeMapper */ public List selectCommunityPostLikeList(CommunityPostLike communityPostLike); + /** + * 查询用户点赞的详细信息 + */ + public List selectCommunityPostLikeListByUserId(Long userId); + /** * 根据postid统计点赞数 */ diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityNoticeService.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityNoticeService.java new file mode 100644 index 0000000..2562eda --- /dev/null +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityNoticeService.java @@ -0,0 +1,62 @@ +package com.inspur.community.service; + +import java.util.List; +import com.inspur.community.domain.CommunityNotice; + +/** + * 社区通知Service接口 + * + * @author zjw + * @date 2024-05-08 + */ +public interface ICommunityNoticeService +{ + /** + * 查询社区通知 + * + * @param noticeId 社区通知主键 + * @return 社区通知 + */ + public CommunityNotice selectCommunityNoticeByNoticeId(String noticeId); + + /** + * 查询社区通知列表 + * + * @param communityNotice 社区通知 + * @return 社区通知集合 + */ + public List selectCommunityNoticeList(CommunityNotice communityNotice); + + /** + * 新增社区通知 + * + * @param communityNotice 社区通知 + * @return 结果 + */ + public int insertCommunityNotice(CommunityNotice communityNotice); + + /** + * 修改社区通知 + * + * @param communityNotice 社区通知 + * @return 结果 + */ + public int updateCommunityNotice(CommunityNotice communityNotice); + + /** + * 批量删除社区通知 + * + * @param noticeIds 需要删除的社区通知主键集合 + * @return 结果 + */ + public int deleteCommunityNoticeByNoticeIds(String[] noticeIds); + + /** + * 删除社区通知信息 + * + * @param noticeId 社区通知主键 + * @return 结果 + */ + public int deleteCommunityNoticeByNoticeId(String noticeId); +} + diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostLikeService.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostLikeService.java index 5ac9e3f..7931106 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostLikeService.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/ICommunityPostLikeService.java @@ -2,6 +2,7 @@ package com.inspur.community.service; import java.util.List; import com.inspur.community.domain.CommunityPostLike; +import com.inspur.community.domain.vo.CommunityPostLikeVO; /** * 社区点赞信息Service接口 @@ -27,6 +28,11 @@ public interface ICommunityPostLikeService */ public List selectCommunityPostLikeList(CommunityPostLike communityPostLike); + /** + * 查询用户点赞的详细信息 + */ + public List selectCommunityPostLikeListByUserId(Long userId); + /** * 新增社区点赞信息 * diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityNoticeServiceImpl.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityNoticeServiceImpl.java new file mode 100644 index 0000000..4f1e5d1 --- /dev/null +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityNoticeServiceImpl.java @@ -0,0 +1,111 @@ +package com.inspur.community.service.impl; + +import java.util.List; + +import com.inspur.common.utils.uuid.IdUtils; +import com.inspur.community.domain.CommunityPostReply; +import com.inspur.community.mapper.CommunityPostReplyMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.inspur.community.mapper.CommunityNoticeMapper; +import com.inspur.community.domain.CommunityNotice; +import com.inspur.community.service.ICommunityNoticeService; + +/** + * 社区通知Service业务层处理 + * + * @author zjw + * @date 2024-05-08 + */ +@Service +public class CommunityNoticeServiceImpl implements ICommunityNoticeService +{ + @Autowired + private CommunityNoticeMapper communityNoticeMapper; + + @Autowired + private CommunityPostReplyMapper communityPostReplyMapper; + + /** + * 查询社区通知 + * + * @param noticeId 社区通知主键 + * @return 社区通知 + */ + @Override + public CommunityNotice selectCommunityNoticeByNoticeId(String noticeId) + { + return communityNoticeMapper.selectCommunityNoticeByNoticeId(noticeId); + } + + /** + * 查询社区通知列表 + * + * @param communityNotice 社区通知 + * @return 社区通知 + */ + @Override + public List selectCommunityNoticeList(CommunityNotice communityNotice) + { + List list = communityNoticeMapper.selectCommunityNoticeList(communityNotice); + for (CommunityNotice notice : list) { + if(notice.getReplyId() == null || notice.getReplyId().equals("")){ + continue; + } + CommunityPostReply reply = communityPostReplyMapper.selectCommunityPostReplyByReplyId(notice.getReplyId()); + notice.setReplyContent(reply.getReplyContent()); + } + return list; + } + + /** + * 新增社区通知 + * + * @param communityNotice 社区通知 + * @return 结果 + */ + @Override + public int insertCommunityNotice(CommunityNotice communityNotice) + { + communityNotice.setNoticeId(IdUtils.simpleUUID()); + communityNotice.setStatus("0"); + return communityNoticeMapper.insertCommunityNotice(communityNotice); + } + + /** + * 修改社区通知 + * + * @param communityNotice 社区通知 + * @return 结果 + */ + @Override + public int updateCommunityNotice(CommunityNotice communityNotice) + { + return communityNoticeMapper.updateCommunityNotice(communityNotice); + } + + /** + * 批量删除社区通知 + * + * @param noticeIds 需要删除的社区通知主键 + * @return 结果 + */ + @Override + public int deleteCommunityNoticeByNoticeIds(String[] noticeIds) + { + return communityNoticeMapper.deleteCommunityNoticeByNoticeIds(noticeIds); + } + + /** + * 删除社区通知信息 + * + * @param noticeId 社区通知主键 + * @return 结果 + */ + @Override + public int deleteCommunityNoticeByNoticeId(String noticeId) + { + return communityNoticeMapper.deleteCommunityNoticeByNoticeId(noticeId); + } +} + diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostHeatServiceImpl.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostHeatServiceImpl.java index 10afe0b..ad1f94a 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostHeatServiceImpl.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostHeatServiceImpl.java @@ -1,6 +1,8 @@ package com.inspur.community.service.impl; import java.util.List; +import java.util.stream.Collectors; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.inspur.community.mapper.CommunityPostHeatMapper; @@ -40,7 +42,10 @@ public class CommunityPostHeatServiceImpl implements ICommunityPostHeatService @Override public List selectCommunityPostHeatList(CommunityPostHeat communityPostHeat) { - return communityPostHeatMapper.selectCommunityPostHeatList(communityPostHeat); + //排序 + List heatList = communityPostHeatMapper.selectCommunityPostHeatList(communityPostHeat); + heatList.stream().sorted((o1, o2) -> heatSortCalculate(o1).compareTo(heatSortCalculate(o2))).collect(Collectors.toList()); + return heatList; } /** @@ -90,5 +95,9 @@ public class CommunityPostHeatServiceImpl implements ICommunityPostHeatService { return communityPostHeatMapper.deleteCommunityPostHeatByPostId(postId); } + + private Double heatSortCalculate(CommunityPostHeat communityPostHeat){ + return 0.4 * communityPostHeat.getViews() + 0.6 * communityPostHeat.getReplies(); + } } diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostLikeServiceImpl.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostLikeServiceImpl.java index 8c83228..9a2dd15 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostLikeServiceImpl.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostLikeServiceImpl.java @@ -5,7 +5,12 @@ import java.util.List; import com.inspur.common.utils.DateUtils; import com.inspur.common.utils.SecurityUtils; +import com.inspur.community.domain.CommunityNotice; +import com.inspur.community.domain.CommunityPostReply; +import com.inspur.community.domain.vo.CommunityPostLikeVO; import com.inspur.community.mapper.CommunityPostHeatMapper; +import com.inspur.community.service.ICommunityNoticeService; +import com.inspur.community.service.ICommunityPostReplyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.inspur.community.mapper.CommunityPostLikeMapper; @@ -27,6 +32,11 @@ public class CommunityPostLikeServiceImpl implements ICommunityPostLikeService @Autowired private CommunityPostHeatMapper communityPostHeatMapper; + @Autowired + private ICommunityNoticeService communityNoticeService; + + @Autowired + private ICommunityPostReplyService communityPostReplyService; /** * 查询社区点赞信息 * @@ -51,6 +61,13 @@ public class CommunityPostLikeServiceImpl implements ICommunityPostLikeService return communityPostLikeMapper.selectCommunityPostLikeList(communityPostLike); } + /** + * 查询用户点赞的详细信息 + */ + public List selectCommunityPostLikeListByUserId(Long userId){ + return communityPostLikeMapper.selectCommunityPostLikeListByUserId(userId); + } + /** * 新增社区点赞信息 * @@ -63,8 +80,19 @@ public class CommunityPostLikeServiceImpl implements ICommunityPostLikeService communityPostLike.setUserId(SecurityUtils.getLoginUser().getUserId()); communityPostLike.setLikeTime(new Date()); //增加热度榜点赞记录加一 - - return communityPostLikeMapper.insertCommunityPostLike(communityPostLike); + //增加通知 + CommunityNotice communityNotice = new CommunityNotice(); + CommunityPostReply postReply = communityPostReplyService.selectCommunityPostReplyByReplyId(communityPostLike.getLikePostId()); + if(postReply!=null){ + communityNotice.setPostId(postReply.getPostId()); +// communityNotice.setPostName(postReply.getReplyContent()); + communityNotice.setUserId(postReply.getUserId()); + communityNotice.setReplyContent(postReply.getReplyContent()); + communityNotice.setReplyId(postReply.getReplyId()); + communityNotice.setNoticeType("1"); + communityNotice.setRemark(postReply.getReplyTime()); + } + return communityPostLikeMapper.insertCommunityPostLike(communityPostLike) & communityNoticeService.insertCommunityNotice(communityNotice); } /** diff --git a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReplyServiceImpl.java b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReplyServiceImpl.java index 7b8d48e..4bf8dbd 100644 --- a/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReplyServiceImpl.java +++ b/inspur-service/inspur-community/src/main/java/com/inspur/community/service/impl/CommunityPostReplyServiceImpl.java @@ -8,15 +8,12 @@ import com.inspur.common.core.domain.entity.SysUser; import com.inspur.common.utils.DateUtils; import com.inspur.common.utils.SecurityUtils; import com.inspur.common.utils.uuid.IdUtils; -import com.inspur.community.domain.CommunityComment; -import com.inspur.community.domain.CommunityPostLike; -import com.inspur.community.mapper.CommunityPostHeatMapper; -import com.inspur.community.mapper.CommunityPostLikeMapper; +import com.inspur.community.domain.*; +import com.inspur.community.domain.vo.CommunityPostInfoVO; +import com.inspur.community.mapper.*; import com.inspur.system.mapper.SysUserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.inspur.community.mapper.CommunityPostReplyMapper; -import com.inspur.community.domain.CommunityPostReply; import com.inspur.community.service.ICommunityPostReplyService; import org.springframework.transaction.annotation.Transactional; @@ -43,6 +40,12 @@ public class CommunityPostReplyServiceImpl implements ICommunityPostReplyService @Autowired private CommunityPostHeatMapper communityPostHeatMapper; + @Autowired + private CommunityNoticeMapper communityNoticeMapper; + + @Autowired + private CommunityPostInfoMapper communityPostInfoMapper; + /** * 查询社区帖子回复 * @@ -158,7 +161,27 @@ public class CommunityPostReplyServiceImpl implements ICommunityPostReplyService communityPostReply.setUserId(SecurityUtils.getLoginUser().getUserId()); communityPostReply.setReplyTime(DateUtils.dateTimeNow(DateUtils.YYYY_MM_DD_HH_MM_SS)); //帖子热度回复量加一 - return communityPostReplyMapper.insertCommunityPostReply(communityPostReply) & communityPostHeatMapper.addReplies(communityPostReply.getPostId()); + //添加通知 + CommunityNotice notice = new CommunityNotice(); + notice.setNoticeId(IdUtils.simpleUUID()); + notice.setStatus("0"); + if("0".equals(communityPostReply.getParentReplyId())){//给发贴人添加通知 + notice.setPostId(communityPostReply.getPostId()); + CommunityPostInfoVO post = communityPostInfoMapper.selectCommunityPostInfoByPostId(communityPostReply.getPostId()); + notice.setUserId(post.getUserId()); + notice.setNoticeType("2"); + notice.setPostName(post.getPostTitle()); + notice.setRemark(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,post.getPostTime())); + }else{//给评论人添加通知 + notice.setReplyId(communityPostReply.getParentReplyId()); + CommunityPostReply parentReply = communityPostReplyMapper.selectCommunityPostReplyByReplyId(communityPostReply.getParentReplyId()); + notice.setUserId(parentReply.getUserId()); + notice.setNoticeType("2"); + notice.setReplyContent(parentReply.getReplyContent()); + notice.setRemark(parentReply.getReplyTime()); + } + return communityPostReplyMapper.insertCommunityPostReply(communityPostReply) & communityPostHeatMapper.addReplies(communityPostReply.getPostId()) + & communityNoticeMapper.insertCommunityNotice(notice); } /** diff --git a/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityNoticeMapper.xml b/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityNoticeMapper.xml new file mode 100644 index 0000000..06c8a34 --- /dev/null +++ b/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityNoticeMapper.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + select notice_id, post_id, reply_id, user_id, reply_content, post_name, notice_type, remark, status from community_notice + + + + + + + + insert into community_notice + + notice_id, + post_id, + reply_id, + user_id, + reply_content, + post_name, + notice_type, + remark, + status, + + + #{noticeId}, + #{postId}, + #{replyId}, + #{userId}, + #{replyContent}, + #{postName}, + #{noticeType}, + #{remark}, + #{status}, + + + + + update community_notice + + post_id = #{postId}, + reply_id = #{replyId}, + user_id = #{userId}, + reply_content = #{replyContent}, + post_name = #{postName}, + notice_type = #{noticeType}, + remark = #{remark}, + status = #{status}, + + where notice_id = #{noticeId} + + + + delete from community_notice where notice_id = #{noticeId} + + + + delete from community_notice where notice_id in + + #{noticeId} + + + \ No newline at end of file diff --git a/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostHeatMapper.xml b/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostHeatMapper.xml index 82f8933..d732e2e 100644 --- a/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostHeatMapper.xml +++ b/inspur-service/inspur-community/src/main/resources/mapper/community/CommunityPostHeatMapper.xml @@ -37,7 +37,6 @@ and post_id = #{postId} and likes = #{likes} and views = #{views} - order by a.views * 0.4 + a.replies * 0.6 desc @@ -28,6 +69,11 @@ where user_id = #{userId} + +