瀏覽代碼

1、收费管理导出增加条件查询
2、增加二维码登录接口

dzx 1 年之前
父節點
當前提交
b211124f74

+ 1 - 1
src/main/java/com/xjrsoft/module/student/dto/PbVXsxxsfytbExcelDto.java

@@ -16,7 +16,7 @@ import java.util.List;
 */
 @Data
 @EqualsAndHashCode(callSuper = false)
-public class PbVXsxxsfytbExcelDto {
+public class PbVXsxxsfytbExcelDto extends PbVXsxxsfytbPageDto {
 
     /**
      * 主键

+ 32 - 0
src/main/java/com/xjrsoft/module/system/controller/LoginController.java

@@ -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并绑定")

+ 14 - 0
src/main/java/com/xjrsoft/module/system/dto/LoginQRCodeDto.java

@@ -0,0 +1,14 @@
+package com.xjrsoft.module.system.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+public class LoginQRCodeDto {
+    @ApiModelProperty("openId")
+    @NotBlank(message = "Code不能为空!")
+    private String openId;
+
+}

+ 9 - 0
src/main/java/com/xjrsoft/module/system/service/ILoginService.java

@@ -4,6 +4,7 @@ import com.xjrsoft.module.system.dto.CreateTokenDto;
 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.vo.CreateTokenVo;
 import com.xjrsoft.module.system.vo.ImgCaptchaVo;
 import com.xjrsoft.module.system.vo.LoginByCodeVo;
@@ -26,4 +27,12 @@ public interface ILoginService {
     CreateTokenVo createToken(CreateTokenDto dto);
 
     ImgCaptchaVo imgCaptcha();
+
+    /**
+     * 微信公众号扫码登录
+     * @param dto
+     * @return
+     * @throws Exception
+     */
+    LoginVo loginQRCode(LoginQRCodeDto dto) throws Exception;
 }

+ 25 - 0
src/main/java/com/xjrsoft/module/system/service/impl/LoginServiceImpl.java

@@ -37,6 +37,7 @@ import com.xjrsoft.module.system.dto.CreateTokenDto;
 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.vo.CreateTokenVo;
 import com.xjrsoft.module.system.vo.ImgCaptchaVo;
@@ -192,6 +193,30 @@ public class LoginServiceImpl implements ILoginService {
         return new ImgCaptchaVo(rKey, captcha.toBase64());
     }
 
+    @Override
+    public LoginVo loginQRCode(LoginQRCodeDto dto) throws Exception {
+        if (licenseConfig.getEnabled()) {
+            //查出所有在线用户
+            List<String> onlineUser = StpUtil.searchSessionId("", 0, -1, true);
+
+            //如果已经登录人数超过授权人数  不允许登录
+            if (onlineUser.size() >= licenseConfig.getLoginMax()) {
+                throw new MyException("登录人数超过授权人数,无法登录,请联系管理员!");
+            }
+        }
+
+        User loginUser = userService.getOne(
+            Wrappers.lambdaQuery(User.class)
+            .eq(User::getOpenId, dto.getOpenId())
+        );
+
+        if (loginUser == null) {
+            throw new MyException("未能查询到您的用户信息");
+        }
+
+        return getLoginInfo(loginUser, "PC");
+    }
+
     private LoginVo getLoginInfo(User loginUser, String loginType) throws Exception {
         LoginVo result = new LoginVo();
         if (loginUser.getEnabledMark() == EnabledMark.DISABLED.getCode()) {

+ 1 - 0
src/main/resources/application-dev.yml

@@ -108,6 +108,7 @@ xjrsoft:
       - /oauth2/* # oauth2
       - /system/bindOpenid # 绑定openid
       - /schedule/schedule/receive-msg
+      - /system/loginQRCode
   email:
     host:  #邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>
     port:  # 邮件服务器的SMTP端口,可选,默认25

+ 1 - 0
src/main/resources/application-pre.yml

@@ -92,6 +92,7 @@ xjrsoft:
       - /oauth2/* # oauth2
       - /system/bindOpenid # 绑定openid
       - /schedule/schedule/receive-msg
+      - /system/loginQRCode
   email:
     host:  #邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>
     port:  # 邮件服务器的SMTP端口,可选,默认25

+ 1 - 0
src/main/resources/application-prod.yml

@@ -87,6 +87,7 @@ xjrsoft:
       - /oauth2/* # oauth2
       - /system/bindOpenid # 绑定openid
       - /schedule/schedule/receive-msg
+      - /system/loginQRCode
   email:
     host:  #邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>
     port:  # 邮件服务器的SMTP端口,可选,默认25