|
|
@@ -1,5 +1,6 @@
|
|
|
package com.xjrsoft.module.system.controller;
|
|
|
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.dev33.satoken.session.SaSession;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
@@ -11,8 +12,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.xjrsoft.common.annotation.XjrLog;
|
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
import com.xjrsoft.common.model.result.R;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.sms.SmsCtcc;
|
|
|
+import com.xjrsoft.common.utils.QrCodeUtil;
|
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
|
+import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
import com.xjrsoft.config.KeyCloakConfig;
|
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
|
@@ -23,6 +27,7 @@ import com.xjrsoft.module.system.dto.KeyCloakLoginInfoDto;
|
|
|
import com.xjrsoft.module.system.dto.LoginByCodeDto;
|
|
|
import com.xjrsoft.module.system.dto.LoginCaptchaDto;
|
|
|
import com.xjrsoft.module.system.dto.LoginDto;
|
|
|
+import com.xjrsoft.module.system.dto.LoginQRCodeDto;
|
|
|
import com.xjrsoft.module.system.service.ILoginService;
|
|
|
import com.xjrsoft.module.system.service.IOauthService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
@@ -38,6 +43,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
@@ -69,6 +75,8 @@ public class LoginController {
|
|
|
|
|
|
private IOauthService oauthService;
|
|
|
|
|
|
+ private final CommonPropertiesConfig commonPropertiesConfig;
|
|
|
+
|
|
|
@PostMapping("/login")
|
|
|
@ApiOperation(value = "登录", notes = "传入账号:account,密码:password")
|
|
|
@XjrLog(value = "账号密码登录成功")
|
|
|
@@ -83,6 +91,30 @@ public class LoginController {
|
|
|
return R.ok(loginService.loginByCode(dto));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping(value = "/loginQRCode")
|
|
|
+ @ApiOperation(value="登录-二维码")
|
|
|
+ @SaCheckPermission("wfstudenttextbookclaim:detail")
|
|
|
+ public RT<String> qrcode() throws Exception {
|
|
|
+ String url = commonPropertiesConfig.getDomainApp() + "/system/QR-code-login";
|
|
|
+ int width = 200;
|
|
|
+ int height = 200;
|
|
|
+ int margin = 1;
|
|
|
+
|
|
|
+ try {
|
|
|
+ String base64 = QrCodeUtil.createBase64(url, width, height, margin);
|
|
|
+ return RT.ok(base64);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/QR-code-login")
|
|
|
+ @ApiOperation(value = "登录", notes = "code")
|
|
|
+ @XjrLog(value = "二维码登录")
|
|
|
+ public R loginQRCode(@RequestBody @Valid LoginQRCodeDto dto) throws Exception {
|
|
|
+ return R.ok(loginService.loginQRCode(dto));
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/bindOpenid")
|
|
|
@ApiOperation(value = "登录", notes = "code")
|
|
|
@XjrLog(value = "code换Openid并绑定")
|