fix:小程序的登录接口添加

V0.5.x
tangfudong 2024-01-04 17:35:19 +08:00
parent 4a1ae2d75a
commit eb434732cf
2 changed files with 18 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.collection.CollUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
@ -69,6 +70,22 @@ public class AuthController {
return loginVo;
}
/**
* ()
*
* @param xcxCode code
* @return
*/
@ApiOperation("小程序登录")
@PostMapping("/xcxLogin")
public LoginVo xcxLogin(@NotBlank(message = "{xcx.appId.not.blank}") String appId,@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) {
LoginVo loginVo = new LoginVo();
// 生成令牌
String token = loginService.xcxLogin(appId,xcxCode);
loginVo.setToken(token);
return loginVo;
}
/**
* 退

View File

@ -172,7 +172,7 @@ public class SysLoginService {
// 生成token
LoginHelper.loginByDevice(loginUser, DeviceType.XCX);
// recordLoginInfo(loginUser.getTenantId(), user.getNickName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
recordLoginInfo(loginUser.getTenantId(), user.getNickName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
// recordLoginInfo(user.getId());
return StpUtil.getTokenValue();
}