feat: 消息详情和部分缺陷修复

This commit is contained in:
bunny 2024-11-01 16:40:45 +08:00
parent 9a7303c596
commit a427c38fcb
17 changed files with 322 additions and 116 deletions

View File

@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@Slf4j
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

View File

@ -54,12 +54,10 @@ public class MessageAddDto {
@Schema(name = "status", title = "0:未读 1:已读")
private Boolean status = false;
@Schema(name = "level", title = "消息等级")
private String level;
@Schema(name = "extra", title = "消息等级详情")
private String extra;
}

View File

@ -0,0 +1,21 @@
package cn.bunny.dao.dto.system.message;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "MessageUserDto对象", title = "用户消息查询内容", description = "用户消息查询内容")
public class MessageUserDto {
@Schema(name = "messageType", title = "消息类型")
private String messageType;
@Schema(name = "status", title = "0:未读 1:已读")
private Boolean status;
}

View File

@ -2,6 +2,7 @@ package cn.bunny.dao.dto.system.router;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
@ -44,6 +45,8 @@ public class RouterAddDto {
@Schema(name = "routerRank", title = "等级")
@JsonProperty("rank")
@NotNull(message = "菜单排序不能为空")
@Max(value = 999, message = "不能超过999")
private Integer routerRank = 99;
@Schema(name = "icon", title = "图标")

View File

@ -2,6 +2,7 @@ package cn.bunny.dao.dto.system.router;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
@ -48,6 +49,8 @@ public class RouterUpdateDto {
@Schema(name = "routerRank", title = "等级")
@JsonProperty("rank")
@NotNull(message = "菜单排序不能为空")
@Max(value = 999, message = "不能超过999")
private Integer routerRank;
@Schema(name = "icon", title = "图标")

View File

@ -0,0 +1,35 @@
package cn.bunny.dao.vo.system.message;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "MessageReceivedWithUser对象", title = "消息接收人用户名等信息", description = "消息接收人用户名等信息")
public class MessageReceivedWithUserVo {
@Schema(name = "receivedUserId", title = "接受者id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JSONField(serializeUsing = ToStringSerializer.class)
private Long receivedUserId;
@Schema(name = "messageId", title = "消息ID")
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JSONField(serializeUsing = ToStringSerializer.class)
private Long messageId;
@Schema(name = "username", title = "用户名")
private String username;
@Schema(name = "nickname", title = "昵称")
private String nickname;
}

View File

@ -1,5 +1,9 @@
package cn.bunny.dao.vo.system.message;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
@ -13,6 +17,12 @@ import lombok.NoArgsConstructor;
@Schema(name = "MessageVo对象", title = "系统消息返回内容", description = "系统消息返回内容")
public class MessageUserVo {
@Schema(name = "id", title = "主键")
@JsonProperty("id")
@JsonFormat(shape = JsonFormat.Shape.STRING)
@JSONField(serializeUsing = ToStringSerializer.class)
private Long id;
@Schema(name = "title", title = "消息标题")
private String title;

View File

@ -3,6 +3,7 @@ package cn.bunny.services.controller;
import cn.bunny.dao.dto.system.message.MessageAddDto;
import cn.bunny.dao.dto.system.message.MessageDto;
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
import cn.bunny.dao.dto.system.message.MessageUserDto;
import cn.bunny.dao.entity.system.Message;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
@ -51,17 +52,25 @@ public class MessageController {
}
@Operation(summary = "分页查询用户消息", description = "分页查询用户消息")
@GetMapping("getUserMessageList/{page}/{limit}")
@GetMapping("/noManage/getUserMessageList/{page}/{limit}")
public Mono<Result<PageResult<MessageUserVo>>> getUserMessageList(
@Parameter(name = "page", description = "当前页", required = true)
@PathVariable("page") Integer page,
@Parameter(name = "limit", description = "每页记录数", required = true)
@PathVariable("limit") Integer limit) {
@PathVariable("limit") Integer limit,
MessageUserDto dto) {
Page<Message> pageParams = new Page<>(page, limit);
PageResult<MessageUserVo> pageResult = messageService.getUserMessageList(pageParams);
PageResult<MessageUserVo> pageResult = messageService.getUserMessageList(pageParams, dto);
return Mono.just(Result.success(pageResult));
}
@Operation(summary = "根据消息id查询消息详情", description = "根据消息id查询消息详情")
@GetMapping("/noManage/getMessageDetailById")
public Mono<Result<MessageVo>> getMessageDetailById(Long id) {
MessageVo vo = messageService.getMessageDetailById(id);
return Mono.just(Result.success(vo));
}
@Operation(summary = "添加系统消息", description = "添加系统消息")
@PostMapping("addMessage")
public Mono<Result<String>> addMessage(@Valid @RequestBody MessageAddDto dto) {

View File

@ -1,18 +1,36 @@
package cn.bunny.services.controller;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.dao.vo.system.message.MessageReceivedWithUserVo;
import cn.bunny.services.service.MessageReceivedService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import java.util.List;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author Bunny
* @since 2024-10-31
*/
@RestController
@RequestMapping("/messageReceived")
@RequestMapping("/admin/messageReceived")
public class MessageReceivedController {
@Autowired
private MessageReceivedService messageReceivedService;
@Operation(summary = "根据消息id获取接收人信息", description = "根据消息id获取接收人信息")
@GetMapping("noManage/getReceivedUserinfoByMessageId")
public Mono<Result<List<MessageReceivedWithUserVo>>> getReceivedUserinfoByMessageId(Long messageId) {
List<MessageReceivedWithUserVo> voList = messageReceivedService.getReceivedUserinfoByMessageId(messageId);
return Mono.just(Result.success(voList));
}
}

View File

@ -1,8 +1,8 @@
package cn.bunny.services.mapper;
import cn.bunny.dao.dto.system.message.MessageDto;
import cn.bunny.dao.dto.system.message.MessageUserDto;
import cn.bunny.dao.entity.system.Message;
import cn.bunny.dao.vo.system.message.MessageUserVo;
import cn.bunny.dao.vo.system.message.MessageVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -40,10 +40,19 @@ public interface MessageMapper extends BaseMapper<Message> {
void deleteBatchIdsWithPhysics(List<Long> ids);
/**
* 分页查询用户消息
* 根据消息所有包含匹配当前消息Id的列表
*
* @param pageParams 系统消息返回列表
* @return 分页结果
* @param pageParams 系统消息分页参数
* @param dto 系统消息查询表单
* @return 系统消息分页结果
*/
IPage<MessageUserVo> selectUserMessageList(@Param("page") Page<Message> pageParams, Long userId);
IPage<Message> selectListByPageWithMessageUserDto(@Param("page") Page<Message> pageParams, @Param("dto") MessageUserDto dto, @Param("messageIds") List<Long> messageIds);
/**
* 根据消息id查询消息详情
*
* @param id 消息id
* @return 消息返回对象
*/
MessageVo selectMessageVoById(Long id);
}

View File

@ -1,6 +1,7 @@
package cn.bunny.services.mapper;
import cn.bunny.dao.entity.system.MessageReceived;
import cn.bunny.dao.vo.system.message.MessageReceivedWithUserVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@ -30,4 +31,12 @@ public interface MessageReceivedMapper extends BaseMapper<MessageReceived> {
* @param ids 消息id
*/
void deleteBatchIdsByMessageIdsWithPhysics(List<Long> ids);
/**
* 根据发送者id批量删除消息接受者
*
* @param messageId 消息id
* @return 消息接收人用户名等信息
*/
List<MessageReceivedWithUserVo> selectUserinfoListByMessageId(Long messageId);
}

View File

@ -1,6 +1,7 @@
package cn.bunny.services.service;
import cn.bunny.dao.entity.system.MessageReceived;
import cn.bunny.dao.vo.system.message.MessageReceivedWithUserVo;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@ -21,4 +22,12 @@ public interface MessageReceivedService extends IService<MessageReceived> {
* @param sendUserIds 发送用户ID
*/
void deleteBatchIdsWithPhysics(List<Long> sendUserIds);
/**
* 根据消息id获取接收人信息
*
* @param messageId 消息id
* @return 消息接收人用户名等信息
*/
List<MessageReceivedWithUserVo> getReceivedUserinfoByMessageId(Long messageId);
}

View File

@ -3,6 +3,7 @@ package cn.bunny.services.service;
import cn.bunny.dao.dto.system.message.MessageAddDto;
import cn.bunny.dao.dto.system.message.MessageDto;
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
import cn.bunny.dao.dto.system.message.MessageUserDto;
import cn.bunny.dao.entity.system.Message;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.system.message.MessageUserVo;
@ -55,7 +56,16 @@ public interface MessageService extends IService<Message> {
* 分页查询用户消息
*
* @param pageParams 系统消息返回列表
* @param dto 查询表单
* @return 分页结果
*/
PageResult<MessageUserVo> getUserMessageList(Page<Message> pageParams);
PageResult<MessageUserVo> getUserMessageList(Page<Message> pageParams, MessageUserDto dto);
/**
* 根据消息id查询消息详情
*
* @param id 消息id
* @return 消息详情
*/
MessageVo getMessageDetailById(Long id);
}

View File

@ -1,6 +1,9 @@
package cn.bunny.services.service.impl;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.entity.system.MessageReceived;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.system.message.MessageReceivedWithUserVo;
import cn.bunny.services.mapper.MessageReceivedMapper;
import cn.bunny.services.service.MessageReceivedService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -28,4 +31,19 @@ public class MessageReceivedServiceImpl extends ServiceImpl<MessageReceivedMappe
public void deleteBatchIdsWithPhysics(List<Long> sendUserIds) {
baseMapper.deleteBatchIdsWithPhysics(sendUserIds);
}
/**
* 根据消息id获取接收人信息
*
* @param messageId 消息id
* @return 消息接收人用户名等信息
*/
@Override
public List<MessageReceivedWithUserVo> getReceivedUserinfoByMessageId(Long messageId) {
if (messageId == null) {
throw new BunnyException(ResultCodeEnum.REQUEST_IS_EMPTY);
}
return baseMapper.selectUserinfoListByMessageId(messageId);
}
}

View File

@ -5,6 +5,7 @@ import cn.bunny.dao.common.entity.BaseEntity;
import cn.bunny.dao.dto.system.message.MessageAddDto;
import cn.bunny.dao.dto.system.message.MessageDto;
import cn.bunny.dao.dto.system.message.MessageUpdateDto;
import cn.bunny.dao.dto.system.message.MessageUserDto;
import cn.bunny.dao.entity.system.Message;
import cn.bunny.dao.entity.system.MessageReceived;
import cn.bunny.dao.pojo.result.PageResult;
@ -61,8 +62,8 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
*/
@Override
public PageResult<MessageVo> getMessageList(Page<Message> pageParams, MessageDto dto) {
// 分页查询消息数据
IPage<MessageVo> page = baseMapper.selectListByPage(pageParams, dto);
List<MessageVo> voList = page.getRecords().stream().map(messageVo -> {
MessageVo vo = new MessageVo();
BeanUtils.copyProperties(messageVo, vo);
@ -81,108 +82,25 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
.build();
}
/**
* 添加系统消息
*
* @param dto 系统消息添加
*/
@Override
public void addMessage(@Valid MessageAddDto dto) {
// 如果发送人为空设置当前登录的人的ID
Long sendUserId = dto.getSendUserId();
if (sendUserId == null) dto.setSendUserId(BaseContext.getUserId());
// 接受人id列表
List<Long> receivedUserIds = dto.getReceivedUserIds();
// 如果接收人为空默认接收全部人
if (receivedUserIds.isEmpty()) {
List<Long> userIds = userMapper.selectList(null).stream().map(BaseEntity::getId).toList();
dto.setReceivedUserIds(userIds);
}
// 保存消息数据
Message message = new Message();
BeanUtils.copyProperties(dto, message);
save(message);
// 保存消息和用户之间关联数据
List<MessageReceived> receivedList = receivedUserIds.stream().map(id -> {
MessageReceived messageReceived = new MessageReceived();
messageReceived.setMessageId(dto.getSendUserId());
messageReceived.setReceivedUserId(id);
return messageReceived;
}).toList();
messageReceivedService.saveBatch(receivedList);
}
/**
* 更新系统消息
*
* @param dto 系统消息更新
*/
@Override
public void updateMessage(@Valid MessageUpdateDto dto) {
// 如果发送人为空设置当前登录的人的ID
Long sendUserId = dto.getSendUserId();
if (sendUserId == null) dto.setSendUserId(BaseContext.getUserId());
// 接受人id列表
List<Long> receivedUserIds = dto.getReceivedUserIds();
// 如果接收人为空默认接收全部人
if (receivedUserIds.isEmpty()) {
List<Long> userIds = userMapper.selectList(null).stream().map(BaseEntity::getId).toList();
dto.setReceivedUserIds(userIds);
}
// 更新内容
Message message = new Message();
BeanUtils.copyProperties(dto, message);
updateById(message);
// 删除这个消息接受下所有发送者
if (sendUserId != null) {
messageReceivedMapper.deleteBatchIdsWithPhysics(List.of(sendUserId));
}
// 保存消息和用户之间关联数据
List<MessageReceived> receivedList = receivedUserIds.stream().map(id -> {
MessageReceived messageReceived = new MessageReceived();
messageReceived.setMessageId(dto.getSendUserId());
messageReceived.setReceivedUserId(id);
return messageReceived;
}).toList();
messageReceivedService.saveBatch(receivedList);
}
/**
* 删除|批量删除系统消息
*
* @param ids 删除id列表
*/
@Override
public void deleteMessage(List<Long> ids) {
baseMapper.deleteBatchIdsWithPhysics(ids);
// 根据消息Id物理删除接受者消息
messageReceivedMapper.deleteBatchIdsByMessageIdsWithPhysics(ids);
}
/**
* 分页查询用户消息
* 用户在主页查询内容为是否已读和消息类型
* 为了方便用户之后进入消息详情页面查询按照消息类型查询消息
* 也可以查询消息是否已读
* 节省带宽的情况下传给前端消息详情等内容
*
* @param pageParams 系统消息返回列表
* @param dto 用户消息查询内容"
* @return 分页结果
*/
@Override
public PageResult<MessageUserVo> getUserMessageList(Page<Message> pageParams) {
// 查询当前用户接收的消息的接收者关系表
public PageResult<MessageUserVo> getUserMessageList(Page<Message> pageParams, MessageUserDto dto) {
// 查询当前用户需要接收的消息id
List<MessageReceived> messageReceivedList = messageReceivedMapper.selectList(Wrappers.<MessageReceived>lambdaQuery().eq(MessageReceived::getReceivedUserId, BaseContext.getUserId()));
List<Long> messageIds = messageReceivedList.stream().map(MessageReceived::getMessageId).toList();
// 根据消息所有包含匹配当前消息Id的列表
Page<Message> page = page(pageParams, Wrappers.<Message>lambdaQuery().in(Message::getId, messageIds));
IPage<Message> page = baseMapper.selectListByPageWithMessageUserDto(pageParams, dto, messageIds);
List<MessageUserVo> voList = page.getRecords().stream().map(messageVo -> {
MessageUserVo vo = new MessageUserVo();
BeanUtils.copyProperties(messageVo, vo);
@ -200,4 +118,104 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
.total(page.getTotal())
.build();
}
/**
* 根据消息id查询消息详情
*
* @param id 消息id
* @return 消息详情
*/
@Override
public MessageVo getMessageDetailById(Long id) {
return baseMapper.selectMessageVoById(id);
}
/**
* 添加系统消息
* 判断发送消息的接收人是否为空如果为空默认是所有用户都是接受者
* 之后要将消息的接受者要保存在消息接收表中在这之前是没有消息id的
* 先要保存消息内容之后获取到保存消息的id
* 将消息的id和接收者的id构建成map插入到消息接收表中
*
* @param dto 系统消息添加
*/
@Override
public void addMessage(@Valid MessageAddDto dto) {
// 如果发送人为空设置当前登录的人的ID
if (dto.getSendUserId() == null) dto.setSendUserId(BaseContext.getUserId());
// 先保存消息数据之后拿到保存消息的id
Message message = new Message();
BeanUtils.copyProperties(dto, message);
save(message);
// 如果接收人为空默认接收全部人
List<Long> receivedUserIds = dto.getReceivedUserIds();
if (receivedUserIds.isEmpty()) {
receivedUserIds = userMapper.selectList(null).stream().map(BaseEntity::getId).toList();
}
// 从之前保存的消息中获取消息id保存到消息接收表中
List<MessageReceived> receivedList = receivedUserIds.stream().map(id -> {
MessageReceived messageReceived = new MessageReceived();
messageReceived.setMessageId(message.getId());
messageReceived.setReceivedUserId(id);
return messageReceived;
}).toList();
messageReceivedService.saveBatch(receivedList);
}
/**
* 更新系统消息
*
* @param dto 系统消息更新
*/
@Override
public void updateMessage(@Valid MessageUpdateDto dto) {
// 如果发送人为空设置当前登录的人的ID
Long sendUserId = dto.getSendUserId();
if (sendUserId == null) dto.setSendUserId(BaseContext.getUserId());
// 如果接收人为空默认接收全部人
List<Long> receivedUserIds = dto.getReceivedUserIds();
if (receivedUserIds.isEmpty()) {
receivedUserIds = userMapper.selectList(null).stream().map(BaseEntity::getId).toList();
}
// 更新内容
Message message = new Message();
BeanUtils.copyProperties(dto, message);
updateById(message);
// 保存消息和用户之间关联数据
List<MessageReceived> receivedList = receivedUserIds.stream().map(id -> {
MessageReceived messageReceived = new MessageReceived();
messageReceived.setMessageId(dto.getId());
messageReceived.setReceivedUserId(id);
return messageReceived;
}).toList();
// 删除这个消息接受下所有发送者
messageReceivedMapper.deleteBatchIdsByMessageIdsWithPhysics(List.of(dto.getId()));
// 插入接收者和消息表
messageReceivedService.saveBatch(receivedList);
}
/**
* 删除|批量删除系统消息
* 删除消息表中的数据还要删除消息接收表中的消息
* 消息接收表根据消息id进行删除
*
* @param ids 删除id列表
*/
@Override
public void deleteMessage(List<Long> ids) {
// 物理删除消息表数据
baseMapper.deleteBatchIdsWithPhysics(ids);
// 根据消息Id物理删除接受者消息
messageReceivedMapper.deleteBatchIdsByMessageIdsWithPhysics(ids);
}
}

View File

@ -11,7 +11,6 @@
<id column="update_user" property="updateUser"/>
<id column="is_deleted" property="isDeleted"/>
<id column="title" property="title"/>
<id column="received_user_ids" property="receivedUserIds"/>
<id column="send_user_id" property="sendUserId"/>
<id column="message_type" property="messageType"/>
<id column="content" property="content"/>
@ -25,7 +24,8 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, create_time, update_time, create_user, update_user, is_deleted, title, received_user_ids, send_user_id, send_nick_name, message_type, content, editor_type, status, level, extra
id
, create_time, update_time, create_user, update_user, is_deleted, title, send_user_id, message_type, content, cover, summary, editor_type, status,level,extra
</sql>
<!-- 分页查询系统消息内容 -->
@ -34,13 +34,11 @@
message.*,
create_user.username as create_username,
update_user.username as update_username,
send_user.nickname as send_nickname,
message_recived.received_user_id as message_recivedids
send_user.nickname as send_nickname
from sys_message message
left join sys_user create_user on create_user.id = message.create_user
left join sys_user update_user on update_user.id = message.update_user
left join sys_user send_user on send_user.id = message.send_user_id
left join sys_message_recived message_recived on message_recived.message_id = message.id
<where>
message.is_deleted = 0
<if test="dto.title != null and dto.title != ''">
@ -65,7 +63,7 @@
and message.level = #{dto.level}
</if>
<if test="dto.extra != null and dto.extra != ''">
and message.extra = #{dto.extra}
and message.extra like CONCAT('%',#{dto.extra},'%')
</if>
<if test="dto.status != null">
and message.status = #{dto.status}
@ -73,11 +71,36 @@
</where>
</select>
<!-- 分页查询用户消息 -->
<select id="selectUserMessageList" resultType="cn.bunny.dao.vo.system.message.MessageUserVo">
<!-- 根据消息所有包含匹配当前消息Id的列表 -->
<select id="selectListByPageWithMessageUserDto" resultType="cn.bunny.dao.entity.system.Message">
select
<include refid="Base_Column_List"/>
from sys_message
<where>
<if test="messageIds != null">
id in
<foreach collection="messageIds" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="dto.status != null">
and status = #{dto.status}
</if>
<if test="dto.messageType != null and dto.messageType != ''">
and message_type like CONCAT('%',#{dto.messageType},'%')
</if>
</where>
</select>
<!-- 根据消息id查询消息详情 -->
<select id="selectMessageVoById" resultType="cn.bunny.dao.vo.system.message.MessageVo">
SELECT message.*,
send_user.nickname AS send_nickname
FROM sys_message message
LEFT JOIN sys_user update_user ON update_user.id = message.update_user
LEFT JOIN sys_user send_user ON send_user.id = message.send_user_id
WHERE message.id = #{id}
</select>
<!-- 物理删除系统消息 -->
<delete id="deleteBatchIdsWithPhysics">

View File

@ -17,7 +17,7 @@
<!-- 根据发送者id批量删除 -->
<delete id="deleteBatchIdsWithPhysics">
delete
from sys_message_recived
from sys_message_received
where received_user_id in
<foreach collection="userIds" item="id" open="(" close=")" separator=",">
#{id}
@ -27,11 +27,23 @@
<!-- 根据消息Id物理删除-->
<delete id="deleteBatchIdsByMessageIdsWithPhysics">
delete
from sys_message_recived
from sys_message_received
where message_id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<!-- 根据发送者id批量删除消息接受者 -->
<select id="selectUserinfoListByMessageId"
resultType="cn.bunny.dao.vo.system.message.MessageReceivedWithUserVo">
SELECT message_received.message_id,
message_received.received_user_id,
USER.nickname,
USER.username
FROM sys_message_received message_received
LEFT JOIN sys_user USER ON USER.id = message_received.received_user_id
where message_received.message_id = #{messageId}
</select>
</mapper>