選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

39 行
953 B

package com.wyz.demo.controller;
import com.wyz.demo.dto.UserDTO;
import com.wyz.demo.po.User;
import com.wyz.demo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
public UserService userService;
@GetMapping("/hello")
public String simpleString(){
return "<h2>/hello</h2><br>";
}
@PostMapping(value = "/add", produces = "application/json")
public void f(UserDTO u){
log.info("-->",u);
User uu = new User();
uu.setId(u.getId());
uu.setUsername(u.getUsername());
uu.setPassword(u.getPassword());
uu.setPhone(u.getPhone());
userService.addUser(uu);
}
}