Commit 917f276a by 段启岩

消息列表更新

parent fe04a6f1
...@@ -56,12 +56,15 @@ public class MessageApi { ...@@ -56,12 +56,15 @@ public class MessageApi {
@ApiOperation("我的消息列表") @ApiOperation("我的消息列表")
@GetMapping("/my/messages") @GetMapping("/my/messages")
public Response<?> getMyMessages(@Valid PageForm pageForm, BindingResult bindingResult, @CurrentSubject Subject subject) { public Response<?> getMyMessages(@Valid PageForm pageForm,
BindingResult bindingResult,
@CurrentSubject Subject subject,
@RequestParam(value = "type" ,required = false) String type) {
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
return Response.fieldError(bindingResult.getFieldError()); return Response.fieldError(bindingResult.getFieldError());
} }
// 根据用户获取列表并返回 // 根据用户获取列表并返回
IPage<Message> messageIPage = messageService.getMessagePage(pageForm.getPage(), pageForm.getSize(), (String) subject.getId()); IPage<Message> messageIPage = messageService.getMessagePage(pageForm.getPage(), pageForm.getSize(), (String) subject.getId(), type);
PageDTO<Message> messagePageDTO = new PageDTO<>(messageIPage); PageDTO<Message> messagePageDTO = new PageDTO<>(messageIPage);
return Response.success(messagePageDTO); return Response.success(messagePageDTO);
} }
......
...@@ -6,8 +6,6 @@ import cn.meteor.beyondclouds.modules.message.exception.MessageServiceException; ...@@ -6,8 +6,6 @@ import cn.meteor.beyondclouds.modules.message.exception.MessageServiceException;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
/** /**
* <p> * <p>
* 服务类 * 服务类
...@@ -35,9 +33,10 @@ public interface IMessageService extends IService<Message> { ...@@ -35,9 +33,10 @@ public interface IMessageService extends IService<Message> {
* @param pageNumber * @param pageNumber
* @param pageSize * @param pageSize
* @param userId * @param userId
* @param type
* @return * @return
*/ */
IPage<Message> getMessagePage(Integer pageNumber, Integer pageSize, String userId); IPage<Message> getMessagePage(Integer pageNumber, Integer pageSize, String userId, String type);
/** /**
* 获取消息详情 * 获取消息详情
......
...@@ -14,6 +14,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -14,6 +14,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
...@@ -44,11 +46,28 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl ...@@ -44,11 +46,28 @@ public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> impl
} }
@Override @Override
public IPage<Message> getMessagePage(Integer pageNumber, Integer pageSize, String userId) { public IPage<Message> getMessagePage(Integer pageNumber, Integer pageSize, String userId, String type) {
IPage<Message> page = new Page<>(pageNumber, pageSize); IPage<Message> page = new Page<>(pageNumber, pageSize);
QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>(); QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>();
messageQueryWrapper.eq("to_id", userId); messageQueryWrapper.eq("to_id", userId);
if (null != type) {
switch (type) {
case "COMMENT":
messageQueryWrapper.in("msg_type", List.of(2, 3, 4, 5, 6));
break;
case "PRAISE":
messageQueryWrapper.in("msg_type", List.of(7));
break;
case "FOLLOW":
messageQueryWrapper.eq("msg_type", List.of(1));
break;
case "NOTICE":
messageQueryWrapper.eq("msg_type", 0);
break;
}
messageQueryWrapper.eq("msg_type", type);
}
messageQueryWrapper.orderByDesc("create_time"); messageQueryWrapper.orderByDesc("create_time");
return page(page, messageQueryWrapper); return page(page, messageQueryWrapper);
} }
......
...@@ -81,6 +81,9 @@ logging: ...@@ -81,6 +81,9 @@ logging:
cn: cn:
meteor: meteor:
beyondclouds: debug beyondclouds: debug
com:
corundumstudio: info
# 云里云外 # 云里云外
beyondclouds: beyondclouds:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment