package com.chenyang.nse.bussiness.controller;

import com.chenyang.nse.bussiness.entity.User;
import com.chenyang.nse.bussiness.service.serviceImp.UserService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/user"})
public class User1Controller {
   @Autowired
   private UserService userService;

   @RequestMapping({"/save"})
   public String save() {
      User user = new User();
      user.setId(7L);
      user.setName("aa");
      user.setPassword("aaa");
      this.userService.save(user);
      return "success";
   }

   @RequestMapping({"/find/{id}"})
   public User findById(@PathVariable("id") Long id) {
      return this.userService.findById(id);
   }

   @RequestMapping({"/find"})
   public List<User> find() {
      List<User> uLst = this.userService.findAll();
      return uLst;
   }

   @RequestMapping({"/update"})
   public String update() {
      User user = new User();
      user.setId(7L);
      user.setName("abcde111");
      user.setPassword("aaa");
      this.userService.update(7L);
      return "success";
   }

   @RequestMapping({"/delete/{id}"})
   public String delete(@PathVariable("id") Long id) {
      this.userService.delete(id);
      return "删除成功";
   }
}
