Skip to content

Commit

Permalink
聊天优化
Browse files Browse the repository at this point in the history
  • Loading branch information
zenofung committed May 17, 2022
1 parent bc8b3fb commit 07572f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -67,10 +68,13 @@ public R save(@RequestBody ImMessageEntity imMessage){
/**
* 修改
*/
@RequestMapping("/update")
@RequestMapping("/updateMessageStatus")
//@RequiresPermissions("wine:immessage:update")
public R update(@RequestBody ImMessageEntity imMessage){
imMessageService.updateById(imMessage);
public R updateMessageStatus(String userId,String msgList){
if (StringUtils.isEmpty(userId)||StringUtils.isEmpty(msgList)){
throw new RuntimeException("");
}
imMessageService.updateMessageStatus(userId,msgList);

return R.ok();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ public interface ImMessageService extends IService<ImMessageEntity> {

ImMessageEntity getOneByListId(String id);


void updateMessageStatus(String userId, String msgList);
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.wine.game.wine.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
Expand Down Expand Up @@ -47,7 +49,11 @@ public PageUtils queryPage(Map<String, Object> params) {
page.getRecords().stream().forEach(m->{
getUserVo(userId, m);
});

//把未读信息变成已读
QueryWrapper<ImMessageEntity> eq = new QueryWrapper<ImMessageEntity>().eq("im_mag_list_id", params.get("imList").toString()).eq("target_id", userId);
ImMessageEntity imMessageEntity=new ImMessageEntity();
imMessageEntity.setMessageStatus(1);
this.update(imMessageEntity,eq);
return new PageUtils(page);
}

Expand All @@ -67,4 +73,13 @@ public ImMessageEntity getOneByListId(String id) {
return imMessageDao.getOneByListId(id);
}

@Override
public void updateMessageStatus(String userId, String msgList) {
QueryWrapper<ImMessageEntity> eq = new QueryWrapper<ImMessageEntity>().eq("im_mag_list_id", msgList).eq("target_id", userId);
ImMessageEntity imMessageEntity=new ImMessageEntity();
imMessageEntity.setMessageStatus(1);
this.update(imMessageEntity,eq);
}


}

0 comments on commit 07572f5

Please sign in to comment.