lrj
2 天以前 dc643ba44fd2a426263015491268a0f0d6b4671d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
    }
}