use of com.besscroft.aurora.mall.common.result.AjaxResult in project aurora-mall by besscroft.
the class UserServiceImpl method login.
@Override
public AjaxResult login(String username, String password) {
if (StrUtil.isEmpty(username) || StrUtil.isEmpty(password)) {
log.error("用户名或密码不能为空!");
}
Map<String, String> params = new HashMap<>();
params.put("client_id", AuthConstants.ADMIN_CLIENT_ID);
params.put("client_secret", "123456");
params.put("grant_type", "password");
params.put("username", username);
params.put("password", password);
AjaxResult accessToken = authFeignClient.getAccessToken(params);
log.info("accessToken:{}", accessToken);
redisTemplate.opsForValue().set(AuthConstants.ADMIN_CLIENT_ID + ":token:user:" + username, accessToken.get("access_token").toString());
return accessToken;
}
use of com.besscroft.aurora.mall.common.result.AjaxResult in project aurora-mall by besscroft.
the class UserServiceTest method login.
@Test
void login() throws Exception {
String username = "admin";
String password = "666666";
AjaxResult result = userService.login(username, password);
LOGGER.info("result:{}", objectMapper.writeValueAsString(result));
}
use of com.besscroft.aurora.mall.common.result.AjaxResult in project aurora-mall by besscroft.
the class UserController method login.
@WebLog(description = "登录接口")
@ApiOperation(value = "登录并返回token")
@PostMapping(value = "/login")
public AjaxResult login(@Validated @RequestBody UserLoginParam userLoginParam) {
log.info("请求进来了,打印UserLoginParam:{}", userLoginParam);
AjaxResult result = userService.login(userLoginParam.getUsername(), userLoginParam.getPassword());
log.info("请求进来了,oauth2Token:{}", result);
return AjaxResult.success(result);
}
Aggregations