package com.rongyichuang.message.api;
|
|
import com.rongyichuang.message.entity.Message;
|
import com.rongyichuang.message.service.MessageService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.graphql.data.method.annotation.Argument;
|
import org.springframework.graphql.data.method.annotation.QueryMapping;
|
import org.springframework.stereotype.Controller;
|
|
import java.util.List;
|
|
/**
|
* 消息GraphQL API控制器
|
*/
|
@Controller
|
public class MessageGraphqlApi {
|
|
@Autowired
|
private MessageService messageService;
|
|
/**
|
* 根据用户ID获取消息列表,按时间倒序
|
*/
|
@QueryMapping
|
public List<Message> getMessagesByUserId(@Argument Long userId) {
|
return messageService.getMessagesByUserId(userId);
|
}
|
}
|