document
API test
POST

Description or Example

# 核心代码 ```java @PostMapping("/login") public String login(AuthLoginVO authLoginVO, RedirectAttributes redirectAttributes, HttpSession session) { LoginTO loginTO = new LoginTO(); BeanUtils.copyProperties(authLoginVO, loginTO); R info = authMemberService.login(loginTO); if (info.getCode() != 0) { // 登录失败, 返回登录页 String msg = info.getData("msg", new TypeReference<String>() { }); redirectAttributes.addFlashAttribute("errors", new HashMap<String, String>() {{ this.put("msg", msg); }}); return "redirect:http://auth.bitmall.com/login.html"; } // 放入对应实现的会话域中 session.setAttribute(UserConstant.SESSION_USER_NAME, info.getData(new TypeReference<MemberVO>(){})); return "redirect:http://www.bitmall.com/"; } ``` ```java @RequestMapping("/member/member/login") R login(@RequestBody LoginTO loginTO); ``` ```java @RequestMapping("/login") public R login(@RequestBody LoginTO loginTO) { MemberEntity member = memberService.login(loginTO); if (member == null) { return R.error(LOGIN_FAILURE.getCode(), LOGIN_FAILURE.getMessage()); } return R.ok(); } ``` ```java @Override @RequestMapping("/login") public R login(@RequestBody LoginTO loginTO) { try { MemberEntity member = memberService.login(loginTO); if (member == null) { return R.error(LOGIN_FAILURE.getCode(), LOGIN_FAILURE.getMessage()); } return R.ok().setData(member); }catch (UsernameException | EmailException e) { // 注册并登录的环节中, 注册的时候可能出现用户名或邮箱重复的异常 return R.error(e.getMessage()); } } ```