update===>:修改消息接口。

This commit is contained in:
haown 2023-10-24 15:33:41 +08:00
parent 17145f6242
commit 7d67518928
6 changed files with 70 additions and 13 deletions

View File

@ -1,6 +1,7 @@
package com.xinelu.applet.controller.chatrecord;
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
import com.xinelu.applet.dto.chatrecord.MarkReadDto;
import com.xinelu.applet.dto.chatrecord.MessageSearchDto;
import com.xinelu.applet.service.chatRecord.IChatRecordService;
import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
@ -18,6 +19,7 @@ import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -62,7 +64,8 @@ public class ChatRecordController extends BaseController {
@PostMapping("/sendMessage")
@Transactional
public AjaxResult sendMessage(@RequestBody ChatRecordDTO chatRecordDTO) {
if (chatRecordService.insertChatRecord(chatRecordDTO) > 0) {
chatRecordDTO.setMessageCategory("3");
if (chatRecordService.insertChatRecord(chatRecordDTO) > 0) {
// 判断接收人是否在线
if (WebSocketUtils.clients.get(chatRecordDTO.getRecipientId().toString()) == null) {
return AjaxResult.success();
@ -96,4 +99,19 @@ public class ChatRecordController extends BaseController {
}
return R.ok(chatRecordService.getMegVoList(messageDto));
}
@ApiOperation("标记为已读")
@GetMapping("/markRead")
public R<String> markRead(MarkReadDto markReadDto) {
return chatRecordService.markRead(markReadDto) < 0 ? R.fail() : R.ok();
}
@ApiOperation("删除消息")
@GetMapping("/deleteMegs")
public R<String> deleteMegs(@RequestBody List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return R.fail("请选择要删除的消息!");
}
return chatRecordService.deleteMegs(ids) > 0 ? R.ok("删除成功") : R.fail("删除失败");
}
}

View File

@ -2,6 +2,7 @@ package com.xinelu.applet.dto.chatrecord;
import com.xinelu.common.core.domain.BaseEntity;
import com.xinelu.common.custominterface.Insert;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.sf.jsqlparser.statement.update.Update;
import org.hibernate.validator.constraints.Length;
@ -21,6 +22,9 @@ public class ChatRecordDTO extends BaseEntity implements Serializable {
private static final long serialVersionUID = -3911806583514536587L;
@ApiModelProperty("消息类别 1通知公告2健康推送3在线咨询 4消息通知")
private String messageCategory;
/**
* 聊天记录业务主键(问诊表id)
*/

View File

@ -68,4 +68,6 @@ public interface ChatRecordMapper {
public int deleteChatRecordByIds(Long[] ids);
Integer updateReadStatus(MarkReadDto markReadDto);
int deleteMegs(@Param("ids") List<Long> ids);
}

View File

@ -1,6 +1,7 @@
package com.xinelu.applet.service.chatRecord;
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
import com.xinelu.applet.dto.chatrecord.MarkReadDto;
import com.xinelu.applet.dto.chatrecord.MessageSearchDto;
import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
import com.xinelu.common.core.domain.AjaxResult;
@ -24,7 +25,7 @@ public interface IChatRecordService {
* @param id 图文咨询-聊天记录主键
* @return 图文咨询-聊天记录
*/
public ChatRecord selectChatRecordById(Long id);
ChatRecord selectChatRecordById(Long id);
/**
* 查询图文咨询-聊天记录列表
@ -32,7 +33,7 @@ public interface IChatRecordService {
* @param chatRecord 图文咨询-聊天记录
* @return 图文咨询-聊天记录集合
*/
public List<ChatRecord> selectChatRecordList(ChatRecord chatRecord);
List<ChatRecord> selectChatRecordList(ChatRecord chatRecord);
/**
* 新增图文咨询-聊天记录
@ -40,7 +41,7 @@ public interface IChatRecordService {
* @param chatRecordDTO 图文咨询-聊天记录
* @return 结果
*/
public int insertChatRecord(ChatRecordDTO chatRecordDTO);
int insertChatRecord(ChatRecordDTO chatRecordDTO);
Boolean sendMessage(ChatRecordDTO chatRecordDTO);
@ -50,7 +51,7 @@ public interface IChatRecordService {
* @param chatRecord 图文咨询-聊天记录
* @return 结果
*/
public int updateChatRecord(ChatRecord chatRecord);
int updateChatRecord(ChatRecord chatRecord);
/**
* 批量删除图文咨询-聊天记录
@ -58,7 +59,7 @@ public interface IChatRecordService {
* @param ids 需要删除的图文咨询-聊天记录主键集合
* @return 结果
*/
public int deleteChatRecordByIds(Long[] ids);
int deleteChatRecordByIds(Long[] ids);
/**
* 删除图文咨询-聊天记录信息
@ -66,7 +67,7 @@ public interface IChatRecordService {
* @param id 图文咨询-聊天记录主键
* @return 结果
*/
public int deleteChatRecordById(Long id);
int deleteChatRecordById(Long id);
/**
@ -75,7 +76,11 @@ public interface IChatRecordService {
* @param multipartFile,consultationId 文件,问诊id
* @return 结果
*/
public AjaxResult uploadChatRecordFile(MultipartFile multipartFile, Long consultationId) throws IOException, InvalidExtensionException;
AjaxResult uploadChatRecordFile(MultipartFile multipartFile, Long consultationId) throws IOException, InvalidExtensionException;
List<MessageCenterVo> getMegVoList(MessageSearchDto messageDto);
Integer markRead(MarkReadDto markReadDto);
Integer deleteMegs(List<Long> ids);
}

View File

@ -1,6 +1,7 @@
package com.xinelu.applet.service.chatRecord.impl;
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
import com.xinelu.applet.dto.chatrecord.MarkReadDto;
import com.xinelu.applet.dto.chatrecord.MessageSearchDto;
import com.xinelu.applet.mapper.chatrecord.ChatRecordMapper;
import com.xinelu.applet.service.chatRecord.IChatRecordService;
@ -20,6 +21,7 @@ import com.xinelu.common.utils.file.MimeTypeUtils;
import com.xinelu.manage.domain.chatRecord.ChatRecord;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -76,6 +78,9 @@ public class ChatRecordServiceImpl implements IChatRecordService {
chatRecord.setCreateTime(DateUtils.getNowDate());
ChatRecord record = new ChatRecord();
BeanUtils.copyBeanProp(record, chatRecord);
record.setReadStatus("0");
record.setSendTime(new Date());
record.setDelFlag(0);
return chatRecordMapper.insertChatRecord(record);
}
@ -209,4 +214,15 @@ public class ChatRecordServiceImpl implements IChatRecordService {
return messageCenterVos;
}
@Override public Integer markRead(MarkReadDto markReadDto) {
if (StringUtils.isBlank(markReadDto.getBindingNo())) {
return -1;
}
return chatRecordMapper.updateReadStatus(markReadDto);
}
@Override public Integer deleteMegs(List<Long> ids) {
return chatRecordMapper.deleteMegs(ids);
}
}

View File

@ -66,7 +66,7 @@
select
<include refid="Message_Vo_List"/>
from chat_record
where del_flag = '0' and (recipient_id = #{recipientId} or sender_id = #{recipientId})
where del_flag = 0 and (recipient_id = #{recipientId} or sender_id = #{recipientId})
<if test="messageCategory != null">
and message_category = #{messageCategory}
</if>
@ -89,7 +89,7 @@
recipient_id,
recipient_name
from chat_record
where del_flag = '0'
where del_flag = 0
and message_category = '3'
and ((sender_id = #{bindingNo} and recipient_id = #{doctorNo})
or (sender_id = #{doctorNo} and recipient_id = #{bindingNo}))
@ -98,7 +98,7 @@
<select id="selectChatRecordList" parameterType="ChatRecord" resultMap="ChatRecordResult">
<include refid="selectChatRecordVo"/>
where del_flag = '0'
where del_flag = 0
and consultation_id = #{consultationId}
and (
(sender_id = #{senderId} and recipient_id = #{recipientId})
@ -218,7 +218,7 @@
<if test="crowds != null">crowds =
#{crowds},
</if>
<if test="crowdsName != null">crowds_name
<if test="crowdsName != null">crowds_name =
#{crowdsName},
</if>
<if test="senderId != null">sender_id =
@ -283,7 +283,7 @@
read_time = #{readTime},
</if>
</trim>
where del_flag = '0' and read_status = '0' and recipient_id = #{recipientId}
where del_flag = 0 and read_status = '0' and recipient_id = #{recipientId}
</update>
<delete id="deleteChatRecordById" parameterType="Long">
@ -298,4 +298,16 @@
#{id}
</foreach>
</delete>
<update id="deleteMegs">
update chat_record set del_flag = 1
<where>
<if test="messageNos != null">
id in
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</update>
</mapper>