1.新增删除公告
2.优化新增公告
This commit is contained in:
@@ -178,6 +178,12 @@ public class RoomController {
|
||||
return ApiResult.success(roomService.pushAnnouncement(RequestHolder.get().getUid(), param));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除公告")
|
||||
@PostMapping("announcement/delete/{id}")
|
||||
public ApiResult announcementDelete(@PathVariable("id") Long id){
|
||||
return ApiResult.success(roomService.announcementDelete(RequestHolder.get().getUid(), id));
|
||||
}
|
||||
|
||||
@Operation(summary = "已读公告")
|
||||
@PostMapping("announcement/read")
|
||||
public ApiResult readAnnouncement(@RequestBody ReadAnnouncementsParam param){
|
||||
|
||||
@@ -5,7 +5,6 @@ import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 聊天公告
|
||||
@@ -16,10 +15,6 @@ public class AnnouncementsParam implements Serializable {
|
||||
@NotNull(message = "请选择群聊")
|
||||
private Long roomId;
|
||||
|
||||
private Long uid;
|
||||
|
||||
@NotEmpty(message = "请输入公告内容")
|
||||
private String content;
|
||||
|
||||
private LocalDateTime publishTime;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,11 @@ public interface RoomAppService {
|
||||
*/
|
||||
AnnouncementsResp getAnnouncement(Long uid, ReadAnnouncementsParam param);
|
||||
|
||||
/**
|
||||
* 删除公告
|
||||
*/
|
||||
Boolean announcementDelete(Long uid, Long id);
|
||||
|
||||
/**
|
||||
* 隐藏会话
|
||||
* @return
|
||||
|
||||
@@ -2,14 +2,12 @@ package com.hula.core.chat.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.hula.common.domain.po.RoomChatInfoPO;
|
||||
import com.hula.common.domain.vo.res.GroupListVO;
|
||||
import com.hula.core.chat.domain.entity.Announcements;
|
||||
import com.hula.core.chat.domain.entity.AnnouncementsReadRecord;
|
||||
import com.hula.core.chat.domain.entity.RoomFriend;
|
||||
import com.hula.core.chat.domain.entity.RoomGroup;
|
||||
import com.hula.core.chat.domain.vo.request.GroupAddReq;
|
||||
import com.hula.core.chat.domain.vo.request.room.AnnouncementsParam;
|
||||
import com.hula.core.chat.domain.vo.response.AnnouncementsResp;
|
||||
|
||||
import java.util.List;
|
||||
@@ -68,6 +66,11 @@ public interface RoomService {
|
||||
*/
|
||||
Boolean readAnnouncement(Long uid, Long announcementId);
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
*/
|
||||
IPage<Announcements> announcementList(Long roomId, IPage<Announcements> page);
|
||||
|
||||
/**
|
||||
* 查询公告
|
||||
*/
|
||||
@@ -78,6 +81,11 @@ public interface RoomService {
|
||||
*/
|
||||
Long getAnnouncementReadCount(Long announcementId);
|
||||
|
||||
/**
|
||||
* 删除指定公告
|
||||
*/
|
||||
Boolean announcementDelete(Long id);
|
||||
|
||||
/**
|
||||
* 保存群公告
|
||||
*/
|
||||
@@ -97,6 +105,4 @@ public interface RoomService {
|
||||
* 创建群成员
|
||||
*/
|
||||
void createGroupMember(Long groupId, Long uid);
|
||||
|
||||
IPage<Announcements> announcementList(Long roomId, IPage<Announcements> page);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ import org.springframework.data.redis.core.ZSetOperations;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
@@ -277,7 +276,8 @@ public class RoomAppServiceImpl implements RoomAppService {
|
||||
|
||||
@Override
|
||||
public Boolean pushAnnouncement(Long uid, AnnouncementsParam param) {
|
||||
List<Long> uids = roomService.getGroupUsers(param.getRoomId(), false);
|
||||
RoomGroup roomGroup = roomGroupCache.get(param.getRoomId());
|
||||
List<Long> uids = roomService.getGroupUsers(roomGroup.getId(), false);
|
||||
if(CollUtil.isNotEmpty(uids)){
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
pushService.sendPushMsg(MessageAdapter.buildRoomGroupAnnouncement(param.getContent()), uids, uid);
|
||||
@@ -344,6 +344,19 @@ public class RoomAppServiceImpl implements RoomAppService {
|
||||
return announcement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean announcementDelete(Long uid, Long id) {
|
||||
// 1. 鉴权
|
||||
RoomGroup roomGroup = roomGroupCache.get(id);
|
||||
GroupMember groupMember = verifyGroupPermissions(uid, roomGroup);
|
||||
|
||||
if(GroupRoleEnum.MEMBER.getType().equals(groupMember.getRole())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return roomService.announcementDelete(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean setHide(Long uid, ContactHideReq req) {
|
||||
return contactDao.setHide(uid, req.getRoomId(), req.getHide());
|
||||
|
||||
@@ -147,6 +147,11 @@ public class RoomServiceImpl implements RoomService {
|
||||
.eq(AnnouncementsReadRecord::getAnnouncementsId, announcementId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean announcementDelete(Long id) {
|
||||
return announcementsDao.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean saveAnnouncements(Announcements announcements) {
|
||||
return announcementsDao.save(announcements);
|
||||
|
||||
Reference in New Issue
Block a user