package com.jpa.jpaspringboot.controller;

import com.jpa.jpaspringboot.entity.User;
import com.jpa.jpaspringboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * GET查，POST改，PUT增，DELETE删
 */

@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/find",method = RequestMethod.GET)
    public List<User> find(){
        return userService.find();
    }

    @RequestMapping(value = "/add",method = RequestMethod.PUT)
    public Object add(){
        userService.add();
        return 200;
    }


}
