ExceptionController.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.yihu.base.security.controller;
  2. import com.yihu.base.security.exception.ApiException;
  3. import com.yihu.base.security.vo.BaseEnvelopStatus;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestMethod;
  6. import org.springframework.web.bind.annotation.RequestParam;
  7. import org.springframework.web.bind.annotation.RestController;
  8. /**
  9. * Created by Administrator on 2018/4/3 0003.
  10. */
  11. @RestController
  12. @RequestMapping("/security/exception")
  13. public class ExceptionController {
  14. /**
  15. * 密码错误
  16. */
  17. @RequestMapping(value = "/badCredentialsException", method = RequestMethod.POST)
  18. public String badCredentialsException(@RequestParam(value = "msg", required = true) String msg) throws ApiException {
  19. throw new ApiException(BaseEnvelopStatus.status_10101.getName(), BaseEnvelopStatus.status_10101.getCode());
  20. }
  21. /**
  22. * 用户不存在
  23. */
  24. @RequestMapping(value = "/usernameNotFoundException", method = RequestMethod.POST)
  25. public String usernameNotFoundException(@RequestParam(value = "msg", required = true) String msg) throws ApiException {
  26. throw new ApiException(BaseEnvelopStatus.status_10100.getName(), BaseEnvelopStatus.status_10100.getCode());
  27. }
  28. }