fuliqi
2024-02-05 5589258324faa6d9e1ec7e5226e98dc2e1a18adc
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
package org.dromara.demo.controller;
 
import org.dromara.demo.domain.Student;
import org.dromara.demo.service.IStudentRepository;
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;
 
@Controller
public class TestJPAController {
    @Autowired
    private IStudentRepository studentRepository;
 
 
    @QueryMapping
    public void addStudent(@Argument Student student){
        studentRepository.save(student);
    }
    @QueryMapping
    public Student getStudent(@Argument Long id){
        return studentRepository.findById(id).orElse(null);
    }
 
}