|
@@ -5,10 +5,12 @@ import cn.hutool.crypto.BCUtil;
|
|
|
import cn.hutool.crypto.SmUtil;
|
|
import cn.hutool.crypto.SmUtil;
|
|
|
import cn.hutool.crypto.asymmetric.SM2;
|
|
import cn.hutool.crypto.asymmetric.SM2;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.alipay.api.AlipayConfig;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.jzg.commons.annotation.IgnoreTenant;
|
|
import com.jzg.commons.annotation.IgnoreTenant;
|
|
|
import com.jzg.commons.constants.EncryptionConstants;
|
|
import com.jzg.commons.constants.EncryptionConstants;
|
|
|
|
|
+import com.jzg.commons.entity.po.SysUserJzgApp;
|
|
|
import com.jzg.commons.request.RequestSingleParam;
|
|
import com.jzg.commons.request.RequestSingleParam;
|
|
|
import com.jzg.commons.util.AssertionUtils;
|
|
import com.jzg.commons.util.AssertionUtils;
|
|
|
import com.jzg.commons.util.MinioUtils;
|
|
import com.jzg.commons.util.MinioUtils;
|
|
@@ -30,8 +32,11 @@ import com.jzg.entity.vo.ModifyPassWordFormVo;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.handler.JzgAuthenticationSuccessHandler;
|
|
import com.jzg.handler.JzgAuthenticationSuccessHandler;
|
|
|
import com.jzg.mapper.SysUploadFilesMapper;
|
|
import com.jzg.mapper.SysUploadFilesMapper;
|
|
|
|
|
+import com.jzg.mapper.SysUserJzgAppMapper;
|
|
|
|
|
+import com.jzg.service.AlipayService;
|
|
|
import com.jzg.service.SysUserService;
|
|
import com.jzg.service.SysUserService;
|
|
|
import com.jzg.commons.util.ImageUtil;
|
|
import com.jzg.commons.util.ImageUtil;
|
|
|
|
|
+import com.jzg.service.WechatService;
|
|
|
import com.wf.captcha.SpecCaptcha;
|
|
import com.wf.captcha.SpecCaptcha;
|
|
|
import com.wf.captcha.base.Captcha;
|
|
import com.wf.captcha.base.Captcha;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -41,6 +46,10 @@ import jakarta.servlet.ServletException;
|
|
|
import jakarta.servlet.ServletOutputStream;
|
|
import jakarta.servlet.ServletOutputStream;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
|
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
|
+import me.chanjar.weixin.mp.api.WxMpService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
|
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
|
|
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
|
import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
|
|
@@ -62,6 +71,7 @@ import java.awt.image.BufferedImage;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.security.*;
|
|
import java.security.*;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -74,6 +84,7 @@ import java.util.regex.Pattern;
|
|
|
@Tag(name="授权接口")
|
|
@Tag(name="授权接口")
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/auth")
|
|
@RequestMapping("/auth")
|
|
|
|
|
+@Slf4j
|
|
|
public class AuthController extends BaseController {
|
|
public class AuthController extends BaseController {
|
|
|
|
|
|
|
|
@Value("${minio.bucket-name}")
|
|
@Value("${minio.bucket-name}")
|
|
@@ -97,6 +108,15 @@ public class AuthController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
SysUploadFilesMapper sysUploadFilesMapper;
|
|
SysUploadFilesMapper sysUploadFilesMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WechatService wechatService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AlipayService alipayService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserJzgAppMapper sysUserJzgAppMapper;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 登录接口
|
|
* 登录接口
|
|
|
* @param loginFormVo
|
|
* @param loginFormVo
|
|
@@ -117,6 +137,15 @@ public class AuthController extends BaseController {
|
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
|
HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
|
|
if(loginFormVo.getSystem().equals("APP")){
|
|
if(loginFormVo.getSystem().equals("APP")){
|
|
|
|
|
+
|
|
|
|
|
+ String weOpenId = null;
|
|
|
|
|
+ String aliOpenId = null;
|
|
|
|
|
+ if(loginFormVo.getType().equals(0)){
|
|
|
|
|
+ weOpenId = wechatService.auth(loginFormVo);
|
|
|
|
|
+
|
|
|
|
|
+ }else if(loginFormVo.getType().equals(1)){
|
|
|
|
|
+ aliOpenId = alipayService.auth(loginFormVo);
|
|
|
|
|
+ }
|
|
|
SysUser userById = sysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
SysUser userById = sysUserService.getOne(new LambdaQueryWrapper<SysUser>()
|
|
|
.eq(SysUser::getMobile, loginFormVo.getUserName()));
|
|
.eq(SysUser::getMobile, loginFormVo.getUserName()));
|
|
|
if(Objects.isNull(userById)) {
|
|
if(Objects.isNull(userById)) {
|
|
@@ -126,6 +155,12 @@ public class AuthController extends BaseController {
|
|
|
appRegisterFormVo.setCaptcha(loginFormVo.getCaptcha());
|
|
appRegisterFormVo.setCaptcha(loginFormVo.getCaptcha());
|
|
|
appRegisterFormVo.setCaptchaId(loginFormVo.getCaptchaId());
|
|
appRegisterFormVo.setCaptchaId(loginFormVo.getCaptchaId());
|
|
|
appRegisterFormVo.setSmsCode(loginFormVo.getSmsCode());
|
|
appRegisterFormVo.setSmsCode(loginFormVo.getSmsCode());
|
|
|
|
|
+ if(StringUtils.isNotBlank(weOpenId)){
|
|
|
|
|
+ appRegisterFormVo.setOpenId(weOpenId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtils.isNotBlank(aliOpenId)){
|
|
|
|
|
+ appRegisterFormVo.setAlipay(aliOpenId);
|
|
|
|
|
+ }
|
|
|
register(appRegisterFormVo);
|
|
register(appRegisterFormVo);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -137,6 +172,8 @@ public class AuthController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@GetMapping("captchaById")
|
|
@GetMapping("captchaById")
|
|
|
@Operation(summary = "获取验证码通过用户ID",
|
|
@Operation(summary = "获取验证码通过用户ID",
|
|
|
description = "获取验证码通过用户ID")
|
|
description = "获取验证码通过用户ID")
|