|
@@ -11,6 +11,7 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.core.env.Environment;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -35,12 +36,10 @@ public class LoginController {
|
|
private LoginService loginService;
|
|
private LoginService loginService;
|
|
@Value("${miniprogram.ValidTime}")
|
|
@Value("${miniprogram.ValidTime}")
|
|
private Integer ValidTime;
|
|
private Integer ValidTime;
|
|
- @Value("${miniprogram.AppId}")
|
|
|
|
- private String AppId;
|
|
|
|
- @Value("${miniprogram.AppSecret}")
|
|
|
|
- private String AppSecret;
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private Environment env;
|
|
|
|
|
|
- public WxJsonModel login(String code, HttpServletRequest request) {
|
|
|
|
|
|
+ public WxJsonModel login(String code, HttpServletRequest request, Integer organizeID) {
|
|
logger.info("Start get SessionKey");
|
|
logger.info("Start get SessionKey");
|
|
WxJsonModel res = WxJsonModel.newInstance();
|
|
WxJsonModel res = WxJsonModel.newInstance();
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -49,8 +48,8 @@ public class LoginController {
|
|
map.put("referer", referer);
|
|
map.put("referer", referer);
|
|
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
|
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
|
Map<String, String> requestUrlParam = new HashMap<String, String>();
|
|
Map<String, String> requestUrlParam = new HashMap<String, String>();
|
|
- requestUrlParam.put("appid", AppId);//小程序appId
|
|
|
|
- requestUrlParam.put("secret", AppSecret);//小程序appsecret
|
|
|
|
|
|
+ requestUrlParam.put("appid", env.getProperty("AppId" + organizeID));//小程序appId
|
|
|
|
+ requestUrlParam.put("secret", env.getProperty("AppSecret") + organizeID);//小程序appsecret
|
|
requestUrlParam.put("js_code", code);//小程序端返回的code
|
|
requestUrlParam.put("js_code", code);//小程序端返回的code
|
|
requestUrlParam.put("grant_type", "authorization_code");//默认参数
|
|
requestUrlParam.put("grant_type", "authorization_code");//默认参数
|
|
//发送post请求读取调用微信接口获取openid用户唯一标识
|
|
//发送post请求读取调用微信接口获取openid用户唯一标识
|
|
@@ -92,7 +91,7 @@ public class LoginController {
|
|
@RequestParam(value = "userOrganizeID") Integer userOrganizeID,
|
|
@RequestParam(value = "userOrganizeID") Integer userOrganizeID,
|
|
HttpServletRequest request) {
|
|
HttpServletRequest request) {
|
|
WxJsonModel res = WxJsonModel.newInstance();
|
|
WxJsonModel res = WxJsonModel.newInstance();
|
|
- WxJsonModel model = login(code, request);
|
|
|
|
|
|
+ WxJsonModel model = login(code, request, userOrganizeID);
|
|
if (model.getCode().equals("-1")) {
|
|
if (model.getCode().equals("-1")) {
|
|
return model;
|
|
return model;
|
|
}
|
|
}
|
|
@@ -163,7 +162,7 @@ public class LoginController {
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public WxJsonModel register(@RequestParam(value = "code", required = true) String code,
|
|
public WxJsonModel register(@RequestParam(value = "code", required = true) String code,
|
|
CmOperationUser operationUser, HttpServletRequest request) {
|
|
CmOperationUser operationUser, HttpServletRequest request) {
|
|
- WxJsonModel model = login(code, request);
|
|
|
|
|
|
+ WxJsonModel model = login(code, request, operationUser.getUserOrganizeID());
|
|
if (model.getCode().equals("-1")) {
|
|
if (model.getCode().equals("-1")) {
|
|
return model;
|
|
return model;
|
|
}
|
|
}
|