UserController.kt 656 字节
Newer Older
2
2293736867 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
package com.example.demo.test.controller

import com.example.demo.test.entity.User
import com.example.demo.test.service.UserService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/test/user")
class UserController {
    @Autowired
    lateinit var userService: UserService

    @GetMapping("/write")
    fun write() = userService.save(User(3,"123",3))

    @GetMapping("/read")
    fun read(): User? = userService.getById(3)
}