提交 daf42be9 作者: han

用户删除接收的消息及后台删除消息之后接收方方随之删除消息

上级 831ae4e2
...@@ -3,10 +3,7 @@ package com.mmc.iuav.user.controller; ...@@ -3,10 +3,7 @@ package com.mmc.iuav.user.controller;
import com.mmc.iuav.response.ResultBody; import com.mmc.iuav.response.ResultBody;
import com.mmc.iuav.user.model.vo.SystemMessageVO; import com.mmc.iuav.user.model.vo.SystemMessageVO;
import com.mmc.iuav.user.service.MessageService; import com.mmc.iuav.user.service.MessageService;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -30,7 +27,7 @@ public class MessageController extends BaseController{ ...@@ -30,7 +27,7 @@ public class MessageController extends BaseController{
@ApiOperation(value = "后台——根据ID查询系统消息") @ApiOperation(value = "后台——根据ID查询系统消息")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/selectSystemMessageById") @GetMapping("/selectSystemMessageById")
public ResultBody selectSystemMessageById(@RequestParam Integer id){ public ResultBody selectSystemMessageById(@ApiParam(value = "消息ID") @RequestParam Integer id){
return messageService.selectSystemMessageById(id); return messageService.selectSystemMessageById(id);
} }
@ApiOperation(value = "后台——系统消息列表") @ApiOperation(value = "后台——系统消息列表")
...@@ -43,7 +40,7 @@ public class MessageController extends BaseController{ ...@@ -43,7 +40,7 @@ public class MessageController extends BaseController{
@ApiOperation(value = "后台——删除消息") @ApiOperation(value = "后台——删除消息")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/removeMessage") @PostMapping("/removeMessage")
public ResultBody removeMessage(@RequestParam Integer id){ public ResultBody removeMessage(@ApiParam(value = "消息ID") @RequestParam Integer id){
return messageService.removeMessage(id); return messageService.removeMessage(id);
} }
...@@ -57,7 +54,7 @@ public class MessageController extends BaseController{ ...@@ -57,7 +54,7 @@ public class MessageController extends BaseController{
@ApiOperation(value = "用户查看——系统消息详情") @ApiOperation(value = "用户查看——系统消息详情")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("/showSystemMessageByUser") @GetMapping("/showSystemMessageByUser")
public ResultBody showSystemMessageByUser(HttpServletRequest request, @RequestParam Integer messageId){ public ResultBody showSystemMessageByUser(HttpServletRequest request,@ApiParam(value = "消息ID") @RequestParam Integer messageId){
Integer userId = this.getUserLoginInfoFromRedis(request).getUserAccountId(); Integer userId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
return messageService.showSystemMessageByUser(userId,messageId); return messageService.showSystemMessageByUser(userId,messageId);
} }
...@@ -65,7 +62,8 @@ public class MessageController extends BaseController{ ...@@ -65,7 +62,8 @@ public class MessageController extends BaseController{
@ApiOperation(value = "用户——删除接收的消息") @ApiOperation(value = "用户——删除接收的消息")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("/removeMessageByUser") @PostMapping("/removeMessageByUser")
public ResultBody removeMessageByUser(@RequestParam Integer id){ public ResultBody removeMessageByUser(HttpServletRequest request,@ApiParam(value = "消息ID") @RequestParam Integer messageId){
return messageService.removeMessageByUser(id); Integer userId = this.getUserLoginInfoFromRedis(request).getUserAccountId();
return messageService.removeMessageByUser(userId,messageId);
} }
} }
...@@ -58,9 +58,13 @@ public interface MessageDao { ...@@ -58,9 +58,13 @@ public interface MessageDao {
* @param id * @param id
* @return * @return
*/ */
int removeReceiverMessage(Integer id); int removeReceiverMessage(@Param("userId") Integer userId,@Param("messageId") Integer messageId);
/** /**
* 根据messageId删除接收方的消息(撤回删除消息之后,接收方应该不能查看)
*/
int removeReceiverMessageByMessageId(@Param("messageId") Integer messageId);
/**
* 查询读取过但是已经被用户删除的信息 * 查询读取过但是已经被用户删除的信息
* @param userId * @param userId
* @param messageId * @param messageId
......
...@@ -53,5 +53,5 @@ public interface MessageService { ...@@ -53,5 +53,5 @@ public interface MessageService {
* @param id * @param id
* @return * @return
*/ */
ResultBody removeMessageByUser(Integer id); ResultBody removeMessageByUser(Integer userId, Integer messageId);
} }
...@@ -20,9 +20,9 @@ public class MessageServiceImpl implements MessageService { ...@@ -20,9 +20,9 @@ public class MessageServiceImpl implements MessageService {
public ResultBody insertSystemMessage(SystemMessageVO messageVO) { public ResultBody insertSystemMessage(SystemMessageVO messageVO) {
SystemMessageDO systemMessageDO = new SystemMessageDO(messageVO); SystemMessageDO systemMessageDO = new SystemMessageDO(messageVO);
if(messageDao.insertSystemMessage(systemMessageDO) != 0){ if(messageDao.insertSystemMessage(systemMessageDO) != 0){
return ResultBody.success("添加成功"); return ResultBody.success("消息发布成功");
} }
return ResultBody.error("添加失败"); return ResultBody.error("消息发布失败");
} }
@Override @Override
...@@ -37,6 +37,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -37,6 +37,7 @@ public class MessageServiceImpl implements MessageService {
@Override @Override
public ResultBody removeMessage(Integer id) { public ResultBody removeMessage(Integer id) {
if(messageDao.removeMessage(id) != 0){ if(messageDao.removeMessage(id) != 0){
return ResultBody.success("删除成功"); return ResultBody.success("删除成功");
} }
return ResultBody.error("删除失败"); return ResultBody.error("删除失败");
...@@ -84,8 +85,8 @@ public class MessageServiceImpl implements MessageService { ...@@ -84,8 +85,8 @@ public class MessageServiceImpl implements MessageService {
} }
@Override @Override
public ResultBody removeMessageByUser(Integer id) { public ResultBody removeMessageByUser(Integer userId, Integer messageId) {
if(messageDao.removeReceiverMessage(id) != 0){ if(messageDao.removeReceiverMessage(userId, messageId) != 0){
return ResultBody.success("删除成功"); return ResultBody.success("删除成功");
} }
return ResultBody.error("删除失败"); return ResultBody.error("删除失败");
......
...@@ -57,7 +57,12 @@ ...@@ -57,7 +57,12 @@
<update id="removeReceiverMessage"> <update id="removeReceiverMessage">
update receiver_message update receiver_message
set is_deleted = 1, deleted_time = NOW() set is_deleted = 1, deleted_time = NOW()
where id = #{id,jdbcType=INTEGER} where user_id = #{userId} and message_id = #{messageId}
</update>
<update id="removeReceiverMessageByMessageId">
update receiver_message
set is_deleted = 1, deleted_time = NOW()
where message_id = #{messageId}
</update> </update>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论