feat: 消息发送缺陷修复
This commit is contained in:
parent
0c1d00d864
commit
4ebc7c3a69
|
@ -26,7 +26,6 @@ public class MessageAddDto {
|
|||
private List<Long> receivedUserIds;
|
||||
|
||||
@Schema(name = "sendUserId", title = "发送人用户ID")
|
||||
@NotNull(message = "发送人用户ID 不能为空")
|
||||
private Long sendUserId;
|
||||
|
||||
@Schema(name = "messageType", title = "消息类型")
|
||||
|
@ -34,6 +33,14 @@ public class MessageAddDto {
|
|||
@NotNull(message = "消息类型 不能为空")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "cover", title = "封面")
|
||||
private String cover;
|
||||
|
||||
@Schema(name = "summary", title = "消息简介")
|
||||
@NotBlank(message = "消息简介 不能为空")
|
||||
@NotNull(message = "消息简介 不能为空")
|
||||
private String summary;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
@NotBlank(message = "消息内容 不能为空")
|
||||
@NotNull(message = "消息内容 不能为空")
|
||||
|
|
|
@ -38,6 +38,14 @@ public class MessageUpdateDto {
|
|||
@NotNull(message = "消息类型 不能为空")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "cover", title = "封面")
|
||||
private String cover;
|
||||
|
||||
@Schema(name = "summary", title = "消息简介")
|
||||
@NotBlank(message = "消息简介 不能为空")
|
||||
@NotNull(message = "消息简介 不能为空")
|
||||
private String summary;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
@NotBlank(message = "消息内容 不能为空")
|
||||
@NotNull(message = "消息内容 不能为空")
|
||||
|
|
|
@ -34,6 +34,12 @@ public class Message extends BaseEntity {
|
|||
@Schema(name = "messageType", title = "sys:系统消息,user用户消息")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "cover", title = "封面")
|
||||
private String cover;
|
||||
|
||||
@Schema(name = "summary", title = "消息简介")
|
||||
private String summary;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
private String content;
|
||||
|
||||
|
|
|
@ -32,6 +32,12 @@ public class MessageVo extends BaseUserVo {
|
|||
@Schema(name = "messageType", title = "sys:系统消息,user用户消息")
|
||||
private String messageType;
|
||||
|
||||
@Schema(name = "cover", title = "封面")
|
||||
private String cover;
|
||||
|
||||
@Schema(name = "summary", title = "消息简介")
|
||||
private String summary;
|
||||
|
||||
@Schema(name = "content", title = "消息内容")
|
||||
private String content;
|
||||
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package cn.bunny.services.service.impl;
|
||||
|
||||
import cn.bunny.common.service.context.BaseContext;
|
||||
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.entity.system.Message;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.dao.vo.system.message.MessageVo;
|
||||
import cn.bunny.services.factory.UserFactory;
|
||||
import cn.bunny.services.mapper.MessageMapper;
|
||||
import cn.bunny.services.mapper.UserMapper;
|
||||
import cn.bunny.services.service.MessageService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -14,6 +18,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import jakarta.validation.Valid;
|
||||
import jodd.util.StringUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -29,6 +34,12 @@ import java.util.List;
|
|||
@Service
|
||||
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private UserFactory userFactory;
|
||||
|
||||
/**
|
||||
* * 系统消息 服务实现类
|
||||
*
|
||||
|
@ -43,6 +54,11 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
|
|||
List<MessageVo> voList = page.getRecords().stream().map(messageVo -> {
|
||||
MessageVo vo = new MessageVo();
|
||||
BeanUtils.copyProperties(messageVo, vo);
|
||||
|
||||
// 设置封面返回内容
|
||||
String cover = vo.getCover();
|
||||
cover = userFactory.checkGetUserAvatar(cover);
|
||||
vo.setCover(cover);
|
||||
return vo;
|
||||
}).toList();
|
||||
return PageResult.<MessageVo>builder()
|
||||
|
@ -60,6 +76,16 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
|
|||
*/
|
||||
@Override
|
||||
public void addMessage(@Valid MessageAddDto dto) {
|
||||
// 如果发送人为空设置当前登录的人的ID
|
||||
Long sendUserId = dto.getSendUserId();
|
||||
if (sendUserId == null) dto.setSendUserId(BaseContext.getUserId());
|
||||
|
||||
// 如果接收人为空默认接收全部人
|
||||
if (dto.getReceivedUserIds().isEmpty()) {
|
||||
List<Long> userIds = userMapper.selectList(null).stream().map(BaseEntity::getId).toList();
|
||||
dto.setReceivedUserIds(userIds);
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
Message message = new Message();
|
||||
BeanUtils.copyProperties(dto, message);
|
||||
|
|
|
@ -11,17 +11,19 @@
|
|||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
<id column="title" property="title"/>
|
||||
<id column="received_user_id" property="receivedUserId"/>
|
||||
<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"/>
|
||||
<id column="cover" property="cover"/>
|
||||
<id column="summary" property="summary"/>
|
||||
<id column="editor_type" property="editorType"/>
|
||||
<id column="status" property="status"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, create_time, update_time, create_user, update_user, is_deleted, title, received_user_id, send_user_id, send_nick_name, message_type, content, editor_type, status
|
||||
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
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询系统消息内容 -->
|
||||
|
|
Loading…
Reference in New Issue