update===>:修改消息接口。
This commit is contained in:
parent
17145f6242
commit
7d67518928
@ -1,6 +1,7 @@
|
|||||||
package com.xinelu.applet.controller.chatrecord;
|
package com.xinelu.applet.controller.chatrecord;
|
||||||
|
|
||||||
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
|
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.dto.chatrecord.MessageSearchDto;
|
||||||
import com.xinelu.applet.service.chatRecord.IChatRecordService;
|
import com.xinelu.applet.service.chatRecord.IChatRecordService;
|
||||||
import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
|
import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
|
||||||
@ -18,6 +19,7 @@ import java.util.Objects;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
@ -62,7 +64,8 @@ public class ChatRecordController extends BaseController {
|
|||||||
@PostMapping("/sendMessage")
|
@PostMapping("/sendMessage")
|
||||||
@Transactional
|
@Transactional
|
||||||
public AjaxResult sendMessage(@RequestBody ChatRecordDTO chatRecordDTO) {
|
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) {
|
if (WebSocketUtils.clients.get(chatRecordDTO.getRecipientId().toString()) == null) {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
@ -96,4 +99,19 @@ public class ChatRecordController extends BaseController {
|
|||||||
}
|
}
|
||||||
return R.ok(chatRecordService.getMegVoList(messageDto));
|
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("删除失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.xinelu.applet.dto.chatrecord;
|
|||||||
|
|
||||||
import com.xinelu.common.core.domain.BaseEntity;
|
import com.xinelu.common.core.domain.BaseEntity;
|
||||||
import com.xinelu.common.custominterface.Insert;
|
import com.xinelu.common.custominterface.Insert;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.sf.jsqlparser.statement.update.Update;
|
import net.sf.jsqlparser.statement.update.Update;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
@ -21,6 +22,9 @@ public class ChatRecordDTO extends BaseEntity implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = -3911806583514536587L;
|
private static final long serialVersionUID = -3911806583514536587L;
|
||||||
|
|
||||||
|
@ApiModelProperty("消息类别 1:通知公告,2:健康推送,3:在线咨询 4:消息通知")
|
||||||
|
private String messageCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聊天记录业务主键(问诊表id)
|
* 聊天记录业务主键(问诊表id)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -68,4 +68,6 @@ public interface ChatRecordMapper {
|
|||||||
public int deleteChatRecordByIds(Long[] ids);
|
public int deleteChatRecordByIds(Long[] ids);
|
||||||
|
|
||||||
Integer updateReadStatus(MarkReadDto markReadDto);
|
Integer updateReadStatus(MarkReadDto markReadDto);
|
||||||
|
|
||||||
|
int deleteMegs(@Param("ids") List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.xinelu.applet.service.chatRecord;
|
package com.xinelu.applet.service.chatRecord;
|
||||||
|
|
||||||
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
|
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.dto.chatrecord.MessageSearchDto;
|
||||||
import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
|
import com.xinelu.applet.vo.chatrecord.MessageCenterVo;
|
||||||
import com.xinelu.common.core.domain.AjaxResult;
|
import com.xinelu.common.core.domain.AjaxResult;
|
||||||
@ -24,7 +25,7 @@ public interface IChatRecordService {
|
|||||||
* @param id 图文咨询-聊天记录主键
|
* @param id 图文咨询-聊天记录主键
|
||||||
* @return 图文咨询-聊天记录
|
* @return 图文咨询-聊天记录
|
||||||
*/
|
*/
|
||||||
public ChatRecord selectChatRecordById(Long id);
|
ChatRecord selectChatRecordById(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询图文咨询-聊天记录列表
|
* 查询图文咨询-聊天记录列表
|
||||||
@ -32,7 +33,7 @@ public interface IChatRecordService {
|
|||||||
* @param chatRecord 图文咨询-聊天记录
|
* @param chatRecord 图文咨询-聊天记录
|
||||||
* @return 图文咨询-聊天记录集合
|
* @return 图文咨询-聊天记录集合
|
||||||
*/
|
*/
|
||||||
public List<ChatRecord> selectChatRecordList(ChatRecord chatRecord);
|
List<ChatRecord> selectChatRecordList(ChatRecord chatRecord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增图文咨询-聊天记录
|
* 新增图文咨询-聊天记录
|
||||||
@ -40,7 +41,7 @@ public interface IChatRecordService {
|
|||||||
* @param chatRecordDTO 图文咨询-聊天记录
|
* @param chatRecordDTO 图文咨询-聊天记录
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertChatRecord(ChatRecordDTO chatRecordDTO);
|
int insertChatRecord(ChatRecordDTO chatRecordDTO);
|
||||||
|
|
||||||
Boolean sendMessage(ChatRecordDTO chatRecordDTO);
|
Boolean sendMessage(ChatRecordDTO chatRecordDTO);
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ public interface IChatRecordService {
|
|||||||
* @param chatRecord 图文咨询-聊天记录
|
* @param chatRecord 图文咨询-聊天记录
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateChatRecord(ChatRecord chatRecord);
|
int updateChatRecord(ChatRecord chatRecord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除图文咨询-聊天记录
|
* 批量删除图文咨询-聊天记录
|
||||||
@ -58,7 +59,7 @@ public interface IChatRecordService {
|
|||||||
* @param ids 需要删除的图文咨询-聊天记录主键集合
|
* @param ids 需要删除的图文咨询-聊天记录主键集合
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteChatRecordByIds(Long[] ids);
|
int deleteChatRecordByIds(Long[] ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除图文咨询-聊天记录信息
|
* 删除图文咨询-聊天记录信息
|
||||||
@ -66,7 +67,7 @@ public interface IChatRecordService {
|
|||||||
* @param id 图文咨询-聊天记录主键
|
* @param id 图文咨询-聊天记录主键
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteChatRecordById(Long id);
|
int deleteChatRecordById(Long id);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +76,11 @@ public interface IChatRecordService {
|
|||||||
* @param multipartFile,consultationId 文件,问诊id
|
* @param multipartFile,consultationId 文件,问诊id
|
||||||
* @return 结果
|
* @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);
|
List<MessageCenterVo> getMegVoList(MessageSearchDto messageDto);
|
||||||
|
|
||||||
|
Integer markRead(MarkReadDto markReadDto);
|
||||||
|
|
||||||
|
Integer deleteMegs(List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.xinelu.applet.service.chatRecord.impl;
|
package com.xinelu.applet.service.chatRecord.impl;
|
||||||
|
|
||||||
import com.xinelu.applet.dto.chatrecord.ChatRecordDTO;
|
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.dto.chatrecord.MessageSearchDto;
|
||||||
import com.xinelu.applet.mapper.chatrecord.ChatRecordMapper;
|
import com.xinelu.applet.mapper.chatrecord.ChatRecordMapper;
|
||||||
import com.xinelu.applet.service.chatRecord.IChatRecordService;
|
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 com.xinelu.manage.domain.chatRecord.ChatRecord;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -76,6 +78,9 @@ public class ChatRecordServiceImpl implements IChatRecordService {
|
|||||||
chatRecord.setCreateTime(DateUtils.getNowDate());
|
chatRecord.setCreateTime(DateUtils.getNowDate());
|
||||||
ChatRecord record = new ChatRecord();
|
ChatRecord record = new ChatRecord();
|
||||||
BeanUtils.copyBeanProp(record, chatRecord);
|
BeanUtils.copyBeanProp(record, chatRecord);
|
||||||
|
record.setReadStatus("0");
|
||||||
|
record.setSendTime(new Date());
|
||||||
|
record.setDelFlag(0);
|
||||||
return chatRecordMapper.insertChatRecord(record);
|
return chatRecordMapper.insertChatRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,4 +214,15 @@ public class ChatRecordServiceImpl implements IChatRecordService {
|
|||||||
|
|
||||||
return messageCenterVos;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,7 +66,7 @@
|
|||||||
select
|
select
|
||||||
<include refid="Message_Vo_List"/>
|
<include refid="Message_Vo_List"/>
|
||||||
from chat_record
|
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">
|
<if test="messageCategory != null">
|
||||||
and message_category = #{messageCategory}
|
and message_category = #{messageCategory}
|
||||||
</if>
|
</if>
|
||||||
@ -89,7 +89,7 @@
|
|||||||
recipient_id,
|
recipient_id,
|
||||||
recipient_name
|
recipient_name
|
||||||
from chat_record
|
from chat_record
|
||||||
where del_flag = '0'
|
where del_flag = 0
|
||||||
and message_category = '3'
|
and message_category = '3'
|
||||||
and ((sender_id = #{bindingNo} and recipient_id = #{doctorNo})
|
and ((sender_id = #{bindingNo} and recipient_id = #{doctorNo})
|
||||||
or (sender_id = #{doctorNo} and recipient_id = #{bindingNo}))
|
or (sender_id = #{doctorNo} and recipient_id = #{bindingNo}))
|
||||||
@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
<select id="selectChatRecordList" parameterType="ChatRecord" resultMap="ChatRecordResult">
|
<select id="selectChatRecordList" parameterType="ChatRecord" resultMap="ChatRecordResult">
|
||||||
<include refid="selectChatRecordVo"/>
|
<include refid="selectChatRecordVo"/>
|
||||||
where del_flag = '0'
|
where del_flag = 0
|
||||||
and consultation_id = #{consultationId}
|
and consultation_id = #{consultationId}
|
||||||
and (
|
and (
|
||||||
(sender_id = #{senderId} and recipient_id = #{recipientId})
|
(sender_id = #{senderId} and recipient_id = #{recipientId})
|
||||||
@ -218,7 +218,7 @@
|
|||||||
<if test="crowds != null">crowds =
|
<if test="crowds != null">crowds =
|
||||||
#{crowds},
|
#{crowds},
|
||||||
</if>
|
</if>
|
||||||
<if test="crowdsName != null">crowds_name
|
<if test="crowdsName != null">crowds_name =
|
||||||
#{crowdsName},
|
#{crowdsName},
|
||||||
</if>
|
</if>
|
||||||
<if test="senderId != null">sender_id =
|
<if test="senderId != null">sender_id =
|
||||||
@ -283,7 +283,7 @@
|
|||||||
read_time = #{readTime},
|
read_time = #{readTime},
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</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>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteChatRecordById" parameterType="Long">
|
<delete id="deleteChatRecordById" parameterType="Long">
|
||||||
@ -298,4 +298,16 @@
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</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>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user