@Test public void login() throws Exception { adminService.login("18721895830","123456"); }
public TokenVo login(String name, String password) throws InvalidArgumentException { if (StringUtils.isBlank(name)) throw new InvalidArgumentException("无效用户名!"); Admin admin = getAdminByName(name.trim()); if (admin == null) throw new InvalidArgumentException("用户名或密码错误!"); boolean access = BCrypt.checkpw(password, admin.getPassword()); if (access){ Token token = oauthService.generateToken(admin.getId(), "ocpay"); if (token ==null){ logger.error("获取token失败!,param name:{},password:{}", name,password); } TokenVo tokenVo = new TokenVo(); BeanUtils.copyProperties(token,tokenVo); return tokenVo; }else { throw new InvalidArgumentException("用户名或密码错误!"); } }
AdminService { public TokenVo login(String name, String password) throws InvalidArgumentException { if (StringUtils.isBlank(name)) throw new InvalidArgumentException("无效用户名!"); Admin admin = getAdminByName(name.trim()); if (admin == null) throw new InvalidArgumentException("用户名或密码错误!"); boolean access = BCrypt.checkpw(password, admin.getPassword()); if (access){ Token token = oauthService.generateToken(admin.getId(), "ocpay"); if (token ==null){ logger.error("获取token失败!,param name:{},password:{}", name,password); } TokenVo tokenVo = new TokenVo(); BeanUtils.copyProperties(token,tokenVo); return tokenVo; }else { throw new InvalidArgumentException("用户名或密码错误!"); } } }
AdminService { public TokenVo login(String name, String password) throws InvalidArgumentException { if (StringUtils.isBlank(name)) throw new InvalidArgumentException("无效用户名!"); Admin admin = getAdminByName(name.trim()); if (admin == null) throw new InvalidArgumentException("用户名或密码错误!"); boolean access = BCrypt.checkpw(password, admin.getPassword()); if (access){ Token token = oauthService.generateToken(admin.getId(), "ocpay"); if (token ==null){ logger.error("获取token失败!,param name:{},password:{}", name,password); } TokenVo tokenVo = new TokenVo(); BeanUtils.copyProperties(token,tokenVo); return tokenVo; }else { throw new InvalidArgumentException("用户名或密码错误!"); } }  }
AdminService { public TokenVo login(String name, String password) throws InvalidArgumentException { if (StringUtils.isBlank(name)) throw new InvalidArgumentException("无效用户名!"); Admin admin = getAdminByName(name.trim()); if (admin == null) throw new InvalidArgumentException("用户名或密码错误!"); boolean access = BCrypt.checkpw(password, admin.getPassword()); if (access){ Token token = oauthService.generateToken(admin.getId(), "ocpay"); if (token ==null){ logger.error("获取token失败!,param name:{},password:{}", name,password); } TokenVo tokenVo = new TokenVo(); BeanUtils.copyProperties(token,tokenVo); return tokenVo; }else { throw new InvalidArgumentException("用户名或密码错误!"); } }  TokenVo login(String name, String password); Admin getAdminByName(String name); boolean addAdmin(String name, String password, String phone, String realName ,Integer adminId); boolean resetPassword(Integer adminId, String password,String name); Admin getAdminById(Integer adminId); Page getUsers(AdminReq admin); }
AdminService { public TokenVo login(String name, String password) throws InvalidArgumentException { if (StringUtils.isBlank(name)) throw new InvalidArgumentException("无效用户名!"); Admin admin = getAdminByName(name.trim()); if (admin == null) throw new InvalidArgumentException("用户名或密码错误!"); boolean access = BCrypt.checkpw(password, admin.getPassword()); if (access){ Token token = oauthService.generateToken(admin.getId(), "ocpay"); if (token ==null){ logger.error("获取token失败!,param name:{},password:{}", name,password); } TokenVo tokenVo = new TokenVo(); BeanUtils.copyProperties(token,tokenVo); return tokenVo; }else { throw new InvalidArgumentException("用户名或密码错误!"); } }  TokenVo login(String name, String password); Admin getAdminByName(String name); boolean addAdmin(String name, String password, String phone, String realName ,Integer adminId); boolean resetPassword(Integer adminId, String password,String name); Admin getAdminById(Integer adminId); Page getUsers(AdminReq admin); static String INIT_PWD; }