UserAction.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.edu.web;
  2. import com.edu.base.Page;
  3. import com.edu.service.user.UserService;
  4. import com.edu.base.ResponseEntity;
  5. import com.edu.user.pojo.User;
  6. import org.springframework.stereotype.Controller;
  7. import org.springframework.web.bind.annotation.PathVariable;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11. import javax.annotation.Resource;
  12. import java.util.List;
  13. /**
  14. * Created by KangJellen on 2017/4/24.
  15. */
  16. @Controller
  17. @RequestMapping("/user")
  18. public class UserAction {
  19. @Resource
  20. private UserService userServiceImpl;
  21. @RequestMapping(value = "/getUserName/{id}", method = RequestMethod.GET, produces = "application/json")
  22. @ResponseBody
  23. public ResponseEntity getUserName(@PathVariable Long id) {
  24. ResponseEntity ret = userServiceImpl.getNameById(id);
  25. return ret;
  26. }
  27. @RequestMapping(value = "/getUserList", method = RequestMethod.GET, produces = "application/json")
  28. @ResponseBody
  29. public ResponseEntity<List<User>> getUserList(User user) {
  30. if(user == null) {
  31. user = new User();
  32. }
  33. Page page = user.getPage();
  34. if(null == page){
  35. page = new Page();
  36. user.setPage(page);
  37. }
  38. ResponseEntity<List<User>> ret = userServiceImpl.getUserList(user);
  39. return ret;
  40. }
  41. }