1
zhang
昨天 5186bf6f2a786775818dc7017ef0bde32cc19201
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.zy.controller;
 
 
import com.zy.entity.User;
import com.zy.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
@RestController
public class UserController {
 
    @DubboReference(timeout = 1000, check = false)//远程注入
    private UserService userService;
 
 
    @GetMapping("/user")
    public String user() {
        User user = userService.queryUser();
        return user.toString();
    }
 
    @GetMapping("/get")
    public String get() {
        return userService.get("user");
    }
 
    @GetMapping("/add")
    public String add() {
        userService.add("user", "123");
        return "ok";
    }
 
    @GetMapping("/user3")
    public List<User> user3() {
        return userService.getDataByMySql();
 
    }
}